mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
Merge branch 'MDL-32064' of git://github.com/timhunt/moodle
This commit is contained in:
commit
f7dbc2814c
@ -143,6 +143,29 @@ M.mod_quiz.nav.init = function(Y) {
|
||||
|
||||
var form = Y.one('#responseform');
|
||||
if (form) {
|
||||
function find_enabled_submit() {
|
||||
// This is rather inelegant, but the CSS3 selector
|
||||
// return form.one('input[type=submit]:enabled');
|
||||
// does not work in IE7, 8 or 9 for me.
|
||||
var enabledsubmit = null;
|
||||
form.all('input[type=submit]').each(function(submit) {
|
||||
if (!enabledsubmit && !submit.get('disabled')) {
|
||||
enabledsubmit = submit;
|
||||
}
|
||||
});
|
||||
return enabledsubmit;
|
||||
}
|
||||
|
||||
function nav_to_page(pageno) {
|
||||
Y.one('#followingpage').set('value', pageno);
|
||||
|
||||
// Automatically submit the form. We do it this strange way because just
|
||||
// calling form.submit() does not run the form's submit event handlers.
|
||||
var submit = find_enabled_submit();
|
||||
submit.set('name', '');
|
||||
submit.getDOMNode().click();
|
||||
};
|
||||
|
||||
Y.delegate('click', function(e) {
|
||||
if (this.hasClass('thispage')) {
|
||||
return;
|
||||
@ -157,22 +180,20 @@ M.mod_quiz.nav.init = function(Y) {
|
||||
} else {
|
||||
pageno = 0;
|
||||
}
|
||||
Y.one('#followingpage').set('value', pageno);
|
||||
|
||||
var questionidmatch = this.get('href').match(/#q(\d+)/);
|
||||
if (questionidmatch) {
|
||||
form.set('action', form.get('action') + '#q' + questionidmatch[1]);
|
||||
}
|
||||
|
||||
form.submit();
|
||||
nav_to_page(pageno);
|
||||
}, document.body, '.qnbutton');
|
||||
}
|
||||
|
||||
if (Y.one('a.endtestlink')) {
|
||||
Y.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
Y.one('#followingpage').set('value', -1);
|
||||
Y.one('#responseform').submit();
|
||||
nav_to_page(-1);
|
||||
}, 'a.endtestlink');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user