|
@@ -1,6 +1,5 @@
|
|
package cn.com.qmth.stmms.admin.exam;
|
|
package cn.com.qmth.stmms.admin.exam;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -22,7 +21,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
-import cn.com.qmth.stmms.admin.vo.ExamQuestionVO;
|
|
|
|
|
|
+import cn.com.qmth.stmms.admin.dto.ExamQuestionDTO;
|
|
import cn.com.qmth.stmms.biz.campus.model.Campus;
|
|
import cn.com.qmth.stmms.biz.campus.model.Campus;
|
|
import cn.com.qmth.stmms.biz.campus.service.CampusService;
|
|
import cn.com.qmth.stmms.biz.campus.service.CampusService;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
@@ -315,13 +314,12 @@ public class MarkGroupController extends BaseExamController {
|
|
@RequestMapping("/save")
|
|
@RequestMapping("/save")
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
public String save(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes,
|
|
public String save(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes,
|
|
- @RequestParam String subjectCode, @RequestParam Integer number,
|
|
|
|
- @RequestParam(required = false) String title, @RequestParam(required = false) String picList,
|
|
|
|
- @RequestParam(required = false) String intervalScoreList, @RequestParam(required = false) String scoreList,
|
|
|
|
- @RequestParam(required = false) Double doubleRate,
|
|
|
|
|
|
+ @RequestParam String subjectCode, @RequestParam Integer number, @RequestParam Boolean reset,
|
|
|
|
+ @RequestParam(required = false) String picList, @RequestParam(required = false) Double doubleRate,
|
|
@RequestParam(required = false) Double arbitrateThreshold,
|
|
@RequestParam(required = false) Double arbitrateThreshold,
|
|
@RequestParam(required = false) Integer scorePolicy, @RequestParam(required = false) MarkMode markMode,
|
|
@RequestParam(required = false) Integer scorePolicy, @RequestParam(required = false) MarkMode markMode,
|
|
- @RequestParam(required = false) Integer trialCount, @RequestParam(required = false) boolean sheetView) {
|
|
|
|
|
|
+ @RequestParam(required = false) Integer trialCount, @RequestParam(required = false) boolean sheetView,
|
|
|
|
+ @RequestParam(required = false) String questionDetail) {
|
|
int examId = getSessionExamId(request);
|
|
int examId = getSessionExamId(request);
|
|
MarkGroup group = groupService.findOne(examId, subjectCode, number);
|
|
MarkGroup group = groupService.findOne(examId, subjectCode, number);
|
|
List<ExamQuestion> questionList = questionService.findByExamAndSubjectAndObjectiveAndGroupNumber(examId,
|
|
List<ExamQuestion> questionList = questionService.findByExamAndSubjectAndObjectiveAndGroupNumber(examId,
|
|
@@ -331,22 +329,9 @@ public class MarkGroupController extends BaseExamController {
|
|
picList = StringEscapeUtils.unescapeHtml(picList);
|
|
picList = StringEscapeUtils.unescapeHtml(picList);
|
|
JSONArray array = JSONArray.fromObject(picList);
|
|
JSONArray array = JSONArray.fromObject(picList);
|
|
List<PictureConfigItem> list = JSONArray.toList(array, new PictureConfigItem(), new JsonConfig());
|
|
List<PictureConfigItem> list = JSONArray.toList(array, new PictureConfigItem(), new JsonConfig());
|
|
- // List<PictureConfigItem> list = PictureConfigItem.parse(picList);
|
|
|
|
if (list != null && !list.isEmpty()) {
|
|
if (list != null && !list.isEmpty()) {
|
|
groupService.updatePicList(examId, subjectCode, number, list);
|
|
groupService.updatePicList(examId, subjectCode, number, list);
|
|
}
|
|
}
|
|
- List<Double> intervalScores = buildDoubleList(intervalScoreList);
|
|
|
|
- if (intervalScores.size() == questionList.size()) {
|
|
|
|
- for (int i = 0; i < questionList.size(); i++) {
|
|
|
|
- ExamQuestion q = questionList.get(i);
|
|
|
|
- q.setIntervalScore(intervalScores.get(i));
|
|
|
|
- questionService.save(q);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- title = StringUtils.trimToNull(title);
|
|
|
|
- if (title != null) {
|
|
|
|
- questionService.updateMainTitle(examId, subjectCode, false, number, title);
|
|
|
|
- }
|
|
|
|
if (doubleRate != null) {
|
|
if (doubleRate != null) {
|
|
groupService.updateDoubleRate(examId, subjectCode, number, doubleRate);
|
|
groupService.updateDoubleRate(examId, subjectCode, number, doubleRate);
|
|
}
|
|
}
|
|
@@ -358,20 +343,36 @@ public class MarkGroupController extends BaseExamController {
|
|
groupService.updateTrialCount(examId, subjectCode, number, trialCount);
|
|
groupService.updateTrialCount(examId, subjectCode, number, trialCount);
|
|
}
|
|
}
|
|
groupService.updateSheetView(examId, subjectCode, number, sheetView);
|
|
groupService.updateSheetView(examId, subjectCode, number, sheetView);
|
|
- // advance update
|
|
|
|
- ScorePolicy policy = scorePolicy != null ? ScorePolicy.findByValue(scorePolicy) : null;
|
|
|
|
- List<Double> scores = buildDoubleList(scoreList);
|
|
|
|
- if (scores.size() > 0) {
|
|
|
|
- try {
|
|
|
|
- lockService.waitlock(LockType.GROUP, true, group.getExamId(), group.getSubjectCode(),
|
|
|
|
- group.getNumber());
|
|
|
|
- markService.updateGroup(group, scores, policy);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("update group error", e);
|
|
|
|
- throw new RuntimeException("更新大题失败", e);
|
|
|
|
- } finally {
|
|
|
|
- lockService.unlock(LockType.GROUP, true, group.getExamId(), group.getSubjectCode(),
|
|
|
|
- group.getNumber());
|
|
|
|
|
|
+ // build questionDetail
|
|
|
|
+ questionDetail = StringEscapeUtils.unescapeHtml(questionDetail);
|
|
|
|
+ array = JSONArray.fromObject(picList);
|
|
|
|
+ List<ExamQuestionDTO> detailList = JSONArray.toList(array, new ExamQuestionDTO(), new JsonConfig());
|
|
|
|
+ if (detailList != null && detailList.size() > 0) {
|
|
|
|
+ // advance update
|
|
|
|
+ if (reset != null && reset.booleanValue()) {
|
|
|
|
+ ScorePolicy policy = scorePolicy != null ? ScorePolicy.findByValue(scorePolicy) : null;
|
|
|
|
+ try {
|
|
|
|
+ lockService.waitlock(LockType.GROUP, true, group.getExamId(), group.getSubjectCode(),
|
|
|
|
+ group.getNumber());
|
|
|
|
+ markService.updateGroup(group, buildQuestionList(group, detailList), policy);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("update group error", e);
|
|
|
|
+ throw new RuntimeException("重置更新大题失败", e);
|
|
|
|
+ } finally {
|
|
|
|
+ lockService.unlock(LockType.GROUP, true, group.getExamId(), group.getSubjectCode(),
|
|
|
|
+ group.getNumber());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (ExamQuestionDTO detail : detailList) {
|
|
|
|
+ List<ExamQuestion> subList = questionService.findByExamAndSubjectAndObjectiveAndMainNumber(
|
|
|
|
+ examId, subjectCode, false, detail.getMainNumber());
|
|
|
|
+ for (int i = 0; i < subList.size(); i++) {
|
|
|
|
+ ExamQuestion question = subList.get(i);
|
|
|
|
+ question.setMainTitle(detail.getMainTitle());
|
|
|
|
+ question.setIntervalScore(detail.getIntervalScoreList()[i]);
|
|
|
|
+ questionService.save(question);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
@@ -389,9 +390,8 @@ public class MarkGroupController extends BaseExamController {
|
|
@RequestMapping("/insert")
|
|
@RequestMapping("/insert")
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
public String insert(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes,
|
|
public String insert(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes,
|
|
- @RequestParam String subjectCode, @RequestParam Integer number,
|
|
|
|
- @RequestParam(required = false) String questionDetail, @RequestParam(required = false) String picList,
|
|
|
|
- @RequestParam(required = false) Double doubleRate,
|
|
|
|
|
|
+ @RequestParam String subjectCode, @RequestParam Integer number, @RequestParam String questionDetail,
|
|
|
|
+ @RequestParam String picList, @RequestParam(required = false) Double doubleRate,
|
|
@RequestParam(required = false) Double arbitrateThreshold,
|
|
@RequestParam(required = false) Double arbitrateThreshold,
|
|
@RequestParam(required = false) Integer scorePolicy, @RequestParam(required = false) String markMode,
|
|
@RequestParam(required = false) Integer scorePolicy, @RequestParam(required = false) String markMode,
|
|
@RequestParam(required = false) Integer trialCount, @RequestParam(required = false) boolean sheetView) {
|
|
@RequestParam(required = false) Integer trialCount, @RequestParam(required = false) boolean sheetView) {
|
|
@@ -418,36 +418,15 @@ public class MarkGroupController extends BaseExamController {
|
|
// build questionDetail
|
|
// build questionDetail
|
|
questionDetail = StringEscapeUtils.unescapeHtml(questionDetail);
|
|
questionDetail = StringEscapeUtils.unescapeHtml(questionDetail);
|
|
array = JSONArray.fromObject(picList);
|
|
array = JSONArray.fromObject(picList);
|
|
- List<ExamQuestionVO> detailList = JSONArray.toList(array, new ExamQuestionVO(), new JsonConfig());
|
|
|
|
|
|
+ List<ExamQuestionDTO> detailList = JSONArray.toList(array, new ExamQuestionDTO(), new JsonConfig());
|
|
|
|
|
|
if (picConfigList != null && detailList != null && picConfigList.size() > 0 && detailList.size() > 0) {
|
|
if (picConfigList != null && detailList != null && picConfigList.size() > 0 && detailList.size() > 0) {
|
|
group = new MarkGroup(examId, subjectCode, number, picConfigList, 0d, doubleRate, arbitrateThreshold,
|
|
group = new MarkGroup(examId, subjectCode, number, picConfigList, 0d, doubleRate, arbitrateThreshold,
|
|
scorePolicy, markMode, trialCount, sheetView);
|
|
scorePolicy, markMode, trialCount, sheetView);
|
|
// clear and replace exam_question
|
|
// clear and replace exam_question
|
|
questionService.deleteByExamAndSubjectAndObjectiveAndGroupNumber(examId, subjectCode, false, number);
|
|
questionService.deleteByExamAndSubjectAndObjectiveAndGroupNumber(examId, subjectCode, false, number);
|
|
- List<ExamQuestion> list = new LinkedList<>();
|
|
|
|
- double totalScore = 0d;
|
|
|
|
- for (ExamQuestionVO detail : detailList) {
|
|
|
|
- int i = 0;
|
|
|
|
- List<Double> scores = buildDoubleList(detail.getScoreList());
|
|
|
|
- for (Double score : scores) {
|
|
|
|
- i++;
|
|
|
|
- totalScore += score;
|
|
|
|
- ExamQuestion question = new ExamQuestion();
|
|
|
|
- question.setExamId(examId);
|
|
|
|
- question.setSubjectCode(subjectCode);
|
|
|
|
- question.setMainTitle(detail.getMainTitle());
|
|
|
|
- question.setMainNumber(detail.getMainNumber());
|
|
|
|
- question.setSubNumber(i);
|
|
|
|
- question.setGroupNumber(number);
|
|
|
|
- question.setObjective(false);
|
|
|
|
- question.setTotalScore(score);
|
|
|
|
- question.setIntervalScore(1d);
|
|
|
|
- list.add(question);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ List<ExamQuestion> list = buildQuestionList(group, detailList);
|
|
questionService.save(list);
|
|
questionService.save(list);
|
|
- group.setTotalScore(totalScore);
|
|
|
|
groupService.save(group);
|
|
groupService.save(group);
|
|
subjectService.updateScore(examId, subjectCode, false, groupService.sumTotalScore(examId, subjectCode));
|
|
subjectService.updateScore(examId, subjectCode, false, groupService.sumTotalScore(examId, subjectCode));
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
@@ -460,27 +439,6 @@ public class MarkGroupController extends BaseExamController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private List<Double> buildDoubleList(String content) {
|
|
|
|
- List<Double> list = new ArrayList<Double>();
|
|
|
|
- content = StringUtils.trimToNull(content);
|
|
|
|
- if (content != null) {
|
|
|
|
- String[] values = StringUtils.split(content, ",");
|
|
|
|
- if (values != null) {
|
|
|
|
- for (String value : values) {
|
|
|
|
- try {
|
|
|
|
- Double number = Double.valueOf(value);
|
|
|
|
- if (number != null) {
|
|
|
|
- list.add(number);
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return list;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@RequestMapping("/getPictureConfig")
|
|
@RequestMapping("/getPictureConfig")
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
public String get(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes,
|
|
public String get(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes,
|
|
@@ -526,4 +484,29 @@ public class MarkGroupController extends BaseExamController {
|
|
examStudent.getSubjectCode(), examStudent.getExamNumber(), examStudent.getSliceCount());
|
|
examStudent.getSubjectCode(), examStudent.getExamNumber(), examStudent.getSliceCount());
|
|
return picUrls;
|
|
return picUrls;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private List<ExamQuestion> buildQuestionList(MarkGroup group, List<ExamQuestionDTO> detailList) {
|
|
|
|
+ List<ExamQuestion> list = new LinkedList<>();
|
|
|
|
+ double totalScore = 0d;
|
|
|
|
+ for (ExamQuestionDTO detail : detailList) {
|
|
|
|
+ int i = 0;
|
|
|
|
+ for (double score : detail.getScoreList()) {
|
|
|
|
+ i++;
|
|
|
|
+ totalScore += score;
|
|
|
|
+ ExamQuestion question = new ExamQuestion();
|
|
|
|
+ question.setExamId(group.getExamId());
|
|
|
|
+ question.setSubjectCode(group.getSubjectCode());
|
|
|
|
+ question.setMainTitle(detail.getMainTitle());
|
|
|
|
+ question.setMainNumber(detail.getMainNumber());
|
|
|
|
+ question.setSubNumber(i);
|
|
|
|
+ question.setGroupNumber(group.getNumber());
|
|
|
|
+ question.setObjective(false);
|
|
|
|
+ question.setTotalScore(score);
|
|
|
|
+ question.setIntervalScore(1d);
|
|
|
|
+ list.add(question);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ group.setTotalScore(totalScore);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
}
|
|
}
|