From 5f403333f85c6de95ebaa0c82d8ca5912e0a9af0 Mon Sep 17 00:00:00 2001 From: jack_rabbit <376168706@qq.com> Date: Tue, 17 Dec 2019 18:15:12 +0800 Subject: [PATCH] 1,完善数字题 --- WebRoot/WEB-INF/jsp/sunvote/teacher/creat_question.jsp | 36 +----------------------------------- WebRoot/static/js/control-604.js | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- 2 files changed, 92 insertions(+), 78 deletions(-) diff --git a/WebRoot/WEB-INF/jsp/sunvote/teacher/creat_question.jsp b/WebRoot/WEB-INF/jsp/sunvote/teacher/creat_question.jsp index 2818672..bdfeb1b 100644 --- a/WebRoot/WEB-INF/jsp/sunvote/teacher/creat_question.jsp +++ b/WebRoot/WEB-INF/jsp/sunvote/teacher/creat_question.jsp @@ -41,41 +41,7 @@
-
-
-

- 一、单选 -

- -
-
-
- 1、 -
    -
  • 请输入答案
  • -
-
-
- 2、 -
    -
  • 请输入答案
  • -
-
-
- 3、 -
    -
  • 请输入答案
  • -
-
-
- 4、 -
    -
  • 请输入答案
  • -
-
-
-
+
diff --git a/WebRoot/static/js/control-604.js b/WebRoot/static/js/control-604.js index fbb975a..6b84cf9 100644 --- a/WebRoot/static/js/control-604.js +++ b/WebRoot/static/js/control-604.js @@ -190,43 +190,77 @@ $(function() { * for(var j=0;j'+option+''); } } */ - case 5: // 多选题 - // $(".content").html(""); - $(".content") - .append( - '

第' - + answer_index_b - + '大题(多选)总分: ' - + (index_e_2 - index_s_2 + 1) - + ' X ' - + fraction2 - + ' = ' - + ((index_e_2 - index_s_2 + 1) * fraction2) - + ' 分

'); - for (var i = index_s_2; i <= index_e_2; i++) { - questionNUm++; - $(".section-" + answer_index_b + " .question_list").append( - '
' + questionNUm - + '、
'); - for (var j = 0; j < a_num; j++) { - option = String.fromCharCode(0x41 + j); - $( - ".section-" + answer_index_b + " .question" - + questionNUm + ' ul').append( - '
  • ' + option + '
  • '); - } - } - total_score += ((index_e_2 - index_s_2 + 1) * fraction2); - $("#score_all").text(total_score); - break; - case 6: break; + + case 5: $(".content") //多选题 + .append( + '

    第' + + answer_index_b + + '大题(多选)总分: ' + + (index_e_2 - index_s_2 + 1) + + ' X ' + + fraction2 + + ' = ' + + ((index_e_2 - index_s_2 + 1) * fraction2) + + ' 分

    '); + for (var i = index_s_2; i <= index_e_2; i++) { + questionNUm++; + $(".section-" + answer_index_b + " .question_list").append( + '
    ' + questionNUm + + '、
    '); + for (var j = 0; j < a_num; j++) { + option = String.fromCharCode(0x41 + j); + $( + ".section-" + answer_index_b + " .question" + + questionNUm + ' ul').append( + '
  • ' + option + '
  • '); + } + } + total_score += ((index_e_2 - index_s_2 + 1) * fraction2); + $("#score_all").text(total_score); + break; + case 6: // 数字题 + // $(".content").html(""); + $(".content") + .append( + '

    第' + + answer_index_b + + '大题(数字题)总分: ' + + (index_e_2 - index_s_2 + 1) + + ' X ' + + fraction2 + + ' = ' + + ((index_e_2 - index_s_2 + 1) * fraction2) + + ' 分

    '); + for (var i = index_s_2; i <= index_e_2; i++) { + questionNUm++; + $(".section-" + answer_index_b + " .question_list").append( + '
    ' + questionNUm + + '、
    '); +// for (var j = 0; j < a_num; j++) { +// option = String.fromCharCode(0x41 + j); +// $( +// ".section-" + answer_index_b + " .question" +// + questionNUm + ' ul').append( +// '
  • ' + option + '
  • '); +// } + } + total_score += ((index_e_2 - index_s_2 + 1) * fraction2); + $("#score_all").text(total_score); + break; } // $(".section-"+answer_index_b).attr("data-score",$(".section-"+answer_index_b).find(".question").length*fraction2); $(".section0").attr("data-score", @@ -375,7 +409,7 @@ $(function() { .eq(k).text(); // console.log(answer); } - if (answer == '') { + if (answer == ''||answer.indexOf("请输入答案")>=0) { alert("还有试题未编辑答案。"); return; } @@ -736,8 +770,10 @@ function keydown2(e){ } } -function NumberCheck(num) { +function NumberCheck(num,obj) { var str = num; + //callback(str,obj) + console.log("num:"+num) var len1 = str.substr(0, 1); var len2 = str.substr(1, 1); //如果第一位是0,第二位不是点,就用数字把点替换掉 @@ -756,8 +792,20 @@ function NumberCheck(num) { } } //正则替换,保留数字和小数点 - str = str.replace(/[^\d^\.]+/g,'') - //如果需要保留小数点后两位,则用下面公式 - //str = str.replace(/\.\d\d$/,'') - return str; + str = str.replace(/[^\-?\d.]/g,'') + + obj.innerText=str + + callback(str,obj) +} +function callback(tp,obj) { + var _div = obj//document.querySelector('.number .on'); + var range = document.createRange(); + + range.selectNodeContents(_div); + range.collapse(false); + + var sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range); } -- libgit2 0.21.4