|
@@ -4,16 +4,11 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.nuliji.tools.Transform;
|
|
|
import com.nuliji.tools.exception.ParameterException;
|
|
|
-import com.qxgmat.data.constants.enums.QuestionContentType;
|
|
|
-import com.qxgmat.data.constants.enums.QuestionType;
|
|
|
-import com.qxgmat.data.constants.enums.SettingKey;
|
|
|
+import com.qxgmat.data.constants.enums.*;
|
|
|
import com.qxgmat.data.constants.enums.module.PaperModule;
|
|
|
import com.qxgmat.data.constants.enums.module.QuestionModule;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
|
-import com.qxgmat.data.relation.entity.QuestionNoRelation;
|
|
|
-import com.qxgmat.data.relation.entity.SentenceQuestionRelation;
|
|
|
-import com.qxgmat.data.relation.entity.UserReportLimitRelation;
|
|
|
-import com.qxgmat.data.relation.entity.UserReportRelation;
|
|
|
+import com.qxgmat.data.relation.entity.*;
|
|
|
import com.qxgmat.service.*;
|
|
|
import com.qxgmat.service.annotation.*;
|
|
|
import com.qxgmat.service.inline.*;
|
|
@@ -88,63 +83,92 @@ public class QuestionFlowService {
|
|
|
private Map<PaperModule, StatReport> finishCallback = new HashMap<>();
|
|
|
|
|
|
public QuestionFlowService(){
|
|
|
- initPaperCallback.put(PaperModule.EXERCISE, (paper, id)->{
|
|
|
- exercisePaperService.initUserPaper(paper, id);
|
|
|
+ initPaperCallback.put(PaperModule.EXERCISE, (userPaper, id)->{
|
|
|
+ ExercisePaper paper = exercisePaperService.get(id);
|
|
|
+ userPaper.setTitle(paper.getTitle());
|
|
|
+ userPaper.setQuestionNoIds(paper.getQuestionNoIds());
|
|
|
// 获取考题时间
|
|
|
- List<QuestionNoRelation> relationList = questionNoService.listWithRelationByIds(paper.getQuestionNoIds());
|
|
|
- Integer time = toolsService.computerTime(relationList);
|
|
|
- paper.setTime(time);
|
|
|
+ List<QuestionNoRelation> relationList = questionNoService.listWithRelationByIds(userPaper.getQuestionNoIds());
|
|
|
+ Integer time = toolsService.computerTime(relationList.toArray(new QuestionNoRelation[0]));
|
|
|
+ userPaper.setTime(time);
|
|
|
});
|
|
|
- initPaperCallback.put(PaperModule.PREVIEW, (paper, id)->{
|
|
|
+ initPaperCallback.put(PaperModule.PREVIEW, (userPaper, id)->{
|
|
|
// 后台主动修改,无需变更
|
|
|
});
|
|
|
- initPaperCallback.put(PaperModule.ERROR, (paper, id)->{
|
|
|
+ initPaperCallback.put(PaperModule.ERROR, (userPaper, id)->{
|
|
|
// 用户主动添加,无需变更
|
|
|
});
|
|
|
- initPaperCallback.put(PaperModule.COLLECT, (paper, id)->{
|
|
|
+ initPaperCallback.put(PaperModule.COLLECT, (userPaper, id)->{
|
|
|
// 用户主动添加,无需变更
|
|
|
});
|
|
|
- initPaperCallback.put(PaperModule.SENTENCE, (paper, id)->{
|
|
|
- sentencePaperService.initUserPaper(paper, id);
|
|
|
+ initPaperCallback.put(PaperModule.SENTENCE, (userPaper, id)->{
|
|
|
+ SentencePaper paper = sentencePaperService.get(id);
|
|
|
+ userPaper.setTitle(paper.getTitle());
|
|
|
+ userPaper.setQuestionNoIds(paper.getQuestionNoIds());
|
|
|
+ userPaper.setQuestionNumber(paper.getQuestionNumber());
|
|
|
+ // 获取考题时间
|
|
|
+ List<SentenceQuestionRelation> relationList = sentenceQuestionService.listWithRelationByIds(userPaper.getQuestionNoIds());
|
|
|
+ Integer time = toolsService.computerTime(relationList.toArray(new SentenceQuestionRelation[0]));
|
|
|
+ userPaper.setTime(time);
|
|
|
+ });
|
|
|
+ initPaperCallback.put(PaperModule.TEXTBOOK, (userPaper, id)->{
|
|
|
+ TextbookPaper paper = textbookPaperService.get(id);
|
|
|
+ userPaper.setTitle(paper.getTitle());
|
|
|
+ userPaper.setQuestionNoIds(paper.getQuestionNoIds());
|
|
|
+ userPaper.setQuestionNumber(paper.getQuestionNumber());
|
|
|
+ // 获取考题时间
|
|
|
+ List<TextbookQuestionRelation> relationList = textbookQuestionService.listWithRelationByIds(userPaper.getQuestionNoIds());
|
|
|
+ Integer time = toolsService.computerTime(relationList.toArray(new TextbookQuestionRelation[0]));
|
|
|
+ userPaper.setTime(time);
|
|
|
});
|
|
|
- initPaperCallback.put(PaperModule.TEXTBOOK, (paper, id)->{
|
|
|
- textbookPaperService.initUserPaper(paper, id);
|
|
|
+ initPaperCallback.put(PaperModule.EXAMINATION, (userPaper, id)->{
|
|
|
+ ExaminationPaper paper = examinationPaperService.get(id);
|
|
|
+ userPaper.setTitle(paper.getTitle());
|
|
|
});
|
|
|
|
|
|
initReportCallback.put(PaperModule.EXERCISE, (report, paper)->{
|
|
|
JSONObject setting = report.getSetting();
|
|
|
if (setting.getBoolean("disorder")){
|
|
|
// 随机试题
|
|
|
- report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
+// 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()));
|
|
|
+// 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()));
|
|
|
+// 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()));
|
|
|
+// report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
}
|
|
|
});
|
|
|
- initReportCallback.put(PaperModule.SENTENCE, (paper, report)->{
|
|
|
+ initReportCallback.put(PaperModule.SENTENCE, (report, paper)->{
|
|
|
// 无特殊设置
|
|
|
});
|
|
|
- initReportCallback.put(PaperModule.TEXTBOOK, (paper, report)->{
|
|
|
+ initReportCallback.put(PaperModule.TEXTBOOK, (report, paper)->{
|
|
|
// 无特殊设置
|
|
|
});
|
|
|
+ initReportCallback.put(PaperModule.EXAMINATION, (report, paper)->{
|
|
|
+ JSONObject setting = report.getSetting();
|
|
|
+ if (setting.getBoolean("disorder")){
|
|
|
+ // 随机试题选项
|
|
|
+// report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
+ }
|
|
|
+ JSONArray order = setting.getJSONArray("order");
|
|
|
+ toolsService.examinationReportInit(report, order);
|
|
|
+ });
|
|
|
|
|
|
nextCallback.put(PaperModule.EXERCISE, (question, report, lastQuestion)->{
|
|
|
Integer questionNoId = this.nextId(report.getQuestionNoIds(), lastQuestion!=null ? lastQuestion.getQuestionNoId():null);
|
|
@@ -177,71 +201,52 @@ public class QuestionFlowService {
|
|
|
nextCallback.put(PaperModule.SENTENCE, (question, report, lastQuestion)->{
|
|
|
Integer questionNoId = this.nextId(report.getQuestionNoIds(), lastQuestion!=null ? lastQuestion.getQuestionNoId():null);
|
|
|
if (questionNoId == 0) return false;
|
|
|
- SentenceQuestion relation = sentenceQuestionService.get(questionNoId);
|
|
|
+ SentenceQuestionRelation relation = sentenceQuestionService.relation(sentenceQuestionService.get(questionNoId));
|
|
|
question.setQuestionNoId(relation.getId());
|
|
|
question.setQuestionId(relation.getQuestionId());
|
|
|
- question.setTime(0);
|
|
|
+ Integer time = toolsService.computerTime(relation);
|
|
|
+ question.setTime(time);
|
|
|
return true;
|
|
|
});
|
|
|
nextCallback.put(PaperModule.TEXTBOOK, (question, report, lastQuestion)->{
|
|
|
Integer questionNoId = this.nextId(report.getQuestionNoIds(), lastQuestion!=null ? lastQuestion.getQuestionNoId():null);
|
|
|
if (questionNoId == 0) return false;
|
|
|
- SentenceQuestion relation = sentenceQuestionService.get(questionNoId);
|
|
|
+ TextbookQuestionRelation relation = textbookQuestionService.relation(textbookQuestionService.get(questionNoId));
|
|
|
+ question.setQuestionNoId(relation.getId());
|
|
|
+ question.setQuestionId(relation.getQuestionId());
|
|
|
+ Integer time = toolsService.computerTime(relation);
|
|
|
+ question.setTime(time);
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ nextCallback.put(PaperModule.EXAMINATION, (question, report, lastQuestion)->{
|
|
|
+ JSONObject setting = report.getSetting();
|
|
|
+ JSONArray order = setting.getJSONArray("order");
|
|
|
+ // 判断数量是否已经完成
|
|
|
+ // 根据设置出题
|
|
|
+ QuestionNoRelation relation = null;
|
|
|
+ // todo 适应性难度判断
|
|
|
+ ExaminationPaper paper = examinationPaperService.get(report.getModuleId());
|
|
|
+ if (paper.getIsAdapt() > 0){
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
question.setQuestionNoId(relation.getId());
|
|
|
question.setQuestionId(relation.getQuestionId());
|
|
|
- question.setTime(0);
|
|
|
+ Integer time = toolsService.computerTime(relation);
|
|
|
+ question.setTime(time);
|
|
|
return true;
|
|
|
});
|
|
|
|
|
|
- submitCallback.put(QuestionModule.BASE, (userQuestion)->{
|
|
|
+ submitCallback.put(QuestionModule.BASE, (userQuestion, userReport)->{
|
|
|
// 判断答题情况
|
|
|
JSONObject userAnswer = userQuestion.getUserAnswer();
|
|
|
Question question = questionService.get(userQuestion.getQuestionId());
|
|
|
JSONObject answer = question.getAnswer();
|
|
|
-
|
|
|
- String type = question.getContent().getString("type");
|
|
|
- QuestionContentType contentType = QuestionContentType.ValueOf(type);
|
|
|
- JSONArray userQuestions = userAnswer.getJSONArray("questions");
|
|
|
- JSONArray questions = answer.getJSONArray("questions");
|
|
|
- for(int i = 0; i< questions.size(); i++){
|
|
|
- JSONObject userOne = userQuestions.getJSONObject(i);
|
|
|
- JSONObject one = questions.getJSONObject(i);
|
|
|
- switch(contentType){
|
|
|
- case DOUBLE:
|
|
|
- JSONArray userDoubleList = userOne.getJSONArray("double");
|
|
|
- JSONArray doubleList = one.getJSONArray("double");
|
|
|
-// if(JSONObject.toJSON(userDoubleList) != JSONObject.toJSON(doubleList)){
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-
|
|
|
- for(int j = 0; j < doubleList.size(); j++){
|
|
|
- JSONArray singleList = doubleList.getJSONArray(j);
|
|
|
- JSONArray userSingleList = userDoubleList.getJSONArray(i);
|
|
|
- for (int k = 0; k < singleList.size(); k++){
|
|
|
- if (userSingleList.getBoolean(k) != singleList.getBoolean(k)){
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case SINGLE:
|
|
|
- case INLINE:
|
|
|
- default:
|
|
|
- JSONArray userSingleList = userOne.getJSONArray("single");
|
|
|
- JSONArray singleList = one.getJSONArray("single");
|
|
|
-// if(JSONObject.toJSON(userSingleList) != JSONObject.toJSON(singleList)){
|
|
|
-// return false;
|
|
|
-// }
|
|
|
- for(int j = 0; j < singleList.size(); j++){
|
|
|
- if (userSingleList.getBoolean(j) != singleList.getBoolean(j)){
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
+ boolean result = this.baseAnswer(userAnswer, answer, question);
|
|
|
+ return result;
|
|
|
});
|
|
|
- submitCallback.put(QuestionModule.SENTENCE, (userQuestion)->{
|
|
|
+ submitCallback.put(QuestionModule.SENTENCE, (userQuestion, userReport)->{
|
|
|
// 判断答题情况
|
|
|
JSONObject userAnswer = userQuestion.getUserAnswer();
|
|
|
Question question = questionService.get(userQuestion.getQuestionId());
|
|
@@ -270,6 +275,13 @@ public class QuestionFlowService {
|
|
|
// 主谓宾判断正确,答题正确
|
|
|
return correct;
|
|
|
});
|
|
|
+ submitCallback.put(QuestionModule.TEXTBOOK, (userQuestion, userReport)->{
|
|
|
+ // 判断答题情况
|
|
|
+ JSONObject userAnswer = userQuestion.getUserAnswer();
|
|
|
+ Question question = questionService.get(userQuestion.getQuestionId());
|
|
|
+ JSONObject answer = question.getAnswer();
|
|
|
+ return this.baseAnswer(userAnswer, answer, question);
|
|
|
+ });
|
|
|
|
|
|
submitAfterCallback.put(QuestionModule.BASE, (userQuestion, question)->{
|
|
|
// 作文不统计
|
|
@@ -350,7 +362,7 @@ public class QuestionFlowService {
|
|
|
}
|
|
|
}
|
|
|
questionService.edit(Question.builder().id(question.getId())
|
|
|
- .answer(answerDistributed)
|
|
|
+ .answerDistributed(answerDistributed)
|
|
|
.build());
|
|
|
|
|
|
});
|
|
@@ -375,11 +387,11 @@ public class QuestionFlowService {
|
|
|
finishCallback.put(PaperModule.SENTENCE, (report, questionList)->{
|
|
|
report.setDetail(this.statSentenceReport(report, questionList));
|
|
|
});
|
|
|
- finishCallback.put(PaperModule.EXAMINATION, (report, questionList)->{
|
|
|
-
|
|
|
- });
|
|
|
finishCallback.put(PaperModule.TEXTBOOK, (report, questionList)->{
|
|
|
-
|
|
|
+ report.setDetail(this.statTextbookReport(report, questionList));
|
|
|
+ });
|
|
|
+ finishCallback.put(PaperModule.EXAMINATION, (report, questionList)->{
|
|
|
+ this.statExaminationReport(report, questionList);
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -484,7 +496,7 @@ public class QuestionFlowService {
|
|
|
// 根据report模块获取试题所属模块
|
|
|
QuestionModule module = QuestionModule.WithPaper(PaperModule.ValueOf(userReport.getPaperModule()));
|
|
|
SubmitQuestion callback = submitCallback.get(module);
|
|
|
- Boolean result = callback.callback(userQuestion);
|
|
|
+ Boolean result = callback.callback(userQuestion, userReport);
|
|
|
userQuestion.setIsCorrect(result ? 1 : 0);
|
|
|
userQuestionService.edit(userQuestion);
|
|
|
|
|
@@ -616,6 +628,57 @@ public class QuestionFlowService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 基本题型的答案判断
|
|
|
+ * @param userAnswer
|
|
|
+ * @param answer
|
|
|
+ * @param question
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Boolean baseAnswer(JSONObject userAnswer, JSONObject answer, Question question){
|
|
|
+ String type = question.getContent().getString("type");
|
|
|
+ QuestionContentType contentType = QuestionContentType.ValueOf(type);
|
|
|
+ JSONArray userQuestions = userAnswer.getJSONArray("questions");
|
|
|
+ JSONArray questions = answer.getJSONArray("questions");
|
|
|
+ for(int i = 0; i< questions.size(); i++){
|
|
|
+ JSONObject userOne = userQuestions.getJSONObject(i);
|
|
|
+ JSONObject one = questions.getJSONObject(i);
|
|
|
+ switch(contentType){
|
|
|
+ case DOUBLE:
|
|
|
+ JSONArray userDoubleList = userOne.getJSONArray("double");
|
|
|
+ JSONArray doubleList = one.getJSONArray("double");
|
|
|
+// if(JSONObject.toJSON(userDoubleList) != JSONObject.toJSON(doubleList)){
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+
|
|
|
+ for(int j = 0; j < doubleList.size(); j++){
|
|
|
+ JSONArray singleList = doubleList.getJSONArray(j);
|
|
|
+ JSONArray userSingleList = userDoubleList.getJSONArray(i);
|
|
|
+ for (int k = 0; k < singleList.size(); k++){
|
|
|
+ if (userSingleList.getBoolean(k) != singleList.getBoolean(k)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SINGLE:
|
|
|
+ case INLINE:
|
|
|
+ default:
|
|
|
+ JSONArray userSingleList = userOne.getJSONArray("single");
|
|
|
+ JSONArray singleList = one.getJSONArray("single");
|
|
|
+// if(JSONObject.toJSON(userSingleList) != JSONObject.toJSON(singleList)){
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+ for(int j = 0; j < singleList.size(); j++){
|
|
|
+ if (userSingleList.getBoolean(j) != singleList.getBoolean(j)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 长难句单个选项答案判断
|
|
|
* @param userAnswer
|
|
|
* @param answer
|
|
@@ -649,60 +712,146 @@ public class QuestionFlowService {
|
|
|
// report
|
|
|
JSONObject detail = new JSONObject();
|
|
|
JSONArray pace = new JSONArray();
|
|
|
- for (UserQuestion userQuestion : questionList){
|
|
|
+ JSONObject difficultMap = new JSONObject();
|
|
|
+ JSONObject placeMap = new JSONObject();
|
|
|
+
|
|
|
+ for (UserQuestion userQuestion:questionList){
|
|
|
+ QuestionNoRelation relation = relationMap.get(userQuestion.getQuestionNoId());
|
|
|
+
|
|
|
// 每题用时
|
|
|
JSONObject one = new JSONObject();
|
|
|
one.put("time", userQuestion.getTime());
|
|
|
one.put("userTime", userQuestion.getUserTime());
|
|
|
one.put("no", userQuestion.getNo());
|
|
|
pace.add(one);
|
|
|
- }
|
|
|
- detail.put("pace", pace);
|
|
|
|
|
|
- JSONObject difficultMap = new JSONObject();
|
|
|
- for (UserQuestion userQuestion:questionList){
|
|
|
+ // 考点用时,以及正确度
|
|
|
+ String placeKey = relation.getQuestion().getPlace();
|
|
|
+ JSONObject place = placeMap.getJSONObject(placeKey);
|
|
|
+ if (place == null){
|
|
|
+ place = new JSONObject();
|
|
|
+ place.put("key", placeKey);
|
|
|
+ place.put("userNumber", 1);
|
|
|
+ place.put("userCorrect", userQuestion.getIsCorrect());
|
|
|
+ place.put("userTime", userQuestion.getUserTime());
|
|
|
+ placeMap.put(placeKey, place);
|
|
|
+ }else{
|
|
|
+ place.put("userNumber", place.getInteger("userNumber") + 1);
|
|
|
+ place.put("userCorrect", place.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
+ place.put("userTime", place.getInteger("userTime") + userQuestion.getUserTime());
|
|
|
+ }
|
|
|
+
|
|
|
// 难度正确度
|
|
|
- QuestionNoRelation relation = relationMap.get(userQuestion.getQuestionNoId());
|
|
|
- String d = relation.getQuestion().getDifficult();
|
|
|
- JSONObject t = difficultMap.getJSONObject(d);
|
|
|
- if (t == null){
|
|
|
- t = new JSONObject();
|
|
|
- t.put("key", d);
|
|
|
- t.put("userNumber", 1);
|
|
|
- t.put("userCorrect", userQuestion.getIsCorrect());
|
|
|
- t.put("totalNumber", relation.getTotalNumber());
|
|
|
- t.put("totalCorrect", relation.getTotalCorrect());
|
|
|
- difficultMap.put(d, t);
|
|
|
+ String difficultKey = relation.getQuestion().getDifficult();
|
|
|
+ JSONObject difficult = difficultMap.getJSONObject(difficultKey);
|
|
|
+ if (difficult == null){
|
|
|
+ difficult = new JSONObject();
|
|
|
+ difficult.put("key", difficultKey);
|
|
|
+ difficult.put("userNumber", 1);
|
|
|
+ difficult.put("userCorrect", userQuestion.getIsCorrect());
|
|
|
+ difficult.put("totalNumber", relation.getTotalNumber());
|
|
|
+ difficult.put("totalCorrect", relation.getTotalCorrect());
|
|
|
+ difficultMap.put(difficultKey, difficult);
|
|
|
}else{
|
|
|
- t.put("userNumber", t.getInteger("userNumber") + 1);
|
|
|
- t.put("userCorrect", t.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
- t.put("totalNumber", t.getInteger("totalNumber") + relation.getTotalNumber());
|
|
|
- t.put("totalCorrect", t.getInteger("totalCorrect") + relation.getTotalCorrect());
|
|
|
+ difficult.put("userNumber", difficult.getInteger("userNumber") + 1);
|
|
|
+ difficult.put("userCorrect", difficult.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
+ difficult.put("totalNumber", difficult.getInteger("totalNumber") + relation.getTotalNumber());
|
|
|
+ difficult.put("totalCorrect", difficult.getInteger("totalCorrect") + relation.getTotalCorrect());
|
|
|
}
|
|
|
}
|
|
|
+ detail.put("pace", pace);
|
|
|
JSONArray difficult = new JSONArray();
|
|
|
difficult.addAll(difficultMap.values());
|
|
|
detail.put("difficult", difficult);
|
|
|
+ JSONArray place = new JSONArray();
|
|
|
+ place.addAll(placeMap.values());
|
|
|
+ detail.put("place", place);
|
|
|
+
|
|
|
+ JSONObject limit = new JSONObject();
|
|
|
+ // 限时统计考试正确度
|
|
|
+ UserReportLimitRelation relation = userReportService.statLimit(report.getPaperModule(), report.getModuleId());
|
|
|
+ limit.put("userNumber", relation.getUserNumber());
|
|
|
+ limit.put("userCorrect", relation.getUserCorrect());
|
|
|
+ detail.put("limit", limit);
|
|
|
+
|
|
|
+ JSONObject info = new JSONObject();
|
|
|
+ // 基本信息
|
|
|
+ info.put("times", paper.getTimes() + 1); // paper还未计数
|
|
|
+ info.put("finishTime", report.getFinishTime());
|
|
|
+ info.put("userTime", report.getUserTime());
|
|
|
+ info.put("time", report.getTime());
|
|
|
+ info.put("questionNumber", report.getQuestionNumber());
|
|
|
+ info.put("userNumber", report.getUserNumber());
|
|
|
+ info.put("userCorrect", report.getUserCorrect());
|
|
|
+ Integer totalNumber = 0;
|
|
|
+ Integer totalCorrect = 0;
|
|
|
+ Integer totalTime = 0;
|
|
|
+ for (QuestionNoRelation questionNoRelation : relationMap.values()){
|
|
|
+ totalNumber += questionNoRelation.getTotalNumber();
|
|
|
+ totalCorrect += questionNoRelation.getTotalCorrect();
|
|
|
+ totalTime += questionNoRelation.getTotalTime();
|
|
|
+ }
|
|
|
+ Integer correctTime = 0;
|
|
|
+ Integer incorrectTime = 0;
|
|
|
+ for (UserQuestion userQuestion : questionList){
|
|
|
+ if (userQuestion.getIsCorrect() > 0){
|
|
|
+ correctTime += userQuestion.getUserTime();
|
|
|
+ }else{
|
|
|
+ incorrectTime += userQuestion.getUserTime();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ info.put("totalNumber", totalNumber);
|
|
|
+ info.put("totalCorrect", totalCorrect);
|
|
|
+ info.put("totalTime", totalTime);
|
|
|
+ info.put("correctTime", correctTime);
|
|
|
+ info.put("incorrectTime", incorrectTime);
|
|
|
+ detail.put("info", info);
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据机经报告格式,统计信息:移除练习中的难度分析
|
|
|
+ * @param report
|
|
|
+ * @param questionList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private JSONObject statTextbookReport(UserReport report, List<UserQuestion> questionList){
|
|
|
+ UserPaper paper = userPaperService.get(report.getPaperId());
|
|
|
+ Collection questionNoIds = Transform.getIds(questionList, UserQuestion.class, "questionNoId");
|
|
|
+ Map<Number, TextbookQuestionRelation> relationMap = textbookQuestionService.mapWithRelationByIds((Integer[])questionNoIds.toArray());
|
|
|
+
|
|
|
+ // report
|
|
|
+ JSONObject detail = new JSONObject();
|
|
|
+ JSONArray pace = new JSONArray();
|
|
|
JSONObject placeMap = new JSONObject();
|
|
|
for (UserQuestion userQuestion:questionList){
|
|
|
+ TextbookQuestionRelation relation = relationMap.get(userQuestion.getQuestionNoId());
|
|
|
+
|
|
|
+ // 每题用时
|
|
|
+ JSONObject one = new JSONObject();
|
|
|
+ one.put("time", userQuestion.getTime());
|
|
|
+ one.put("userTime", userQuestion.getUserTime());
|
|
|
+ one.put("no", userQuestion.getNo());
|
|
|
+ pace.add(one);
|
|
|
+
|
|
|
// 考点用时,以及正确度
|
|
|
- QuestionNoRelation relation = relationMap.get(userQuestion.getQuestionNoId());
|
|
|
- String d = relation.getQuestion().getPlace();
|
|
|
- JSONObject t = placeMap.getJSONObject(d);
|
|
|
- if (t == null){
|
|
|
- t = new JSONObject();
|
|
|
- t.put("key", d);
|
|
|
- t.put("userNumber", 1);
|
|
|
- t.put("userCorrect", userQuestion.getIsCorrect());
|
|
|
- t.put("userTime", userQuestion.getUserTime());
|
|
|
- placeMap.put(d, t);
|
|
|
+ String placeKey = relation.getQuestion().getPlace();
|
|
|
+ JSONObject place = placeMap.getJSONObject(placeKey);
|
|
|
+ if (place == null){
|
|
|
+ place = new JSONObject();
|
|
|
+ place.put("key", placeKey);
|
|
|
+ place.put("userNumber", 1);
|
|
|
+ place.put("userCorrect", userQuestion.getIsCorrect());
|
|
|
+ place.put("userTime", userQuestion.getUserTime());
|
|
|
+ placeMap.put(placeKey, place);
|
|
|
}else{
|
|
|
- t.put("userNumber", t.getInteger("userNumber") + 1);
|
|
|
- t.put("userCorrect", t.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
- t.put("userTime", t.getInteger("userTime") + userQuestion.getUserTime());
|
|
|
+ place.put("userNumber", place.getInteger("userNumber") + 1);
|
|
|
+ place.put("userCorrect", place.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
+ place.put("userTime", place.getInteger("userTime") + userQuestion.getUserTime());
|
|
|
}
|
|
|
}
|
|
|
+ detail.put("pace", pace);
|
|
|
JSONArray place = new JSONArray();
|
|
|
place.addAll(placeMap.values());
|
|
|
detail.put("place", place);
|
|
@@ -726,7 +875,7 @@ public class QuestionFlowService {
|
|
|
Integer totalNumber = 0;
|
|
|
Integer totalCorrect = 0;
|
|
|
Integer totalTime = 0;
|
|
|
- for (QuestionNoRelation questionNoRelation : relationMap.values()){
|
|
|
+ for (TextbookQuestionRelation questionNoRelation : relationMap.values()){
|
|
|
totalNumber += questionNoRelation.getTotalNumber();
|
|
|
totalCorrect += questionNoRelation.getTotalCorrect();
|
|
|
totalTime += questionNoRelation.getTotalTime();
|
|
@@ -821,4 +970,185 @@ public class QuestionFlowService {
|
|
|
detail.put("info", info);
|
|
|
return detail;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据模考报告格式,统计信息
|
|
|
+ * @param report
|
|
|
+ * @param questionList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void statExaminationReport(UserReport report, List<UserQuestion> questionList){
|
|
|
+ UserPaper paper = userPaperService.get(report.getPaperId());
|
|
|
+ Collection questionNoIds = Transform.getIds(questionList, UserQuestion.class, "questionNoId");
|
|
|
+ Map<Number, QuestionNoRelation> relationMap = questionNoService.mapWithRelationByIds((Integer[])questionNoIds.toArray());
|
|
|
+
|
|
|
+ // report
|
|
|
+ JSONObject detail = new JSONObject();
|
|
|
+ JSONObject score = new JSONObject();
|
|
|
+
|
|
|
+ // 成绩单
|
|
|
+ JSONObject subjectMap = new JSONObject();
|
|
|
+ JSONObject typeMap = new JSONObject();
|
|
|
+ JSONObject tempMap = new JSONObject();
|
|
|
+
|
|
|
+ for (UserQuestion userQuestion : questionList){
|
|
|
+ QuestionNoRelation relation = relationMap.get(userQuestion.getQuestionNoId());
|
|
|
+ QuestionType questionType = QuestionType.ValueOf(relation.getQuestion().getQuestionType());
|
|
|
+ QuestionSubject questionSubject = QuestionSubject.FromType(questionType);
|
|
|
+ JSONObject type = typeMap.getJSONObject(questionType.key);
|
|
|
+ JSONObject temp = tempMap.getJSONObject(questionSubject.key);
|
|
|
+ JSONObject subject = subjectMap.getJSONObject(questionSubject.key);
|
|
|
+
|
|
|
+ // 归类
|
|
|
+ if (type == null || type.isEmpty()){
|
|
|
+ type = new JSONObject();
|
|
|
+ type.put("key", questionType.key);
|
|
|
+ JSONObject initTypeInfo = new JSONObject();
|
|
|
+ // 初始化题型基础信息
|
|
|
+ initTypeInfo.put("userNumber", 0);
|
|
|
+ initTypeInfo.put("userTime", 0);
|
|
|
+ initTypeInfo.put("userCorrect", 0);
|
|
|
+ initTypeInfo.put("correctTime", 0);
|
|
|
+ initTypeInfo.put("incorrectTime", 0);
|
|
|
+ initTypeInfo.put("diffCorrect", 0f);
|
|
|
+ initTypeInfo.put("diffIncorrect", 0f);
|
|
|
+ type.put("info", initTypeInfo);
|
|
|
+ temp = new JSONObject();
|
|
|
+ temp.put("place", new JSONObject());
|
|
|
+ temp.put("difficult", new JSONObject());
|
|
|
+ tempMap.put(questionSubject.key, temp);
|
|
|
+ }
|
|
|
+ if (subject == null || subject.isEmpty()){
|
|
|
+ subject = new JSONObject();
|
|
|
+ subject.put("key", questionSubject.key);
|
|
|
+ subject.put("pace", new JSONArray());
|
|
|
+ JSONObject initSubjectInfo = new JSONObject();
|
|
|
+ JSONObject subjectBase = toolsService.examinationSubjectInit(questionSubject);
|
|
|
+ // 初始化学科基础信息
|
|
|
+ initSubjectInfo.put("questionNumber", subjectBase.getIntValue("number"));
|
|
|
+ initSubjectInfo.put("time", subjectBase.getIntValue("time"));
|
|
|
+ initSubjectInfo.put("userNumber", 0);
|
|
|
+ initSubjectInfo.put("userTime", 0);
|
|
|
+ initSubjectInfo.put("difficultScore", 0);
|
|
|
+ subject.put("info", initSubjectInfo);
|
|
|
+ subjectMap.put(questionSubject.key, subject);
|
|
|
+ }
|
|
|
+ JSONArray pace = subject.getJSONArray("pace");
|
|
|
+ JSONObject placeMap = temp.getJSONObject("place");
|
|
|
+ JSONObject difficultMap = temp.getJSONObject("difficult");
|
|
|
+ JSONObject typeInfo = type.getJSONObject("info");
|
|
|
+ JSONObject subjectInfo = type.getJSONObject("info");
|
|
|
+
|
|
|
+ // 每题用时
|
|
|
+ JSONObject one = new JSONObject();
|
|
|
+ one.put("time", userQuestion.getTime());
|
|
|
+ one.put("userTime", userQuestion.getUserTime());
|
|
|
+ one.put("no", userQuestion.getNo());
|
|
|
+ pace.add(one);
|
|
|
+
|
|
|
+ // 考点用时,以及正确度
|
|
|
+ String placeKey = relation.getQuestion().getPlace();
|
|
|
+ JSONObject place = placeMap.getJSONObject(placeKey);
|
|
|
+ if (place == null){
|
|
|
+ place = new JSONObject();
|
|
|
+ place.put("key", placeKey);
|
|
|
+ place.put("userNumber", 1);
|
|
|
+ place.put("userCorrect", userQuestion.getIsCorrect());
|
|
|
+ place.put("userTime", userQuestion.getUserTime());
|
|
|
+ placeMap.put(placeKey, place);
|
|
|
+ }else{
|
|
|
+ place.put("userNumber", place.getInteger("userNumber") + 1);
|
|
|
+ place.put("userCorrect", place.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
+ place.put("userTime", place.getInteger("userTime") + userQuestion.getUserTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 难度正确度
|
|
|
+ String difficultKey = relation.getQuestion().getDifficult();
|
|
|
+ JSONObject difficult = difficultMap.getJSONObject(difficultKey);
|
|
|
+ if (difficult == null){
|
|
|
+ difficult = new JSONObject();
|
|
|
+ difficult.put("key", difficultKey);
|
|
|
+ difficult.put("userNumber", 1);
|
|
|
+ difficult.put("userCorrect", userQuestion.getIsCorrect());
|
|
|
+ difficult.put("totalNumber", relation.getTotalNumber());
|
|
|
+ difficult.put("totalCorrect", relation.getTotalCorrect());
|
|
|
+ difficultMap.put(difficultKey, difficult);
|
|
|
+ }else{
|
|
|
+ difficult.put("userNumber", difficult.getInteger("userNumber") + 1);
|
|
|
+ difficult.put("userCorrect", difficult.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
+ difficult.put("totalNumber", difficult.getInteger("totalNumber") + relation.getTotalNumber());
|
|
|
+ difficult.put("totalCorrect", difficult.getInteger("totalCorrect") + relation.getTotalCorrect());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 基础数据
|
|
|
+ typeInfo.put("userNumber", typeInfo.getIntValue("userNumber")+1);
|
|
|
+ typeInfo.put("userTime", typeInfo.getIntValue("userTime")+userQuestion.getUserTime());
|
|
|
+ typeInfo.put("userCorrect", typeInfo.getIntValue("userCorrect")+userQuestion.getIsCorrect());
|
|
|
+ if (userQuestion.getIsCorrect() > 0){
|
|
|
+ typeInfo.put("correctTime", typeInfo.getIntValue("correctTime")+userQuestion.getUserTime());
|
|
|
+ }else{
|
|
|
+ typeInfo.put("incorrectTime", typeInfo.getIntValue("incorrectTime")+userQuestion.getUserTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ subjectInfo.put("userNumber", subjectInfo.getIntValue("userNumber")+1);
|
|
|
+ subjectInfo.put("userTime", subjectInfo.getIntValue("userTime")+userQuestion.getUserTime());
|
|
|
+
|
|
|
+ // 题型难度分计算
|
|
|
+ QuestionDifficult questionDifficult = QuestionDifficult.ValueOf(difficultKey);
|
|
|
+ Integer difficultScore = QuestionDifficult.GetScore(questionDifficult);
|
|
|
+
|
|
|
+ if (userQuestion.getIsCorrect() > 0){
|
|
|
+ typeInfo.put("diffCorrect", typeInfo.getFloatValue("diffCorrect") + toolsService.diffScore(relation.getTotalNumber(), relation.getTotalCorrect(), difficultScore));
|
|
|
+ }else{
|
|
|
+ typeInfo.put("diffIncorrect", typeInfo.getFloatValue("diffIncorrect") + toolsService.diffScore(relation.getTotalNumber(), relation.getTotalCorrect(), difficultScore));
|
|
|
+ }
|
|
|
+
|
|
|
+ subjectInfo.put("difficultScore", subjectInfo.getIntValue("difficultScore")+difficultScore);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算难度平均值
|
|
|
+ for (String key : typeMap.keySet()) {
|
|
|
+ JSONObject type = typeMap.getJSONObject(key);
|
|
|
+ JSONObject typeInfo = type.getJSONObject("info");
|
|
|
+ typeInfo.put("avgDiffCorrect", toolsService.avgDiffScore(typeInfo.getFloat("diffCorrect"), typeInfo.getIntValue("userCorrect")));
|
|
|
+ typeInfo.put("avgDiffIncorrect", toolsService.avgDiffScore(typeInfo.getFloat("diffIncorrect"), typeInfo.getIntValue("userNumber") - typeInfo.getIntValue("userCorrect")));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 学科得分计算
|
|
|
+ JSONObject quantSubject = subjectMap.getJSONObject(QuestionSubject.QUANT.key);
|
|
|
+ JSONObject quantInfo = quantSubject.getJSONObject("info");
|
|
|
+ Integer quantScore = toolsService.quantScore(quantInfo.getIntValue("number"), quantInfo.getIntValue("userNumber"), quantInfo.getInteger("difficultScore"), quantInfo.getInteger("userCorrect"));
|
|
|
+ JSONObject verbalSubject = subjectMap.getJSONObject(QuestionSubject.VERBAL.key);
|
|
|
+ JSONObject verbalInfo = verbalSubject.getJSONObject("info");
|
|
|
+ Integer verbalScore = toolsService.verbalScore(verbalInfo.getIntValue("number"), verbalInfo.getIntValue("userNumber"), verbalInfo.getInteger("difficultScore"), verbalInfo.getInteger("userCorrect"));
|
|
|
+ JSONObject irSubject = subjectMap.getJSONObject(QuestionSubject.IR.key);
|
|
|
+ JSONObject irInfo = irSubject.getJSONObject("info");
|
|
|
+ Integer irScore = toolsService.irScore(irInfo.getIntValue("number"), irInfo.getIntValue("userNumber"), irInfo.getInteger("difficultScore"), irInfo.getInteger("userCorrect"));
|
|
|
+
|
|
|
+ Rank rank = toolsService.totalScore(quantScore, verbalScore);
|
|
|
+ score.put("total", rank.getTotalScore());
|
|
|
+ score.put("totalRank", rank.getTotalRank());
|
|
|
+ score.put("quant", quantScore);
|
|
|
+ score.put("quantRank", rank.getQuantRank());
|
|
|
+ score.put("verbal", verbalScore);
|
|
|
+ score.put("ir", irScore);
|
|
|
+ score.put("irRank", rank.getIrRank());
|
|
|
+
|
|
|
+ detail.put("subject", subjectMap);
|
|
|
+ detail.put("type", typeMap);
|
|
|
+
|
|
|
+ JSONObject info = new JSONObject();
|
|
|
+ // 基本信息
|
|
|
+ info.put("times", paper.getTimes() + 1); // paper还未计数
|
|
|
+ info.put("finishTime", report.getFinishTime());
|
|
|
+ info.put("userTime", report.getUserTime());
|
|
|
+ info.put("time", report.getTime());
|
|
|
+ info.put("questionNumber", report.getQuestionNumber());
|
|
|
+ info.put("userNumber", report.getUserNumber());
|
|
|
+ info.put("userCorrect", report.getUserCorrect());
|
|
|
+ detail.put("info", info);
|
|
|
+
|
|
|
+ report.setDetail(detail);
|
|
|
+ report.setScore(score);
|
|
|
+ }
|
|
|
}
|