|
@@ -4,7 +4,9 @@ import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -26,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import cn.com.qmth.stmms.admin.thread.MarkGroupDeleteThread;
|
|
|
+import cn.com.qmth.stmms.admin.thread.ScoreCalculateThread;
|
|
|
import cn.com.qmth.stmms.api.dto.GroupDTO;
|
|
|
import cn.com.qmth.stmms.api.dto.GroupQuestionDTO;
|
|
|
import cn.com.qmth.stmms.api.dto.PaperDTO;
|
|
@@ -46,6 +49,7 @@ import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.InspectHistoryService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.MarkerClassService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.MarkerService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.SubjectUserService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.query.ExamQuestionSearchQuery;
|
|
@@ -63,6 +67,7 @@ import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
|
import cn.com.qmth.stmms.common.enums.ExamType;
|
|
|
import cn.com.qmth.stmms.common.enums.LockType;
|
|
|
import cn.com.qmth.stmms.common.enums.ObjectiveStatus;
|
|
|
+import cn.com.qmth.stmms.common.enums.QuestionType;
|
|
|
import cn.com.qmth.stmms.common.enums.Role;
|
|
|
import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
|
|
|
import cn.com.qmth.stmms.common.enums.UserSource;
|
|
@@ -125,6 +130,9 @@ public class CoreController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private SchoolService schoolService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MarkerClassService markerClassService;
|
|
|
+
|
|
|
public static final String USER_PASSWORD = "123456";
|
|
|
|
|
|
@RequestMapping(value = "/exam/save", method = RequestMethod.POST)
|
|
@@ -624,6 +632,22 @@ public class CoreController extends BaseApiController {
|
|
|
if (objective) {
|
|
|
validate("answer", q.getAnswer(), true, 16);
|
|
|
q.setAnswer(q.getAnswer().toUpperCase());
|
|
|
+ if (q.getType() == null && q.getAnswer().length() > 1) {
|
|
|
+ q.setType(QuestionType.MULTIPLE);
|
|
|
+ }
|
|
|
+ if (q.getType() == null && q.getAnswer().length() == 1) {
|
|
|
+ q.setType(QuestionType.SINGLE);
|
|
|
+ }
|
|
|
+ if (QuestionType.TRUE_OR_FALSE.equals(q.getType())
|
|
|
+ && (!q.getAnswer().contains("A") && !q.getAnswer().contains("B"))) {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.replaceMessage(":qurstion type TRUR_OR_FALSE invalid");
|
|
|
+ }
|
|
|
+ if (QuestionType.SINGLE.equals(q.getType()) && q.getAnswer().length() > 1) {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.replaceMessage(":qurstion type SINGLE but answer>1 ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ q.setType(null);
|
|
|
+ q.setObjectivePolicy(null);
|
|
|
}
|
|
|
q.setExamId(examId);
|
|
|
q.setSubjectCode(subjectCode);
|
|
@@ -673,6 +697,7 @@ public class CoreController extends BaseApiController {
|
|
|
value.accumulate("mainTitle", q.getMainTitle());
|
|
|
value.accumulate("totalScore", q.getTotalScore());
|
|
|
value.accumulate("answer", q.getAnswer() == null ? "" : q.getAnswer());
|
|
|
+ value.accumulate("type", q.getType() == null ? "" : q.getType().toString());
|
|
|
result.add(value);
|
|
|
}
|
|
|
return result;
|
|
@@ -871,7 +896,7 @@ public class CoreController extends BaseApiController {
|
|
|
@RequestMapping(value = "/exam/question/list", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
@RoleRequire({ Role.SCHOOL_ADMIN, Role.SCHOOL_DEV, Role.SUBJECT_HEADER, Role.COLLEGE_ADMIN })
|
|
|
- public JSONArray paperQuery(HttpServletRequest request, @RequestParam Integer examId,
|
|
|
+ public JSONArray questionList(HttpServletRequest request, @RequestParam Integer examId,
|
|
|
@RequestParam String subjectCode) {
|
|
|
ApiUser user = RequestUtils.getApiUser(request);
|
|
|
JSONArray result = new JSONArray();
|
|
@@ -902,6 +927,7 @@ public class CoreController extends BaseApiController {
|
|
|
value.accumulate("mainTitle", q.getMainTitle());
|
|
|
value.accumulate("totalScore", q.getTotalScore());
|
|
|
value.accumulate("answer", q.getAnswer() == null ? "" : q.getAnswer());
|
|
|
+ value.accumulate("type", q.getType() == null ? "" : q.getType().toString());
|
|
|
result.add(value);
|
|
|
}
|
|
|
return result;
|
|
@@ -973,4 +999,60 @@ public class CoreController extends BaseApiController {
|
|
|
result.accumulate("updateTime", DateUtils.formatDateTime(new Date()));
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value = "/user/class/save", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCHOOL_DEV, Role.SUBJECT_HEADER, Role.COLLEGE_ADMIN })
|
|
|
+ public JSONObject userClassSave(HttpServletRequest request, @RequestParam Integer examId,
|
|
|
+ @RequestParam List<String> className, @RequestParam String account) {
|
|
|
+ ApiUser user = RequestUtils.getApiUser(request);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ // 输入字段预处理并初步校验
|
|
|
+ account = validate("account", account, true, 32);
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
+ if (exam == null || !validateSchool(user.getSchoolId(), exam.getSchoolId())
|
|
|
+ || exam.getStatus() != ExamStatus.START) {
|
|
|
+ throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
+ }
|
|
|
+ User u = userService.findByAccount(exam.getSchoolId(), account);
|
|
|
+ if (u == null || !Role.MARKER.equals(u.getRole())) {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.appendMessage(": account error");
|
|
|
+ }
|
|
|
+ markerClassService.save(u.getId(), examId, className.stream().toArray(String[]::new));
|
|
|
+ result.accumulate("updateTime", DateUtils.formatDateTime(new Date()));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/exam/subject/calculate", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCHOOL_DEV })
|
|
|
+ public JSONObject calculate(HttpServletRequest request, @RequestParam Integer examId,
|
|
|
+ @RequestParam String subjectCode) {
|
|
|
+ ApiUser user = RequestUtils.getApiUser(request);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ // 输入字段预处理并初步校验
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
+ if (exam == null) {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.replaceMessage("examId invalid");
|
|
|
+ } else if (!validateSchool(user.getSchoolId(), exam.getSchoolId()) || exam.getStatus() != ExamStatus.START) {
|
|
|
+ throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
+ }
|
|
|
+ ExamSubject subject = subjectService.find(examId, subjectCode);
|
|
|
+ if (subject == null) {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.replaceMessage("subjectCode invalid");
|
|
|
+ }
|
|
|
+ Set<String> subjectSet = new HashSet<String>();
|
|
|
+ if (!lockService.isLocked(LockType.SCORE_CALCULATE, exam.getId(), subjectCode)) {
|
|
|
+ subjectSet.add(subjectCode);
|
|
|
+ }
|
|
|
+ if (!subjectSet.isEmpty()) {
|
|
|
+ ScoreCalculateThread thread = new ScoreCalculateThread(exam.getId(), subjectSet, lockService,
|
|
|
+ studentService, questionService, examService, subjectService, fileService, false);
|
|
|
+ taskExecutor.submit(thread);
|
|
|
+ result.accumulate("updateTime", DateUtils.formatDateTime(new Date()));
|
|
|
+ return result;
|
|
|
+ } else {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.replaceMessage("subject is calculate");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|