Commit 28147eccbd73ac66bf03ae3940a38ceef407ab7f
1 parent
c3639430
修改加载控制条
Showing
3 changed files
with
52 additions
and
9 deletions
WebRoot/WEB-INF/jsp/sunvote/teacher/creat_question.jsp
| ... | ... | @@ -107,7 +107,7 @@ |
| 107 | 107 | </div> |
| 108 | 108 | <div class="modal-footer"> |
| 109 | 109 | <button type="button" class="btn btn-default" id="fast_submit">确定</button> |
| 110 | - <button type="button" class="btn btn-primary" data-dismiss="fast">取消</button> | |
| 110 | + <button type="button" class="btn btn-primary" data-dismiss="modal">取消</button> | |
| 111 | 111 | </div> |
| 112 | 112 | </div><!-- /.modal-content --> |
| 113 | 113 | </div><!-- /.modal-dialog --> |
| ... | ... | @@ -178,7 +178,7 @@ |
| 178 | 178 | </div> |
| 179 | 179 | <div class="modal-footer"> |
| 180 | 180 | <button type="button" class="btn btn-default" id="addQuestion_submit">确定</button> |
| 181 | - <button type="button" class="btn btn-primary" data-dismiss="addQuestion">取消</button> | |
| 181 | + <button type="button" class="btn btn-primary" data-dismiss="modal">取消</button> | |
| 182 | 182 | </div> |
| 183 | 183 | </div><!-- /.modal-content --> |
| 184 | 184 | </div><!-- /.modal-dialog --> |
| ... | ... | @@ -205,14 +205,20 @@ |
| 205 | 205 | </div> |
| 206 | 206 | <div class="modal-footer"> |
| 207 | 207 | <button type="button" class="btn btn-default" id="time_submit">确定</button> |
| 208 | - <button type="button" class="btn btn-primary" data-dismiss="test_time">取消</button> | |
| 208 | + <button type="button" class="btn btn-primary" data-dismiss="modal">取消</button> | |
| 209 | 209 | </div> |
| 210 | 210 | </div><!-- /.modal-content --> |
| 211 | 211 | </div><!-- /.modal-dialog --> |
| 212 | 212 | </div><!-- /.modal --> |
| 213 | +<div class="loading" style="background:rgba(0,0,0,0.5);width:100%;height:100%;position:absolute;top:0;display:none;"> | |
| 214 | + <img src="../static/images/loading.gif" width="200px" style="position:absolute;top:0;bottom:0;left:0;right:0;margin:auto;"/> | |
| 215 | +</div> | |
| 213 | 216 | <script> |
| 214 | 217 | var testData = ${pd.JSON}; |
| 215 | 218 | var URL = "<%=basePath%>api/v1/uploadpaper"; |
| 219 | + if(testData.questions.length>0){ | |
| 220 | + $("title").html("浏览试卷"); | |
| 221 | + } | |
| 216 | 222 | //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"}]}]}; |
| 217 | 223 | //var testData={"title":"TEST1","exam_time":46,"paper_type":"1","subject_id":"1","grade_id":"1","user_id":"1","score":5,"questions":[]}; |
| 218 | 224 | </script> | ... | ... |
WebRoot/WEB-INF/jsp/sunvote/teacher/teacher_main.jsp
| ... | ... | @@ -199,7 +199,7 @@ |
| 199 | 199 | var name = $("#enter_title").val(); |
| 200 | 200 | var time = $("#enter_time").val(); |
| 201 | 201 | window.open("<%=basePath%>" + "paper/npaper.do?" + "name=" + name + "&time=" + time); |
| 202 | - $(".title_time").hide(); | |
| 202 | + $(".title_time").modal("hide"); | |
| 203 | 203 | }); |
| 204 | 204 | </script> |
| 205 | 205 | ... | ... |
WebRoot/static/js/control.js
| ... | ... | @@ -210,7 +210,7 @@ |
| 210 | 210 | $("#save").click(function(){ |
| 211 | 211 | var url= URL; |
| 212 | 212 | var data={ |
| 213 | - title: $(".text-center").text(), | |
| 213 | + title: $(".text-center").html(), | |
| 214 | 214 | exam_time: parseInt($("#time").text()), |
| 215 | 215 | paper_type: "1", |
| 216 | 216 | subject_id: "1", |
| ... | ... | @@ -268,9 +268,8 @@ |
| 268 | 268 | data=JSON.stringify(data); |
| 269 | 269 | dataJson={"json":data}; |
| 270 | 270 | console.log(data); |
| 271 | - ajax_submit(url,dataJson); | |
| 271 | +// ajax_submit(url,dataJson); | |
| 272 | 272 | var suc=ajax_submit(url,dataJson); |
| 273 | -// alert(suc); | |
| 274 | 273 | if(suc==1){ |
| 275 | 274 | |
| 276 | 275 | } |
| ... | ... | @@ -282,23 +281,61 @@ |
| 282 | 281 | |
| 283 | 282 | /*ajax封装函数*/ |
| 284 | 283 | function ajax_submit(url,data){ |
| 284 | + $(".loading").css("display","block"); | |
| 285 | 285 | var flag=0; |
| 286 | 286 | $.ajax({ |
| 287 | 287 | url:url, |
| 288 | 288 | type:"POST", |
| 289 | - async:false, | |
| 289 | + //async:false, | |
| 290 | 290 | data:data, |
| 291 | 291 | dataType:"json", |
| 292 | 292 | success:function(data){ |
| 293 | 293 | flag=1; |
| 294 | + $(".loading").css("display","none"); | |
| 294 | 295 | alert("保存成功"); |
| 295 | 296 | window.close(); |
| 296 | 297 | } |
| 297 | 298 | }) |
| 298 | 299 | return flag; |
| 299 | 300 | } |
| 301 | +function fastSort(array,head,tail){ | |
| 302 | + //考虑到给每个分区操作的时候都是在原有的数组中进行操作的,所以这里head,tail来确定分片的位置 | |
| 303 | + /*生成随机项*/ | |
| 304 | + var randomnum = parseInt((head + tail) / 2 ); | |
| 305 | + var random = array[randomnum]; | |
| 306 | + /*将小于random的项放置在其左边 策略就是通过一个临时的数组来储存分好区的结果,再到原数组中替换*/ | |
| 307 | + var arrayTemp = []; | |
| 308 | + var unshiftHead = 0; | |
| 309 | + for(var i = head;i <= tail;i++){ | |
| 310 | + if(parseInt(array[i].rank)<parseInt(random.rank)){ | |
| 311 | + arrayTemp.unshift(array[i]); | |
| 312 | + unshiftHead++; | |
| 313 | + }else if(parseInt(array[i].rank)>parseInt(random.rank)){ | |
| 314 | + arrayTemp.push(array[i]); | |
| 315 | + } | |
| 316 | + /*当它等于的时候放哪,这里我想选择放到队列的前面,也就是从unshift后的第一个位置放置*/ | |
| 317 | + if(parseInt(array[i].rank)===parseInt(random.rank)){ | |
| 318 | + arrayTemp.splice(unshiftHead,0,array[i]); | |
| 319 | + } | |
| 320 | + } | |
| 321 | + /*将对应项覆盖原来的记录*/ | |
| 322 | + for(var j = head , u=0;j <= tail;j++,u++){ | |
| 323 | + array.splice(j,1,arrayTemp[u]); | |
| 324 | + } | |
| 325 | + /*寻找中间项所在的index*/ | |
| 326 | + var nowIndex = array.indexOf(random); | |
| 300 | 327 | |
| 301 | - | |
| 328 | + /*设置出口,当要放进去的片段只有2项的时候就可以收工了*/ | |
| 329 | + if(arrayTemp.length <= 2){ | |
| 330 | + return; | |
| 331 | + } | |
| 332 | + /*递归,同时应用其左右两个区域*/ | |
| 333 | + fastSort(array,head,nowIndex); | |
| 334 | + fastSort(array,nowIndex+1,tail); | |
| 335 | + } | |
| 336 | + if(testData.questions.length > 0 && testData.questions[0].questions.length > 1){ | |
| 337 | + fastSort(testData.questions[0].questions,0,testData.questions[0].questions.length-1); | |
| 338 | + } | |
| 302 | 339 | creatHtml(testData); |
| 303 | 340 | function creatHtml(data){ |
| 304 | 341 | console.log(data); | ... | ... |