divscript type=textjavascript $btn-area enterclickfunction $thisattrdisabled true; enter$this 1; $btn-area continueclickfunction $thisattrdisabled true; enter
</div>
<script type="text/javascript">
// when "enter" button is clicked
$(".btn-area .enter").click(function () {
$(this).attr("disabled", true); // disable the button to prevent multiple clicks
enter($(this), 1); // call the enter function with type 1 (for starting the exam)
})
// when "continue" button is clicked
$(".btn-area .continue").click(function () {
$(this).attr("disabled", true); // disable the button to prevent multiple clicks
enter($(this), 0); // call the enter function with type 0 (for continuing the exam)
})
// when "view" button is clicked
$(".btn-area .view").click(function () {
$(this).attr("disabled", true); // disable the button to prevent multiple clicks
view($(this).parent('.btn-area').attr('examineId')); // call the view function with the examineId as parameter
})
// when the checkbox for exam agreement is clicked
$(".checkEnter").click(function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
$(".shenmingDialog .btn-public").addClass('btn-disabled'); // disable the "enter" button in the exam agreement dialog
} else {
$(this).addClass('selected');
$(".shenmingDialog .btn-public").removeClass('btn-disabled'); // enable the "enter" button in the exam agreement dialog
}
})
<pre><code>// function for starting or continuing the exam
function enter($this, type) {
var examineId = $this.attr('examineId');
var examineName = $this.attr('examineName');
var examineScore = $this.attr('examineScore');
var examineTime = $this.attr('examineTime');
$("#examineName").html(examineName);
$("#examineScore").html(examineScore);
$("#examineTime").html(examineTime);
if (type == 1) { // if type is 1, show the exam agreement dialog
var dialog = $.dialog({
title: "考试协议",
content: $(".shenmingDialog")[0],
width: "650px",
lock: true
});
$(".shenmingDialog .btn-public").unbind("click");
$(".shenmingDialog .btn-public").click(function () {
if ($(this).hasClass("btn-disabled")) {
return false;
}
var inputC = $(".checkEnter");
if (inputC.hasClass('selected')) { // if the checkbox is checked, start the exam
location.href = CONTEXTPATH + "/examine/paper/" + examineId + ".mooc";
}
});
$(".shenmingDialog .btn-cancel").unbind("click");
$(".shenmingDialog .btn-cancel").click(function () { // if the "cancel" button is clicked, reset the checkbox and close the dialog
$(".checkEnter").removeClass('selected');
$(".shenmingDialog .btn-public").addClass('btn-disabled');
dialog.close();
});
} else { // if type is 0, continue the exam
location.href = CONTEXTPATH + "/examine/paper/" + examineId + ".mooc";
}
}
// function for viewing the exam result
function view(examineId) {
location.href = CONTEXTPATH + "/examine/paper/view/" + examineId + ".mooc";
}
</code></pre>
</script>
</div>
原文地址: https://www.cveoy.top/t/topic/bPt4 著作权归作者所有。请勿转载和采集!