答题系统html源码,答题系统.html 答题系统
未央暮城⾃主考试系统
||
当前
未做
待查
已做
财经法规与会计职业道德考试
1⼁单选题
【答案解析】
上⼀题
下⼀题
计算器
设置待查
交卷
提⽰
当前考试已暂停,点击下⽅按钮继续答题
继续
//配置信息设置
var indexItem = 0; //全局变量,当前的题⽬编号
var maxtime = 60 * 60; //⼀个⼩时,按秒计算,⾃⼰调整!
var itemCouAll = subject[subject.length - 1].order; //⼤题总数
var t; //定时器
// ----- 填充HTML ------
var orderNo = [];
//写⼊各个⼤题的div
var itemChooseHTML = '';
for (var i = 0; i < itemCouAll; i++) {
itemChooseHTML +=
`
-
第${i+1}道⼤题
`
}
//写⼊div下的ul li
//获取每个div下应有多少li
var orderCou = [];
for (var i = 0; i < itemCouAll; i++) {
var m = 0;
for (var j = 0; j < subject.length; j++) {
if (subject[j].order === i + 1) {
m++;
}
}
orderCou[i] = m;
}
for (var i = 0; i < itemCouAll; i++) {
var optionHTML = '';
for (var j = 0; j < orderCou[i]; j++) {
optionHTML += `
${j+1}`
}
html导航源码
}
//绑定各个li,注意这⾥的i的作⽤域,可使⽤虚拟属性,参考wwwblogs/wangyongshf/p/7466799.html var liList = ElementById('itemChoose').getElementsByTagName('li');
for (var i = 0; i < liList.length; i++) {
liList[i].index = i;
liList[i].onclick = function() {
indexItem = this.index;
refresh();
}
}
//设置各个li的class,是否符合回答规范、设置了待查标记
for (var i = 0; i < liList.length; i++) {
liList[i].className = YesOrNo(i);
if (subject[i].mark) { //设置待查标记
liList[i].classList.add('markAnswer');
} else {
liList[i].ve('markAnswer');
}
}
// 开始倒计时
t = setInterval("CountDown()", 1000);
refresh(); //加载题⽬
}
// ------ 计时程序 -----
function CountDown() {
if (maxtime >= 0) {
//写⼊HTML
hours = checkTime(parseInt(maxtime / 60 / 60) % 60);
minutes = checkTime(parseInt(maxtime / 60) % 60);
seconds = checkTime(parseInt(maxtime % 60));
msg = hours + ":" + minutes + ":" + seconds;
maxtime--;
if (maxtime === 5 * 60) {
}
} else {
clearInterval(t);
alert("时间到,结束!");
//开始结算
}
}
function checkTime(i) { //将0-9的数字前⾯加上0,例1变为01
if (i < 10) {
i = "0" + i;
}
return i;
}
//
//题⽬刷新
//
function refresh() {
//题⽬序号与题⽬类型描述⽂本
var itemType = ''; //单选题、多选题
switch (subject[indexItem].type) {
case "single":
itemType = '单选题';
break;
case "judge":
itemType = '判断题';
break;
case "multiple":
itemType = '多选题';
break;
case "indeterminate":
itemType = '不定项';
break;
}
var describeText = "";
describeText += subject[indexItem].describe;
//答案选项
var optNum = subject[indexItem].option.length;
var optionText = "";
var inputType = "";
var inputName = subject[indexItem].type;
switch (subject[indexItem].type) {
case "single":
case "judge":
inputType = "radio";
break;
case "multiple":
case "indeterminate":
inputType = "checkbox";
break;
}
for (var i = 0; i < optNum; i++) {
var itemChecked = '';
if (subject[indexItem].type === 'indeterminate' || subject[indexItem].type === 'multiple') {
if (subject[indexItem].answer.charAt(i) !== '_' && subject[indexItem].answer.charAt(i) !== '') { itemChecked = 'checked="checked"';
}
} else {
if (subject[indexItem].answer === String.fromCharCode(65 + i)) {
itemChecked = 'checked="checked"';
}
}
optionText +=
`
${String.fromCharCode(65 + i)}
${subject[indexItem].option[i]}
`
}
//答案解析
//按钮禁⽤状态
if (indexItem === 0) {
} else if (indexItem === subject.length - 1) {

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。