|
@@ -577,12 +577,12 @@ public class QuestionFlowService {
|
|
|
if (!userReport.getUserId().equals(userId)){
|
|
|
throw new ParameterException("试卷不存在");
|
|
|
}
|
|
|
- if (userReport.getDetail() != null && userReport.getFinishTime() != null){
|
|
|
- throw new ParameterException("做题结束");
|
|
|
- }
|
|
|
- if (userReport.getUserNumber()>=userReport.getQuestionNumber()){
|
|
|
- throw new ParameterException("答题结束,请提交完成");
|
|
|
- }
|
|
|
+// if (userReport.getDetail() != null && userReport.getFinishTime() != null){
|
|
|
+// throw new ParameterException("做题结束");
|
|
|
+// }
|
|
|
+// if (userReport.getUserNumber()>=userReport.getQuestionNumber()){
|
|
|
+// throw new ParameterException("答题结束,请提交完成");
|
|
|
+// }
|
|
|
|
|
|
return relationReport(userReport);
|
|
|
}
|
|
@@ -881,7 +881,7 @@ public class QuestionFlowService {
|
|
|
String stage = setting.getString("stage");
|
|
|
JSONObject time = setting.getJSONObject("time");
|
|
|
JSONObject number = setting.getJSONObject("number");
|
|
|
- time.put(stage, time.getIntValue(stage)+ lastQuestion.getUserTime());
|
|
|
+ time.put(stage, time.getIntValue(stage)+ (lastQuestion !=null ?lastQuestion.getUserTime():0));
|
|
|
Integer totalNumber = toolsService.examinationSubjectNumber(stage);
|
|
|
// 判断数量是否已经完成
|
|
|
if (number.getIntValue(stage) >= totalNumber){
|
|
@@ -920,7 +920,7 @@ public class QuestionFlowService {
|
|
|
}else{
|
|
|
questionNoId = randomCompute(subject, paper, questionTypes, setting, subnumber, ids, userQuestionList);
|
|
|
}
|
|
|
- if (questionNoId == 0) {
|
|
|
+ if (questionNoId ==null || questionNoId == 0) {
|
|
|
throw new ParameterException("模考出题流程错误:题目生成错误");
|
|
|
}
|
|
|
QuestionNoRelation relation = questionNoService.getWithRelation(questionNoId);
|
|
@@ -928,6 +928,7 @@ public class QuestionFlowService {
|
|
|
question.setQuestionId(relation.getQuestionId());
|
|
|
question.setQuestionType(relation.getQuestion().getQuestionType());
|
|
|
question.setTime(toolsService.computerTime(relation));
|
|
|
+ question.setStage(stage);
|
|
|
// 更新题目数
|
|
|
number.put(stage, subnumber + 1);
|
|
|
return true;
|
|
@@ -1065,7 +1066,7 @@ public class QuestionFlowService {
|
|
|
}
|
|
|
// 判断是否后续阅读题
|
|
|
JSONObject rc = setting.getJSONObject("rc");
|
|
|
- if(rc.getInteger(subnumber.toString()) != null){
|
|
|
+ if(rc != null && rc.getInteger(subnumber.toString()) != null){
|
|
|
return rc.getIntValue(subnumber.toString());
|
|
|
}
|
|
|
break;
|
|
@@ -1415,8 +1416,8 @@ public class QuestionFlowService {
|
|
|
|
|
|
JSONObject limit = new JSONObject();
|
|
|
// 限时统计考试正确度
|
|
|
- UserReportLimitRelation relation = userReportService.statLimit(report.getPaperOrigin(), report.getOriginId());
|
|
|
- limit.put("userNumber", relation.getUserNumber());
|
|
|
+ UserReportLimitRelation relation = userQuestionService.statLimit(report.getId());
|
|
|
+ limit.put("userNumber", questionList.size());
|
|
|
limit.put("userCorrect", relation.getUserCorrect());
|
|
|
detail.put("limit", limit);
|
|
|
|
|
@@ -1508,8 +1509,8 @@ public class QuestionFlowService {
|
|
|
|
|
|
JSONObject limit = new JSONObject();
|
|
|
// 限时统计考试正确度
|
|
|
- UserReportLimitRelation relation = userReportService.statLimit(report.getPaperOrigin(), report.getOriginId());
|
|
|
- limit.put("userNumber", relation.getUserNumber());
|
|
|
+ UserReportLimitRelation relation = userQuestionService.statLimit(report.getId());
|
|
|
+ limit.put("userNumber", questionList.size());
|
|
|
limit.put("userCorrect", relation.getUserCorrect());
|
|
|
detail.put("limit", limit);
|
|
|
|
|
@@ -1632,8 +1633,13 @@ public class QuestionFlowService {
|
|
|
*/
|
|
|
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());
|
|
|
+ Integer[] tmpIds = new Integer[questionList.size()];
|
|
|
+ int i = 0;
|
|
|
+ for (UserQuestion question: questionList) {
|
|
|
+ tmpIds[i] = question.getQuestionNoId();
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ Map<Number, QuestionNoRelation> relationMap = questionNoService.mapWithRelationByIds(tmpIds);
|
|
|
|
|
|
// report
|
|
|
JSONObject detail = new JSONObject();
|
|
@@ -1642,7 +1648,6 @@ public class QuestionFlowService {
|
|
|
// 成绩单
|
|
|
JSONObject subjectMap = new JSONObject();
|
|
|
JSONObject typeMap = new JSONObject();
|
|
|
- JSONObject tempMap = new JSONObject();
|
|
|
JSONObject difficult = null;
|
|
|
JSONObject place = null;
|
|
|
for (UserQuestion userQuestion : questionList){
|
|
@@ -1650,35 +1655,15 @@ public class QuestionFlowService {
|
|
|
QuestionType questionType = QuestionType.ValueOf(relation.getQuestion().getQuestionType());
|
|
|
QuestionSubject questionSubject = QuestionSubject.FromType(questionType);
|
|
|
JSONObject type = typeMap.getJSONObject(questionType.key);
|
|
|
- JSONObject tempType = tempMap.getJSONObject(questionType.key);
|
|
|
JSONObject subject = subjectMap.getJSONObject(questionSubject.key);
|
|
|
- JSONObject tempSubject = tempMap.getJSONObject(questionSubject.key);
|
|
|
|
|
|
// 归类
|
|
|
- if (type == null || type.isEmpty()){
|
|
|
- type = new JSONObject();
|
|
|
- type.put("key", questionType.key);
|
|
|
- subject.put("pace", new JSONArray());
|
|
|
- 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);
|
|
|
- typeMap.put(questionType.key, type);
|
|
|
- tempType = new JSONObject();
|
|
|
- tempType.put("place", new JSONObject());
|
|
|
- tempType.put("difficult", new JSONObject());
|
|
|
- tempMap.put(questionType.key, tempType);
|
|
|
- }
|
|
|
if (subject == null || subject.isEmpty()){
|
|
|
subject = new JSONObject();
|
|
|
subject.put("key", questionSubject.key);
|
|
|
subject.put("pace", new JSONArray());
|
|
|
+ subject.put("place", new JSONObject());
|
|
|
+ subject.put("difficult", new JSONObject());
|
|
|
JSONObject initSubjectInfo = new JSONObject();
|
|
|
JSONObject subjectBase = toolsService.examinationSubjectInit(questionSubject);
|
|
|
// 初始化学科基础信息
|
|
@@ -1694,18 +1679,32 @@ public class QuestionFlowService {
|
|
|
initSubjectInfo.put("difficultScore", 0);
|
|
|
subject.put("info", initSubjectInfo);
|
|
|
subjectMap.put(questionSubject.key, subject);
|
|
|
- tempSubject = new JSONObject();
|
|
|
- tempSubject.put("place", new JSONObject());
|
|
|
- tempSubject.put("difficult", new JSONObject());
|
|
|
- tempMap.put(questionSubject.key, tempType);
|
|
|
+ }
|
|
|
+ if (type == null || type.isEmpty()){
|
|
|
+ type = new JSONObject();
|
|
|
+ type.put("key", questionType.key);
|
|
|
+ type.put("pace", new JSONArray());
|
|
|
+ type.put("place", new JSONObject());
|
|
|
+ type.put("difficult", new JSONObject());
|
|
|
+ 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);
|
|
|
+ typeMap.put(questionType.key, type);
|
|
|
}
|
|
|
JSONArray paceType = type.getJSONArray("pace");
|
|
|
- JSONObject placeTypeMap = tempType.getJSONObject("place");
|
|
|
- JSONObject difficultTypeMap = tempType.getJSONObject("difficult");
|
|
|
+ JSONObject placeTypeMap = type.getJSONObject("place");
|
|
|
+ JSONObject difficultTypeMap = type.getJSONObject("difficult");
|
|
|
JSONObject typeInfo = type.getJSONObject("info");
|
|
|
JSONArray paceSubject = subject.getJSONArray("pace");
|
|
|
- JSONObject placeSubjectMap = tempType.getJSONObject("place");
|
|
|
- JSONObject difficultSubjectMap = tempType.getJSONObject("difficult");
|
|
|
+ JSONObject placeSubjectMap = subject.getJSONObject("place");
|
|
|
+ JSONObject difficultSubjectMap = subject.getJSONObject("difficult");
|
|
|
JSONObject subjectInfo = subject.getJSONObject("info");
|
|
|
|
|
|
// 每题用时
|
|
@@ -1827,15 +1826,24 @@ public class QuestionFlowService {
|
|
|
}
|
|
|
|
|
|
// 学科得分计算
|
|
|
+ Integer quantScore = 0;
|
|
|
+ Integer verbalScore = 0;
|
|
|
+ Integer irScore = 0;
|
|
|
JSONObject quantSubject = subjectMap.getJSONObject(QuestionSubject.QUANT.key);
|
|
|
- JSONObject quantInfo = quantSubject.getJSONObject("info");
|
|
|
- Integer quantScore = toolsService.quantScore(quantInfo.getIntValue("number"), quantInfo.getIntValue("userNumber"), quantInfo.getFloatValue("difficultScore"), quantInfo.getInteger("userCorrect"));
|
|
|
+ if (quantSubject != null){
|
|
|
+ JSONObject quantInfo = quantSubject.getJSONObject("info");
|
|
|
+ quantScore = toolsService.quantScore(quantInfo.getIntValue("number"), quantInfo.getIntValue("userNumber"), quantInfo.getFloatValue("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.getFloatValue("difficultScore"), verbalInfo.getInteger("userCorrect"));
|
|
|
+ if (verbalSubject != null){
|
|
|
+ JSONObject verbalInfo = verbalSubject.getJSONObject("info");
|
|
|
+ verbalScore = toolsService.verbalScore(verbalInfo.getIntValue("number"), verbalInfo.getIntValue("userNumber"), verbalInfo.getFloatValue("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"));
|
|
|
+ if (irSubject != null){
|
|
|
+ JSONObject irInfo = irSubject.getJSONObject("info");
|
|
|
+ irScore = toolsService.irScore(irInfo.getIntValue("number"), irInfo.getIntValue("userNumber"), irInfo.getInteger("difficultScore"), irInfo.getInteger("userCorrect"));
|
|
|
+ }
|
|
|
|
|
|
Rank rank = toolsService.totalScore(quantScore, verbalScore);
|
|
|
score.put("totalScore", rank.getTotalScore());
|