Explorar el Código

选做题分组

yin hace 13 horas
padre
commit
91aefdd30e

+ 0 - 3
stmms-web/src/main/java/cn/com/qmth/stmms/api/controller/admin/OperationLogController.java

@@ -34,9 +34,6 @@ public class OperationLogController extends BaseApiController {
     @Autowired
     private OperationLogService logService;
 
-    @Autowired
-    private ExamService examService;
-
     @ApiOperation(value = "日志列表")
     @RequestMapping(value = "query", method = RequestMethod.POST)
     @ResponseBody

+ 16 - 16
stmms-web/src/main/java/cn/com/qmth/stmms/api/controller/admin/ReportController.java

@@ -125,7 +125,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "总量分析导出")
     @Logging(menu = "课程总量统计导出", type = LogType.EXPORT)
-    @RequestMapping("/subject/export")
+    @RequestMapping(value="/subject/export", method = RequestMethod.POST)
     public void subjectExport(ReportSubjectQuery query, HttpServletResponse response) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -155,7 +155,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "分段统计")
     @Logging(menu = "课程分段统计", type = LogType.QUERY)
-    @RequestMapping("/range")
+    @RequestMapping(value="/range", method = RequestMethod.POST)
     public JSONArray rangeList(ReportSubjectQuery query) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -183,7 +183,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程统计导出")
     @Logging(menu = "课程统计导出", type = LogType.EXPORT)
-    @RequestMapping("/range/export")
+    @RequestMapping(value="/range/export", method = RequestMethod.POST)
     public void rangeExport(ReportSubjectQuery query, HttpServletResponse response,
             @RequestParam(required = false) Boolean all) {
         int examId = getSessionExamId();
@@ -244,7 +244,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "成绩分析计算")
     @Logging(menu = "科目成绩分析计算", type = LogType.UPDATE)
-    @RequestMapping("/calculate")
+    @RequestMapping(value="/calculate", method = RequestMethod.POST)
     public ResultMessage calculate(@RequestParam String subjectCode, @RequestParam Boolean objective) {
         int examId = getSessionExamId();
         Set<String> subjectSet = new HashSet<String>();
@@ -321,7 +321,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程学院分析")
     @Logging(menu = "课程学院分析", type = LogType.QUERY)
-    @RequestMapping("/college")
+    @RequestMapping(value="/college", method = RequestMethod.POST)
     public PageResult<ReportSubjectCollege> collegeList(ReportSubjectQuery query) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -342,7 +342,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程学院分析导出")
     @Logging(menu = "课程学院分析导出", type = LogType.EXPORT)
-    @RequestMapping("/college/export")
+    @RequestMapping(value="/college/export", method = RequestMethod.POST)
     public void collegeExport(ReportSubjectQuery query, HttpServletResponse response) {
         int examId = getSessionExamId();
         query.setExamId(examId);
@@ -367,7 +367,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程大题分析")
     @Logging(menu = "课程大题分析", type = LogType.QUERY)
-    @RequestMapping("/group")
+    @RequestMapping(value="/group", method = RequestMethod.POST)
     public PageResult<ReportSubjectGroup> group(ReportSubjectQuery query) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -389,7 +389,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程大题分析导出")
     @Logging(menu = "课程大题分析导出", type = LogType.EXPORT)
-    @RequestMapping("/group/export")
+    @RequestMapping(value="/group/export", method = RequestMethod.POST)
     public void groupExport(ReportSubjectQuery query, HttpServletResponse response) {
         int examId = getSessionExamId();
         query.setExamId(examId);
@@ -414,7 +414,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程小题分析")
     @Logging(menu = "课程小题分析", type = LogType.QUERY)
-    @RequestMapping("/question")
+    @RequestMapping(value="/question", method = RequestMethod.POST)
     public PageResult<ReportSubjectQuestion> questionList(ReportSubjectQuery query) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -436,7 +436,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程小题分析导出")
     @Logging(menu = "课程小题分析导出", type = LogType.EXPORT)
-    @RequestMapping("/question/export")
+    @RequestMapping(value="/question/export", method = RequestMethod.POST)
     public void questionExport(ReportSubjectQuery query, HttpServletResponse response) {
         int examId = getSessionExamId();
         query.setExamId(examId);
@@ -462,7 +462,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "班级分析")
     @Logging(menu = "课程班级分析", type = LogType.QUERY)
-    @RequestMapping("/class")
+    @RequestMapping(value="/class", method = RequestMethod.POST)
     public PageResult<ReportSubjectClass> classList(ReportSubjectQuery query) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -483,7 +483,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "班级分析导出")
     @Logging(menu = "课程班级分析导出", type = LogType.EXPORT)
-    @RequestMapping("/class/export")
+    @RequestMapping(value="/class/export", method = RequestMethod.POST)
     public void classExport(ReportSubjectQuery query, HttpServletResponse response) {
         int examId = getSessionExamId();
         query.setExamId(examId);
@@ -507,7 +507,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程老师分析")
     @Logging(menu = "课程老师分析", type = LogType.QUERY)
-    @RequestMapping("/teacher")
+    @RequestMapping(value="/teacher", method = RequestMethod.POST)
     public PageResult<ReportSubjectTeacher> teacherList(ReportSubjectQuery query) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -530,7 +530,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程老师分析导出")
     @Logging(menu = "课程老师分析导出", type = LogType.EXPORT)
-    @RequestMapping("/teacher/export")
+    @RequestMapping(value="/teacher/export", method = RequestMethod.POST)
     public void export(ReportSubjectQuery query, HttpServletResponse response) {
         int examId = getSessionExamId();
         query.setExamId(examId);
@@ -558,7 +558,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程教师班级分析")
     @Logging(menu = "课程教师班级分析", type = LogType.QUERY)
-    @RequestMapping("/teacher/class")
+    @RequestMapping(value="/teacher/class", method = RequestMethod.POST)
     public PageResult<ReportSubjectTeacherClass> teacherClassList(ReportSubjectQuery query) {
         ApiUser wu = getApiUser();
         int examId = getSessionExamId();
@@ -581,7 +581,7 @@ public class ReportController extends BaseApiController {
 
     @ApiOperation(value = "课程教师班级分析导出")
     @Logging(menu = "课程教师班级分析导出", type = LogType.EXPORT)
-    @RequestMapping("/teacher/class/export")
+    @RequestMapping(value="/teacher/class/export", method = RequestMethod.POST)
     public void teacherClassExport(ReportSubjectQuery query, HttpServletResponse response) {
         int examId = getSessionExamId();
         query.setExamId(examId);

+ 238 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/api/controller/admin/SelectiveGroupController.java

@@ -0,0 +1,238 @@
+package cn.com.qmth.stmms.api.controller.admin;
+
+import java.util.*;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.core.task.AsyncTaskExecutor;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.qmth.boot.core.exception.StatusException;
+
+import cn.com.qmth.stmms.admin.dto.SelectivePartDTO;
+import cn.com.qmth.stmms.admin.thread.SubjectiveCalculateThread;
+import cn.com.qmth.stmms.api.controller.BaseApiController;
+import cn.com.qmth.stmms.biz.exam.bean.ResultMessage;
+import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
+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.model.SelectiveGroup;
+import cn.com.qmth.stmms.biz.exam.service.*;
+import cn.com.qmth.stmms.biz.lock.LockService;
+import cn.com.qmth.stmms.biz.mark.service.MarkService;
+import cn.com.qmth.stmms.common.annotation.Logging;
+import cn.com.qmth.stmms.common.domain.ApiUser;
+import cn.com.qmth.stmms.common.enums.LockType;
+import cn.com.qmth.stmms.common.enums.LogType;
+import cn.com.qmth.stmms.common.enums.ScorePolicy;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+@Api(tags = "选做题管理")
+@Controller("adminSelectiveGroupController")
+@RequestMapping("/api/admin/selective")
+public class SelectiveGroupController extends BaseApiController {
+
+    protected static Logger log = LoggerFactory.getLogger(SelectiveGroupController.class);
+
+    @Autowired
+    private ExamQuestionService questionService;
+
+    @Autowired
+    private MarkGroupService groupService;
+
+    @Autowired
+    private ExamSubjectService subjectService;
+
+    @Autowired
+    private SelectiveGroupService selectiveGroupService;
+
+    @Qualifier("task-executor")
+    @Autowired
+    private AsyncTaskExecutor taskExecutor;
+
+    @Autowired
+    private LockService lockService;
+
+    @Autowired
+    private MarkService markService;
+
+    @Autowired
+    private ExamStudentService studentService;
+
+    @Autowired
+    private MarkerService markerService;
+
+    @Autowired
+    private InspectedService inspectedService;
+
+    @ApiOperation(value = "选做题分组列表")
+    @RequestMapping(value = "/group", method = RequestMethod.POST)
+    @ResponseBody
+    public List<SelectiveGroup> query(@RequestParam String subjectCode) {
+        int examId = getSessionExamId();
+        return selectiveGroupService.findIndexByExamIdAndSubjectCode(examId, subjectCode);
+    }
+
+    @ApiOperation(value = "选做题列表")
+    @RequestMapping(value = "/question", method = RequestMethod.POST)
+    @ResponseBody
+    public List<ExamQuestion> question(@RequestParam String subjectCode) {
+        int examId = getSessionExamId();
+        List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCode(examId, subjectCode);
+        Map<Integer, SelectiveGroup> map = new HashMap<Integer, SelectiveGroup>();
+        for (SelectiveGroup selectiveGroup : list) {
+            map.put(selectiveGroup.getMainNumber(), selectiveGroup);
+        }
+        List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjective(examId, subjectCode, false);
+        for (ExamQuestion examQuestion : questions) {
+            if (map.containsKey(examQuestion.getMainNumber())) {
+                examQuestion.setSelective(true);
+                examQuestion.setSelectiveIndex(map.get(examQuestion.getMainNumber()).getSelectiveIndex());
+                examQuestion.setSelectivePart(map.get(examQuestion.getMainNumber()).getSelectivePart());
+                examQuestion.setScorePolicy(map.get(examQuestion.getMainNumber()).getScorePolicy().getValue());
+            }
+        }
+        return questions;
+    }
+
+    @ApiOperation(value = "取分规则")
+    @RequestMapping(value = "scorePolicys", method = RequestMethod.POST)
+    @ResponseBody
+    public List<ScorePolicy> scorePolicyList() {
+        ScorePolicy[] scorePolicyList = { ScorePolicy.MAX, ScorePolicy.MIN, ScorePolicy.MIN_WITHOUT_ZERO };
+        return Arrays.asList(scorePolicyList);
+    }
+
+    @ApiOperation(value = "选做题组新增")
+    @Logging(menu = "选做题新增", type = LogType.ADD)
+    @RequestMapping(value = "/group/save", method = RequestMethod.POST)
+    @Transactional
+    public ResultMessage save(@RequestParam String subjectCode, @RequestParam Integer selectiveCount,
+            @RequestParam Integer scorePolicy, @RequestParam Integer selectivePart,
+            @RequestParam(required = true, defaultValue = "false") Boolean enableAllSelectiveAdd,
+            @RequestParam String parts) {
+        int examId = getSessionExamId();
+        if (selectiveCount >= selectivePart) {
+            throw new StatusException("选做题数量不能大于已选择题目数量");
+        }
+        List<MarkGroup> groups = groupService.findByExamAndSubject(examId, subjectCode);
+        if (groups != null && groups.size() > 0) {
+            throw new StatusException("该科目已经存在分组,无法设置");
+        }
+        List<SelectivePartDTO> partList = getPartList(parts);
+        if (checkTotalScore(examId, subjectCode, partList)) {
+            throw new StatusException("选做题区分数必须一样");
+        }
+        int index = selectiveGroupService.findMaxIndexByExamIdAndSubjectCode(examId, subjectCode);
+        List<SelectiveGroup> list = new ArrayList<SelectiveGroup>();
+        for (SelectivePartDTO part : partList) {
+            for (Integer mainNumber : part.getMainNumbers()) {
+                list.add(new SelectiveGroup(examId, subjectCode, mainNumber, index + 1, selectiveCount,
+                        part.getSelectivePart(), ScorePolicy.findByValue(scorePolicy)));
+            }
+        }
+        selectiveGroupService.save(list);
+        subjectService.updateSelective(examId, subjectCode, true);
+        subjectService.updateScore(examId, subjectCode, false,
+                questionService.sumTotalScore(examId, subjectCode, false));
+        ExamSubject subject = subjectService.find(examId, subjectCode);
+        if (subject.isEnableAllSelective() != enableAllSelectiveAdd) {
+            subjectService.updateEnableAllSelective(examId, subjectCode, enableAllSelectiveAdd);
+        }
+        return resultOk();
+    }
+
+    private boolean checkTotalScore(int examId, String subjectCode, List<SelectivePartDTO> parts) {
+        List<ExamQuestion> questions = questionService.findMainByExamAndSubjectAndObjective(examId, subjectCode, false);
+        Map<Integer, ExamQuestion> map = new HashMap<Integer, ExamQuestion>();
+        for (ExamQuestion examQuestion : questions) {
+            map.put(examQuestion.getMainNumber(), examQuestion);
+        }
+        Set<Double> scores = new HashSet<Double>();
+        for (SelectivePartDTO part : parts) {
+            double totalScore = 0;
+            for (Integer mainNumber : part.getMainNumbers()) {
+                totalScore = totalScore + map.get(mainNumber).getTotalScore();
+            }
+            scores.add(totalScore);
+        }
+        return scores.size() > 1;
+    }
+
+    private List<SelectivePartDTO> getPartList(String parts) {
+        List<SelectivePartDTO> list = new ArrayList<SelectivePartDTO>();
+        if (StringUtils.isNotBlank(parts)) {
+            parts = StringEscapeUtils.unescapeHtml(parts);
+            JSONArray array = JSONArray.fromObject(parts);
+            for (int i = 0; i < array.size(); i++) {
+                JSONObject part = array.getJSONObject(i);
+                SelectivePartDTO dto = new SelectivePartDTO();
+                dto.setSelectivePart(part.getInt("selectivePart"));
+                List<Integer> mainNumbers = new ArrayList<Integer>();
+                JSONArray mainNumberArr = part.getJSONArray("mainNumbers");
+                for (Object object : mainNumberArr) {
+                    mainNumbers.add(Integer.parseInt(object.toString()));
+                }
+                dto.setMainNumbers(mainNumbers);
+                list.add(dto);
+            }
+        }
+        return list;
+    }
+
+    @ApiOperation(value = "选做题组删除")
+    @Logging(menu = "删除选做题", type = LogType.DELETE)
+    @RequestMapping(value = "/group/delete", method = RequestMethod.POST)
+    @Transactional
+    public ResultMessage delete(@RequestParam String subjectCode, @RequestParam Integer selectiveIndex) {
+        int examId = getSessionExamId();
+        List<MarkGroup> groups = groupService.findByExamAndSubject(examId, subjectCode);
+        if (groups != null && groups.size() > 0) {
+            throw new StatusException("该科目已经存在分组,无法设置");
+        }
+        selectiveGroupService.deleteByExamIdAndSubjectCodeAndSelectiveIndex(examId, subjectCode, selectiveIndex);
+        return resultOk();
+    }
+
+    @ApiOperation(value = "选做题区分规则修改")
+    @Logging(menu = "修改选做题取分规则", type = LogType.UPDATE)
+    @RequestMapping(value = "/group/edit", method = RequestMethod.POST)
+    @Transactional
+    public ResultMessage edit(@RequestParam String subjectCode, @RequestParam Integer selectiveIndex,
+            @RequestParam Integer policy,
+            @RequestParam(required = true, defaultValue = "false") Boolean enableAllSelective) {
+        int examId = getSessionExamId();
+        if (lockService.isLocked(LockType.SCORE_CALCULATE, examId, subjectCode)) {
+            throw new StatusException("正在统分中,请稍后再试");
+        }
+        ExamSubject subject = subjectService.find(examId, subjectCode);
+        if (subject.isEnableAllSelective() != enableAllSelective) {
+            subjectService.updateEnableAllSelective(examId, subjectCode, enableAllSelective);
+        }
+        List<SelectiveGroup> list = selectiveGroupService.findByExamIdAndSubjectCodeAndSelectiveIndex(examId,
+                subjectCode, selectiveIndex);
+        if (!list.isEmpty() && list.get(0).getScorePolicy().equals(ScorePolicy.findByValue(policy))) {
+            return resultOk();
+        } else {
+            selectiveGroupService.updateScorePolicy(examId, subjectCode, selectiveIndex,
+                    ScorePolicy.findByValue(policy));
+            SubjectiveCalculateThread thread = new SubjectiveCalculateThread(examId, subjectCode, markService,
+                    lockService, questionService, groupService, markerService, inspectedService, studentService);
+            taskExecutor.submit(thread);
+        }
+        return resultOk();
+    }
+
+}