|
@@ -5,10 +5,15 @@ import java.util.List;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringEscapeUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.ui.Model;
|
|
@@ -17,10 +22,15 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
+import cn.com.qmth.stmms.biz.campus.model.Campus;
|
|
|
+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.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.query.ExamStudentSearchQuery;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
|
+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.exam.service.MarkerService;
|
|
@@ -29,9 +39,11 @@ import cn.com.qmth.stmms.biz.mark.service.TaskService;
|
|
|
import cn.com.qmth.stmms.common.auth.annotation.RoleRequire;
|
|
|
import cn.com.qmth.stmms.common.domain.WebUser;
|
|
|
import cn.com.qmth.stmms.common.enums.Role;
|
|
|
+import cn.com.qmth.stmms.common.utils.PictureUrlBuilder;
|
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
|
-import net.sf.json.JSONArray;
|
|
|
-import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
@Controller("markGroupController")
|
|
|
@RequestMapping("/admin/exam/group")
|
|
@@ -53,6 +65,15 @@ public class MarkGroupController extends BaseExamController {
|
|
|
|
|
|
@Autowired
|
|
|
private TaskService taskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamStudentService examStudentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CampusService campusService;
|
|
|
+
|
|
|
+ @Value("${slice.image.server}")
|
|
|
+ private String imageServer;
|
|
|
|
|
|
@RequestMapping
|
|
|
public String list(HttpServletRequest request, Model model, @RequestParam String subjectCode) {
|
|
@@ -220,7 +241,10 @@ public class MarkGroupController extends BaseExamController {
|
|
|
subjectCode, false, number);
|
|
|
if (group != null) {
|
|
|
// quick update
|
|
|
- List<PictureConfigItem> list = PictureConfigItem.parse(picList);
|
|
|
+ picList = StringEscapeUtils.unescapeHtml(picList);
|
|
|
+ JSONArray array = JSONArray.fromObject(picList);
|
|
|
+ List<PictureConfigItem> list = JSONArray.toList(array, PictureConfigItem.class);
|
|
|
+ //List<PictureConfigItem> list = PictureConfigItem.parse(picList);
|
|
|
if (list != null && !list.isEmpty()) {
|
|
|
groupService.updatePicList(examId, subjectCode, number, list);
|
|
|
}
|
|
@@ -288,8 +312,11 @@ public class MarkGroupController extends BaseExamController {
|
|
|
return "redirect:/admin/exam/group/add";
|
|
|
} else {
|
|
|
// create group
|
|
|
+ picList = StringEscapeUtils.unescapeHtml(picList);
|
|
|
+ JSONArray array = JSONArray.fromObject(picList);
|
|
|
+ List<PictureConfigItem> list = JSONArray.toList(array, PictureConfigItem.class);
|
|
|
group = new MarkGroup(examId, subjectCode, number, StringUtils.trimToNull(title),
|
|
|
- PictureConfigItem.parse(picList), 0d);
|
|
|
+ list, 0d);
|
|
|
List<Double> scores = buildDoubleList(scoreList);
|
|
|
if (group.getTitle() != null && group.getPicList() != null && scores.size() > 0) {
|
|
|
// clear and replace exam_question
|
|
@@ -343,5 +370,58 @@ public class MarkGroupController extends BaseExamController {
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @RequestMapping("/getPictureConfig")
|
|
|
+ @RoleRequire(Role.SCHOOL_ADMIN)
|
|
|
+ public String get(HttpServletRequest request, Model model, RedirectAttributes redirectAttributes,
|
|
|
+ @RequestParam String subjectCode, @RequestParam Integer number,
|
|
|
+ @RequestParam(required = false) String picList) throws JsonProcessingException {
|
|
|
+ int examId = getSessionExamId(request);
|
|
|
+ ExamStudentSearchQuery query = new ExamStudentSearchQuery();
|
|
|
+ query.setExamId(examId);
|
|
|
+ query.setSubjectCode(subjectCode);
|
|
|
+ query.setUpload(true);
|
|
|
+ List<ExamStudent> examStudents = examStudentService.findByQuery(query).getResult();
|
|
|
+ MarkGroup group = null;
|
|
|
+ if(number!=null){
|
|
|
+ group = groupService.findOne(examId, subjectCode, number);
|
|
|
+ }
|
|
|
+ if (examStudents.size()>0) {
|
|
|
+ model.addAttribute("picUrls", buildPicUrl(group,examStudents.get(0)));
|
|
|
+ model.addAttribute("pictureConfig", buildPictureConfig(group));
|
|
|
+ if(StringUtils.isNotBlank(picList)){
|
|
|
+ model.addAttribute("pictureConfig", StringEscapeUtils.unescapeHtml(picList));
|
|
|
+ }
|
|
|
+ model.addAttribute("imageServer", imageServer);
|
|
|
+ return "modules/mark/picConfig";
|
|
|
+ } else {
|
|
|
+ addMessage(redirectAttributes, "参数有误");
|
|
|
+ redirectAttributes.addAttribute("subjectCode", subjectCode);
|
|
|
+ return "redirect:/admin/exam/group";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String buildPictureConfig(MarkGroup group) throws JsonProcessingException {
|
|
|
+ if(group!=null){
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ String json = mapper.writeValueAsString(group.getPictureConfigList());
|
|
|
+ return json;
|
|
|
+ }else{
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String buildPicUrl(MarkGroup group,ExamStudent examStudent) {
|
|
|
+ List<String> picUrls = null;
|
|
|
+ Campus campus = campusService.findBySchoolAndName(examStudent.getSchoolId(), examStudent.getCampusName());
|
|
|
+ if(group == null){
|
|
|
+ picUrls = PictureUrlBuilder.getSliceUrls(examStudent.getExamId(), campus.getId(), examStudent.getSubjectCode(), examStudent.getExamNumber(), examStudent.getSliceCount());
|
|
|
+ }else{
|
|
|
+ List<String> picNumbers = new ArrayList<String>();
|
|
|
+ picNumbers.add(String.valueOf(group.getNumber()));
|
|
|
+ picUrls = PictureUrlBuilder.getSliceUrls(examStudent.getExamId(), campus.getId(), examStudent.getSubjectCode(), examStudent.getExamNumber(), picNumbers);
|
|
|
+ }
|
|
|
+
|
|
|
+ return picUrls.toString();
|
|
|
+ }
|
|
|
}
|