</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');
    $(&quot;#examineName&quot;).html(examineName);
    $(&quot;#examineScore&quot;).html(examineScore);
    $(&quot;#examineTime&quot;).html(examineTime);
    if (type == 1) { // if type is 1, show the exam agreement dialog
        var dialog = $.dialog({
            title: &quot;考试协议&quot;,
            content: $(&quot;.shenmingDialog&quot;)[0],
            width: &quot;650px&quot;,
            lock: true
        });
        $(&quot;.shenmingDialog .btn-public&quot;).unbind(&quot;click&quot;);
        $(&quot;.shenmingDialog .btn-public&quot;).click(function () {
            if ($(this).hasClass(&quot;btn-disabled&quot;)) {
                return false;
            }
            var inputC = $(&quot;.checkEnter&quot;);
            if (inputC.hasClass('selected')) { // if the checkbox is checked, start the exam
                location.href = CONTEXTPATH + &quot;/examine/paper/&quot; + examineId + &quot;.mooc&quot;;
            }
        });
        $(&quot;.shenmingDialog .btn-cancel&quot;).unbind(&quot;click&quot;);
        $(&quot;.shenmingDialog .btn-cancel&quot;).click(function () { // if the &quot;cancel&quot; button is clicked, reset the checkbox and close the dialog
            $(&quot;.checkEnter&quot;).removeClass('selected');
            $(&quot;.shenmingDialog .btn-public&quot;).addClass('btn-disabled');
            dialog.close();
        });
    } else { // if type is 0, continue the exam
        location.href = CONTEXTPATH + &quot;/examine/paper/&quot; + examineId + &quot;.mooc&quot;;
    }
}

// function for viewing the exam result
function view(examineId) {
    location.href = CONTEXTPATH + &quot;/examine/paper/view/&quot; + examineId + &quot;.mooc&quot;;
}
</code></pre>
</script>
</div>
divscript type=textjavascript $btn-area enterclickfunction $thisattrdisabled true; enter$this 1; $btn-area continueclickfunction $thisattrdisabled true; enter

原文地址: https://www.cveoy.top/t/topic/bPt4 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录