问题
第一步,点击...,显示红色的罩层
第二步,点击启动答题
点击了启动答题,就产生问题了
第一次点击的时候,只发一次ajax,第二次点击,就会触发2次,一直叠加
要循环的html
{{=it.paperName}}
{{=it.paperTypeName}}
{{=it.createTime}}
状态:
{{? it.status==="not_start"}}
未答题
{{?? it.status==="started"}}
答题中
{{??}}
结束答题
{{?}}
{{=it.questionCount}}题
{{? it.paperTypeId===6}}
{{=it.className}} - {{=it.studentName}}
{{??}}
{{=it.className}}
{{?}}
已提交0/1
未批改
正确率
{{=it.accuracy}}%
//3个点点点
{{? it.status==="not_start"}}
启动答题
取消答题
{{?? it.status==="started"}}
结束答题
开始扫描
开始批改
{{??}} {{? it.correctStatus==="not_start"}}
开始扫描
开始批改
{{??}}
批改完成
{{?}} {{?}} {{? it.courseId}}
{{??}}
{{?}}
点击事件
function IndexControl() {
var Red = $('.app-index .index-body .body-item .item-red');
var showRed = $('.app-index .index-body .body-item .item-white .white-right .right-bottom');
// var startBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-start');
var stopBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-stop');
var delBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-del');
var editBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-edit');
var scanBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-scan');
//显示红色遮罩层
showRed.click(function() {
$(this).parents('.item-white').siblings('.item-red').css('display', 'flex');
$(this).parents('.body-item').siblings().children('.item-red').hide();
$(this).parents('.body-item').siblings('.actived').children('.item-red').show();
var courseId = $(this).parents('.item-white').siblings(".item-red").children('.courseIdindex').val();
classId = $('#selectclassId').val();
piId = $(this).parents('.item-white').find('.this-paperId').val()
testId = $(this).parents('.item-white').children(".white-left").children('.testId').val()
// var startBtn = $(this).parents(".item-white").siblings(".item-red").find(".group-img-start");
// startControl(startBtn, courseId, classId, piId,testId);
//点击启动答题
$(this).parents(".item-white").siblings(".item-red").find(".group-img-start").click(function(event){
event.stopPropagation();
starttest_paper(courseId, classId, piId,testId)
})
stopControl(stopBtn, courseId, classId, piId,testId);
cancelControl(delBtn, courseId, classId, piId,testId);
editControl(editBtn, testId);
scanControl(scanBtn, testId);
});
//隐藏红色遮罩层
Red.click(function() {
$(this).hide();
})
}
ajax
function starttest_paper(courseId,classId,paperId,testId, callback) {
var createBy = $api.getStorage('global_userId');
api.ajax({
url: cbd_server_url + 'exam/start',
method: 'put',
dataType: 'json',
headers:{
"Content-Type":'application/json',
},
data:{
body: {
id: testId,
paperId: paperId,
classId: classId,
courseId: courseId,
createBy:createBy
}
//status: "started"
// })
},
}, function(ret, err) {
if (ret) {
console.log(JSON.stringify(ret))
var result = ret.msg;
callback && callback(result);
} else {
console.log(JSON.stringify(err))
}
})
}