Adding Functions for Assessments

Tuesday, Sep 4, 2018

Confirmation before submitting assessments

When you only give a limited number of attempts to a student each submission is valuable, to ensure that students are aware that they are submitting the form and therefore will use up one of these attempts it it worthwhile giving them notification of this. Use this code to do so.

$(document).ready(function() {

// Confirmation alert before submitting assessment forms
 $("input[name='btnSubmit']").click(function(e) {
        var wrnMsg= $('#formScoreMessage').text();
        var alertStr= 'Please confirm you want to SUBMIT your homework for marking by Clever Training. There is a limit of 3 attempts, after which you will no longer be able to change your answers. Press SUBMIT to use one attempt. If you wish to return to your homework press CANCEL. There is a SAVE DRAFT button at the bottom of each page of homework. Press this and it will send you a link to your email address so you can complete your homework at a later time.';
        alertStr= alertStr + '\n\n' + wrnMsg + '';
        var c = confirm(alertStr);
 // end of Confirmation alert before submitting assessment forms


Adding automatic draft save on assessments

If your assessments have a large number of questions or you find that students tend to forget to save their draft perhaps this automatic save will ensure they never wander away and leave valuable attempts unsent and miss out on valuable marks. By using this feature you don’t need to use the draft save button, and you should not set up email notifications when a form is saved as draft - otherwise many emails might be sent.

Basically this function sends an updated for each time a for is modified.

$(document).ready(function() {
 // Ajax autosave form
    $('form').on('keyup change paste', 'input, select, textarea', function(){
        if ($(".extranetForm3302").length > 0){
            console.log('Exam Form changed!');
            var frmData = $('.csAjxFrm').serialize();
            frmData += "&btn=draft";
                type: "POST",
                url: "/extranet/steppost",
                data: frmData,
                success: function(msg) {
                console.log('Success: ' + frmData);
                error: function (xhr, ajaxOptions, thrownError) {
                    console.log('Error: ' + xhr.status + '--' + thrownError);
        } else {
            console.log('Not Exam Form!');
 // end of Ajax autosave form

How to make this feature only apply to those forms that are for assessments, and not other forms?

You can create a unique javascript file that is referred to in the link using js=filename.js or you can use the inbuilt option to only apply to certain assessments, using the Form Id as an identifier.

You can see the line:

if ($(".extranetForm3302").length > 0)

that’s a class name (of a div) used as a flag.

If you have another form in another page with another div which has another class name, you can use some div like:

if ($((".extranetForm3302").length > 0) || (".something").length > 0))

so the script will run in both cases.

Obviously you can use if something || anotherthing || anotheranotherthing || anotheranotherthing || anotheranotherthing if you want and the script will run in all cases.