Browse Source

自定义判分策略

xiatian 1 year ago
parent
commit
03841b2cef

+ 1 - 0
install/mysql/init/stmms_ft.sql

@@ -278,6 +278,7 @@ CREATE TABLE `eb_exam_question`
     `interval_score`   double      NOT NULL COMMENT '评卷间隔分',
     `interval_score`   double      NOT NULL COMMENT '评卷间隔分',
     `objective_policy` varchar(16)          DEFAULT NULL COMMENT '客观题判分策略',
     `objective_policy` varchar(16)          DEFAULT NULL COMMENT '客观题判分策略',
 	`question_type`		varchar(32)         DEFAULT NULL COMMENT '题型',
 	`question_type`		varchar(32)         DEFAULT NULL COMMENT '题型',
+	`customize_policy`	text  DEFAULT NULL COMMENT '自定义判分策略',
     PRIMARY KEY (`id`),
     PRIMARY KEY (`id`),
     KEY `index1` (`exam_id`, `subject_code`, `is_objective`, `main_number`, `sub_number`, `paper_type`)
     KEY `index1` (`exam_id`, `subject_code`, `is_objective`, `main_number`, `sub_number`, `paper_type`)
 ) ENGINE = InnoDB
 ) ENGINE = InnoDB

+ 3 - 1
install/mysql/upgrade/1.3.16.sql

@@ -5,4 +5,6 @@ USE `stmms_ft`;
 update b_role_info set name='评卷组长' where name='科组长';
 update b_role_info set name='评卷组长' where name='科组长';
 update b_role_info set name='系统管理员' where name='学校管理员';
 update b_role_info set name='系统管理员' where name='学校管理员';
 update b_role_info set name='成绩查询员' where name='学校查询员';
 update b_role_info set name='成绩查询员' where name='学校查询员';
-update b_role_info set name='评卷管理员' where name='学院管理员';
+update b_role_info set name='评卷管理员' where name='学院管理员';
+
+ALTER TABLE eb_exam_question ADD COLUMN `customize_policy`	text  DEFAULT NULL COMMENT '自定义判分策略';

+ 11 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/model/ExamQuestion.java

@@ -73,6 +73,9 @@ public class ExamQuestion implements Serializable, QuestionNumberBean {
 
 
     @Column(name = "name", nullable = true, length = 128)
     @Column(name = "name", nullable = true, length = 128)
     private String name;
     private String name;
+    
+    @Column(name = "customize_policy", nullable = true)
+    private String customizePolicy;
 
 
     @Transient
     @Transient
     private ExamSubject subject;
     private ExamSubject subject;
@@ -364,4 +367,12 @@ public class ExamQuestion implements Serializable, QuestionNumberBean {
         this.deleting = deleting;
         this.deleting = deleting;
     }
     }
 
 
+	public String getCustomizePolicy() {
+		return customizePolicy;
+	}
+
+	public void setCustomizePolicy(String customizePolicy) {
+		this.customizePolicy = customizePolicy;
+	}
+
 }
 }

+ 26 - 1
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/utils/ScoreCalculateUtil.java

@@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
 import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
 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.ExamStudent;
 import cn.com.qmth.stmms.common.enums.ObjectivePolicy;
 import cn.com.qmth.stmms.common.enums.ObjectivePolicy;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 
 public class ScoreCalculateUtil {
 public class ScoreCalculateUtil {
 
 
@@ -66,6 +68,16 @@ public class ScoreCalculateUtil {
             // 任选给分
             // 任选给分
             if (ObjectivePolicy.ALL.equals(question.getObjectivePolicy())) {
             if (ObjectivePolicy.ALL.equals(question.getObjectivePolicy())) {
                 score = answer.length() == 0 || answer.equals("#") ? 0 : question.getTotalScore();
                 score = answer.length() == 0 || answer.equals("#") ? 0 : question.getTotalScore();
+            } else if(ObjectivePolicy.CUSTOMIZE.equals(question.getObjectivePolicy())){
+            	for (int i = 0; i < answer.length(); i++) {
+                    if (!question.getAnswer().contains(String.valueOf(answer.charAt(i)))) {
+                        correct = false;
+                        break;
+                    }
+                }
+            	 if (correct) {
+                     score = getScore(answer.length(),question.getCustomizePolicy());
+                 }
             } else {
             } else {
                 for (int i = 0; i < answer.length(); i++) {
                 for (int i = 0; i < answer.length(); i++) {
                     if (!question.getAnswer().contains(String.valueOf(answer.charAt(i)))) {
                     if (!question.getAnswer().contains(String.valueOf(answer.charAt(i)))) {
@@ -90,7 +102,20 @@ public class ScoreCalculateUtil {
         }
         }
     }
     }
 
 
-    private void calculateSubjective(List<ExamQuestion> sList, ScoreInfo scoreInfo) {
+    private double getScore(int length, String customizePolicy) {
+    	JSONArray ja=JSONArray.fromObject(customizePolicy);
+    	for(int i=0;i<ja.size();i++) {
+    		JSONObject jo=ja.getJSONObject(i);
+    		int count=Integer.valueOf(jo.getString("answerCount"));
+    		if(length==count) {
+    			double score=Double.valueOf(jo.getString("answerScore"));
+    			return score;
+    		}
+    	}
+		return 0;
+	}
+
+	private void calculateSubjective(List<ExamQuestion> sList, ScoreInfo scoreInfo) {
 
 
     }
     }
 
 

+ 1 - 1
stmms-common/src/main/java/cn/com/qmth/stmms/common/enums/ObjectivePolicy.java

@@ -5,7 +5,7 @@ package cn.com.qmth.stmms.common.enums;
  * 
  * 
  */
  */
 public enum ObjectivePolicy {
 public enum ObjectivePolicy {
-    NONE("无", 1), ALL("任选给分", 2), LEAK("漏选给分", 3);
+    NONE("无", 1), ALL("任选给分", 2), LEAK("漏选给分", 3), CUSTOMIZE("自定义", 4);
 
 
     private String name;
     private String name;
 
 

+ 13 - 30
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/PaperController.java

@@ -20,10 +20,8 @@ import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -42,6 +40,9 @@ import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 
+import com.aliyun.oss.common.utils.BinaryUtil;
+import com.qmth.boot.tools.io.ZipReader;
+
 import cn.com.qmth.stmms.admin.dto.ObjectiveQuestionDTO;
 import cn.com.qmth.stmms.admin.dto.ObjectiveQuestionDTO;
 import cn.com.qmth.stmms.admin.dto.QuestionDTO;
 import cn.com.qmth.stmms.admin.dto.QuestionDTO;
 import cn.com.qmth.stmms.admin.dto.SubjectQuestionDTO;
 import cn.com.qmth.stmms.admin.dto.SubjectQuestionDTO;
@@ -76,12 +77,6 @@ import cn.com.qmth.stmms.biz.file.service.FileService;
 import cn.com.qmth.stmms.biz.lock.LockService;
 import cn.com.qmth.stmms.biz.lock.LockService;
 import cn.com.qmth.stmms.biz.mark.service.MarkService;
 import cn.com.qmth.stmms.biz.mark.service.MarkService;
 import cn.com.qmth.stmms.biz.report.service.ReportService;
 import cn.com.qmth.stmms.biz.report.service.ReportService;
-import cn.com.qmth.stmms.biz.report.service.ReportSubjectClassService;
-import cn.com.qmth.stmms.biz.report.service.ReportSubjectCollegeService;
-import cn.com.qmth.stmms.biz.report.service.ReportSubjectGroupService;
-import cn.com.qmth.stmms.biz.report.service.ReportSubjectQuestionService;
-import cn.com.qmth.stmms.biz.report.service.ReportSubjectService;
-import cn.com.qmth.stmms.biz.report.service.ReportSubjectTeacherService;
 import cn.com.qmth.stmms.common.annotation.Logging;
 import cn.com.qmth.stmms.common.annotation.Logging;
 import cn.com.qmth.stmms.common.annotation.RoleRequire;
 import cn.com.qmth.stmms.common.annotation.RoleRequire;
 import cn.com.qmth.stmms.common.domain.WebUser;
 import cn.com.qmth.stmms.common.domain.WebUser;
@@ -96,9 +91,8 @@ import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
 import cn.com.qmth.stmms.common.utils.ExportExcel;
 import cn.com.qmth.stmms.common.utils.ExportExcel;
 import cn.com.qmth.stmms.common.utils.ImportExcel;
 import cn.com.qmth.stmms.common.utils.ImportExcel;
 import cn.com.qmth.stmms.common.utils.RequestUtils;
 import cn.com.qmth.stmms.common.utils.RequestUtils;
-
-import com.aliyun.oss.common.utils.BinaryUtil;
-import com.qmth.boot.tools.io.ZipReader;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 
 @Controller("examPaperController")
 @Controller("examPaperController")
 @RequestMapping("/admin/exam/paper")
 @RequestMapping("/admin/exam/paper")
@@ -144,24 +138,6 @@ public class PaperController extends BaseExamController {
     @Autowired
     @Autowired
     private MarkService markService;
     private MarkService markService;
 
 
-    @Autowired
-    private ReportSubjectQuestionService reportSubjectQuestionService;
-
-    @Autowired
-    private ReportSubjectClassService reportSubjectClassService;
-
-    @Autowired
-    private ReportSubjectTeacherService reportSubjectTeacherService;
-
-    @Autowired
-    private ReportSubjectCollegeService reportSubjectCollegeService;
-
-    @Autowired
-    private ReportSubjectGroupService reportSubjectGroupService;
-
-    @Autowired
-    private ReportSubjectService reportSubjectService;
-
     @Autowired
     @Autowired
     private MarkerService markerService;
     private MarkerService markerService;
 
 
@@ -601,6 +577,9 @@ public class PaperController extends BaseExamController {
     @RoleRequire(Role.SCHOOL_ADMIN)
     @RoleRequire(Role.SCHOOL_ADMIN)
     public String update(HttpServletRequest request, RedirectAttributes redirectAttributes, @RequestParam Integer id,
     public String update(HttpServletRequest request, RedirectAttributes redirectAttributes, @RequestParam Integer id,
             ExamQuestion question, ExamSubjectSearchQuery query, @RequestParam(required = false) Boolean upload) {
             ExamQuestion question, ExamSubjectSearchQuery query, @RequestParam(required = false) Boolean upload) {
+    	if(question.getCustomizePolicy()!=null) {
+    		question.setCustomizePolicy(StringEscapeUtils.unescapeHtml(question.getCustomizePolicy()));
+    	}
         int examId = getSessionExamId(request);
         int examId = getSessionExamId(request);
         ExamQuestion old = questionService.findById(id);
         ExamQuestion old = questionService.findById(id);
         String u = upload == null ? "" : upload.toString();
         String u = upload == null ? "" : upload.toString();
@@ -644,6 +623,7 @@ public class PaperController extends BaseExamController {
             old.setAnswer(question.getAnswer().toUpperCase());
             old.setAnswer(question.getAnswer().toUpperCase());
             old.setPaperType(question.getPaperType());
             old.setPaperType(question.getPaperType());
             old.setType(question.getType());
             old.setType(question.getType());
+            old.setCustomizePolicy(question.getCustomizePolicy());
             questionService.saveAndFlush(old);
             questionService.saveAndFlush(old);
             questionService.updateMainTitle(examId, question.getSubjectCode(), question.isObjective(),
             questionService.updateMainTitle(examId, question.getSubjectCode(), question.isObjective(),
                     question.getMainNumber(), question.getMainTitle());
                     question.getMainNumber(), question.getMainTitle());
@@ -851,6 +831,9 @@ public class PaperController extends BaseExamController {
     @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,
             ExamQuestion question, ExamSubjectSearchQuery query, @RequestParam(required = false) Boolean upload) {
             ExamQuestion question, ExamSubjectSearchQuery query, @RequestParam(required = false) Boolean upload) {
+    	if(question.getCustomizePolicy()!=null) {
+    		question.setCustomizePolicy(StringEscapeUtils.unescapeHtml(question.getCustomizePolicy()));
+    	}
         int examId = getSessionExamId(request);
         int examId = getSessionExamId(request);
         ExamQuestion old = questionService.findByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(examId,
         ExamQuestion old = questionService.findByExamAndSubjectAndObjectiveAndMainNumberAndSubNumber(examId,
                 question.getSubjectCode(), question.isObjective(), question.getMainNumber(), question.getSubNumber());
                 question.getSubjectCode(), question.isObjective(), question.getMainNumber(), question.getSubNumber());

+ 139 - 5
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/questionAdd.jsp

@@ -7,6 +7,7 @@
 	<%@include file="/WEB-INF/views/include/head.jsp" %>
 	<%@include file="/WEB-INF/views/include/head.jsp" %>
 	 <script type="text/javascript">
 	 <script type="text/javascript">
         $(document).ready(function () {
         $(document).ready(function () {
+        	$("#customize-div").hide();
             $("#inputForm").validate({
             $("#inputForm").validate({
                 submitHandler: function (form) {
                 submitHandler: function (form) {
                     loading('正在提交,请稍等...');
                     loading('正在提交,请稍等...');
@@ -32,7 +33,14 @@
                     $(".objectiveDiv").hide();
                     $(".objectiveDiv").hide();
                 }
                 }
             });
             });
-            
+            $("[name='objectivePolicy']").change(function () {
+                if($(this).val()=="4"){
+                	$("#customize-div").show();
+                	reShowBtn();
+                }else{
+                	$("#customize-div").hide();
+                }
+            });
             $('#btnSubmit').click(function () {
             $('#btnSubmit').click(function () {
                     var score = $('#interval-score-input').val();
                     var score = $('#interval-score-input').val();
                     var reg= /^-?\d+\.?\d{0,2}$/; 
                     var reg= /^-?\d+\.?\d{0,2}$/; 
@@ -45,10 +53,121 @@
                     	alert('满分不能为空且大于等于0分');
                     	alert('满分不能为空且大于等于0分');
                     	return false;
                     	return false;
                     }
                     }
+                    if(!buildParam()){
+                    	return false;
+                    }
                     $('#inputForm').submit();
                     $('#inputForm').submit();
             });
             });
         });
         });
+        function editRow(btn){
+        	var ob=$(btn);
+        	if("-"==ob.val()){
+        		ob.parent().remove();
+        	}else{
+        		var temrow=ob.parent().clone();
+        		$(temrow).children("[name='answerCount']").val("");
+        		$(temrow).children("[name='answerScore']").val("");
+        		ob.parent().parent().append(temrow);
+        	}
+        	reShowBtn();
+        }
+        function reShowBtn(){
+        	if($("#customize-div").children("div").size()==1){
+        		$(".edit-button[value='-']").hide();
+        	}else{
+        		$(".edit-button[value='-']").show();
+        	}
+        	$(".edit-button[value='+']").hide();
+        	$("#customize-div").children("div:last-child").children("input:last-child").show();
+        }
+        function checkParam(){
+        	var countSet = new Set();
+        	var regCount= /^[1-9]+\d*$/;
+        	var regScore= /^-?\d+\.?\d{0,2}$/; 
+        	var answerLength=$("[name='answer']").val().trim().length;
+        	var maxScore=$('#total-score-input').val();
+        	var hasMxScore=false;
+        	try{
+	        	var acArr=$("[name='answerCount']");
+	        	var countSize=0;
+	        	acArr.each(function(){
+	        		countSize++;
+	        		var tem=$(this).val();
+	        		if(!tem||tem.trim()==""){
+	        			throw new Error("自定义判分策略,答对个数不能为空"); 
+	        		}
+	        		tem=parseInt(tem.trim());
+	        		if(!regCount.test(tem)){
+	        			throw new Error("自定义判分策略,答对个数只能是正整数"); 
+	        		}
+	        		if(tem>answerLength){
+	        			throw new Error("自定义判分策略,答对个数不能大于答案数量"); 
+	        		}
+	        		countSet.add(tem);
+	        	});
+	        	if(countSize!=countSet.size){
+	        		throw new Error("自定义判分策略,答对个数有重复"); 
+	        	}
+	        	var asArr=$("[name='answerScore']");
+	        	asArr.each(function(){
+	        		var tem=$(this).val();
+	        		if(!tem||tem.trim()==""){
+	        			throw new Error("自定义判分策略,给分不能为空"); 
+	        		}
+	        		tem=parseFloat(tem.trim());
+        		 	if (!regScore.test(tem) ||tem<=0) {
+        		 		throw new Error("自定义判分策略,给分必须大于等于0分且只支持两位小数");
+                 	}
+        		 	if (tem>maxScore) {
+        		 		throw new Error("自定义判分策略,给分不能大于小题满分");
+                 	}
+	        		if(maxScore==tem){
+	        			hasMxScore=true;
+	        		}
+	        	});
+	        	if(!hasMxScore){
+        			throw new Error("自定义判分策略,小题满分未完成分配"); 
+        		}
+        		return true;
+        	}catch(e){
+        		alert(e.message);
+        		return false;
+        	}
+        }
+        function buildParam(){
+        	if($("[name='objectivePolicy']").val()=="4"){
+        		if(!checkParam()){
+        			return false;
+        		}
+        		var arr=[];
+        		$("#customize-div").children("div").each(function(){
+        			var tem={};
+        			tem['answerCount']=$(this).children("[name='answerCount']:first").val().trim();
+        			tem['answerScore']=$(this).children("[name='answerScore']:first").val().trim();
+        			arr.push(tem);
+        		});
+        		$("#customizePolicy").val(JSON.stringify(arr));
+        	}else{
+        		$("#customizePolicy").val("");
+        	}
+        	return true;
+        }
     </script>
     </script>
+    <style type="text/css">
+    .edit-button {
+        width:26px !important;
+        border-radius: 50%;
+        border: 1px solid #ccc;
+        margin-left:5px;
+    }
+    .customize-input{
+    	width:30px;
+    }
+     .customize-row{
+    	margin-bottom: 5px;
+    }
+    
+    </style>
 </head>
 </head>
 <body>
 <body>
 	<ul class="nav nav-tabs">
 	<ul class="nav nav-tabs">
@@ -62,6 +181,7 @@
 	 	<input type="hidden" id="level" name="level" value="${query.level }"/>
 	 	<input type="hidden" id="level" name="level" value="${query.level }"/>
 	 	<input type="hidden" id="upload" name="upload" value="${upload}"/>
 	 	<input type="hidden" id="upload" name="upload" value="${upload}"/>
 	 	<input type="hidden" id="totalScoreNotEqual" name="totalScoreNotEqual" value="${query.totalScoreNotEqual }"/>
 	 	<input type="hidden" id="totalScoreNotEqual" name="totalScoreNotEqual" value="${query.totalScoreNotEqual }"/>
+	 	<input type="hidden" id="customizePolicy" name="customizePolicy"/>
 	 	
 	 	
 	 	<input type="hidden" name="subjectCode" value="${subjectCode}"/>
 	 	<input type="hidden" name="subjectCode" value="${subjectCode}"/>
 		<div class="control-group">
 		<div class="control-group">
@@ -135,10 +255,24 @@
 				<label class="control-label">判分策略</label>
 				<label class="control-label">判分策略</label>
 				<div class="controls">
 				<div class="controls">
 					<select class="input-small" name="objectivePolicy">
 					<select class="input-small" name="objectivePolicy">
-	                <c:forEach items="${objectivePolicyList}" var="item">
-	                	 <option value="${item.value}" <c:if test="${item.value==examQuestion.objectivePolicy.value}">selected</c:if>>${item.name}</option>
-	                </c:forEach>
-	            </select>
+		                <c:forEach items="${objectivePolicyList}" var="item">
+		                	 <option value="${item.value}" <c:if test="${item.value==examQuestion.objectivePolicy.value}">selected</c:if>>${item.name}</option>
+		                </c:forEach>
+		            </select>
+				</div>
+			</div>
+			<div id="customize-div" class="control-group">
+				<label class="control-label"></label>
+				<div class="controls customize-row">
+					答对
+					<input type="text" name="answerCount" htmlEscape="false" maxlength="10" class="customize-input"
+	                       value=""/>
+	                       	个给
+	                <input type="text" name="answerScore" htmlEscape="false" maxlength="10" class="customize-input"
+	                       value=""/>
+	                       	分
+	                <input type="button" class="edit-button" value="-" onclick="editRow(this)"/>
+	                <input type="button" class="edit-button" value="+" onclick="editRow(this)"/>
 				</div>
 				</div>
 			</div>
 			</div>
 		</div>
 		</div>

+ 154 - 2
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/questionEdit.jsp

@@ -7,6 +7,8 @@
 	<%@include file="/WEB-INF/views/include/head.jsp" %>
 	<%@include file="/WEB-INF/views/include/head.jsp" %>
 	<script type="text/javascript">
 	<script type="text/javascript">
         $(document).ready(function () {
         $(document).ready(function () {
+        	$("#customize-div").hide();
+        	initCustomizeDiv();
             $("#inputForm").validate({
             $("#inputForm").validate({
                 submitHandler: function (form) {
                 submitHandler: function (form) {
                     loading('正在提交,请稍等...');
                     loading('正在提交,请稍等...');
@@ -22,6 +24,14 @@
                     }
                     }
                 }
                 }
             });
             });
+            $("[name='objectivePolicy']").change(function () {
+                if($(this).val()=="4"){
+                	$("#customize-div").show();
+                	reShowBtn();
+                }else{
+                	$("#customize-div").hide();
+                }
+            });
             if ($("#objective").is(':checked')) {
             if ($("#objective").is(':checked')) {
                 $(".objectiveDiv").show();
                 $(".objectiveDiv").show();
             }else{
             }else{
@@ -39,10 +49,138 @@
                 	alert('满分不能为空且大于等于0分');
                 	alert('满分不能为空且大于等于0分');
                 	return false;
                 	return false;
                 }
                 }
+                if(!buildParam()){
+                	return false;
+                }
                 $('#inputForm').submit();
                 $('#inputForm').submit();
+        	});
         });
         });
-        });
+        function editRow(btn){
+        	var ob=$(btn);
+        	if("-"==ob.val()){
+        		ob.parent().remove();
+        	}else{
+        		var temrow=ob.parent().clone();
+        		$(temrow).children("[name='answerCount']").val("");
+        		$(temrow).children("[name='answerScore']").val("");
+        		ob.parent().parent().append(temrow);
+        	}
+        	reShowBtn();
+        }
+        function reShowBtn(){
+        	if($("#customize-div").children("div").size()==1){
+        		$(".edit-button[value='-']").hide();
+        	}else{
+        		$(".edit-button[value='-']").show();
+        	}
+        	$(".edit-button[value='+']").hide();
+        	$("#customize-div").children("div:last-child").children("input:last-child").show();
+        }
+        function checkParam(){
+        	var countSet = new Set();
+        	var regCount= /^[1-9]+\d*$/;
+        	var regScore= /^-?\d+\.?\d{0,2}$/; 
+        	var answerLength=$("[name='answer']").val().trim().length;
+        	var maxScore=$('#total-score-input').val();
+        	var hasMxScore=false;
+        	try{
+	        	var acArr=$("[name='answerCount']");
+	        	var countSize=0;
+	        	acArr.each(function(){
+	        		countSize++;
+	        		var tem=$(this).val();
+	        		if(!tem||tem.trim()==""){
+	        			throw new Error("自定义判分策略,答对个数不能为空"); 
+	        		}
+	        		tem=parseInt(tem.trim());
+	        		if(!regCount.test(tem)){
+	        			throw new Error("自定义判分策略,答对个数只能是正整数"); 
+	        		}
+	        		if(tem>answerLength){
+	        			throw new Error("自定义判分策略,答对个数不能大于答案数量"); 
+	        		}
+	        		countSet.add(tem);
+	        	});
+	        	if(countSize!=countSet.size){
+	        		throw new Error("自定义判分策略,答对个数有重复"); 
+	        	}
+	        	var asArr=$("[name='answerScore']");
+	        	asArr.each(function(){
+	        		var tem=$(this).val();
+	        		if(!tem||tem.trim()==""){
+	        			throw new Error("自定义判分策略,给分不能为空"); 
+	        		}
+	        		tem=parseFloat(tem.trim());
+        		 	if (!regScore.test(tem) ||tem<=0) {
+        		 		throw new Error("自定义判分策略,给分必须大于等于0分且只支持两位小数");
+                 	}
+        		 	if (tem>maxScore) {
+        		 		throw new Error("自定义判分策略,给分不能大于小题满分");
+                 	}
+	        		if(maxScore==tem){
+	        			hasMxScore=true;
+	        		}
+	        	});
+	        	if(!hasMxScore){
+        			throw new Error("自定义判分策略,小题满分未完成分配"); 
+        		}
+        		return true;
+        	}catch(e){
+        		alert(e.message);
+        		return false;
+        	}
+        }
+        function buildParam(){
+        	if($("[name='objectivePolicy']").val()=="4"){
+        		if(!checkParam()){
+        			return false;
+        		}
+        		var arr=[];
+        		$("#customize-div").children("div").each(function(){
+        			var tem={};
+        			tem['answerCount']=$(this).children("[name='answerCount']:first").val().trim();
+        			tem['answerScore']=$(this).children("[name='answerScore']:first").val().trim();
+        			arr.push(tem);
+        		});
+        		$("#customizePolicy").val(JSON.stringify(arr));
+        	}else{
+        		$("#customizePolicy").val("");
+        	}
+        	return true;
+        }
+        function initCustomizeDiv(){
+        	if($("[name='objectivePolicy']").val()=="4"){
+        		$("#customize-div").show();
+        		var customizePolicy=JSON.parse('${examQuestion.customizePolicy}');
+        		var count = customizePolicy.length;
+        		var firstRow=$(".customize-row");
+        		$(firstRow).children("[name='answerCount']").val(customizePolicy[0]["answerCount"]);
+        		$(firstRow).children("[name='answerScore']").val(customizePolicy[0]["answerScore"]);
+        		for(var i = 1; i < count; i++) {
+       			  	var temRow=firstRow.clone();
+	       			$(temRow).children("[name='answerCount']").val(customizePolicy[i]["answerCount"]);
+	        		$(temRow).children("[name='answerScore']").val(customizePolicy[i]["answerScore"]);
+	        		$("#customize-div").append(temRow);
+       			}
+        		reShowBtn();
+        	}
+        }
     </script>
     </script>
+    <style type="text/css">
+    .edit-button {
+        width:26px !important;
+        border-radius: 50%;
+        border: 1px solid #ccc;
+        margin-left:5px;
+    }
+    .customize-input{
+    	width:30px;
+    }
+     .customize-row{
+    	margin-bottom: 5px;
+    }
+    
+    </style>
 </head>
 </head>
 <body>
 <body>
 <ul class="nav nav-tabs">
 <ul class="nav nav-tabs">
@@ -56,7 +194,7 @@
 	 	<input type="hidden" id="level" name="level" value="${query.level }"/>
 	 	<input type="hidden" id="level" name="level" value="${query.level }"/>
 	 	<input type="hidden" id="upload" name="upload" value="${upload}"/>
 	 	<input type="hidden" id="upload" name="upload" value="${upload}"/>
 	 	<input type="hidden" id="totalScoreNotEqual" name="totalScoreNotEqual" value="${query.totalScoreNotEqual }"/>
 	 	<input type="hidden" id="totalScoreNotEqual" name="totalScoreNotEqual" value="${query.totalScoreNotEqual }"/>
-	 	
+	 	<input type="hidden" id="customizePolicy" name="customizePolicy"/>
 	 	<input type="hidden" name="subjectCode" value="${examQuestion.subjectCode}"/>
 	 	<input type="hidden" name="subjectCode" value="${examQuestion.subjectCode}"/>
 	 	<input type="hidden" name="id" value="${examQuestion.id}"/>
 	 	<input type="hidden" name="id" value="${examQuestion.id}"/>
 		<div class="control-group">
 		<div class="control-group">
@@ -137,6 +275,20 @@
 	            </select>
 	            </select>
 				</div>
 				</div>
 			</div>
 			</div>
+			<div id="customize-div" class="control-group">
+				<label class="control-label"></label>
+				<div class="controls customize-row">
+					答对
+					<input type="text" name="answerCount" htmlEscape="false" maxlength="10" class="customize-input"
+	                       value=""/>
+	                       	个给
+	                <input type="text" name="answerScore" htmlEscape="false" maxlength="10" class="customize-input"
+	                       value=""/>
+	                       	分
+	                <input type="button" class="edit-button" value="-" onclick="editRow(this)"/>
+	                <input type="button" class="edit-button" value="+" onclick="editRow(this)"/>
+				</div>
+			</div>
 		</div>
 		</div>
 		<div class="form-actions">
 		<div class="form-actions">
 			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
 			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>