|
@@ -22,7 +22,9 @@ import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
import cn.com.qmth.stmms.common.enums.Role;
|
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
|
import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
import net.sf.json.JsonConfig;
|
|
|
+
|
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -37,6 +39,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -94,13 +97,16 @@ public class ExamController extends BaseExamController {
|
|
|
model.addAttribute("exam", exam);
|
|
|
model.addAttribute("statusList", ExamStatus.values());
|
|
|
model.addAttribute("pictureConfig", buildPictureConfig(exam.getSheetConfig()));
|
|
|
+ model.addAttribute("passScore", exam.getPassScore());
|
|
|
+ model.addAttribute("excellentScore", exam.getExcellentScore());
|
|
|
return "modules/exam/examEdit";
|
|
|
}
|
|
|
|
|
|
@Logging(menu = "创建考试", type = LogType.ADD)
|
|
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
|
- public String save(HttpServletRequest request, Exam exam, RedirectAttributes redirectAttributes) {
|
|
|
+ public String save(HttpServletRequest request, Exam exam, @RequestParam(required = false) Double passScore,
|
|
|
+ @RequestParam(required = false) Double excellentScore, RedirectAttributes redirectAttributes) {
|
|
|
User user = RequestUtils.getWebUser(request).getUser();
|
|
|
exam.setSchoolId(user.getSchoolId());
|
|
|
exam.setCreatorId(user.getId());
|
|
@@ -108,6 +114,10 @@ public class ExamController extends BaseExamController {
|
|
|
if (exam.getType().equals(ExamType.MULTI_MEDIA)) {
|
|
|
exam.setForceSpecialTag(false);
|
|
|
}
|
|
|
+ JSONObject sasConfig = new JSONObject();
|
|
|
+ sasConfig.accumulate("passScore", passScore);
|
|
|
+ sasConfig.accumulate("excellentScore", excellentScore);
|
|
|
+ exam.setSasConfig(sasConfig.toString());
|
|
|
exam = examService.save(exam);
|
|
|
addMessage(redirectAttributes, "创建考试'" + exam.getName() + "'成功");
|
|
|
return "redirect:/admin/exam/list";
|
|
@@ -117,7 +127,8 @@ public class ExamController extends BaseExamController {
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
|
- public String edit(HttpServletRequest request, Exam exam, @RequestParam(required = false) String picList) {
|
|
|
+ public String edit(HttpServletRequest request, Exam exam, @RequestParam(required = false) String picList,
|
|
|
+ @RequestParam(required = false) Double passScore, @RequestParam(required = false) Double excellentScore) {
|
|
|
User user = RequestUtils.getWebUser(request).getUser();
|
|
|
Exam oldExam = examService.findById(exam.getId());
|
|
|
if (oldExam != null && oldExam.getSchoolId().equals(user.getSchoolId())) {
|
|
@@ -126,8 +137,10 @@ public class ExamController extends BaseExamController {
|
|
|
oldExam.setDescription(exam.getDescription());
|
|
|
oldExam.setStatus(exam.getStatus());
|
|
|
oldExam.setForceSpecialTag(exam.isForceSpecialTag());
|
|
|
- oldExam.setPassScore(exam.getPassScore());
|
|
|
- oldExam.setExcellentScore(exam.getExcellentScore());
|
|
|
+ JSONObject sasConfig = new JSONObject();
|
|
|
+ sasConfig.accumulate("passScore", passScore);
|
|
|
+ sasConfig.accumulate("excellentScore", excellentScore);
|
|
|
+ oldExam.setSasConfig(sasConfig.toString());
|
|
|
if (StringUtils.isNotBlank(picList)) {
|
|
|
String sheetConfig = StringEscapeUtils.unescapeHtml(picList);
|
|
|
JSONArray array = JSONArray.fromObject(sheetConfig);
|