|
@@ -16,6 +16,8 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.core.task.AsyncTaskExecutor;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -45,6 +47,7 @@ import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
|
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;
|
|
|
import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
|
import cn.com.qmth.stmms.biz.lock.LockService;
|
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkService;
|
|
@@ -833,4 +836,41 @@ public class CoreController extends BaseApiController {
|
|
|
result.accumulate("updateTime", DateUtils.formatDateTime(new Date()));
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @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,
|
|
|
+ @RequestParam String subjectCode) {
|
|
|
+ ApiUser user = RequestUtils.getApiUser(request);
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
+ // 输入字段预处理并初步校验
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
+ if (exam == null || !exam.getSchoolId().equals(user.getSchoolId()) || exam.getStatus() != ExamStatus.START) {
|
|
|
+ throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
+ }
|
|
|
+ subjectCode = validate("subjectCode", subjectCode, true, 64);
|
|
|
+ ExamSubject subject = subjectService.find(examId, subjectCode);
|
|
|
+ if (subject == null) {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.appendMessage(": subjectCode error");
|
|
|
+ }
|
|
|
+ ExamQuestionSearchQuery query = new ExamQuestionSearchQuery();
|
|
|
+ query.setExamId(examId);
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
+ query.setSort(new Sort(Direction.ASC, "subjectCode", "paperType", "mainNumber", "subNumber"));
|
|
|
+ query.setPageNumber(1);
|
|
|
+ query.setPageSize(Integer.MAX_VALUE);
|
|
|
+ query = questionService.findByQuery(query);
|
|
|
+ for (ExamQuestion q : query.getResult()) {
|
|
|
+ JSONObject value = new JSONObject();
|
|
|
+ value.accumulate("objective", q.isObjective());
|
|
|
+ value.accumulate("mainNumber", q.getMainNumber());
|
|
|
+ value.accumulate("subNumber", q.getSubNumber());
|
|
|
+ value.accumulate("mainTitle", q.getMainTitle());
|
|
|
+ value.accumulate("totalScore", q.getTotalScore());
|
|
|
+ value.accumulate("answer", q.getAnswer() == null ? "" : q.getAnswer());
|
|
|
+ result.add(value);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|