|
@@ -1,13 +1,18 @@
|
|
|
package com.qxgmat.service.extend;
|
|
|
|
|
|
+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.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.service.*;
|
|
|
import com.qxgmat.service.annotation.*;
|
|
@@ -15,7 +20,6 @@ import com.qxgmat.service.inline.QuestionNoService;
|
|
|
import com.qxgmat.service.inline.QuestionService;
|
|
|
import com.qxgmat.service.inline.SentenceQuestionService;
|
|
|
import com.qxgmat.service.inline.UserReportService;
|
|
|
-import com.qxgmat.util.annotation.Callback;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -30,7 +34,7 @@ public class QuestionFlowService {
|
|
|
private ExercisePaperService exercisePaperService;
|
|
|
|
|
|
@Resource
|
|
|
- private HomeworkPreviewService homeworkPreviewService;
|
|
|
+ private PreviewService previewService;
|
|
|
|
|
|
@Resource
|
|
|
private ExaminationPaperService examinationPaperService;
|
|
@@ -85,10 +89,10 @@ public class QuestionFlowService {
|
|
|
exercisePaperService.initUserPaper(paper, id);
|
|
|
|
|
|
List<QuestionNoRelation> relationList = questionNoService.listWithRelationByIds(paper.getQuestionNoIds());
|
|
|
- Integer time = toolsService.computerTime(SettingKey.EXERCISE_TIME, relationList);
|
|
|
+ Integer time = toolsService.computerTime(relationList);
|
|
|
paper.setTime(time);
|
|
|
});
|
|
|
- initPaperCallback.put(PaperModule.HOMEWORK_PREVIEW, (paper, id)->{
|
|
|
+ initPaperCallback.put(PaperModule.PREVIEW, (paper, id)->{
|
|
|
|
|
|
});
|
|
|
initPaperCallback.put(PaperModule.ERROR, (paper, id)->{
|
|
@@ -108,7 +112,7 @@ public class QuestionFlowService {
|
|
|
report.setQuestionNoIds(this.randomQuestionNoIds(paper.getQuestionNoIds()));
|
|
|
}
|
|
|
});
|
|
|
- initReportCallback.put(PaperModule.HOMEWORK_PREVIEW, (report, paper)->{
|
|
|
+ initReportCallback.put(PaperModule.PREVIEW, (report, paper)->{
|
|
|
JSONObject setting = report.getSetting();
|
|
|
if (setting.getBoolean("disorder")){
|
|
|
|
|
@@ -136,31 +140,27 @@ public class QuestionFlowService {
|
|
|
nextCallback.put(PaperModule.EXERCISE, (question, report, lastQuestion)->{
|
|
|
Integer questionNoId = this.nextId(report.getQuestionNoIds(), lastQuestion!=null ? lastQuestion.getQuestionNoId():null);
|
|
|
if (questionNoId == 0) return false;
|
|
|
- this.bindQuestionNo(question, questionNoId, SettingKey.EXERCISE_TIME);
|
|
|
+ this.bindQuestionNo(question, questionNoId);
|
|
|
|
|
|
usersService.edit(User.builder().id(question.getUserId()).latestExercise(report.getPaperId()).build());
|
|
|
return true;
|
|
|
});
|
|
|
- nextCallback.put(PaperModule.HOMEWORK_PREVIEW, (question, report, lastQuestion)->{
|
|
|
+ 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, SettingKey.EXERCISE_TIME);
|
|
|
+ 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;
|
|
|
-
|
|
|
- UserPaper paper = userPaperService.get(report.getPaperId());
|
|
|
- this.bindQuestionNo(question, questionNoId, SettingKey.getTimeByPaperModule(PaperModule.ValueOf(paper.getModuleExtend())));
|
|
|
+ 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;
|
|
|
-
|
|
|
- UserPaper paper = userPaperService.get(report.getPaperId());
|
|
|
- this.bindQuestionNo(question, questionNoId, SettingKey.getTimeByPaperModule(PaperModule.ValueOf(paper.getModuleExtend())));
|
|
|
+ this.bindQuestionNo(question, questionNoId);
|
|
|
|
|
|
usersService.edit(User.builder().id(question.getUserId()).latestError(report.getPaperId()).build());
|
|
|
return true;
|
|
@@ -177,23 +177,72 @@ public class QuestionFlowService {
|
|
|
|
|
|
submitCallback.put(QuestionModule.BASE, (userQuestion)->{
|
|
|
|
|
|
- JSONObject answer = userQuestion.getUserAnswer();
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
});
|
|
|
submitCallback.put(QuestionModule.SENTENCE, (userQuestion)->{
|
|
|
|
|
|
- JSONObject answer = userQuestion.getUserAnswer();
|
|
|
+ JSONObject userAnswer = userQuestion.getUserAnswer();
|
|
|
Question question = questionService.get(userQuestion.getQuestionId());
|
|
|
+ JSONObject answer = question.getAnswer();
|
|
|
|
|
|
- return true;
|
|
|
+ boolean correct = true;
|
|
|
+ JSONObject detail = new JSONObject();
|
|
|
+
|
|
|
+ boolean subjectCorrect = this.sentenceAnswer(userAnswer.getJSONArray("subject"), answer.getJSONArray("subject"));
|
|
|
+ detail.put("subject", subjectCorrect);
|
|
|
+ correct = correct & subjectCorrect;
|
|
|
+
|
|
|
+ boolean predicateCorrect = this.sentenceAnswer(userAnswer.getJSONArray("predicate"), answer.getJSONArray("predicate"));
|
|
|
+ detail.put("predicate", predicateCorrect);
|
|
|
+ correct = correct & predicateCorrect;
|
|
|
+
|
|
|
+ boolean objectCorrect = this.sentenceAnswer(userAnswer.getJSONArray("object"), answer.getJSONArray("object"));
|
|
|
+ detail.put("object", objectCorrect);
|
|
|
+ correct = correct & objectCorrect;
|
|
|
+
|
|
|
+ boolean optionsCorrect = this.sentenceAnswer(userAnswer.getJSONArray("options"), answer.getJSONArray("options"));
|
|
|
+ detail.put("options", optionsCorrect);
|
|
|
+
|
|
|
+
|
|
|
+ userQuestion.setDetail(detail);
|
|
|
+
|
|
|
+ return correct;
|
|
|
});
|
|
|
|
|
|
submitAfterCallback.put(QuestionModule.BASE, (userQuestion)->{
|
|
|
|
|
|
questionNoService.accumulation(userQuestion);
|
|
|
questionService.accumulation(userQuestion);
|
|
|
+
|
|
|
});
|
|
|
submitAfterCallback.put(QuestionModule.SENTENCE, (userQuestion)->{
|
|
|
|
|
@@ -202,14 +251,26 @@ public class QuestionFlowService {
|
|
|
});
|
|
|
|
|
|
finishCallback.put(PaperModule.EXERCISE, (report, questionList)->{
|
|
|
-
|
|
|
+ report.setDetail(this.statExerciseReport(report, questionList));
|
|
|
});
|
|
|
- finishCallback.put(PaperModule.HOMEWORK_PREVIEW, (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));
|
|
|
});
|
|
|
finishCallback.put(PaperModule.EXAMINATION, (report, questionList)->{
|
|
|
|
|
|
});
|
|
|
+ finishCallback.put(PaperModule.TEXTBOOK, (report, questionList)->{
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
@@ -286,7 +347,7 @@ public class QuestionFlowService {
|
|
|
if (!report.getUserId().equals(userId)){
|
|
|
throw new ParameterException("试卷不存在");
|
|
|
}
|
|
|
- userQuestion = userQuestionService.addByReport(report, userQuestion, nextCallback.get(PaperModule.ValueOf(report.getModule())));
|
|
|
+ userQuestion = userQuestionService.addByReport(report, userQuestion, nextCallback.get(PaperModule.ValueOf(report.getPaperModule())));
|
|
|
}
|
|
|
|
|
|
return userQuestion;
|
|
@@ -311,16 +372,20 @@ public class QuestionFlowService {
|
|
|
UserReport userReport = userReportService.get(userQuestion.getReportId());
|
|
|
|
|
|
|
|
|
- QuestionModule module = QuestionModule.WithPaper(PaperModule.ValueOf(userReport.getModule()));
|
|
|
+ QuestionModule module = QuestionModule.WithPaper(PaperModule.ValueOf(userReport.getPaperModule()));
|
|
|
SubmitQuestion callback = submitCallback.get(module);
|
|
|
- boolean result = callback.callback(userQuestion);
|
|
|
+ Boolean result = callback.callback(userQuestion);
|
|
|
userQuestion.setIsCorrect(result ? 1 : 0);
|
|
|
userQuestionService.edit(userQuestion);
|
|
|
|
|
|
|
|
|
if (toolsService.filterTime(userQuestion)){
|
|
|
- SubmitAfterQuestion afterCallback = submitAfterCallback.get(module);
|
|
|
- afterCallback.callback(userQuestion);
|
|
|
+ Question question = questionService.get(userQuestion.getQuestionId());
|
|
|
+
|
|
|
+ if (!question.getQuestionType().equals(QuestionType.AWA.key)){
|
|
|
+ SubmitAfterQuestion afterCallback = submitAfterCallback.get(module);
|
|
|
+ afterCallback.callback(userQuestion);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -349,8 +414,9 @@ public class QuestionFlowService {
|
|
|
userReport.setFinishTime(new Date());
|
|
|
List<UserQuestion> userQuestionList = userQuestionService.listByReport(userId, userReportId);
|
|
|
|
|
|
- StatReport callback = finishCallback.get(PaperModule.ValueOf(userReport.getModule()));
|
|
|
+ StatReport callback = finishCallback.get(PaperModule.ValueOf(userReport.getPaperModule()));
|
|
|
callback.callback(userReport, userQuestionList);
|
|
|
+ userReportService.edit(userReport);
|
|
|
|
|
|
|
|
|
userPaperService.accumulation(userReport);
|
|
@@ -368,6 +434,18 @@ public class QuestionFlowService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ * 获取报告题目列表
|
|
|
+ * @param userReportId
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<UserQuestion> listByReport(Integer userReportId, Integer userId){
|
|
|
+
|
|
|
+ List<UserQuestion> userQuestionList = userQuestionService.listByReport(userId, userReportId);
|
|
|
+ return userQuestionList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
* 乱序生成题目列表
|
|
|
* @param questionNoIds
|
|
|
* @return
|
|
@@ -408,18 +486,12 @@ public class QuestionFlowService {
|
|
|
* 关联绑定questionNo类型试题
|
|
|
* @param question
|
|
|
* @param questionNoId
|
|
|
- * @param settingKey
|
|
|
*/
|
|
|
- private void bindQuestionNo(UserQuestion question, Integer questionNoId, SettingKey settingKey){
|
|
|
+ private void bindQuestionNo(UserQuestion question, Integer questionNoId){
|
|
|
QuestionNoRelation relation = questionNoService.getWithRelation(questionNoId);
|
|
|
question.setQuestionNoId(relation.getId());
|
|
|
question.setQuestionId(relation.getQuestionId());
|
|
|
- if (settingKey != null) {
|
|
|
-
|
|
|
- settingKey = SettingKey.getTimeByPaperModule(PaperModule.ValueOf(relation.getModule()));
|
|
|
- }
|
|
|
-
|
|
|
- Integer time = toolsService.computerTime(settingKey, relation);
|
|
|
+ Integer time = toolsService.computerTime(relation);
|
|
|
question.setTime(time);
|
|
|
}
|
|
|
|
|
@@ -435,4 +507,211 @@ public class QuestionFlowService {
|
|
|
relation.setPaper(paper);
|
|
|
return relation;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 长难句单个选项答案判断
|
|
|
+ * @param userAnswer
|
|
|
+ * @param answer
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Boolean sentenceAnswer(JSONArray userAnswer, JSONArray answer){
|
|
|
+
|
|
|
+ if (userAnswer.size() == answer.size()){
|
|
|
+ for(Object s : userAnswer){
|
|
|
+ if (!answer.contains(s)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 根据练习报告格式,统计信息
|
|
|
+ * @param report
|
|
|
+ * @param questionList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private JSONObject statExerciseReport(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());
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject detail = new JSONObject();
|
|
|
+ JSONArray pace = new JSONArray();
|
|
|
+ for (UserQuestion userQuestion : questionList){
|
|
|
+
|
|
|
+ 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){
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONArray difficult = new JSONArray();
|
|
|
+ difficult.addAll(difficultMap.values());
|
|
|
+ detail.put("difficult", difficult);
|
|
|
+
|
|
|
+ JSONObject placeMap = new JSONObject();
|
|
|
+ for (UserQuestion userQuestion:questionList){
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }else{
|
|
|
+ t.put("userNumber", t.getInteger("userNumber") + 1);
|
|
|
+ t.put("userCorrect", t.getInteger("userCorrect") + userQuestion.getIsCorrect());
|
|
|
+ t.put("userTime", t.getInteger("userTime") + userQuestion.getUserTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ 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 statSentenceReport(UserReport report, List<UserQuestion> questionList){
|
|
|
+ UserPaper paper = userPaperService.get(report.getPaperId());
|
|
|
+ Collection questionNoIds = Transform.getIds(questionList, UserQuestion.class, "questionNoId");
|
|
|
+ Map<Number, SentenceQuestionRelation> relationMap = sentenceQuestionService.mapWithRelationByIds((Integer[])questionNoIds.toArray());
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject detail = new JSONObject();
|
|
|
+ JSONObject ability = new JSONObject();
|
|
|
+ Integer struct = 0;
|
|
|
+ Integer logic = 0;
|
|
|
+ Integer speed = 0;
|
|
|
+ for (UserQuestion userQuestion:questionList){
|
|
|
+ SentenceQuestionRelation relation = relationMap.get(userQuestion.getQuestionNoId());
|
|
|
+ if (userQuestion.getIsCorrect() > 0){
|
|
|
+ struct += 1;
|
|
|
+ }
|
|
|
+ if (userQuestion.getUserTime() < userQuestion.getTime()){
|
|
|
+ speed += 1;
|
|
|
+ }
|
|
|
+ JSONObject questionDetail = userQuestion.getDetail();
|
|
|
+ if (questionDetail.getBoolean("options")){
|
|
|
+ logic += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ability.put("struct", struct * 100 / report.getQuestionNumber());
|
|
|
+ ability.put("logic", logic * 100 / report.getQuestionNumber());
|
|
|
+ ability.put("speed", speed * 100 / report.getQuestionNumber());
|
|
|
+ ability.put("score", (struct * 40 + logic * 30 + speed * 30) / report.getQuestionNumber());
|
|
|
+ detail.put("ability", ability);
|
|
|
+
|
|
|
+ JSONObject info = new JSONObject();
|
|
|
+
|
|
|
+ info.put("times", paper.getTimes() + 1);
|
|
|
+ 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 (SentenceQuestionRelation 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;
|
|
|
+ }
|
|
|
}
|