|
@@ -6,6 +6,7 @@ import com.nuliji.tools.Transform;
|
|
|
import com.nuliji.tools.exception.ParameterException;
|
|
|
import com.qxgmat.data.constants.enums.*;
|
|
|
import com.qxgmat.data.constants.enums.module.PaperModule;
|
|
|
+import com.qxgmat.data.constants.enums.module.PaperOrigin;
|
|
|
import com.qxgmat.data.constants.enums.module.QuestionModule;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
|
import com.qxgmat.data.relation.entity.*;
|
|
@@ -92,15 +93,6 @@ public class QuestionFlowService {
|
|
|
Integer time = toolsService.computerTime(relationList.toArray(new QuestionNoRelation[0]));
|
|
|
userPaper.setTime(time);
|
|
|
});
|
|
|
- initPaperCallback.put(PaperModule.PREVIEW, (userPaper, id)->{
|
|
|
- // 后台主动修改,无需变更
|
|
|
- });
|
|
|
- initPaperCallback.put(PaperModule.ERROR, (userPaper, id)->{
|
|
|
- // 用户主动添加,无需变更
|
|
|
- });
|
|
|
- initPaperCallback.put(PaperModule.COLLECT, (userPaper, id)->{
|
|
|
- // 用户主动添加,无需变更
|
|
|
- });
|
|
|
initPaperCallback.put(PaperModule.SENTENCE, (userPaper, id)->{
|
|
|
SentencePaper paper = sentencePaperService.get(id);
|
|
|
userPaper.setTitle(paper.getTitle());
|
|
@@ -133,27 +125,6 @@ public class QuestionFlowService {
|
|
|
// report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
}
|
|
|
});
|
|
|
- initReportCallback.put(PaperModule.PREVIEW, (report, paper)->{
|
|
|
- JSONObject setting = report.getSetting();
|
|
|
- if (setting.getBoolean("disorder")){
|
|
|
- // 随机试题
|
|
|
-// report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
- }
|
|
|
- });
|
|
|
- initReportCallback.put(PaperModule.COLLECT, (report, paper)->{
|
|
|
- JSONObject setting = report.getSetting();
|
|
|
- if (setting.getBoolean("disorder")){
|
|
|
- // 随机试题
|
|
|
-// report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
- }
|
|
|
- });
|
|
|
- initReportCallback.put(PaperModule.ERROR, (report, paper)->{
|
|
|
- JSONObject setting = report.getSetting();
|
|
|
- if (setting.getBoolean("disorder")){
|
|
|
- // 随机试题
|
|
|
-// report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
- }
|
|
|
- });
|
|
|
initReportCallback.put(PaperModule.SENTENCE, (report, paper)->{
|
|
|
// 无特殊设置
|
|
|
});
|
|
@@ -176,24 +147,6 @@ public class QuestionFlowService {
|
|
|
this.bindQuestionNo(question, questionNoId);
|
|
|
// 设定最后一次练习记录
|
|
|
usersService.edit(User.builder().id(question.getUserId()).latestExercise(report.getPaperId()).build());
|
|
|
- return true;
|
|
|
- });
|
|
|
- nextCallback.put(PaperModule.PREVIEW, (question, report, lastQuestion)->{
|
|
|
- Integer questionNoId = this.nextId(report.getQuestionNoIds(), lastQuestion!=null ? lastQuestion.getQuestionNoId():null);
|
|
|
- if (questionNoId == 0) return false;
|
|
|
- this.bindQuestionNo(question, questionNoId);
|
|
|
- return true;
|
|
|
- });
|
|
|
- nextCallback.put(PaperModule.COLLECT, (question, report, lastQuestion)->{
|
|
|
- Integer questionNoId = this.nextId(report.getQuestionNoIds(), lastQuestion!=null ? lastQuestion.getQuestionNoId():null);
|
|
|
- if (questionNoId == 0) return false;
|
|
|
- this.bindQuestionNo(question, questionNoId);
|
|
|
- return true;
|
|
|
- });
|
|
|
- nextCallback.put(PaperModule.ERROR, (question, report, lastQuestion)->{
|
|
|
- Integer questionNoId = this.nextId(report.getQuestionNoIds(), lastQuestion!=null ? lastQuestion.getQuestionNoId():null);
|
|
|
- if (questionNoId == 0) return false;
|
|
|
- this.bindQuestionNo(question, questionNoId);
|
|
|
// 设定最后一次错题记录
|
|
|
usersService.edit(User.builder().id(question.getUserId()).latestError(report.getPaperId()).build());
|
|
|
return true;
|
|
@@ -225,7 +178,7 @@ public class QuestionFlowService {
|
|
|
// 根据设置出题
|
|
|
QuestionNoRelation relation = null;
|
|
|
// todo 适应性难度判断
|
|
|
- ExaminationPaper paper = examinationPaperService.get(report.getModuleId());
|
|
|
+ ExaminationPaper paper = examinationPaperService.get(report.getOriginId());
|
|
|
if (paper.getIsAdapt() > 0){
|
|
|
|
|
|
}else{
|
|
@@ -243,8 +196,7 @@ public class QuestionFlowService {
|
|
|
JSONObject userAnswer = userQuestion.getUserAnswer();
|
|
|
Question question = questionService.get(userQuestion.getQuestionId());
|
|
|
JSONObject answer = question.getAnswer();
|
|
|
- boolean result = this.baseAnswer(userAnswer, answer, question);
|
|
|
- return result;
|
|
|
+ return (boolean) this.baseAnswer(userAnswer, answer, question);
|
|
|
});
|
|
|
submitCallback.put(QuestionModule.SENTENCE, (userQuestion, userReport)->{
|
|
|
// 判断答题情况
|
|
@@ -292,98 +244,23 @@ public class QuestionFlowService {
|
|
|
questionNoService.accumulation(userQuestion);
|
|
|
questionService.accumulation(userQuestion);
|
|
|
// 统计答案分布
|
|
|
- JSONObject answerDistributed = question.getAnswerDistributed();
|
|
|
- JSONObject answer = question.getAnswer();
|
|
|
- JSONObject userAnswer = userQuestion.getUserAnswer();
|
|
|
-
|
|
|
- String type = question.getContent().getString("type");
|
|
|
- QuestionContentType contentType = QuestionContentType.ValueOf(type);
|
|
|
- JSONArray userQuestions = userAnswer.getJSONArray("questions");
|
|
|
- JSONArray questions = answer.getJSONArray("questions");
|
|
|
- JSONArray distributed = answerDistributed.getJSONArray("questions");
|
|
|
- if (distributed == null || distributed.isEmpty()){
|
|
|
- distributed = new JSONArray();
|
|
|
- answerDistributed.put("questions", distributed);
|
|
|
- }
|
|
|
- for(int i = 0; i< questions.size(); i++){
|
|
|
- JSONObject userOne = userQuestions.getJSONObject(i);
|
|
|
- JSONObject one = questions.getJSONObject(i);
|
|
|
- JSONObject target = distributed.getJSONObject(i);
|
|
|
- if (target == null || target.isEmpty()){
|
|
|
- target = new JSONObject();
|
|
|
- distributed.add(i, target);
|
|
|
- }
|
|
|
- switch(contentType){
|
|
|
- case DOUBLE:
|
|
|
- JSONArray userDoubleList = userOne.getJSONArray("double");
|
|
|
- JSONArray doubleList = one.getJSONArray("double");
|
|
|
- JSONArray doubleResult = target.getJSONArray("double");
|
|
|
- if (doubleResult == null || doubleResult.isEmpty()){
|
|
|
- doubleResult = new JSONArray();
|
|
|
- target.put("double", doubleResult);
|
|
|
- }
|
|
|
- for(int j = 0; j < doubleList.size(); j++){
|
|
|
- JSONArray singleList = doubleList.getJSONArray(j);
|
|
|
- JSONArray userSingleList = userDoubleList.getJSONArray(i);
|
|
|
- JSONArray singleResult = doubleResult.getJSONArray(j);
|
|
|
- if (singleResult == null){
|
|
|
- singleResult = new JSONArray(0);
|
|
|
- doubleResult.set(j, singleResult);
|
|
|
- }
|
|
|
- for (int k = 0; k < singleList.size(); k++){
|
|
|
- if (singleResult.get(k) == null){
|
|
|
- singleResult.set(k, 0);
|
|
|
- }
|
|
|
- if (userSingleList.getBoolean(k)){
|
|
|
- singleResult.set(k, singleResult.getIntValue(k)+1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case SINGLE:
|
|
|
- case INLINE:
|
|
|
- default:
|
|
|
- JSONArray userSingleList = userOne.getJSONArray("single");
|
|
|
- JSONArray singleList = one.getJSONArray("single");
|
|
|
- JSONArray singleResult = target.getJSONArray("single");
|
|
|
- if (singleResult == null || singleResult.isEmpty()){
|
|
|
- singleResult = new JSONArray();
|
|
|
- target.put("single", singleResult);
|
|
|
- }
|
|
|
- for(int j = 0; j < singleList.size(); j++){
|
|
|
- if (singleResult.get(j) == null){
|
|
|
- singleResult.set(j, 0);
|
|
|
- }
|
|
|
- if (userSingleList.getBoolean(j)){
|
|
|
- singleResult.set(j, singleResult.getIntValue(j)+1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- questionService.edit(Question.builder().id(question.getId())
|
|
|
- .answerDistributed(answerDistributed)
|
|
|
- .build());
|
|
|
-
|
|
|
+ this.answerDistributed(userQuestion, question);
|
|
|
});
|
|
|
submitAfterCallback.put(QuestionModule.SENTENCE, (userQuestion, question)->{
|
|
|
- // 更新题目及题目编号统计
|
|
|
- questionService.accumulation(userQuestion);
|
|
|
+ // 更新题目及长难句统计
|
|
|
sentenceQuestionService.accumulation(userQuestion);
|
|
|
+ questionService.accumulation(userQuestion);
|
|
|
+ });
|
|
|
+ submitAfterCallback.put(QuestionModule.TEXTBOOK, (userQuestion, question)->{
|
|
|
+ // 更新题目及机经统计
|
|
|
+ textbookQuestionService.accumulation(userQuestion);
|
|
|
+ questionService.accumulation(userQuestion);
|
|
|
+ this.answerDistributed(userQuestion, question);
|
|
|
});
|
|
|
|
|
|
finishCallback.put(PaperModule.EXERCISE, (report, questionList)->{
|
|
|
report.setDetail(this.statExerciseReport(report, questionList));
|
|
|
});
|
|
|
- finishCallback.put(PaperModule.PREVIEW, (report, questionList)->{
|
|
|
- report.setDetail(this.statExerciseReport(report, questionList));
|
|
|
- });
|
|
|
- finishCallback.put(PaperModule.COLLECT, (report,questionList)->{
|
|
|
- report.setDetail(this.statExerciseReport(report, questionList));
|
|
|
- });
|
|
|
- finishCallback.put(PaperModule.ERROR, (report, questionList)->{
|
|
|
- report.setDetail(this.statExerciseReport(report, questionList));
|
|
|
- });
|
|
|
finishCallback.put(PaperModule.SENTENCE, (report, questionList)->{
|
|
|
report.setDetail(this.statSentenceReport(report, questionList));
|
|
|
});
|
|
@@ -399,21 +276,21 @@ public class QuestionFlowService {
|
|
|
/**
|
|
|
* 开始新一轮做题
|
|
|
* @param userId
|
|
|
- * @param module
|
|
|
+ * @param origin
|
|
|
* @param paperId
|
|
|
* @param setting
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public UserReportRelation start(Integer userId, PaperModule module, Integer paperId, JSONObject setting){
|
|
|
- UserPaper paper = userPaperService.getByPaper(userId, module, paperId, initPaperCallback.get(module));
|
|
|
+ public UserReportRelation start(Integer userId, PaperOrigin origin, Integer paperId, JSONObject setting){
|
|
|
+ UserPaper paper = userPaperService.getByPaper(userId, origin, paperId, initPaperCallback.get(origin));
|
|
|
// 查找对应的report是否有,如果没有或reset为1,则添加
|
|
|
if (paper.getIsReset() > 0) {
|
|
|
paper.setIsReset(0);
|
|
|
userPaperService.edit(paper);
|
|
|
}
|
|
|
// 记录考试设置
|
|
|
- UserReport userReport = userReportService.addByPaper(paper, setting, initReportCallback.get(module));
|
|
|
+ UserReport userReport = userReportService.addByPaper(paper, setting, initReportCallback.get(PaperModule.ValueOf(paper.getPaperModule())));
|
|
|
|
|
|
return relationReport(userReport);
|
|
|
}
|
|
@@ -713,6 +590,86 @@ public class QuestionFlowService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 统计答案分布
|
|
|
+ * @param userQuestion
|
|
|
+ * @param question
|
|
|
+ */
|
|
|
+ private void answerDistributed(UserQuestion userQuestion, Question question){
|
|
|
+ JSONObject answerDistributed = question.getAnswerDistributed();
|
|
|
+ JSONObject answer = question.getAnswer();
|
|
|
+ JSONObject userAnswer = userQuestion.getUserAnswer();
|
|
|
+
|
|
|
+ String type = question.getContent().getString("type");
|
|
|
+ QuestionContentType contentType = QuestionContentType.ValueOf(type);
|
|
|
+ JSONArray userQuestions = userAnswer.getJSONArray("questions");
|
|
|
+ JSONArray questions = answer.getJSONArray("questions");
|
|
|
+ JSONArray distributed = answerDistributed.getJSONArray("questions");
|
|
|
+ if (distributed == null || distributed.isEmpty()){
|
|
|
+ distributed = new JSONArray();
|
|
|
+ answerDistributed.put("questions", distributed);
|
|
|
+ }
|
|
|
+ for(int i = 0; i< questions.size(); i++){
|
|
|
+ JSONObject userOne = userQuestions.getJSONObject(i);
|
|
|
+ JSONObject one = questions.getJSONObject(i);
|
|
|
+ JSONObject target = distributed.getJSONObject(i);
|
|
|
+ if (target == null || target.isEmpty()){
|
|
|
+ target = new JSONObject();
|
|
|
+ distributed.add(i, target);
|
|
|
+ }
|
|
|
+ switch(contentType){
|
|
|
+ case DOUBLE:
|
|
|
+ JSONArray userDoubleList = userOne.getJSONArray("double");
|
|
|
+ JSONArray doubleList = one.getJSONArray("double");
|
|
|
+ JSONArray doubleResult = target.getJSONArray("double");
|
|
|
+ if (doubleResult == null || doubleResult.isEmpty()){
|
|
|
+ doubleResult = new JSONArray();
|
|
|
+ target.put("double", doubleResult);
|
|
|
+ }
|
|
|
+ for(int j = 0; j < doubleList.size(); j++){
|
|
|
+ JSONArray singleList = doubleList.getJSONArray(j);
|
|
|
+ JSONArray userSingleList = userDoubleList.getJSONArray(i);
|
|
|
+ JSONArray singleResult = doubleResult.getJSONArray(j);
|
|
|
+ if (singleResult == null){
|
|
|
+ singleResult = new JSONArray(0);
|
|
|
+ doubleResult.set(j, singleResult);
|
|
|
+ }
|
|
|
+ for (int k = 0; k < singleList.size(); k++){
|
|
|
+ if (singleResult.get(k) == null){
|
|
|
+ singleResult.set(k, 0);
|
|
|
+ }
|
|
|
+ if (userSingleList.getBoolean(k)){
|
|
|
+ singleResult.set(k, singleResult.getIntValue(k)+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SINGLE:
|
|
|
+ case INLINE:
|
|
|
+ default:
|
|
|
+ JSONArray userSingleList = userOne.getJSONArray("single");
|
|
|
+ JSONArray singleList = one.getJSONArray("single");
|
|
|
+ JSONArray singleResult = target.getJSONArray("single");
|
|
|
+ if (singleResult == null || singleResult.isEmpty()){
|
|
|
+ singleResult = new JSONArray();
|
|
|
+ target.put("single", singleResult);
|
|
|
+ }
|
|
|
+ for(int j = 0; j < singleList.size(); j++){
|
|
|
+ if (singleResult.get(j) == null){
|
|
|
+ singleResult.set(j, 0);
|
|
|
+ }
|
|
|
+ if (userSingleList.getBoolean(j)){
|
|
|
+ singleResult.set(j, singleResult.getIntValue(j)+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ questionService.edit(Question.builder().id(question.getId())
|
|
|
+ .answerDistributed(answerDistributed)
|
|
|
+ .build());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 根据练习报告格式,统计信息
|
|
|
* @param report
|
|
|
* @param questionList
|
|
@@ -783,7 +740,7 @@ public class QuestionFlowService {
|
|
|
|
|
|
JSONObject limit = new JSONObject();
|
|
|
// 限时统计考试正确度
|
|
|
- UserReportLimitRelation relation = userReportService.statLimit(report.getPaperModule(), report.getModuleId());
|
|
|
+ UserReportLimitRelation relation = userReportService.statLimit(report.getPaperOrigin(), report.getOriginId());
|
|
|
limit.put("userNumber", relation.getUserNumber());
|
|
|
limit.put("userCorrect", relation.getUserCorrect());
|
|
|
detail.put("limit", limit);
|
|
@@ -872,7 +829,7 @@ public class QuestionFlowService {
|
|
|
|
|
|
JSONObject limit = new JSONObject();
|
|
|
// 限时统计考试正确度
|
|
|
- UserReportLimitRelation relation = userReportService.statLimit(report.getPaperModule(), report.getModuleId());
|
|
|
+ UserReportLimitRelation relation = userReportService.statLimit(report.getPaperOrigin(), report.getOriginId());
|
|
|
limit.put("userNumber", relation.getUserNumber());
|
|
|
limit.put("userCorrect", relation.getUserCorrect());
|
|
|
detail.put("limit", limit);
|