|
|
|
@ -413,6 +413,10 @@
|
|
|
|
|
background-color: #FF635C;
|
|
|
|
|
margin-left: 240px !important;
|
|
|
|
|
}
|
|
|
|
|
#quit{
|
|
|
|
|
background-color: #FF635C;
|
|
|
|
|
margin-left: 50px !important;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
@ -459,6 +463,7 @@
|
|
|
|
|
<button id="nextItem">下一题</button>
|
|
|
|
|
<button id="markItem">设置待查</button>
|
|
|
|
|
<button id="submit">交卷</button>
|
|
|
|
|
<button id="quit">退出</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -535,19 +540,19 @@
|
|
|
|
|
// 输出考试开始时间和结束时间
|
|
|
|
|
document.querySelector('.kaishi').innerText = formatDateTime(currentTime)
|
|
|
|
|
document.querySelector('.jieshu').innerText = formatDateTime(examStartTime)
|
|
|
|
|
function checkExamTime (){
|
|
|
|
|
var currentTime1 = new Date();
|
|
|
|
|
if (currentTime1 > examStartTime) {
|
|
|
|
|
// 超时,进行强制提交操作
|
|
|
|
|
console.log("已超过考试开始时间,进行强制提交操作。");
|
|
|
|
|
clearInterval(intervalID);
|
|
|
|
|
} else {
|
|
|
|
|
// 未超时,正常进行考试
|
|
|
|
|
console.log("考试开始时间:" + formatDateTime(currentTime));
|
|
|
|
|
console.log("考试结束时间:" + formatDateTime(examStartTime));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var intervalID = setInterval(checkExamTime , 60000);
|
|
|
|
|
// function checkExamTime (){
|
|
|
|
|
// var currentTime1 = new Date();
|
|
|
|
|
// if (currentTime1 > examStartTime) {
|
|
|
|
|
// // 超时,进行强制提交操作
|
|
|
|
|
// console.log("已超过考试开始时间,进行强制提交操作。");
|
|
|
|
|
// clearInterval(intervalID);
|
|
|
|
|
// } else {
|
|
|
|
|
// // 未超时,正常进行考试
|
|
|
|
|
// console.log("考试开始时间:" + formatDateTime(currentTime));
|
|
|
|
|
// console.log("考试结束时间:" + formatDateTime(examStartTime));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// var intervalID = setInterval(checkExamTime , 60000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var subject = [
|
|
|
|
@ -579,7 +584,8 @@
|
|
|
|
|
success: function(data) {
|
|
|
|
|
// 请求成功时,初始化答题系统
|
|
|
|
|
subject = data.rows;
|
|
|
|
|
subject.forEach(function(item, index) {
|
|
|
|
|
for (let index = 0; index < subject.length; index++) {
|
|
|
|
|
let item = subject[index];
|
|
|
|
|
// 添加属性
|
|
|
|
|
item.order = 1;
|
|
|
|
|
item.type = "single";
|
|
|
|
@ -591,8 +597,8 @@
|
|
|
|
|
item.optionb,
|
|
|
|
|
item.optionc,
|
|
|
|
|
item.optiond
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
externalFunction(); // 调用外部函数的示例
|
|
|
|
|
},
|
|
|
|
|
error: function() {
|
|
|
|
@ -600,7 +606,7 @@
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
var maxtime = 45 * 60; //一个小时,按秒计算,自己调整!
|
|
|
|
|
var maxtime = 45 * 60;
|
|
|
|
|
var t; //定时器
|
|
|
|
|
// ------ 计时程序 -----
|
|
|
|
|
function CountDown() {
|
|
|
|
@ -630,7 +636,7 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkTime(i) { //将0-9的数字前面加上0,例1变为01
|
|
|
|
|
function checkTime(i) { //将0-9的数字前面加上0
|
|
|
|
|
if (i < 10) {
|
|
|
|
|
i = "0" + i;
|
|
|
|
|
}
|
|
|
|
@ -645,14 +651,12 @@
|
|
|
|
|
// ----- 填充HTML ------
|
|
|
|
|
var orderNo = [];
|
|
|
|
|
|
|
|
|
|
//写入各个大题的div
|
|
|
|
|
//写入各个题的div
|
|
|
|
|
var itemChooseHTML = '';
|
|
|
|
|
for (var i = 0; i < itemCouAll; i++) {
|
|
|
|
|
itemChooseHTML +=
|
|
|
|
|
`
|
|
|
|
|
<div id = ${'order'+i} >
|
|
|
|
|
<!-- <button> - </button>-->
|
|
|
|
|
<!-- <p>第${i+1}道大题</p>-->
|
|
|
|
|
<ul></ul>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
@ -683,7 +687,6 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//绑定各个li,注意这里的i的作用域,可使用虚拟属性,参考https://www.cnblogs.com/wangyongshf/p/7466799.html
|
|
|
|
|
var liList = document.getElementById('itemChoose').getElementsByTagName('li');
|
|
|
|
|
for (var i = 0; i < liList.length; i++) {
|
|
|
|
|
liList[i].index = i;
|
|
|
|
@ -817,6 +820,8 @@
|
|
|
|
|
if (indexItem) {
|
|
|
|
|
indexItem--;
|
|
|
|
|
refresh();
|
|
|
|
|
}else{
|
|
|
|
|
alert('已经是第一题了')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -824,6 +829,8 @@
|
|
|
|
|
if (indexItem < subject.length - 1) {
|
|
|
|
|
indexItem++;
|
|
|
|
|
refresh();
|
|
|
|
|
}else{
|
|
|
|
|
alert('已经是最后一题了')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -947,84 +954,178 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
document.getElementById('submit').onclick = function() {
|
|
|
|
|
submitMethid();
|
|
|
|
|
var sub = 'submit'
|
|
|
|
|
submitMethid(sub);
|
|
|
|
|
};
|
|
|
|
|
document.getElementById('quit').onclick = function() {
|
|
|
|
|
let confirmation = confirm("退出后将考试进度将重置,确认退出?");
|
|
|
|
|
if (confirmation) {
|
|
|
|
|
window.location.href = `/system/exam`;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
function submitMethid(){
|
|
|
|
|
function submitMethid(sub){
|
|
|
|
|
var htmlText = '';
|
|
|
|
|
var account = 0; //总得分
|
|
|
|
|
for (var i = 0; i < subject.length; i++) {
|
|
|
|
|
if(sub=== 'submit'){
|
|
|
|
|
let confirmation = confirm("只能提交一次,确定提交吗?");
|
|
|
|
|
if (confirmation) {
|
|
|
|
|
for (var i = 0; i < subject.length; i++) {
|
|
|
|
|
|
|
|
|
|
//计算当前题目得分
|
|
|
|
|
var nowAccount;
|
|
|
|
|
if (subject[i].type === 'single') {
|
|
|
|
|
if (subject[i].answer === '' || subject[i].answer !== subject[i].note) {
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = 2;
|
|
|
|
|
}
|
|
|
|
|
} else if (subject[i].type === 'judge') {
|
|
|
|
|
if (subject[i].answer === '' || subject[i].answer !== subject[i].note) {
|
|
|
|
|
nowAccount = -0.5;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (subject[i].type === 'indeterminate') {
|
|
|
|
|
if (subject[i].answer === '') { //如果未填写答案
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
var hasError = false; //假设没有错误选项
|
|
|
|
|
for (var j = 0; j < subject[i].option.length; j++) {
|
|
|
|
|
if (subject[i].answer.charAt(j) !== '_' && subject[i].note.charAt(j) === '_') { //有错误选项
|
|
|
|
|
hasError = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasError) {
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = subject[i].answer.replace(/_/g, "").length / subject[i].note.replace(/_/g, "").length * 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计算当前题目得分
|
|
|
|
|
var nowAccount;
|
|
|
|
|
if (subject[i].type === 'single') {
|
|
|
|
|
if (subject[i].answer === '' || subject[i].answer !== subject[i].note) {
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = 2;
|
|
|
|
|
}
|
|
|
|
|
} else if (subject[i].type === 'judge') {
|
|
|
|
|
if (subject[i].answer === '' || subject[i].answer !== subject[i].note) {
|
|
|
|
|
nowAccount = -0.5;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (subject[i].type === 'indeterminate') {
|
|
|
|
|
if (subject[i].answer === '') { //如果未填写答案
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
var hasError = false; //假设没有错误选项
|
|
|
|
|
for (var j = 0; j < subject[i].option.length; j++) {
|
|
|
|
|
if (subject[i].answer.charAt(j) !== '_' && subject[i].note.charAt(j) === '_') { //有错误选项
|
|
|
|
|
hasError = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else { //多选题
|
|
|
|
|
if (subject[i].answer === '') { //如果未填写答案
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
var hasError = false; //假设没有错误选项
|
|
|
|
|
for (var j = 0; j < subject[i].option.length; j++) {
|
|
|
|
|
if (subject[i].answer.charAt(j) !== '_' && subject[i].note.charAt(j) === '_') { //有错误选项
|
|
|
|
|
hasError = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasError) {
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
if (subject[i].answer === subject[i].note) { //全部正确
|
|
|
|
|
nowAccount = 4;
|
|
|
|
|
} else {
|
|
|
|
|
if (subject[i].answer.replace(/_/g, "").length >= 4) {
|
|
|
|
|
nowAccount = 3;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = subject[i].answer.replace(/_/g, "").length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasError) {
|
|
|
|
|
htmlText += '题目' + i + ' 答案' + subject[i].note + ' 回答' + subject[i].answer + ' 得分' + nowAccount.toFixed(2) + '\n';
|
|
|
|
|
account += nowAccount;
|
|
|
|
|
}
|
|
|
|
|
let params = {
|
|
|
|
|
examResult:account,
|
|
|
|
|
userName:userName,
|
|
|
|
|
dept:deptName,
|
|
|
|
|
startTime:formatDateTime(currentTime),
|
|
|
|
|
endTime:getCurrentDateTime(),
|
|
|
|
|
type:param,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
alert('您的总得分为:' + account + '分');
|
|
|
|
|
document.getElementById('submit').disabled = true
|
|
|
|
|
document.getElementById('submit').style.backgroundColor = '#999'
|
|
|
|
|
window.location.href = `/system/exam`;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
for (var i = 0; i < subject.length; i++) {
|
|
|
|
|
|
|
|
|
|
//计算当前题目得分
|
|
|
|
|
var nowAccount;
|
|
|
|
|
if (subject[i].type === 'single') {
|
|
|
|
|
if (subject[i].answer === '' || subject[i].answer !== subject[i].note) {
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = subject[i].answer.replace(/_/g, "").length / subject[i].note.replace(/_/g, "").length * 4;
|
|
|
|
|
nowAccount = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else { //多选题
|
|
|
|
|
if (subject[i].answer === '') { //如果未填写答案
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
var hasError = false; //假设没有错误选项
|
|
|
|
|
for (var j = 0; j < subject[i].option.length; j++) {
|
|
|
|
|
if (subject[i].answer.charAt(j) !== '_' && subject[i].note.charAt(j) === '_') { //有错误选项
|
|
|
|
|
hasError = true;
|
|
|
|
|
break;
|
|
|
|
|
} else if (subject[i].type === 'judge') {
|
|
|
|
|
if (subject[i].answer === '' || subject[i].answer !== subject[i].note) {
|
|
|
|
|
nowAccount = -0.5;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (subject[i].type === 'indeterminate') {
|
|
|
|
|
if (subject[i].answer === '') { //如果未填写答案
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
var hasError = false; //假设没有错误选项
|
|
|
|
|
for (var j = 0; j < subject[i].option.length; j++) {
|
|
|
|
|
if (subject[i].answer.charAt(j) !== '_' && subject[i].note.charAt(j) === '_') { //有错误选项
|
|
|
|
|
hasError = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasError) {
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = subject[i].answer.replace(/_/g, "").length / subject[i].note.replace(/_/g, "").length * 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (hasError) {
|
|
|
|
|
} else { //多选题
|
|
|
|
|
if (subject[i].answer === '') { //如果未填写答案
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
if (subject[i].answer === subject[i].note) { //全部正确
|
|
|
|
|
nowAccount = 4;
|
|
|
|
|
var hasError = false; //假设没有错误选项
|
|
|
|
|
for (var j = 0; j < subject[i].option.length; j++) {
|
|
|
|
|
if (subject[i].answer.charAt(j) !== '_' && subject[i].note.charAt(j) === '_') { //有错误选项
|
|
|
|
|
hasError = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasError) {
|
|
|
|
|
nowAccount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
if (subject[i].answer.replace(/_/g, "").length >= 4) {
|
|
|
|
|
nowAccount = 3;
|
|
|
|
|
if (subject[i].answer === subject[i].note) { //全部正确
|
|
|
|
|
nowAccount = 4;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = subject[i].answer.replace(/_/g, "").length;
|
|
|
|
|
if (subject[i].answer.replace(/_/g, "").length >= 4) {
|
|
|
|
|
nowAccount = 3;
|
|
|
|
|
} else {
|
|
|
|
|
nowAccount = subject[i].answer.replace(/_/g, "").length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
htmlText += '题目' + i + ' 答案' + subject[i].note + ' 回答' + subject[i].answer + ' 得分' + nowAccount.toFixed(2) + '\n';
|
|
|
|
|
account += nowAccount;
|
|
|
|
|
}
|
|
|
|
|
htmlText += '题目' + i + ' 答案' + subject[i].note + ' 回答' + subject[i].answer + ' 得分' + nowAccount.toFixed(2) + '\n';
|
|
|
|
|
account += nowAccount;
|
|
|
|
|
let params = {
|
|
|
|
|
examResult:account,
|
|
|
|
|
userName:userName,
|
|
|
|
|
dept:deptName,
|
|
|
|
|
startTime:formatDateTime(currentTime),
|
|
|
|
|
endTime:getCurrentDateTime(),
|
|
|
|
|
type:param,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
alert('您的总得分为:' + account + '分');
|
|
|
|
|
document.getElementById('submit').disabled = true
|
|
|
|
|
document.getElementById('submit').style.backgroundColor = '#999'
|
|
|
|
|
window.location.href = `/system/exam`;
|
|
|
|
|
}
|
|
|
|
|
let params = {
|
|
|
|
|
examResult:account,
|
|
|
|
|
userName:userName,
|
|
|
|
|
dept:deptName,
|
|
|
|
|
startTime:formatDateTime(currentTime),
|
|
|
|
|
endTime:getCurrentDateTime(),
|
|
|
|
|
type:param,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
alert('您的总得分为:' + account + '分');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 返回一个闭包,包含内部函数的引用
|
|
|
|
|
// 返回一个包含内部函数引用的对象
|
|
|
|
|