diff --git a/mod/survey/amd/build/validation.min.js b/mod/survey/amd/build/validation.min.js index 004399b74d8..56bf8462a2e 100644 --- a/mod/survey/amd/build/validation.min.js +++ b/mod/survey/amd/build/validation.min.js @@ -1 +1 @@ -define(["jquery","core/str","core/modal_factory","core/notification"],function(a,b,c,d){return{ensureRadiosChosen:function(e,f){var g=b.get_strings([{key:"error",component:"moodle"},{key:"questionsnotanswered",component:"survey"}]).then(function(a){return c.create({type:c.types.CANCEL,title:a[0],body:a[1]})})["catch"](d.exception),h=a("#"+e);h.submit(function(a){var b=!1;return f.forEach(function(a){var c=h.find('input:radio[name="'+a.name+'"]:checked');c.val()==a["default"]&&(b=!0)}),!b||(a.preventDefault(),g.then(function(a){a.show()}),!1)})}}}); \ No newline at end of file +define(["jquery","core/str","core/modal_factory","core/notification"],function(a,b,c,d){return{ensureRadiosChosen:function(e){var f=b.get_strings([{key:"error",component:"moodle"},{key:"questionsnotanswered",component:"survey"}]).then(function(a){return c.create({type:c.types.CANCEL,title:a[0],body:a[1]})})["catch"](d.exception),g=a("#"+e);g.submit(function(a){return 0===g.find('input:radio[data-survey-default="true"]:checked').length||(a.preventDefault(),f.then(function(a){a.show()}),!1)})}}}); \ No newline at end of file diff --git a/mod/survey/amd/src/validation.js b/mod/survey/amd/src/validation.js index f04de066643..41f78dc0fb7 100644 --- a/mod/survey/amd/src/validation.js +++ b/mod/survey/amd/src/validation.js @@ -31,7 +31,7 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], functi * @param {String} formid HTML id of form * @param {Array} questions */ - ensureRadiosChosen: function(formid, questions) { + ensureRadiosChosen: function(formid) { // Prepare modal for display in case of problems. var modalPromise = Str.get_strings([ {key: 'error', component: 'moodle'}, @@ -46,15 +46,8 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/notification'], functi var form = $('#' + formid); form.submit(function(e) { - var error = false; - questions.forEach(function(question) { - var checkedResponse = form.find('input:radio[name="' + question.name + '"]:checked'); - if (checkedResponse.val() == question.default) { - error = true; - } - }); - - if (error) { + // Look for unanswered questions.. + if (form.find('input:radio[data-survey-default="true"]:checked').length !== 0) { e.preventDefault(); // Display the modal error. modalPromise.then(function(modal) { diff --git a/mod/survey/lib.php b/mod/survey/lib.php index 38a6e7e4378..73f67a68d1e 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -497,7 +497,7 @@ function survey_shorten_name ($name, $numwords) { * @param object $question */ function survey_print_multi($question) { - global $USER, $DB, $qnum, $checklist, $DB, $OUTPUT; //TODO: this is sloppy globals abuse + global $USER, $DB, $qnum, $DB, $OUTPUT; //TODO: this is sloppy globals abuse $stripreferthat = get_string("ipreferthat", "survey"); $strifoundthat = get_string("ifoundthat", "survey"); @@ -555,15 +555,13 @@ function survey_print_multi($question) { echo $q->text ."\n"; $default = get_accesshide($strdefault); - echo "