Browse Source

增加强制标功能

ting.yin 6 years ago
parent
commit
196bc3bbb6

+ 16 - 1
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/model/Exam.java

@@ -38,8 +38,15 @@ public class Exam implements Serializable {
 
     @Enumerated(EnumType.ORDINAL)
     private ExamStatus status;
-
+    
+    @Column(name = "description", length = 128, nullable = true)
     private String description;
+    
+    /**
+     * 开启强制特殊标记
+     */
+    @Column(name = "force_special_tag", nullable = false)
+    private boolean forceSpecialTag;
 
     @Temporal(TemporalType.TIMESTAMP)
     @Column(name = "create_time")
@@ -124,4 +131,12 @@ public class Exam implements Serializable {
         this.schoolId = schoolId;
     }
 
+	public boolean isForceSpecialTag() {
+		return forceSpecialTag;
+	}
+
+	public void setForceSpecialTag(boolean forceSpecialTag) {
+		this.forceSpecialTag = forceSpecialTag;
+	}
+
 }

+ 14 - 3
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/ExamController.java

@@ -85,7 +85,16 @@ public class ExamController extends BaseParameterController {
         model.addAttribute("exam", exam);
         return "modules/exam/examForm";
     }
-
+    
+    
+    @RequestMapping("/edit/{examId}")
+    public String edit(@PathVariable Integer examId, Model model) {
+    	Exam exam = examService.findById(examId);
+        model.addAttribute("exam", exam);
+        model.addAttribute("statusList", ExamStatus.values());
+        return "modules/exam/examEdit";
+    }
+    
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     // @AuthRequire({ Auth.EXAM_CREATE })
     public String save(HttpServletRequest request, Exam exam, RedirectAttributes redirectAttributes) {
@@ -100,16 +109,18 @@ public class ExamController extends BaseParameterController {
 
     @RequestMapping(value = "/edit", method = RequestMethod.POST)
     // @AuthRequire({ Auth.EXAM_CREATE })
-    public String examEdit(HttpServletRequest request, Exam exam) {
+    public String examEdit(HttpServletRequest request, Exam exam,int StatusValue) {
         User user = RequestUtils.getWebUser(request).getUser();
         Exam oldExam = examService.findById(exam.getId());
         if (oldExam != null && oldExam.getCreatorId().intValue() == user.getId().intValue()) {
             oldExam.setName(exam.getName());
             oldExam.setExamTime(exam.getExamTime());
             oldExam.setDescription(exam.getDescription());
+            oldExam.setStatus(ExamStatus.findByValue(StatusValue));
+            oldExam.setForceSpecialTag(exam.isForceSpecialTag());
             examService.save(oldExam);
         }
-        return "redirect:/exam/list";
+        return "redirect:/admin/exam";
     }
 
 	@RequestMapping("/view/{examId}")

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

@@ -0,0 +1,87 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+	<title>考试管理</title>
+	<meta name="decorator" content="default"/>
+	<%@include file="/WEB-INF/views/include/head.jsp" %>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			$("#name").focus();
+			$("#inputForm").validate({
+				submitHandler: function(form){
+					loading('正在提交,请稍等...');
+					form.submit();
+				},
+				errorContainer: "#messageBox",
+				errorPlacement: function(error, element) {
+					$("#messageBox").text("输入有误,请先更正。");
+					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+						error.appendTo(element.parent().parent());
+					} else {
+						error.insertAfter(element);
+					}
+				}
+			});
+		});
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/admin/exam">考试列表</a></li>
+		<li class="active"><a href="##">编辑考试</a></li>
+	</ul><br/>
+	<form:form id="inputForm" modelAttribute="exam" action="${ctx}/admin/exam/edit" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<tags:message content="${message}"/>
+		<div class="control-group">
+			<label class="control-label">考试名称:</label>
+			<div class="controls">
+				<form:input path="name" htmlEscape="false" maxlength="200" class="required"/>
+			</div>
+		</div>
+		<!-- <div class="control-group">
+			<label class="control-label">考试日期:</label>
+			<div class="controls">
+				<input name="examTime" type="text" maxlength="200" class="required" placeholder="格式:yyyy-MM-dd"/>
+			</div>
+		</div> -->
+		<div class="control-group">
+			<label class="control-label">考试日期:</label>
+			<div class="controls">
+				<input name="examTime" type="text" readonly="readonly" maxlength="20" class="Wdate required"
+					value="${exam.examTime }"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
+			</div>
+		</div>
+				<div class="control-group">
+			<label class="control-label">强制标记</label>
+			<div class="controls">
+				<input name="forceSpecialTag" type="checkbox" <c:if test="${exam.forceSpecialTag}">checked</c:if>/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">状态</label>
+			<div class="controls">
+				<select class="input-small" name="StatusValue">
+                <c:forEach items="${statusList}" var="item">
+                	 <option value="${item.value}" <c:if test="${item.value==exam.status.value}">selected</c:if>>${item.name}</option>
+                </c:forEach>
+            </select>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label">描述:</label>
+			<div class="controls">
+				<form:textarea path="description" htmlEscape="false" rows="4" maxlength="200" class="input-xxlarge"/>
+			</div>
+		</div>
+		<div class="form-actions">
+			<%-- <shiro:hasPermission name="exam:course:edit"> --%>
+			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
+			<%-- </shiro:hasPermission> --%>
+			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+		</div>
+	</form:form>
+</body>
+</html>

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

@@ -53,6 +53,12 @@
 					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
 			</div>
 		</div>
+		<div class="control-group">
+			<label class="control-label">强制标记</label>
+			<div class="controls">
+				<input name="forceSpecialTag" type="checkbox" <c:if test="${exam.forceSpecialTag}">checked</c:if>/>
+			</div>
+		</div>
 		<div class="control-group">
 			<label class="control-label">描述:</label>
 			<div class="controls">

+ 7 - 1
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/examList.jsp

@@ -30,6 +30,7 @@
 				<th>编号</th>
 				<th>考试名称</th>
 				<th>考试时间</th>
+				<th>强制标记</th>
 				<th>状态</th>
 				<th>操作</th>
 			</tr>
@@ -46,9 +47,14 @@
 				</td>
 
 				<td><fmt:formatDate value="${exam.examTime}" pattern="yyyy-MM-dd" /></td>
+				<td><c:if test="${exam.forceSpecialTag}">是</c:if>
+					<c:if test="${!exam.forceSpecialTag}">否</c:if>
+				</td>
+				
 				<td>${exam.status.name}</td>
 				<td>
-    				<a href="${ctx}/admin/exam/view/${exam.id}/info">详情</a>
+    				<a href="${ctx}/admin/exam/view/${exam.id}/info">详情</a>    				
+    				<a href="${ctx}/admin/exam/edit/${exam.id}">编辑</a>
 				</td>
 			</tr>
 		</c:forEach>

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

@@ -34,6 +34,7 @@
 <script type="text/javascript" src="${ctxStatic}/mark-new/js/modules/change-name.js"></script>
 <script type="text/javascript" src="${ctxStatic}/mark-new/js/modules/tag-process.js"></script>
 <script type="text/javascript" src="${ctxStatic}/mark-new/js/modules/view-sidebar.js"></script>
+<script type="text/javascript" src="${ctxStatic}/mark-new/js/modules/specialTag.js"></script>
 </head>
 <body>
 	<div class="container-fluid" id="container"></div>

+ 13 - 0
stmms-web/src/main/webapp/static/mark-new/js/mark-control.js

@@ -239,6 +239,10 @@ MarkControl.prototype.initTriggers = function(option) {
         var timestamp = new Date().getTime();
         context.task.spent = timestamp;
     });
+    
+    this.on('task.submit.forceSpecialTag', this, function(event, context, eventObject) {
+        
+    });
 
     $(document).keypress(this, function(event) {
         if (self.context.listenKeyboard != false) {
@@ -502,6 +506,14 @@ MarkControl.prototype.submitTask = function(submitUrl) {
         task.spent = timestamp - task.spent;
         	
         this.trigger('task.submit.before');
+        
+        //开启强制标记
+        if(this.option.forceSpecialTag===true){
+        	console.log(task);
+        	if(task.tagList==undefined ||task.tagList==null ||task.tagList.length <= 0){
+        		return;
+        	}
+        }
         if (this.taskControl != undefined) {
             //已定义任务引擎
             this.taskControl.submit(task, function(status) {
@@ -511,6 +523,7 @@ MarkControl.prototype.submitTask = function(submitUrl) {
                 }
                 //markControl.context.task = undefined;
                 markControl.trigger('task.submit.success');
+                markControl.trigger('mark.specialTag.success');
                 //markControl.getTask();
             }, function(message) {
                 markControl.trigger('task.submit.error', message);

+ 66 - 38
stmms-web/src/main/webapp/static/mark-new/js/modules/image-builder.js

@@ -22,48 +22,76 @@ ImageBuilder.prototype.build = function(task, callback) {
     //调用图片预加载函数,实现回调函数
     var imageObjects = [];
     this.loadImages(imageObjects, task.pictureUrls, 0, function(images) {
-        var maxWidth = 0;
-        var maxHeight = 0;
-        for (var i = 0; i < images.length; i++) {
-            //计算最大宽度与合计高度
-            var image = images[i];
-            maxWidth = Math.max(maxWidth, image.width);
-            maxHeight = Math.max(maxHeight, image.height);
-        }
-        //列数和行数
-        var bodyWidth = $(document.body).width();
-        var widthCount = parseInt(bodyWidth / maxWidth);
-        var heightCount = Math.ceil(images.length/widthCount);
-        if (maxWidth > 0 && maxHeight > 0) {
-            //设置画布大小及背景颜色
-            self.canvas.width = maxWidth*widthCount;
-            self.canvas.height = maxHeight*heightCount;
-            self.ctx.fillStyle = "#FFFFFF";
-            self.ctx.fillRect(0, 0, maxWidth*widthCount, maxHeight*heightCount);
-            //绘画到画布
-            var height = 0;
-            var width = 0;
-            var x = 0;
+//横排模式
+//        var maxWidth = 0;
+//        var maxHeight = 0;
+//        for (var i = 0; i < images.length; i++) {
+//            //计算最大宽度与合计高度
+//            var image = images[i];
+//            maxWidth = Math.max(maxWidth, image.width);
+//            maxHeight = Math.max(maxHeight, image.height);
+//        }
+//        //列数和行数
+//        var bodyWidth = $(document.body).width();
+//        var widthCount = parseInt(bodyWidth / maxWidth);
+//        var heightCount = Math.ceil(images.length/widthCount);
+//        if (maxWidth > 0 && maxHeight > 0) {
+//            //设置画布大小及背景颜色
+//            self.canvas.width = maxWidth*widthCount;
+//            self.canvas.height = maxHeight*heightCount;
+//            self.ctx.fillStyle = "#FFFFFF";
+//            self.ctx.fillRect(0, 0, maxWidth*widthCount, maxHeight*heightCount);
+//            //绘画到画布
+//            var height = 0;
+//            var width = 0;
+//            var x = 0;
+//            for (var i = 0; i < images.length; i++) {
+//                var image = images[i];
+//                
+//                var y = i%widthCount;
+//                if(y==0){//另起一行
+//                	width = 0;
+//                	x=0;
+//                }
+//                width = maxWidth*x;
+//                var z = parseInt(i/widthCount);
+//                height = maxHeight*z;
+//                self.ctx.drawImage(image, 0, 0, image.width, image.height,width , height, image.width, image.height);
+//                x++;
+//            }
+//            //生成合并后的图像数据
+//            task.imageData = this.canvas.toDataURL("image/jpeg");
+//            self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.height);
+//        }
+//        callback();
+    	//普通情况
+            var maxWidth = 0;
+            var totalHeight = 0;
             for (var i = 0; i < images.length; i++) {
+                //计算最大宽度与合计高度
                 var image = images[i];
-                
-                var y = i%widthCount;
-                if(y==0){//另起一行
-                	width = 0;
-                	x=0;
+                maxWidth = Math.max(maxWidth, image.width);
+                totalHeight += image.height;
+            }
+            if (maxWidth > 0 && totalHeight > 0) {
+                //设置画布大小及背景颜色
+                self.canvas.width = maxWidth;
+                self.canvas.height = totalHeight;
+                self.ctx.fillStyle = "#FFFFFF";
+                self.ctx.fillRect(0, 0, maxWidth, totalHeight);
+                //绘画到画布
+                var height = 0;
+                for (var i = 0; i < images.length; i++) {
+                    var image = images[i];
+                    self.ctx.drawImage(image, 0, 0, image.width, image.height, 0, height, image.width, image.height);
+                    height += image.height;
                 }
-                width = maxWidth*x;
-                var z = parseInt(i/widthCount);
-                height = maxHeight*z;
-                self.ctx.drawImage(image, 0, 0, image.width, image.height,width , height, image.width, image.height);
-                x++;
+                //生成合并后的图像数据
+                task.imageData = this.canvas.toDataURL("image/jpeg");
+                self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.height);
             }
-            //生成合并后的图像数据
-            task.imageData = this.canvas.toDataURL("image/jpeg");
-            self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.height);
-        }
-        callback();
-    }, function(error) {
+            callback();
+    	}, function(error) {
         if (error) {
             console.log(error);
         }

+ 158 - 0
stmms-web/src/main/webapp/static/mark-new/js/modules/specialTag.js

@@ -0,0 +1,158 @@
+//特殊标识模块
+var specialTag = function(option, success) {
+    var object = new SpecialTag(option);
+    success();
+    return object;
+}
+
+function SpecialTag(option) {
+    this.markControl = option.markControl;
+    this.maxWidth = option.width != undefined ? option.width : 200;
+    this.show = false;
+    this.tagName = undefined;
+    this.init();
+    this.markControl.on('task.get.before', this, function(event, context, eventObject) {
+        this.task = undefined;
+        this.reset();
+    });
+    this.markControl.on('task.get.success', this, function(event, context, eventObject) {
+        this.task = context.task;
+        if(this.task.tagList==undefined){
+        	this.task.tagList=[];
+        }
+        this.markControl.trigger('special.tag.disable');
+    });
+    this.markControl.on('task.get.none', this, function(event, context, eventObject) {
+        this.task = undefined;
+    });
+    this.markControl.on('image.click.event', this, function(event, context, eventObject) {
+        if(this.task!=undefined && this.tagName!=undefined && this.show==true){
+        	var specialTag = {
+        		tagName : this.tagName,
+        		positionX : eventObject.positionX,
+        		positionY : eventObject.positionY
+        	}
+            this.task.tagList.push(specialTag);
+            this.markControl.trigger('mark.tag.show', {
+                	content: specialTag.tagName,
+                	positionX: specialTag.positionX,
+                	positionY: specialTag.positionY
+            });
+        }
+    })
+    //图片重新加载后,恢复显示所有标记
+    this.markControl.on('image.reload.event', this, function(event, context, eventObject) {
+        if(this.task != undefined){
+            for(var i = 0; i <this.task.tagList.length; i++) {
+                this.markControl.trigger('mark.tag.show', {
+                	content: this.task.tagList[i].tagName,
+                	positionX: this.task.tagList[i].positionX,
+                	positionY: this.task.tagList[i].positionY
+                });
+            }
+        }
+    });
+}
+
+SpecialTag.prototype.init = function() {
+    var self = this;
+    this.container = getDom(this.container_dom, this.markControl).appendTo(this.markControl.container);
+    this.container.width(this.maxWidth);
+    this.container.offset({
+        top: 100,
+        left: 800
+    });
+    this.container.header = getDom(this.container_header_dom, this.markControl).appendTo(this.container);
+    this.container.header.width('100%');
+
+    this.container.content = getDom(this.container_content_dom, this.markControl).appendTo(this.container);
+    this.container.content.width('100%');
+
+    this.onclickList = this.container.content.find('#problem-list');
+
+    this.container.draggable({
+        containment: "window"
+    });
+
+    this.onclickList.find('a').click(function () {
+        self.tagName = undefined;
+        if(self.task!=undefined){
+        	if($(this).hasClass('selected')){
+        		self.tagName = undefined;
+        		$(this).removeClass('selected');
+        	}else{
+        		self.tagName = $(this).attr('value');
+        		self.onclickList.find('a').removeClass('selected');
+        		$(this).addClass('selected');
+        	}
+        }
+        if(self.tagName != undefined){
+        	self.markControl.trigger('special.tag.enable');
+        }else{
+        	self.markControl.trigger('special.tag.disable');
+        }
+        
+    });
+    this.container.find('#undo-button').click(function(){
+    	if(self.task!=undefined){
+    		self.task.tagList.pop();
+    		self.markControl.trigger('mark.tag.clear');
+    	}
+    });
+    this.container.find('#clear-button').click(function(){
+    	if(self.task!=undefined){
+    		self.task.tagList=[];
+    		self.markControl.trigger('mark.tag.clear');
+    	}
+    });
+    this.container.header.find('#close-button').click(function() {
+        self.toggle(false);
+    });
+
+    this.control = getDom(this.control_dom, this.markControl).appendTo(this.markControl.container.assistant);
+    this.control.find('#show-SpecialTag-button').click(function() {
+        self.markControl.container.assistant.hide();
+        self.toggle(true);
+    });
+    this.control.find('#hide-SpecialTag-button').click(function() {
+        self.markControl.container.assistant.hide();
+        self.toggle(false);
+    });
+}
+
+SpecialTag.prototype.toggle = function(show) {
+    if (show == true) {
+        this.show = true;
+        this.container.show();
+    } else {
+        this.show = false;
+        this.markControl.trigger('special.tag.disable')
+        this.container.hide();
+        this.onclickList.find('a').removeClass('selected');
+    }
+}
+
+SpecialTag.prototype.reset = function() {
+    this.tagName = $(this).attr('value');
+    this.onclickList.find('a').removeClass('selected');
+}
+
+SpecialTag.prototype.container_dom = '<div class="score-board score-board-popover" style="display:none"></div>';
+
+SpecialTag.prototype.container_header_dom = '<div class="header" style="border-radius: 15px 15px 0px 0px;">\
+<p class="fl" id="header">特殊标记</p>\
+<a class="header-close" id="close-button" href="#"><img src="{staticServer}/images/close.png"></a>\
+</div>';
+
+SpecialTag.prototype.container_content_dom = '<div class="content popover-content" style="padding:4px;border-radius: 0px 0px 15px 15px;">\
+<p id="problem-list" class="popover-list buttonCss">\
+    <a href="#" value="√">√</a>\
+    <a href="#" value="X">×</a>\
+    <a href="#" value="乄">乄</a></p>\
+<p><a href="#" id="undo-button" style="margin-left: 20px;">回&nbsp;&nbsp;&nbsp;退</a>\
+<a href="#" id="clear-button">全部清除</a></p></div>';
+
+SpecialTag.prototype.control_dom = '<h3 class="popover-title">特殊标记</h3>\
+<div class="popover-content"><p id="problem-list" class="popover-list">\
+<a href="#" id="show-SpecialTag-button">打开</a><a href="#" id="hide-SpecialTag-button">关闭</a>\
+</p></div>';

+ 3 - 0
stmms-web/src/main/webapp/static/mark-new/js/modules/warning-info.js

@@ -45,6 +45,9 @@ function WarningInfo(option) {
     this.markControl.on('task.submit.error', this, function(event, context, eventObject) {
         this.toggle(true, '网络异常,任务提交失败', '关闭');
     });
+    this.markControl.on('task.submit.forceSpecialTag', this, function(event, context, eventObject) {
+        this.toggle(true, '强制特殊标记已开启,至少使用一个特殊标记', '关闭');
+    });
 }
 
 WarningInfo.prototype.init = function() {