|
@@ -4,10 +4,12 @@ import cn.com.qmth.stmms.api.exception.ApiException;
|
|
|
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.query.ExamStudentSearchQuery;
|
|
|
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.file.service.FileService;
|
|
|
import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
|
import cn.com.qmth.stmms.common.annotation.RoleRequire;
|
|
@@ -55,11 +57,15 @@ public class CoreController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private FileService fileService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExamSubjectService subjectService;
|
|
|
+
|
|
|
@RequestMapping(value = "/exam/save", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
@RoleRequire({ Role.SCHOOL_ADMIN, Role.SCHOOL_DEV })
|
|
|
public JSONObject examSave(HttpServletRequest request, @RequestParam(required = false) Integer id,
|
|
|
- @RequestParam(required = false) String code, @RequestParam String name, @RequestParam String examTime) {
|
|
|
+ @RequestParam(required = false) String code, @RequestParam String name, @RequestParam String examTime,
|
|
|
+ @RequestParam String type) {
|
|
|
ApiUser user = RequestUtils.getApiUser(request);
|
|
|
JSONObject result = new JSONObject();
|
|
|
// 输入字段预处理并初步校验
|
|
@@ -92,6 +98,7 @@ public class CoreController extends BaseApiController {
|
|
|
current.setForbiddenInfo(false);
|
|
|
current.setObjectiveStatus(ObjectiveStatus.WAITING);
|
|
|
current.setCreateTime(new Date());
|
|
|
+ current.setType(ExamType.valueOf(type));
|
|
|
} else if (!current.getSchoolId().equals(user.getSchoolId()) || current.getStatus() != ExamStatus.START) {
|
|
|
throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
}
|
|
@@ -407,4 +414,35 @@ public class CoreController extends BaseApiController {
|
|
|
result.accumulate("totalCount", count);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value = "/exam/subject/save", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCHOOL_DEV })
|
|
|
+ public JSONObject subjectSave(HttpServletRequest request, @RequestParam Integer examId, @RequestParam String code,
|
|
|
+ @RequestParam String name, @RequestParam(required = false) String remark) {
|
|
|
+ ApiUser user = RequestUtils.getApiUser(request);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ // 输入字段预处理并初步校验
|
|
|
+ code = validate("code", code, true, 32);
|
|
|
+ name = validate("name", name, true, 32);
|
|
|
+ remark = validate("remark", remark, false, 64);
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
+ if (exam == null) {
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.replaceMessage("examId invalid");
|
|
|
+ } else if (!exam.getSchoolId().equals(user.getSchoolId()) || exam.getStatus() != ExamStatus.START) {
|
|
|
+ throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
+ }
|
|
|
+ ExamSubject subject = subjectService.find(examId, code);
|
|
|
+ if (subject == null) {
|
|
|
+ subject = new ExamSubject();
|
|
|
+ subject.setCode(code);
|
|
|
+ subject.setExamId(examId);
|
|
|
+ }
|
|
|
+ subject.setName(name);
|
|
|
+ subject.setRemark(remark);
|
|
|
+ subject = subjectService.save(subject);
|
|
|
+ result.accumulate("updateTime", DateUtils.formatDateTime(new Date()));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|