-
+


diff --git a/WebRoot/static/js/control-604.js b/WebRoot/static/js/control-604.js
index 6b84cf9..154675c 100644
--- a/WebRoot/static/js/control-604.js
+++ b/WebRoot/static/js/control-604.js
@@ -1,5 +1,5 @@
var questionNUm = 0;
-/*数字转汉字数字*/
+/* 数字转汉字数字 */
var chnNumChar = [ "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" ];
var chnUnitSection = [ "", "万", "亿", "万亿", "亿亿" ];
var chnUnitChar = [ "", "十", "百", "千" ];
@@ -8,9 +8,7 @@ var score = 0;
var total_score = 0;
var answerLen = 0;
-
$(function() {
-
function creat(str_ans, a_num, fraction) {
// $(".section").remove();
@@ -31,9 +29,22 @@ $(function() {
}
}
q_num = str.length;
- $(".content").append('第' + answer_index_b+ '大题(单选)总分: '
- + q_num + ' X ' + fraction + ' = ' + (q_num * fraction)
+ $(".content")
+ .append(
+ '
第' + answer_index_b+ '大题(单选)总分: '
- + q_num + ' X ' + fraction + ' = ' + (q_num * fraction)
+ $(".content")
+ .append(
+ '第'
+ + answer_index_b
+ + '大题(单选)总分: '
+ + q_num
+ + ' X '
+ + fraction
+ + ' = '
+ + (q_num * fraction)
+ ' 分
');
for (var i = 0; i < q_num; i++) {
str_temp = str[i];
@@ -65,14 +76,13 @@ $(function() {
// return;
}
}
- $(".section-" + answer_index_b).attr("data-score",
- q_num * fraction);
+ $(".section-" + answer_index_b).attr("data-score", q_num * fraction);
total_score += q_num * fraction;
$("#score_all").text(total_score);
}
/***************************************************************************
- * 1、单选题 2、完形填空 3、阅读理解 4、判断题 5、多选题
+ * 1、单选题 2、完形填空 3、阅读理解 4、判断题 5、多选题 6、数字题
**************************************************************************/
function addQuestion(type, a_num, index_s_2, index_e_2, fraction2) {
@@ -86,9 +96,11 @@ $(function() {
.append(
' '
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、'
+ '单选
');
@@ -104,15 +116,19 @@ $(function() {
+ '');
}
}
+ total_score += ((index_e_2 - index_s_2 + 1) * fraction2);
+ $("#score_all").text(total_score);
break;
case 2: // 完形填空
$(".content")
.append(
' '
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、完形填空
');
for (var i = index_s_2; i <= index_e_2; i++) {
@@ -127,15 +143,19 @@ $(function() {
+ '');
}
}
+ total_score += ((index_e_2 - index_s_2 + 1) * fraction2);
+ $("#score_all").text(total_score);
break;
case 3: // 阅读理解
$(".content")
.append(
' '
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、阅读理解
');
for (var i = index_s_2; i <= index_e_2; i++) {
@@ -150,15 +170,19 @@ $(function() {
+ '');
}
}
+ total_score += ((index_e_2 - index_s_2 + 1) * fraction2);
+ $("#score_all").text(total_score);
break;
case 4: // 判断题
$(".content")
.append(
' '
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、判断题
');
for (var i = index_s_2; i <= index_e_2; i++) {
@@ -176,6 +200,8 @@ $(function() {
+ '');
}
}
+ total_score += ((index_e_2 - index_s_2 + 1) * fraction2);
+ $("#score_all").text(total_score);
break;
/*
* case 5: //多选题 $(".content").append(''+option+''); } }
*/
-
- 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
+
+ case 5:
+ $(".content")
+ // 多选题
+ .append(
+ ' '
+ + question_num
+ + '、多选题
');
+ for (var i = index_s_2; i <= index_e_2; i++) {
+ questionNUm++;
+ $(".section-" + answer_index_b + " .question_list").append(
+ '' + i
+ + '、
');
+ 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(
+ ' '
+ + question_num
+ + '、数字题
');
+ for (var i = index_s_2; i <= index_e_2; i++) {
+ questionNUm++;
+ $(".section-" + answer_index_b + " .question_list")
+ .append(
+ ''
+ + i
+ '、- 请输入答案
');
-// 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;
+ // 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",
@@ -269,10 +288,17 @@ $(function() {
$(document).on('click', '.remove', function() { // 删除按钮
$(this).parent().parent(".section").remove();
+ for(i=0;i<$(".section").length;i++){
+ $(".section").eq(i).find(".que_num").text(SectionToChinese(i+1)+'、');
+
+ var className = $(".section").attr("class").replace(/\d+/g,i);
+ console.log(className)
+ $(".section").attr("class",className);
+ }
})
$("#fast_submit").click(function() { // 点击确定,创建答案列表
- // $("#addQuestion").attr("disabled","disabled");
+ // $("#addQuestion").attr("disabled","disabled");
var answer = $("#answer").val();
var num_ans = $("#num_ans").val();
var fraction = $("#fraction").val();
@@ -296,8 +322,8 @@ $(function() {
/* 添加试题的确定按钮 */
$("#addQuestion_submit").click(function() {
- $("#fast").attr("disabled","disabled");
- var type_2 = parseInt($("#type").val());
+ $("#fast").attr("disabled", "disabled");
+ var type_2 = parseInt($("#type").val());
var index_s_2 = 1;// parseInt($("#index_s_2").val())
var index_e_2 = parseInt($("#index_s_2").val());
// var answer_2=$("#answer_2").val();
@@ -326,7 +352,9 @@ $(function() {
if ($("#type").val() == 4) {
$("#num_ans_2").val(2);
$("#num_ans_2").attr("disabled", "disabled");
- } else {
+ }else if($("#type").val() == 6){
+ $("#num_ans_2").closest(".form-group").css("display","none");
+ }else {
$("#num_ans_2").removeAttr("disabled");
$("#num_ans_2").val(4);
@@ -357,7 +385,9 @@ $(function() {
}
})
/* 提交保存数据 */
- $("#save").click(function() {
+ $("#save")
+ .click(
+ function() {
var url = URL;
var data = {
@@ -378,7 +408,7 @@ $(function() {
// rank++;
data.questions[i] = {
chapter_id : "0",
- problem_type_id : "0",
+ problem_type_id : $(".section").eq(i).attr("data-type"),
knowledge_id : "0",
// content:
// $(".section").eq(i).find(".que_name").text(),
@@ -393,8 +423,7 @@ $(function() {
part_score : "",
remark : "",
rank : rank,
- no_name : $(".section").eq(i).find(
- ".que_num").text(),
+ no_name : "",//$(".section").eq(i).find(".que_num").text(),
questions : []
}
for (j = 0; j < $(".section").eq(i).find(
@@ -409,13 +438,14 @@ $(function() {
.eq(k).text();
// console.log(answer);
}
- if (answer == ''||answer.indexOf("请输入答案")>=0) {
+ if (answer == ''
+ || answer.indexOf("请输入答案") >= 0) {
alert("还有试题未编辑答案。");
return;
}
data.questions[i].questions[j] = {
chapter_id : "0",
- problem_type_id : "0",
+ problem_type_id : $(".section").eq(i).attr("data-type"),//"0",//data-type="1"
knowledge_id : "0",
content : "",
option_num : $(".section").eq(i).find(
@@ -442,7 +472,7 @@ $(function() {
"json" : data
};
console.log(data);
- //ajax_submit(url, dataJson);
+ ajax_submit(url, dataJson);
} else
alert("请添加试题");
});
@@ -459,10 +489,13 @@ $(function() {
contentType : "application/x-www-form-urlencoded; charset=utf-8",
success : function(data) {
$(".loading").css("display", "none");
- if(testData.paper_type == '1'){
- window.location.href = JUMP_URL + "?a=1&defaulturl=../paper/list2.do";
- }else{
- window.location.href = JUMP_URL + "?a=1&defaulturl=../paper/list4.do?school_id=" + testData.school_id ;
+ if (testData.paper_type == '1') {
+ window.location.href = JUMP_URL
+ + "?a=1&defaulturl=../paper/list2.do";
+ } else {
+ window.location.href = JUMP_URL
+ + "?a=1&defaulturl=../paper/list5.do?school_id="
+ + testData.school_id;
}
}
})
@@ -503,22 +536,22 @@ $(function() {
fastSort(array, nowIndex + 1, tail);
}
function creatHtml(data) {
- data.questions.sort(function (a, b) {
-// if (a.rank < b.rank) {
-// return -1;
-// } else if (a.rank == b.rank) {
-// return 0;
-// } else {
-// return 1;
-// }
- var rankA = isNaN(parseInt(a.rank))?0:parseInt(a.rank);
- var rankB = isNaN(parseInt(b.rank))?0:parseInt(b.rank);
- return rankA-rankB;
+ data.questions.sort(function(a, b) {
+ // if (a.rank < b.rank) {
+ // return -1;
+ // } else if (a.rank == b.rank) {
+ // return 0;
+ // } else {
+ // return 1;
+ // }
+ var rankA = isNaN(parseInt(a.rank)) ? 0 : parseInt(a.rank);
+ var rankB = isNaN(parseInt(b.rank)) ? 0 : parseInt(b.rank);
+ return rankA - rankB;
})
console.log(data);
$(".header_box h1").html(data.title);
$("#time").html(data.exam_time);
- if(data.score != null && data.score > 0 && data.score != ''){
+ if (data.score != null && data.score > 0 && data.score != '') {
$("#score_all").html(data.score);
}
@@ -530,35 +563,42 @@ $(function() {
for (var i = 0; i < data.questions.length; i++) {
if (data.questions[i].questions) {
- var sortTemp = data.questions[i].questions.sort(function (a, b) {
-// if (parseInt(a.rank) < parseInt(b.rank)) {
-// return -1;
-// } else if (a.rank == b.rank) {
-// return 0;
-// } else {
-// return 1;
-// }
- var rankA = isNaN(parseInt(a.rank))?0:parseInt(a.rank);
- var rankB = isNaN(parseInt(b.rank))?0:parseInt(b.rank);
- return rankA-rankB;
+ var sortTemp = data.questions[i].questions.sort(function(a, b) {
+ // if (parseInt(a.rank) < parseInt(b.rank)) {
+ // return -1;
+ // } else if (a.rank == b.rank) {
+ // return 0;
+ // } else {
+ // return 1;
+ // }
+ var rankA = isNaN(parseInt(a.rank)) ? 0 : parseInt(a.rank);
+ var rankB = isNaN(parseInt(b.rank)) ? 0 : parseInt(b.rank);
+ return rankA - rankB;
})
console.log(sortTemp)
+ var tixing = "";
+ switch(data.questions[i].problem_type_id){
+ case '1':tixing="单选题";break;
+ case '5':tixing="多选题";break;
+ case '4':tixing="判断题";break;
+ case '6':tixing="数字题";break;
+ }
$(".content")
.append(
' '
- + '第'
- + (i + 1)
- + '大题总分:'
+ +SectionToChinese(i+1)+'、'
+ + tixing
+ + '(总分:'
+ data.questions[i].questions.length
+ " X "
+ (parseFloat(data.questions[i].sug_score) / data.questions[i].questions.length)
+ " = "
+ data.questions[i].sug_score
- + ''
+ + '分)'
+ ''
+ data.questions[i].content
+ '
');
@@ -596,7 +636,7 @@ $(function() {
'' + (++questionNUm)
+ '、
');
- if ($(".section-" + i).find(".que_name").text() == "判断题") {
+ if ($(".section-" + i).attr("data-type") == "4") {
for (var k = 0; k < parseInt(data.questions[i].questions[j].option_num); k++) {
str_temp = data.questions[i].questions[j].answer;
if (k % 2 == 0) {
@@ -618,6 +658,13 @@ $(function() {
".question" + (j + 1) + ' ul li').eq(1)
.attr("class", "btn btn-default on");
}
+ }else if($(".section-" + i).attr("data-type") == "6"){
+ str_temp = data.questions[i].questions[j].answer;
+ $(".section-" + i).find(
+ ".question" + (j + 1) + ' ul').append(
+ ''+str_temp+' ');
+ if(!$(".section-" + i).hasClass("number"))
+ $(".section-" + i).addClass("number");
} else {
for (var k = 0; k < parseInt(data.questions[i].questions[j].option_num); k++) {
str_temp = data.questions[i].questions[j].answer;
@@ -644,8 +691,7 @@ $(function() {
}
}
-
- /*快速建题中,每输入五个答案就加一个空格*/
+ /* 快速建题中,每输入五个答案就加一个空格 */
$("#answer").on("input propertychange", function(event) {
var answerStr = "";
answerStr = $("#answer").val();
@@ -669,8 +715,6 @@ $(function() {
}
})
-
-
function SectionToChinese(section) {
var strIns = '', chnStr = '';
var unitPos = 0;
@@ -694,33 +738,33 @@ $(function() {
return chnStr;
}
-
if (template != null && template.length > 0) {
-
- $("#addQuestion").attr("disabled", "disabled");
- $("#fast").attr("disabled", "disabled");
- for (var i = 0; i < template.length; i++) {
- if (template[i].type == 1) {
- var answer = "";
- for (var j = 0; j < template[i].questionNum; j++) {
- answer += "1";
- }
- creat(answer, template[i].optionNum, template[i].score);
- }
- if (template[i].type == 2) {
- addQuestion(5, template[i].optionNum, 1,
- template[i].questionNum, template[i].score);
+
+ $("#addQuestion").attr("disabled", "disabled");
+ $("#fast").attr("disabled", "disabled");
+ for (var i = 0; i < template.length; i++) {
+ if (template[i].type == 1) {
+ var answer = "";
+ for (var j = 0; j < template[i].questionNum; j++) {
+ answer += "1";
}
+ creat(answer, template[i].optionNum, template[i].score);
}
- if(testData != null){
- $(".header_box h1").html(testData.title);
- $("#time").html(testData.exam_time);
- if(testData.score != null && testData.score > 0 && testData.score != ''){
- $("#score_all").html(testData.score);
- }
+ if (template[i].type == 2) {
+ addQuestion(5, template[i].optionNum, 1,
+ template[i].questionNum, template[i].score);
}
-
- }else if (testData != null && testData.questions != null
+ }
+ if (testData != null) {
+ $(".header_box h1").html(testData.title);
+ $("#time").html(testData.exam_time);
+ if (testData.score != null && testData.score > 0
+ && testData.score != '') {
+ $("#score_all").html(testData.score);
+ }
+ }
+
+ } else if (testData != null && testData.questions != null
&& testData.questions.length > 0) {
fastSort(testData.questions, 0, testData.questions.length - 1);
for (var i = 0; i < testData.questions.length; i++) {
@@ -732,74 +776,75 @@ $(function() {
}
}
creatHtml(testData);
- }else{
- if(testData != null){
+ } else {
+ if (testData != null) {
$(".header_box h1").html(testData.title);
$("#time").html(testData.exam_time);
- if(testData.score != null && testData.score > 0 && testData.score != ''){
+ if (testData.score != null && testData.score > 0
+ && testData.score != '') {
$("#score_all").html(testData.score);
}
}
}
-
- $(".content").on("focus",".number .on",function(){
- if($(this).text()=="请输入答案")
+
+ $(".content").on("focus", ".number .on", function() {
+ if ($(this).text() == "请输入答案")
$(this).text("");
-
-
+
})
- $(".content").on("blur",".number .on",function(){
- if($(this).text()==""){
+ $(".content").on("blur", ".number .on", function() {
+ if ($(this).text() == "") {
$(this).text("请输入答案");
}
-
+
})
-
+
})
/**
* 数字校验
+ *
* @param e
*/
-function keydown2(e){
- var reg= /^[0-9]*$/;
- console.log(reg.test(e.text()));
- console.log(e.text())
- if(!reg.test(e.text())){
- e.text("");
+function keydown2(e) {
+ var reg = /^[0-9]*$/;
+ console.log(reg.test(e.text()));
+ console.log(e.text())
+ if (!reg.test(e.text())) {
+ e.text("");
+ }
+}
+
+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,第二位不是点,就用数字把点替换掉
+ if (str.length > 1 && len1 == 0 && len2 != ".") {
+ str = str.substr(1, 1);
+ }
+ // 第一位不能是.
+ if (len1 == ".") {
+ str = "";
+ }
+ // 限制只能输入一个小数点
+ if (str.indexOf(".") != -1) {
+ var str_ = str.substr(str.indexOf(".") + 1);
+ if (str_.indexOf(".") != -1) {
+ str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
}
}
+ // 正则替换,保留数字和小数点
+ str = str.replace(/[^\-?\d.]/g, '')
+
+ obj.innerText = str
-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,第二位不是点,就用数字把点替换掉
- if (str.length > 1 && len1 == 0 && len2 != ".") {
- str = str.substr(1, 1);
- }
- //第一位不能是.
- if (len1 == ".") {
- str = "";
- }
- //限制只能输入一个小数点
- if (str.indexOf(".") != -1) {
- var str_ = str.substr(str.indexOf(".") + 1);
- if (str_.indexOf(".") != -1) {
- str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
- }
- }
- //正则替换,保留数字和小数点
- str = str.replace(/[^\-?\d.]/g,'')
-
- obj.innerText=str
-
- callback(str,obj)
+ callback(str, obj)
}
-function callback(tp,obj) {
- var _div = obj//document.querySelector('.number .on');
+function callback(tp, obj) {
+ var _div = obj// document.querySelector('.number .on');
var range = document.createRange();
range.selectNodeContents(_div);
diff --git a/resources/dbconfig.properties b/resources/dbconfig.properties
index e7df42d..0762557 100644
--- a/resources/dbconfig.properties
+++ b/resources/dbconfig.properties
@@ -1,10 +1,10 @@
#数据源 1
-#url:jdbc:mysql://47.107.98.47:3306/education2?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+url:jdbc:mysql://47.107.98.47:3306/education2?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://120.78.57.84:3306/edu?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://120.78.57.84:3306/education3?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://192.168.0.3:3306/education?autoReconnect=true&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://120.78.219.152:3306/fhadmin?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
-url:jdbc:mysql://121.40.201.117:3306/luming?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+#url:jdbc:mysql://121.40.201.117:3306/luming?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
driverClassName:com.mysql.jdbc.Driver
#username:root
#password:ZrZxKeYp
diff --git a/resources/mybatis1/sunvote/PaperMapper.xml b/resources/mybatis1/sunvote/PaperMapper.xml
index 30ada3c..396003e 100644
--- a/resources/mybatis1/sunvote/PaperMapper.xml
+++ b/resources/mybatis1/sunvote/PaperMapper.xml
@@ -257,7 +257,7 @@
where 1 = 1
AND
- (SCHOOL_ID = #{SCHOOL_ID} AND PAPER_TYPE = '2') OR
+ (SCHOOL_ID = #{SCHOOL_ID} AND PAPER_TYPE = '2' AND SUBJECT_ID=#{SUBJECT_ID}) OR
(USER_ID = #{USER_ID} AND PAPER_TYPE = #{PAPER_TYPE})
order by CREATE_DATE DESC
diff --git a/src/com/fh/controller/sunvote/paper/PaperController.java b/src/com/fh/controller/sunvote/paper/PaperController.java
index ce46354..77ea0b9 100644
--- a/src/com/fh/controller/sunvote/paper/PaperController.java
+++ b/src/com/fh/controller/sunvote/paper/PaperController.java
@@ -467,7 +467,7 @@ public class PaperController extends BaseController {
|| list.get(i).get("NO_NAME").toString().isEmpty()) {
continue;
}
- Float que_score = Float.valueOf(list.get(i).get("SCORE")
+ Float que_score = list.get(i).getString("SCORE").isEmpty()?0:Float.valueOf(list.get(i).get("SCORE")
.toString());
temp.put("QUESTION_ID", questionid);
PageData question = questionService.findById(temp);
第' + + answer_index_b + + '大题(单选)总分: ' + + q_num + + ' X ' + + fraction + + ' = ' + + (q_num * fraction) + ' 分
'
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、'
+ '单选
' + question_num + '、' + '单选
'
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、完形填空
' + question_num + '、完形填空
'
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、阅读理解
' + question_num + '、阅读理解
'
+ + '" data-score="'
+ + ((index_e_2 - index_s_2 + 1) * fraction2)
+ + '"> '
+ question_num
+ '、判断题
' + question_num + '、判断题
'+option+''); } }
*/
-
- case 5: $(".content") //多选题
- .append(
- ' ');
- for (var i = index_s_2; i <= index_e_2; i++) {
- questionNUm++;
- $(".section-" + answer_index_b + " .question_list").append(
- '' + option + ' ');
- }
- }
- total_score += ((index_e_2 - index_s_2 + 1) * fraction2);
- $("#score_all").text(total_score);
- break;
- case 6: // 数字题
- // $(".content").html("");
- $(".content")
- .append(
- ' ');
- for (var i = index_s_2; i <= index_e_2; i++) {
- questionNUm++;
- $(".section-" + answer_index_b + " .question_list").append(
- '
第' - + answer_index_b - + '大题(多选)总分: ' - + (index_e_2 - index_s_2 + 1) - + ' X ' - + fraction2 - + ' = ' - + ((index_e_2 - index_s_2 + 1) * fraction2) - + ' 分
' + questionNUm
- + '、
');
- for (var j = 0; j < a_num; j++) {
- option = String.fromCharCode(0x41 + j);
- $(
- ".section-" + answer_index_b + " .question"
- + questionNUm + ' ul').append(
- '第' - + answer_index_b - + '大题(数字题)总分: ' - + (index_e_2 - index_s_2 + 1) - + ' X ' - + fraction2 - + ' = ' - + ((index_e_2 - index_s_2 + 1) * fraction2) - + ' 分
' + questionNUm
+
+ case 5:
+ $(".content")
+ // 多选题
+ .append(
+ ' ');
+ for (var i = index_s_2; i <= index_e_2; i++) {
+ questionNUm++;
+ $(".section-" + answer_index_b + " .question_list").append(
+ '' + option + ' ');
+ }
+ }
+ total_score += ((index_e_2 - index_s_2 + 1) * fraction2);
+ $("#score_all").text(total_score);
+ break;
+ case 6: // 数字题
+ // $(".content").html("");
+ $(".content")
+ .append(
+ ' ');
+ for (var i = index_s_2; i <= index_e_2; i++) {
+ questionNUm++;
+ $(".section-" + answer_index_b + " .question_list")
+ .append(
+ '' + option + ' ');
-// }
- }
- total_score += ((index_e_2 - index_s_2 + 1) * fraction2);
- $("#score_all").text(total_score);
- break;
+ // 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",
@@ -269,10 +288,17 @@ $(function() {
$(document).on('click', '.remove', function() { // 删除按钮
$(this).parent().parent(".section").remove();
+ for(i=0;i<$(".section").length;i++){
+ $(".section").eq(i).find(".que_num").text(SectionToChinese(i+1)+'、');
+
+ var className = $(".section").attr("class").replace(/\d+/g,i);
+ console.log(className)
+ $(".section").attr("class",className);
+ }
})
$("#fast_submit").click(function() { // 点击确定,创建答案列表
- // $("#addQuestion").attr("disabled","disabled");
+ // $("#addQuestion").attr("disabled","disabled");
var answer = $("#answer").val();
var num_ans = $("#num_ans").val();
var fraction = $("#fraction").val();
@@ -296,8 +322,8 @@ $(function() {
/* 添加试题的确定按钮 */
$("#addQuestion_submit").click(function() {
- $("#fast").attr("disabled","disabled");
- var type_2 = parseInt($("#type").val());
+ $("#fast").attr("disabled", "disabled");
+ var type_2 = parseInt($("#type").val());
var index_s_2 = 1;// parseInt($("#index_s_2").val())
var index_e_2 = parseInt($("#index_s_2").val());
// var answer_2=$("#answer_2").val();
@@ -326,7 +352,9 @@ $(function() {
if ($("#type").val() == 4) {
$("#num_ans_2").val(2);
$("#num_ans_2").attr("disabled", "disabled");
- } else {
+ }else if($("#type").val() == 6){
+ $("#num_ans_2").closest(".form-group").css("display","none");
+ }else {
$("#num_ans_2").removeAttr("disabled");
$("#num_ans_2").val(4);
@@ -357,7 +385,9 @@ $(function() {
}
})
/* 提交保存数据 */
- $("#save").click(function() {
+ $("#save")
+ .click(
+ function() {
var url = URL;
var data = {
@@ -378,7 +408,7 @@ $(function() {
// rank++;
data.questions[i] = {
chapter_id : "0",
- problem_type_id : "0",
+ problem_type_id : $(".section").eq(i).attr("data-type"),
knowledge_id : "0",
// content:
// $(".section").eq(i).find(".que_name").text(),
@@ -393,8 +423,7 @@ $(function() {
part_score : "",
remark : "",
rank : rank,
- no_name : $(".section").eq(i).find(
- ".que_num").text(),
+ no_name : "",//$(".section").eq(i).find(".que_num").text(),
questions : []
}
for (j = 0; j < $(".section").eq(i).find(
@@ -409,13 +438,14 @@ $(function() {
.eq(k).text();
// console.log(answer);
}
- if (answer == ''||answer.indexOf("请输入答案")>=0) {
+ if (answer == ''
+ || answer.indexOf("请输入答案") >= 0) {
alert("还有试题未编辑答案。");
return;
}
data.questions[i].questions[j] = {
chapter_id : "0",
- problem_type_id : "0",
+ problem_type_id : $(".section").eq(i).attr("data-type"),//"0",//data-type="1"
knowledge_id : "0",
content : "",
option_num : $(".section").eq(i).find(
@@ -442,7 +472,7 @@ $(function() {
"json" : data
};
console.log(data);
- //ajax_submit(url, dataJson);
+ ajax_submit(url, dataJson);
} else
alert("请添加试题");
});
@@ -459,10 +489,13 @@ $(function() {
contentType : "application/x-www-form-urlencoded; charset=utf-8",
success : function(data) {
$(".loading").css("display", "none");
- if(testData.paper_type == '1'){
- window.location.href = JUMP_URL + "?a=1&defaulturl=../paper/list2.do";
- }else{
- window.location.href = JUMP_URL + "?a=1&defaulturl=../paper/list4.do?school_id=" + testData.school_id ;
+ if (testData.paper_type == '1') {
+ window.location.href = JUMP_URL
+ + "?a=1&defaulturl=../paper/list2.do";
+ } else {
+ window.location.href = JUMP_URL
+ + "?a=1&defaulturl=../paper/list5.do?school_id="
+ + testData.school_id;
}
}
})
@@ -503,22 +536,22 @@ $(function() {
fastSort(array, nowIndex + 1, tail);
}
function creatHtml(data) {
- data.questions.sort(function (a, b) {
-// if (a.rank < b.rank) {
-// return -1;
-// } else if (a.rank == b.rank) {
-// return 0;
-// } else {
-// return 1;
-// }
- var rankA = isNaN(parseInt(a.rank))?0:parseInt(a.rank);
- var rankB = isNaN(parseInt(b.rank))?0:parseInt(b.rank);
- return rankA-rankB;
+ data.questions.sort(function(a, b) {
+ // if (a.rank < b.rank) {
+ // return -1;
+ // } else if (a.rank == b.rank) {
+ // return 0;
+ // } else {
+ // return 1;
+ // }
+ var rankA = isNaN(parseInt(a.rank)) ? 0 : parseInt(a.rank);
+ var rankB = isNaN(parseInt(b.rank)) ? 0 : parseInt(b.rank);
+ return rankA - rankB;
})
console.log(data);
$(".header_box h1").html(data.title);
$("#time").html(data.exam_time);
- if(data.score != null && data.score > 0 && data.score != ''){
+ if (data.score != null && data.score > 0 && data.score != '') {
$("#score_all").html(data.score);
}
@@ -530,35 +563,42 @@ $(function() {
for (var i = 0; i < data.questions.length; i++) {
if (data.questions[i].questions) {
- var sortTemp = data.questions[i].questions.sort(function (a, b) {
-// if (parseInt(a.rank) < parseInt(b.rank)) {
-// return -1;
-// } else if (a.rank == b.rank) {
-// return 0;
-// } else {
-// return 1;
-// }
- var rankA = isNaN(parseInt(a.rank))?0:parseInt(a.rank);
- var rankB = isNaN(parseInt(b.rank))?0:parseInt(b.rank);
- return rankA-rankB;
+ var sortTemp = data.questions[i].questions.sort(function(a, b) {
+ // if (parseInt(a.rank) < parseInt(b.rank)) {
+ // return -1;
+ // } else if (a.rank == b.rank) {
+ // return 0;
+ // } else {
+ // return 1;
+ // }
+ var rankA = isNaN(parseInt(a.rank)) ? 0 : parseInt(a.rank);
+ var rankB = isNaN(parseInt(b.rank)) ? 0 : parseInt(b.rank);
+ return rankA - rankB;
})
console.log(sortTemp)
+ var tixing = "";
+ switch(data.questions[i].problem_type_id){
+ case '1':tixing="单选题";break;
+ case '5':tixing="多选题";break;
+ case '4':tixing="判断题";break;
+ case '6':tixing="数字题";break;
+ }
$(".content")
.append(
' ');
@@ -596,7 +636,7 @@ $(function() {
''+str_temp+' ');
+ if(!$(".section-" + i).hasClass("number"))
+ $(".section-" + i).addClass("number");
} else {
for (var k = 0; k < parseInt(data.questions[i].questions[j].option_num); k++) {
str_temp = data.questions[i].questions[j].answer;
@@ -644,8 +691,7 @@ $(function() {
}
}
-
- /*快速建题中,每输入五个答案就加一个空格*/
+ /* 快速建题中,每输入五个答案就加一个空格 */
$("#answer").on("input propertychange", function(event) {
var answerStr = "";
answerStr = $("#answer").val();
@@ -669,8 +715,6 @@ $(function() {
}
})
-
-
function SectionToChinese(section) {
var strIns = '', chnStr = '';
var unitPos = 0;
@@ -694,33 +738,33 @@ $(function() {
return chnStr;
}
-
if (template != null && template.length > 0) {
-
- $("#addQuestion").attr("disabled", "disabled");
- $("#fast").attr("disabled", "disabled");
- for (var i = 0; i < template.length; i++) {
- if (template[i].type == 1) {
- var answer = "";
- for (var j = 0; j < template[i].questionNum; j++) {
- answer += "1";
- }
- creat(answer, template[i].optionNum, template[i].score);
- }
- if (template[i].type == 2) {
- addQuestion(5, template[i].optionNum, 1,
- template[i].questionNum, template[i].score);
+
+ $("#addQuestion").attr("disabled", "disabled");
+ $("#fast").attr("disabled", "disabled");
+ for (var i = 0; i < template.length; i++) {
+ if (template[i].type == 1) {
+ var answer = "";
+ for (var j = 0; j < template[i].questionNum; j++) {
+ answer += "1";
}
+ creat(answer, template[i].optionNum, template[i].score);
}
- if(testData != null){
- $(".header_box h1").html(testData.title);
- $("#time").html(testData.exam_time);
- if(testData.score != null && testData.score > 0 && testData.score != ''){
- $("#score_all").html(testData.score);
- }
+ if (template[i].type == 2) {
+ addQuestion(5, template[i].optionNum, 1,
+ template[i].questionNum, template[i].score);
}
-
- }else if (testData != null && testData.questions != null
+ }
+ if (testData != null) {
+ $(".header_box h1").html(testData.title);
+ $("#time").html(testData.exam_time);
+ if (testData.score != null && testData.score > 0
+ && testData.score != '') {
+ $("#score_all").html(testData.score);
+ }
+ }
+
+ } else if (testData != null && testData.questions != null
&& testData.questions.length > 0) {
fastSort(testData.questions, 0, testData.questions.length - 1);
for (var i = 0; i < testData.questions.length; i++) {
@@ -732,74 +776,75 @@ $(function() {
}
}
creatHtml(testData);
- }else{
- if(testData != null){
+ } else {
+ if (testData != null) {
$(".header_box h1").html(testData.title);
$("#time").html(testData.exam_time);
- if(testData.score != null && testData.score > 0 && testData.score != ''){
+ if (testData.score != null && testData.score > 0
+ && testData.score != '') {
$("#score_all").html(testData.score);
}
}
}
-
- $(".content").on("focus",".number .on",function(){
- if($(this).text()=="请输入答案")
+
+ $(".content").on("focus", ".number .on", function() {
+ if ($(this).text() == "请输入答案")
$(this).text("");
-
-
+
})
- $(".content").on("blur",".number .on",function(){
- if($(this).text()==""){
+ $(".content").on("blur", ".number .on", function() {
+ if ($(this).text() == "") {
$(this).text("请输入答案");
}
-
+
})
-
+
})
/**
* 数字校验
+ *
* @param e
*/
-function keydown2(e){
- var reg= /^[0-9]*$/;
- console.log(reg.test(e.text()));
- console.log(e.text())
- if(!reg.test(e.text())){
- e.text("");
+function keydown2(e) {
+ var reg = /^[0-9]*$/;
+ console.log(reg.test(e.text()));
+ console.log(e.text())
+ if (!reg.test(e.text())) {
+ e.text("");
+ }
+}
+
+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,第二位不是点,就用数字把点替换掉
+ if (str.length > 1 && len1 == 0 && len2 != ".") {
+ str = str.substr(1, 1);
+ }
+ // 第一位不能是.
+ if (len1 == ".") {
+ str = "";
+ }
+ // 限制只能输入一个小数点
+ if (str.indexOf(".") != -1) {
+ var str_ = str.substr(str.indexOf(".") + 1);
+ if (str_.indexOf(".") != -1) {
+ str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
}
}
+ // 正则替换,保留数字和小数点
+ str = str.replace(/[^\-?\d.]/g, '')
+
+ obj.innerText = str
-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,第二位不是点,就用数字把点替换掉
- if (str.length > 1 && len1 == 0 && len2 != ".") {
- str = str.substr(1, 1);
- }
- //第一位不能是.
- if (len1 == ".") {
- str = "";
- }
- //限制只能输入一个小数点
- if (str.indexOf(".") != -1) {
- var str_ = str.substr(str.indexOf(".") + 1);
- if (str_.indexOf(".") != -1) {
- str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
- }
- }
- //正则替换,保留数字和小数点
- str = str.replace(/[^\-?\d.]/g,'')
-
- obj.innerText=str
-
- callback(str,obj)
+ callback(str, obj)
}
-function callback(tp,obj) {
- var _div = obj//document.querySelector('.number .on');
+function callback(tp, obj) {
+ var _div = obj// document.querySelector('.number .on');
var range = document.createRange();
range.selectNodeContents(_div);
diff --git a/resources/dbconfig.properties b/resources/dbconfig.properties
index e7df42d..0762557 100644
--- a/resources/dbconfig.properties
+++ b/resources/dbconfig.properties
@@ -1,10 +1,10 @@
#数据源 1
-#url:jdbc:mysql://47.107.98.47:3306/education2?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+url:jdbc:mysql://47.107.98.47:3306/education2?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://120.78.57.84:3306/edu?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://120.78.57.84:3306/education3?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://192.168.0.3:3306/education?autoReconnect=true&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
#url:jdbc:mysql://120.78.219.152:3306/fhadmin?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
-url:jdbc:mysql://121.40.201.117:3306/luming?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+#url:jdbc:mysql://121.40.201.117:3306/luming?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
driverClassName:com.mysql.jdbc.Driver
#username:root
#password:ZrZxKeYp
diff --git a/resources/mybatis1/sunvote/PaperMapper.xml b/resources/mybatis1/sunvote/PaperMapper.xml
index 30ada3c..396003e 100644
--- a/resources/mybatis1/sunvote/PaperMapper.xml
+++ b/resources/mybatis1/sunvote/PaperMapper.xml
@@ -257,7 +257,7 @@
where 1 = 1
AND
- (SCHOOL_ID = #{SCHOOL_ID} AND PAPER_TYPE = '2') OR
+ (SCHOOL_ID = #{SCHOOL_ID} AND PAPER_TYPE = '2' AND SUBJECT_ID=#{SUBJECT_ID}) OR
(USER_ID = #{USER_ID} AND PAPER_TYPE = #{PAPER_TYPE})
order by CREATE_DATE DESC
diff --git a/src/com/fh/controller/sunvote/paper/PaperController.java b/src/com/fh/controller/sunvote/paper/PaperController.java
index ce46354..77ea0b9 100644
--- a/src/com/fh/controller/sunvote/paper/PaperController.java
+++ b/src/com/fh/controller/sunvote/paper/PaperController.java
@@ -467,7 +467,7 @@ public class PaperController extends BaseController {
|| list.get(i).get("NO_NAME").toString().isEmpty()) {
continue;
}
- Float que_score = Float.valueOf(list.get(i).get("SCORE")
+ Float que_score = list.get(i).getString("SCORE").isEmpty()?0:Float.valueOf(list.get(i).get("SCORE")
.toString());
temp.put("QUESTION_ID", questionid);
PageData question = questionService.findById(temp);
' + + question_num + + '、多选题
' + i
+ + '、
');
+ for (var j = 0; j < a_num; j++) {
+ option = String.fromCharCode(0x41 + j);
+ $(
+ ".section-" + answer_index_b + " .question"
+ + questionNUm + ' ul').append(
+ '' + + question_num + + '、数字题
'
+ + i
+ '、
');
-// for (var j = 0; j < a_num; j++) {
-// option = String.fromCharCode(0x41 + j);
-// $(
-// ".section-" + answer_index_b + " .question"
-// + questionNUm + ' ul').append(
-// '- 请输入答案
' - + '第' - + (i + 1) - + '大题总分:' + +SectionToChinese(i+1)+'、' + + tixing + + '(总分:' + data.questions[i].questions.length + " X " + (parseFloat(data.questions[i].sug_score) / data.questions[i].questions.length) + " = " + data.questions[i].sug_score - + '' + + '分)' + '' + data.questions[i].content + '
' + (++questionNUm)
+ '、
');
- if ($(".section-" + i).find(".que_name").text() == "判断题") {
+ if ($(".section-" + i).attr("data-type") == "4") {
for (var k = 0; k < parseInt(data.questions[i].questions[j].option_num); k++) {
str_temp = data.questions[i].questions[j].answer;
if (k % 2 == 0) {
@@ -618,6 +658,13 @@ $(function() {
".question" + (j + 1) + ' ul li').eq(1)
.attr("class", "btn btn-default on");
}
+ }else if($(".section-" + i).attr("data-type") == "6"){
+ str_temp = data.questions[i].questions[j].answer;
+ $(".section-" + i).find(
+ ".question" + (j + 1) + ' ul').append(
+ '