mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 21:45:37 +02:00
MDL-34741 use 2in3 in mod_survey
This commit is contained in:
parent
69ccc32d4f
commit
2de3515fcc
@ -1,26 +1,27 @@
|
||||
function checkform(e) {
|
||||
var error = false;
|
||||
if (document.getElementById('surveyform')) {
|
||||
var surveyform = document.getElementById('surveyform');
|
||||
for (var i=0; i < surveycheck.questions.length; i++) {
|
||||
var tempquestion = surveycheck.questions[i];
|
||||
if (surveyform[tempquestion['question']][tempquestion['default']].checked) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
alert(M.str.survey.questionsnotanswered);
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function survey_attach_onsubmit() {
|
||||
M.mod_survey = {};
|
||||
|
||||
M.mod_survey.init = function(Y) {
|
||||
if (document.getElementById('surveyform')) {
|
||||
var surveyform = document.getElementById('surveyform');
|
||||
YAHOO.util.Event.addListener('surveyform', "submit", checkform);
|
||||
Y.YUI2.util.Event.addListener('surveyform', "submit", function(e) {
|
||||
var error = false;
|
||||
if (document.getElementById('surveyform')) {
|
||||
var surveyform = document.getElementById('surveyform');
|
||||
for (var i=0; i < surveycheck.questions.length; i++) {
|
||||
var tempquestion = surveycheck.questions[i];
|
||||
if (surveyform[tempquestion['question']][tempquestion['default']].checked) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
alert(M.str.survey.questionsnotanswered);
|
||||
Y.YUI2.util.Event.preventDefault(e);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -198,10 +198,14 @@ $completion->set_module_viewed($cm);
|
||||
$checkarray['questions'][] = Array('question'=>$question, 'default'=>$default);
|
||||
}
|
||||
}
|
||||
$PAGE->requires->js('/mod/survey/survey.js');
|
||||
$PAGE->requires->data_for_js('surveycheck', $checkarray);
|
||||
$module = array(
|
||||
'name' => 'mod_survey',
|
||||
'fullpath' => '/mod/survey/survey.js',
|
||||
'requires' => array('yui2-event'),
|
||||
);
|
||||
$PAGE->requires->string_for_js('questionsnotanswered', 'survey');
|
||||
$PAGE->requires->js_function_call('survey_attach_onsubmit');
|
||||
$PAGE->requires->js_init_call('M.mod_survey.init', $checkarray, true, $module);
|
||||
|
||||
echo '<br />';
|
||||
echo '<input type="submit" value="'.get_string("clicktocontinue", "survey").'" />';
|
||||
|
Loading…
x
Reference in New Issue
Block a user