Procházet zdrojové kódy

增加按考试配置阅卷方式

ting.yin před 6 roky
rodič
revize
6ec11e024b

+ 31 - 15
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/model/Exam.java

@@ -14,6 +14,7 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
 import cn.com.qmth.stmms.common.enums.ExamStatus;
+import cn.com.qmth.stmms.common.enums.MarkMode;
 
 @Entity
 @Table(name = "eb_exam")
@@ -38,10 +39,10 @@ public class Exam implements Serializable {
 
     @Enumerated(EnumType.ORDINAL)
     private ExamStatus status;
-    
+
     @Column(name = "description", length = 128, nullable = true)
     private String description;
-    
+
     /**
      * 开启强制特殊标记
      */
@@ -58,13 +59,20 @@ public class Exam implements Serializable {
 
     @Column(name = "creator_id")
     private Integer creatorId;
-    
+
     /**
      * 开启/关闭 原卷显示
      */
     @Column(name = "show_sheet", nullable = false)
     private boolean showSheet;
 
+    /**
+     * 强制评卷模式
+     */
+    @Column(name = "mark_mode", nullable = true)
+    @Enumerated(EnumType.STRING)
+    private MarkMode markMode;
+
     public Integer getId() {
         return id;
     }
@@ -137,20 +145,28 @@ public class Exam implements Serializable {
         this.schoolId = schoolId;
     }
 
-	public boolean isForceSpecialTag() {
-		return forceSpecialTag;
-	}
+    public boolean isForceSpecialTag() {
+        return forceSpecialTag;
+    }
+
+    public void setForceSpecialTag(boolean forceSpecialTag) {
+        this.forceSpecialTag = forceSpecialTag;
+    }
 
-	public void setForceSpecialTag(boolean forceSpecialTag) {
-		this.forceSpecialTag = forceSpecialTag;
-	}
+    public boolean isShowSheet() {
+        return showSheet;
+    }
 
-	public boolean isShowSheet() {
-		return showSheet;
-	}
+    public void setShowSheet(boolean showSheet) {
+        this.showSheet = showSheet;
+    }
 
-	public void setShowSheet(boolean showSheet) {
-		this.showSheet = showSheet;
-	}
+    public MarkMode getMarkMode() {
+        return markMode;
+    }
+
+    public void setMarkMode(MarkMode markMode) {
+        this.markMode = markMode;
+    }
 
 }

+ 20 - 16
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/model/Marker.java

@@ -8,6 +8,8 @@ import java.util.Set;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
@@ -20,6 +22,7 @@ import javax.persistence.Transient;
 import org.apache.commons.lang.StringUtils;
 
 import cn.com.qmth.stmms.common.annotation.ExcelField;
+import cn.com.qmth.stmms.common.enums.MarkMode;
 
 @Entity
 @Table(name = "eb_marker")
@@ -60,8 +63,9 @@ public class Marker implements Serializable {
     @Column(name = "last_login_time")
     private Date lastLoginTime;
 
-    @Column(name = "mode")
-    private String mode;
+    @Column(name = "mode", nullable = true)
+    @Enumerated(EnumType.STRING)
+    private MarkMode mode;
 
     @Transient
     @ExcelField(title = "科目(导入时可为空)", align = 2, sort = 20)
@@ -81,11 +85,11 @@ public class Marker implements Serializable {
 
     @Column(name = "top_count")
     private Integer topCount;
-    
-    @ManyToMany(cascade = CascadeType.PERSIST, fetch=FetchType.EAGER)
-    @JoinTable(name="eb_exam_subject_marker",
-		    joinColumns={@JoinColumn(name="marker_id")},
-    		inverseJoinColumns={@JoinColumn(name="subject_code",referencedColumnName = "code"),@JoinColumn(name="exam_id",referencedColumnName = "exam_id")})
+
+    @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
+    @JoinTable(name = "eb_exam_subject_marker", joinColumns = { @JoinColumn(name = "marker_id") }, inverseJoinColumns = {
+            @JoinColumn(name = "subject_code", referencedColumnName = "code"),
+            @JoinColumn(name = "exam_id", referencedColumnName = "exam_id") })
     private Set<ExamSubject> examSubjects = new HashSet<>();
 
     public Integer getId() {
@@ -160,7 +164,7 @@ public class Marker implements Serializable {
         this.number = number;
     }
 
-    public void buildLoginName(int number,String code) {
+    public void buildLoginName(int number, String code) {
         StringBuilder name = new StringBuilder();
         name.append(examId).append(LOGINNAME_SPLITE);
         name.append(code).append(LOGINNAME_SPLITE);
@@ -227,11 +231,11 @@ public class Marker implements Serializable {
         this.name = name;
     }
 
-    public String getMode() {
+    public MarkMode getMode() {
         return mode;
     }
 
-    public void setMode(String mode) {
+    public void setMode(MarkMode mode) {
         this.mode = mode;
     }
 
@@ -243,11 +247,11 @@ public class Marker implements Serializable {
         this.topCount = topCount;
     }
 
-	public Set<ExamSubject> getExamSubjects() {
-		return examSubjects;
-	}
+    public Set<ExamSubject> getExamSubjects() {
+        return examSubjects;
+    }
 
-	public void setExamSubjects(Set<ExamSubject> examSubjects) {
-		this.examSubjects = examSubjects;
-	}
+    public void setExamSubjects(Set<ExamSubject> examSubjects) {
+        this.examSubjects = examSubjects;
+    }
 }

+ 14 - 0
stmms-common/src/main/java/cn/com/qmth/stmms/common/enums/ExamStatus.java

@@ -1,5 +1,8 @@
 package cn.com.qmth.stmms.common.enums;
 
+import java.util.LinkedList;
+import java.util.List;
+
 public enum ExamStatus {
 
     START("开始考试", 0), CALCULATING("正在统分", 1), CHECKING("数据检查中", 2), ENDED("已结束", 3);
@@ -7,6 +10,8 @@ public enum ExamStatus {
     private String name;
 
     private int value;
+    
+    private static List<ExamStatus> list;
 
     private ExamStatus(String name, int value) {
         this.name = name;
@@ -31,4 +36,13 @@ public enum ExamStatus {
         }
         return status;
     }
+    
+    public static List<ExamStatus> getStatusList() {
+        if (list == null) {
+            list = new LinkedList<ExamStatus>();
+            list.add(ExamStatus.START);
+            list.add(ExamStatus.ENDED);
+        }
+        return list;
+    }
 }

+ 29 - 0
stmms-common/src/main/java/cn/com/qmth/stmms/common/enums/MarkMode.java

@@ -0,0 +1,29 @@
+package cn.com.qmth.stmms.common.enums;
+
+/**
+ * 评卷模式
+ * 
+ */
+public enum MarkMode {
+
+    COMMON("普通"), TRACK("轨迹");
+
+    private String name;
+
+    private MarkMode(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static MarkMode findByName(String name) {
+        for (MarkMode c : MarkMode.values()) {
+            if (c.toString().equalsIgnoreCase(name)) {
+                return c;
+            }
+        }
+        return null;
+    }
+}

+ 5 - 1
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/ExamController.java

@@ -31,6 +31,7 @@ import cn.com.qmth.stmms.common.auth.annotation.AuthRequire;
 import cn.com.qmth.stmms.common.enums.Auth;
 import cn.com.qmth.stmms.common.enums.ExamStatus;
 import cn.com.qmth.stmms.common.enums.LibraryStatus;
+import cn.com.qmth.stmms.common.enums.MarkMode;
 import cn.com.qmth.stmms.common.enums.UserType;
 import cn.com.qmth.stmms.common.session.model.StmmsSession;
 import cn.com.qmth.stmms.common.utils.Paginator;
@@ -83,6 +84,7 @@ public class ExamController extends BaseParameterController {
     // @AuthRequire({ Auth.EXAM_CREATE })
     public String add(Exam exam, Model model) {
         model.addAttribute("exam", exam);
+        model.addAttribute("markModeList", MarkMode.values());
         return "modules/exam/examForm";
     }
     
@@ -91,7 +93,8 @@ public class ExamController extends BaseParameterController {
     public String edit(@PathVariable Integer examId, Model model) {
     	Exam exam = examService.findById(examId);
         model.addAttribute("exam", exam);
-        model.addAttribute("statusList", ExamStatus.values());
+        model.addAttribute("statusList", ExamStatus.getStatusList());
+        model.addAttribute("markModeList", MarkMode.values());
         return "modules/exam/examEdit";
     }
     
@@ -119,6 +122,7 @@ public class ExamController extends BaseParameterController {
             oldExam.setStatus(ExamStatus.findByValue(StatusValue));
             oldExam.setForceSpecialTag(exam.isForceSpecialTag());
             oldExam.setShowSheet(exam.isShowSheet());
+            oldExam.setMarkMode(exam.getMarkMode());
             examService.save(oldExam);
         }
         return "redirect:/admin/exam";

+ 13 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/common/controller/BaseController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.WebDataBinder;
 import org.springframework.web.bind.annotation.InitBinder;
 
 import cn.com.qmth.stmms.common.enums.ExamSubjectStatus;
+import cn.com.qmth.stmms.common.enums.MarkMode;
 import cn.com.qmth.stmms.common.utils.DateUtils;
 
 public abstract class BaseController {
@@ -52,6 +53,18 @@ public abstract class BaseController {
                 }
             }
         });
+        // MarkMode 类型转换
+        binder.registerCustomEditor(MarkMode.class, new PropertyEditorSupport() {
+
+            @Override
+            public void setAsText(String text) {
+                try {
+                    setValue(MarkMode.findByName(text));
+                } catch (Exception e) {
+                    setValue(null);
+                }
+            }
+        });
 
         binder.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));
     }

+ 22 - 12
stmms-web/src/main/java/cn/com/qmth/stmms/mark/MarkController.java

@@ -37,6 +37,7 @@ import cn.com.qmth.stmms.biz.mark.service.TaskService;
 import cn.com.qmth.stmms.common.controller.BaseController;
 import cn.com.qmth.stmms.common.enums.ExamSubjectStatus;
 import cn.com.qmth.stmms.common.enums.LibraryStatus;
+import cn.com.qmth.stmms.common.enums.MarkMode;
 import cn.com.qmth.stmms.common.session.model.StmmsSession;
 import cn.com.qmth.stmms.common.utils.RequestUtils;
 
@@ -156,24 +157,33 @@ public class MarkController extends BaseController {
     public ModelAndView index(HttpServletRequest request, @RequestParam(value = "mode", required = false) String mode) {
         StmmsSession session = RequestUtils.getSession(request);
         Marker marker = RequestUtils.getWebUser(request).getMarker();
-        ModelAndView modelAndView = getMarkModeView(marker, mode);
+        ModelAndView modelAndView = getMarkModeView(marker, MarkMode.findByName(mode));
         preProcess(marker, session, modelAndView);
         return modelAndView;
     }
 
-    private ModelAndView getMarkModeView(Marker marker, String mode) {
-        if (StringUtils.isNotBlank(mode)) {
-            marker.setMode(mode);
+    private ModelAndView getMarkModeView(Marker marker, MarkMode mode) {
+        boolean forceMode = false;
+        Exam exam = examService.findById(marker.getExamId());
+        if (exam != null && exam.getMarkMode() != null) {
+            mode = exam.getMarkMode();
+            forceMode = true;
         }
-        String view = null;
-        if ("track".equals(marker.getMode())) {
-            view = "modules/mark/markTrack";
-        } else {
-            marker.setMode("common");
-            view = "modules/mark/markNew";
+        // 否则取评卷员当前记录的评卷模式
+        if (mode == null) {
+            mode = marker.getMode();
         }
-        markerService.save(marker);
-        return new ModelAndView(view);
+        if (mode == null) {
+            mode = MarkMode.COMMON;
+        }
+        if (marker.getMode() != mode) {
+            marker.setMode(mode);
+            markerService.save(marker);
+        }
+        ModelAndView view = new ModelAndView(
+                mode == MarkMode.TRACK ? "modules/mark/markTrack" : "modules/mark/markNew");
+        view.addObject("forceMode", forceMode);
+        return view;
     }
 
     @RequestMapping("/logout")

+ 11 - 0
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/examEdit.jsp

@@ -66,6 +66,17 @@
 				<input name="showSheet" type="checkbox" <c:if test="${exam.showSheet}">checked</c:if>/>
 			</div>
 		</div>
+		<div class="control-group">
+            <label class="control-label">评卷模式</label>
+            <div class="controls">
+            <select name="markMode">
+                <option value="">不限</option>
+                <c:forEach items="${markModeList}" var="item">
+                    <option value="${item}" <c:if test="${exam.markMode!=null && exam.markMode==item}">selected</c:if>>${item.name}</option>
+                </c:forEach>
+            </select>
+            </div>
+        </div>
 		<div class="control-group">
 			<label class="control-label">状态</label>
 			<div class="controls">

+ 11 - 0
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/examForm.jsp

@@ -65,6 +65,17 @@
 				<input name="showSheet" type="checkbox" <c:if test="${exam.showSheet}">checked</c:if>/>
 			</div>
 		</div>
+		<div class="control-group">
+            <label class="control-label">评卷模式</label>
+            <div class="controls">
+            <select name="markMode">
+                <option value="">不限</option>
+                <c:forEach items="${markModeList}" var="item">
+                     <option value="${item}" >${item.name}</option>
+                </c:forEach>
+            </select>
+            </div>
+        </div>
 		<div class="control-group">
 			<label class="control-label">描述:</label>
 			<div class="controls">

+ 3 - 0
stmms-web/src/main/webapp/WEB-INF/views/modules/mark/markNew.jsp

@@ -47,6 +47,9 @@
 				userName : '${web_user.name}',
 				logoutUrl: '${ctx}/mark/logout',
 				clearUrl: '${ctx}/mark/clear',
+				<c:if test="${forceMode==false}">
+				switchTrackUrl: '${ctx}/mark/index?mode=track',
+				</c:if>
 				forceSpecialTag : eval('${exam.forceSpecialTag}'.toLowerCase()),
 				modules : {
 					'single-image-view' : {},

+ 3 - 0
stmms-web/src/main/webapp/WEB-INF/views/modules/mark/markTrack.jsp

@@ -40,6 +40,9 @@
 				userName : '${web_user.name}',
 				logoutUrl: '${ctx}/mark/logout',
 				clearUrl: '${ctx}/mark/clear',
+				<c:if test="${forceMode==false}">
+				switchCommonUrl: '${ctx}/mark/index?mode=common',
+				</c:if>
 				forceSpecialTag : eval('${exam.forceSpecialTag}'.toLowerCase()),
 				modules : {
 					'single-image-view' : {},

+ 7 - 1
stmms-web/src/main/webapp/static/mark-new/js/mark-control.js

@@ -38,6 +38,12 @@ MarkControl.prototype.initContainer = function() {
     }
     this.container.center = getDom(this.center_dom, this).appendTo(this.container);
     this.container.header = getDom(this.center_header_dom, this).appendTo(this.container.center).find('.header');
+    
+    if(this.option.switchTrackUrl!=undefined && this.option.switchTrackUrl.length>0){
+    	var switchButton = this.container.header.find('#switch-track-button');
+    	switchButton.attr('href', this.option.switchTrackUrl);
+    	switchButton.show();
+    }
     this.container.centerContent = getDom(this.center_content_dom, this).appendTo(this.container.center);
     this.container.imageContent = getDom(this.image_content_dom, this).appendTo(this.container.centerContent);
 
@@ -566,7 +572,7 @@ MarkControl.prototype.sidebar_dom = '<div class="mark-sidebar span2 hide"></div>
 MarkControl.prototype.center_dom = '<div class="center-content span12"></div>';
 
 MarkControl.prototype.center_header_dom = '<div class="row-fluid"><div class="header"><p class="tips">\
-<em><a href="/mark/index?mode=track" class="btn">切换到轨迹模式</a>\
+<em><a href="##" class="btn" id="switch-track-button" style="display:none">切换到轨迹模式</a>\
 <a href="javascript:void(0)" id="assistant-button" class="btn"><i class="icon-wrench"></i> 小助手</a></em>\
 <a class="useinfo" href="#"><i class="icon-user icon-white"></i><i id="mark-user-name"></i></a>\
 <a class="logout" id="logout-link" href="{logoutUrl}"><i class="icon-off icon-white"></i> <i id="logout-title">退出</i></a>\

+ 6 - 1
stmms-web/src/main/webapp/static/mark-track/js/mark-control.js

@@ -39,6 +39,11 @@ MarkControl.prototype.initContainer = function() {
     }
     this.container.center = getDom(this.center_dom, this).appendTo(this.container);
     this.container.header = getDom(this.center_header_dom, this).appendTo(this.container.center).find('.header');
+    if(this.option.switchCommonUrl!=undefined && this.option.switchCommonUrl.length>0){
+    	var switchButton = this.container.header.find('#switch-common-button');
+    	switchButton.attr('href', this.option.switchCommonUrl);
+    	switchButton.show();
+    }
     this.container.centerContainer = getDom(this.center_content_dom, this).appendTo(this.container.center);
     this.container.centerContent = this.container.centerContainer.find('.image-content');
     this.container.centerNavbar = this.container.centerContent.find('nav');
@@ -581,7 +586,7 @@ MarkControl.prototype.sidebar_dom = '<div class="mark-sidebar span2 hide"></div>
 MarkControl.prototype.center_dom = '<div class="center-content span12"></div>';
 
 MarkControl.prototype.center_header_dom = '<div class="row-fluid"><div class="header"><p class="tips">\
-<em><a href="/mark/index?mode=common" class="btn">切换到普通模式</a>\
+<em><a href="##" class="btn" id="switch-common-button" style="display:none">切换到普通模式</a>\
 <a href="javascript:void(0)" id="assistant-button" class="btn"><i class="icon-wrench"></i> 小助手</a></em>\
 <a class="useinfo" href="#"><i class="icon-user icon-white"></i><i id="mark-user-name"></i></a>\
 <a class="logout" id="logout-link" href="{logoutUrl}"><i class="icon-off icon-white"></i> <i id="logout-title">退出</i></a>\