|
@@ -0,0 +1,118 @@
|
|
|
+package cn.com.qmth.stmms.admin.exam;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
|
+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.MarkGroupService;
|
|
|
+import cn.com.qmth.stmms.biz.mark.model.ProblemHistory;
|
|
|
+import cn.com.qmth.stmms.biz.mark.model.ProblemType;
|
|
|
+import cn.com.qmth.stmms.biz.mark.query.ProblemHistorySearchQuery;
|
|
|
+import cn.com.qmth.stmms.biz.mark.service.ProblemHistoryService;
|
|
|
+import cn.com.qmth.stmms.biz.mark.service.ProblemTypeService;
|
|
|
+import cn.com.qmth.stmms.common.enums.HistoryStatus;
|
|
|
+import cn.com.qmth.stmms.common.enums.MarkStatus;
|
|
|
+import cn.com.qmth.stmms.common.utils.DateUtils;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/admin/exam/problem/history")
|
|
|
+public class ProblemHistoryController extends BaseExamController {
|
|
|
+
|
|
|
+ protected static Logger log = LoggerFactory.getLogger(ProblemHistoryController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProblemTypeService problemService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProblemHistoryService historyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamStudentService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamSubjectService subjectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MarkGroupService groupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamQuestionService questionService;
|
|
|
+
|
|
|
+ @RequestMapping
|
|
|
+ public String list(HttpServletRequest request, Model model, ProblemHistorySearchQuery query) {
|
|
|
+ int examId = getSessionExamId(request);
|
|
|
+ if (examId > 0) {
|
|
|
+ List<ProblemType> problemTypes = problemService.findByExamId(examId);
|
|
|
+ Map<Integer, ProblemType> problemMap = new HashMap<Integer, ProblemType>();
|
|
|
+ for (ProblemType problemType : problemTypes) {
|
|
|
+ problemMap.put(problemType.getId(), problemType);
|
|
|
+ }
|
|
|
+ query.setExamId(examId);
|
|
|
+ query.setStatus(HistoryStatus.WAITING);
|
|
|
+ query.orderByExamNumber();
|
|
|
+ query = historyService.findByQuery(query);
|
|
|
+
|
|
|
+ List<ExamStudent> list = new LinkedList<ExamStudent>();
|
|
|
+ for (ProblemHistory history : query.getResult()) {
|
|
|
+ ExamStudent student = studentService.findById(history.getStudentId());
|
|
|
+ student.setNumber(history.getGroupNumber());
|
|
|
+ student.setProblemType(problemMap.get(history.getProblemId()));
|
|
|
+ student.setMarkTime(DateUtils.formatDateTime(history.getCreateTime()));
|
|
|
+ student.setLibraryId(history.getLibraryId());
|
|
|
+ list.add(student);
|
|
|
+ }
|
|
|
+ model.addAttribute("resultList", list);
|
|
|
+ model.addAttribute("query", query);
|
|
|
+ model.addAttribute("subjectList", getProblemSubject(examId));
|
|
|
+ model.addAttribute("problemList", problemTypes);
|
|
|
+ List<MarkGroup> groupList = groupService.findByExamAndSubjectAndStatus(examId, query.getSubjectCode(),
|
|
|
+ MarkStatus.FORMAL);
|
|
|
+ for (MarkGroup group : groupList) {
|
|
|
+ List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjectiveAndGroupNumber(examId,
|
|
|
+ group.getSubjectCode(), false, group.getNumber());
|
|
|
+ group.setQuestionList(questions);
|
|
|
+ }
|
|
|
+ model.addAttribute("groupList", groupList);
|
|
|
+ model.addAttribute("statusList", HistoryStatus.getOptionList());
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
+ model.addAttribute("examType", exam.getType());
|
|
|
+ return "modules/exam/problemHistory";
|
|
|
+ }
|
|
|
+ return "redirect:/admin/exam/list";
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamSubject> getProblemSubject(int examId) {
|
|
|
+ List<ExamSubject> list = new LinkedList<ExamSubject>();
|
|
|
+ List<String> codes = historyService.findProblemSubjectCode(examId);
|
|
|
+ for (String code : codes) {
|
|
|
+ ExamSubject subject = subjectService.find(examId, code);
|
|
|
+ if (subject != null) {
|
|
|
+ list.add(subject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|