Commit 803a7d44e14c502268e03f258a2bc6029cf4b407
1 parent
878393f3
1.增加数字题
Showing
2 changed files
with
101 additions
and
9 deletions
WebRoot/WEB-INF/jsp/sunvote/teacher/creat_question.jsp
@@ -19,6 +19,9 @@ | @@ -19,6 +19,9 @@ | ||
19 | <script type="text/javascript" src="../static/js/jquery.min.js"></script> | 19 | <script type="text/javascript" src="../static/js/jquery.min.js"></script> |
20 | <!-- 最新的 Bootstrap 核心 JavaScript 文件 --> | 20 | <!-- 最新的 Bootstrap 核心 JavaScript 文件 --> |
21 | <script src="../static/js/bootstrap.min.js"></script> | 21 | <script src="../static/js/bootstrap.min.js"></script> |
22 | + <style> | ||
23 | + .number li{width:100px;outline: none;} | ||
24 | + </style> | ||
22 | </head> | 25 | </head> |
23 | <body> | 26 | <body> |
24 | <div class="page-header"> | 27 | <div class="page-header"> |
@@ -38,7 +41,41 @@ | @@ -38,7 +41,41 @@ | ||
38 | </div> | 41 | </div> |
39 | 42 | ||
40 | <div class="content container"> | 43 | <div class="content container"> |
41 | - | 44 | + <div class="section section-1 number" data-fraction="1" data-score=""> |
45 | + <div class="title"> | ||
46 | + <h3> | ||
47 | + <span class="que_num">一、</span><span class="que_name">单选</span> | ||
48 | + </h3> | ||
49 | + <input type="button" class="btn btn-danger pull-right remove" | ||
50 | + name="remove" value="删除"> | ||
51 | + </div> | ||
52 | + <div class="question_list"> | ||
53 | + <div class="question question1"> | ||
54 | + <span>1、</span> | ||
55 | + <ul> | ||
56 | + <li class="btn btn-default on" contenteditable="true" onkeydown="$(this).text(NumberCheck($(this).text()))">请输入答案</li> | ||
57 | + </ul> | ||
58 | + </div> | ||
59 | + <div class="question question2"> | ||
60 | + <span>2、</span> | ||
61 | + <ul> | ||
62 | + <li class="btn btn-default on" contenteditable="true">请输入答案</li> | ||
63 | + </ul> | ||
64 | + </div> | ||
65 | + <div class="question question3"> | ||
66 | + <span>3、</span> | ||
67 | + <ul> | ||
68 | + <li class="btn btn-default on" contenteditable="true">请输入答案</li> | ||
69 | + </ul> | ||
70 | + </div> | ||
71 | + <div class="question question4"> | ||
72 | + <span>4、</span> | ||
73 | + <ul> | ||
74 | + <li class="btn btn-default on" contenteditable="true">请输入答案</li> | ||
75 | + </ul> | ||
76 | + </div> | ||
77 | + </div> | ||
78 | + </div> | ||
42 | </div> | 79 | </div> |
43 | 80 | ||
44 | <!-- 快速出题 --> | 81 | <!-- 快速出题 --> |
@@ -102,7 +139,7 @@ | @@ -102,7 +139,7 @@ | ||
102 | <h4 class="modal-title">添加试题</h4> | 139 | <h4 class="modal-title">添加试题</h4> |
103 | </div> | 140 | </div> |
104 | <div class="modal-body"> | 141 | <div class="modal-body"> |
105 | - <!--<div class="form-group"> | 142 | + <div class="form-group"> |
106 | <label for="type" class="col-sm-2 control-label">题目名称</label> | 143 | <label for="type" class="col-sm-2 control-label">题目名称</label> |
107 | <div class="col-sm-10"> | 144 | <div class="col-sm-10"> |
108 | <select class="form-control" id="type"> | 145 | <select class="form-control" id="type"> |
@@ -111,10 +148,11 @@ | @@ -111,10 +148,11 @@ | ||
111 | <option value="3">阅读理解</option> | 148 | <option value="3">阅读理解</option> |
112 | <option value="4">判断题</option> | 149 | <option value="4">判断题</option> |
113 | <option value="5">多选题</option> | 150 | <option value="5">多选题</option> |
151 | + <option value="6">数字题</option> | ||
114 | </select> | 152 | </select> |
115 | </div> | 153 | </div> |
116 | <div class="clearfix"></div> | 154 | <div class="clearfix"></div> |
117 | - </div>--> | 155 | + </div> |
118 | <div class="form-group"> | 156 | <div class="form-group"> |
119 | <label for="index_s_2" class="col-sm-2 control-label">题数</label> | 157 | <label for="index_s_2" class="col-sm-2 control-label">题数</label> |
120 | <div class="col-sm-10"> | 158 | <div class="col-sm-10"> |
@@ -201,8 +239,8 @@ | @@ -201,8 +239,8 @@ | ||
201 | $("title").html(title); | 239 | $("title").html(title); |
202 | } | 240 | } |
203 | $(document).ready(function(){ | 241 | $(document).ready(function(){ |
204 | - var _height = $(".page-header").height(); | ||
205 | - $(".content").css("padding-top",_height); | 242 | + var _height = $(".page-header").outerHeight(); |
243 | + $(".content").css("padding-top",_height+80); | ||
206 | 244 | ||
207 | }); | 245 | }); |
208 | 246 | ||
@@ -211,8 +249,8 @@ | @@ -211,8 +249,8 @@ | ||
211 | //var testData={"title":"TEST1","exam_time":46,"paper_type":"1","subject_id":"1","grade_id":"1","user_id":"1","score":5,"questions":[{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"单选","option_num":"","option_content":"","answer":"","difficulty":"","analysis":"","question_from":"","score":1,"part_score":"","remark":"","rank":"1","no_name":"一、","questions":[{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"A","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.1"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"B","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.2"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"C","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.3"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"D","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.4"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"A","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.5"}]}]}; | 249 | //var testData={"title":"TEST1","exam_time":46,"paper_type":"1","subject_id":"1","grade_id":"1","user_id":"1","score":5,"questions":[{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"单选","option_num":"","option_content":"","answer":"","difficulty":"","analysis":"","question_from":"","score":1,"part_score":"","remark":"","rank":"1","no_name":"一、","questions":[{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"A","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.1"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"B","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.2"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"C","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.3"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"D","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.4"},{"chapter_id":"0","problem_type_id":"0","knowledge_id":"0","content":"","option_num":4,"option_content":"","answer":"A","difficulty":"0","analysis":"","question_from":"1","score":1,"part_score":"0","remark":"","rank":"2","no_name":"1.5"}]}]}; |
212 | //var testData={"title":"TEST1","exam_time":46,"paper_type":"1","subject_id":"1","grade_id":"1","user_id":"1","score":5,"questions":[]}; | 250 | //var testData={"title":"TEST1","exam_time":46,"paper_type":"1","subject_id":"1","grade_id":"1","user_id":"1","score":5,"questions":[]}; |
213 | </script> | 251 | </script> |
214 | -<script type="text/javascript" src="../static/js/control-604.js?a=4"></script> | ||
215 | 252 | ||
253 | +<script>document.write('<script src="../static/js/control-604.js?a=' + new Date().getTime() + '"><\/script>')</script> | ||
216 | 254 | ||
217 | </body> | 255 | </body> |
218 | </html> | 256 | </html> |
219 | \ No newline at end of file | 257 | \ No newline at end of file |
WebRoot/static/js/control-604.js
@@ -226,6 +226,7 @@ $(function() { | @@ -226,6 +226,7 @@ $(function() { | ||
226 | total_score += ((index_e_2 - index_s_2 + 1) * fraction2); | 226 | total_score += ((index_e_2 - index_s_2 + 1) * fraction2); |
227 | $("#score_all").text(total_score); | 227 | $("#score_all").text(total_score); |
228 | break; | 228 | break; |
229 | + case 6: break; | ||
229 | } | 230 | } |
230 | // $(".section-"+answer_index_b).attr("data-score",$(".section-"+answer_index_b).find(".question").length*fraction2); | 231 | // $(".section-"+answer_index_b).attr("data-score",$(".section-"+answer_index_b).find(".question").length*fraction2); |
231 | $(".section0").attr("data-score", | 232 | $(".section0").attr("data-score", |
@@ -261,8 +262,8 @@ $(function() { | @@ -261,8 +262,8 @@ $(function() { | ||
261 | 262 | ||
262 | /* 添加试题的确定按钮 */ | 263 | /* 添加试题的确定按钮 */ |
263 | $("#addQuestion_submit").click(function() { | 264 | $("#addQuestion_submit").click(function() { |
264 | - // $("#fast").attr("disabled","disabled"); | ||
265 | - var type_2 = 5;// parseInt($("#type").val()) | 265 | + $("#fast").attr("disabled","disabled"); |
266 | + var type_2 = parseInt($("#type").val()); | ||
266 | var index_s_2 = 1;// parseInt($("#index_s_2").val()) | 267 | var index_s_2 = 1;// parseInt($("#index_s_2").val()) |
267 | var index_e_2 = parseInt($("#index_s_2").val()); | 268 | var index_e_2 = parseInt($("#index_s_2").val()); |
268 | // var answer_2=$("#answer_2").val(); | 269 | // var answer_2=$("#answer_2").val(); |
@@ -407,7 +408,7 @@ $(function() { | @@ -407,7 +408,7 @@ $(function() { | ||
407 | "json" : data | 408 | "json" : data |
408 | }; | 409 | }; |
409 | console.log(data); | 410 | console.log(data); |
410 | - ajax_submit(url, dataJson); | 411 | + //ajax_submit(url, dataJson); |
411 | } else | 412 | } else |
412 | alert("请添加试题"); | 413 | alert("请添加试题"); |
413 | }); | 414 | }); |
@@ -706,4 +707,57 @@ $(function() { | @@ -706,4 +707,57 @@ $(function() { | ||
706 | } | 707 | } |
707 | } | 708 | } |
708 | } | 709 | } |
710 | + | ||
711 | + $(".content").on("focus",".number .on",function(){ | ||
712 | + if($(this).text()=="请输入答案") | ||
713 | + $(this).text(""); | ||
714 | + | ||
715 | + | ||
716 | + }) | ||
717 | + $(".content").on("blur",".number .on",function(){ | ||
718 | + if($(this).text()==""){ | ||
719 | + $(this).text("请输入答案"); | ||
720 | + } | ||
721 | + | ||
722 | + }) | ||
723 | + | ||
709 | }) | 724 | }) |
725 | + | ||
726 | +/** | ||
727 | + * 数字校验 | ||
728 | + * @param e | ||
729 | + */ | ||
730 | +function keydown2(e){ | ||
731 | + var reg= /^[0-9]*$/; | ||
732 | + console.log(reg.test(e.text())); | ||
733 | + console.log(e.text()) | ||
734 | + if(!reg.test(e.text())){ | ||
735 | + e.text(""); | ||
736 | + } | ||
737 | + } | ||
738 | + | ||
739 | +function NumberCheck(num) { | ||
740 | + var str = num; | ||
741 | + var len1 = str.substr(0, 1); | ||
742 | + var len2 = str.substr(1, 1); | ||
743 | + //如果第一位是0,第二位不是点,就用数字把点替换掉 | ||
744 | + if (str.length > 1 && len1 == 0 && len2 != ".") { | ||
745 | + str = str.substr(1, 1); | ||
746 | + } | ||
747 | + //第一位不能是. | ||
748 | + if (len1 == ".") { | ||
749 | + str = ""; | ||
750 | + } | ||
751 | + //限制只能输入一个小数点 | ||
752 | + if (str.indexOf(".") != -1) { | ||
753 | + var str_ = str.substr(str.indexOf(".") + 1); | ||
754 | + if (str_.indexOf(".") != -1) { | ||
755 | + str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1); | ||
756 | + } | ||
757 | + } | ||
758 | + //正则替换,保留数字和小数点 | ||
759 | + str = str.replace(/[^\d^\.]+/g,'') | ||
760 | + //如果需要保留小数点后两位,则用下面公式 | ||
761 | + //str = str.replace(/\.\d\d$/,'') | ||
762 | + return str; | ||
763 | +} |