MDL-34741 use 2in3 in mod_quiz

This commit is contained in:
Petr Škoda
2012-08-11 20:40:09 +02:00
parent 7b66b651da
commit f387bb9bb7
3 changed files with 39 additions and 26 deletions
+21 -19
View File
@@ -35,12 +35,12 @@ function quiz_edit_init(Y) {
}, '.quizsavegradesform');
// Add random question dialogue --------------------------------------------
var randomquestiondialog = YAHOO.util.Dom.get('randomquestiondialog');
var randomquestiondialog = Y.YUI2.util.Dom.get('randomquestiondialog');
if (randomquestiondialog) {
YAHOO.util.Dom.get(document.body).appendChild(randomquestiondialog);
Y.YUI2.util.Dom.get(document.body).appendChild(randomquestiondialog);
}
quiz_edit.randomquestiondialog = new YAHOO.widget.Dialog('randomquestiondialog', {
quiz_edit.randomquestiondialog = new Y.YUI2.widget.Dialog('randomquestiondialog', {
modal: true,
width: '100%',
iframe: true,
@@ -58,34 +58,34 @@ function quiz_edit_init(Y) {
}
// Show the form on button click.
YAHOO.util.Event.addListener(quiz_edit_config.dialoglisteners, 'click', function(e) {
Y.YUI2.util.Event.addListener(quiz_edit_config.dialoglisteners, 'click', function(e) {
// Transfer the page number from the button form to the pop-up form.
var addrandombutton = YAHOO.util.Event.getTarget(e);
var addpagehidden = YAHOO.util.Dom.getElementsByClassName('addonpage_formelement', 'input', addrandombutton.form);
var addrandombutton = Y.YUI2.util.Event.getTarget(e);
var addpagehidden = Y.YUI2.util.Dom.getElementsByClassName('addonpage_formelement', 'input', addrandombutton.form);
document.getElementById('rform_qpage').value = addpagehidden[0].value;
// Show the dialogue and stop the default action.
quiz_edit.randomquestiondialog.show();
YAHOO.util.Event.stopEvent(e);
Y.YUI2.util.Event.stopEvent(e);
});
// Make escape close the dialogue.
quiz_edit.randomquestiondialog.cfg.setProperty('keylisteners', [new YAHOO.util.KeyListener(
quiz_edit.randomquestiondialog.cfg.setProperty('keylisteners', [new Y.YUI2.util.KeyListener(
document, {keys:[27]}, function(types, args, obj) { quiz_edit.randomquestiondialog.hide();
})]);
// Make the form cancel button close the dialogue.
YAHOO.util.Event.addListener('id_cancel', 'click', function(e) {
Y.YUI2.util.Event.addListener('id_cancel', 'click', function(e) {
quiz_edit.randomquestiondialog.hide();
YAHOO.util.Event.preventDefault(e);
Y.YUI2.util.Event.preventDefault(e);
});
YAHOO.util.Event.addListener('id_existingcategory', 'click', quiz_yui_workaround);
Y.YUI2.util.Event.addListener('id_existingcategory', 'click', quiz_yui_workaround);
YAHOO.util.Event.addListener('id_newcategory', 'click', quiz_yui_workaround);
Y.YUI2.util.Event.addListener('id_newcategory', 'click', quiz_yui_workaround);
// Repaginate dialogue -----------------------------------------------------
quiz_edit.repaginatedialog = new YAHOO.widget.Dialog('repaginatedialog', {
quiz_edit.repaginatedialog = new Y.YUI2.widget.Dialog('repaginatedialog', {
modal: true,
width: '30em',
iframe: true,
@@ -104,17 +104,17 @@ function quiz_edit_init(Y) {
}
// Show the form on button click.
YAHOO.util.Event.addListener('repaginatecommand', 'click', function() {
Y.YUI2.util.Event.addListener('repaginatecommand', 'click', function() {
quiz_edit.repaginatedialog.show();
});
// Reposition the dialogue when the window resizes. For some reason this was not working automatically.
YAHOO.widget.Overlay.windowResizeEvent.subscribe(function() {
Y.YUI2.widget.Overlay.windowResizeEvent.subscribe(function() {
quiz_edit.repaginatedialog.cfg.setProperty('context', ['repaginatecommand', 'tr', 'br', ['beforeShow']]);
});
// Make escape close the dialogue.
quiz_edit.repaginatedialog.cfg.setProperty('keylisteners', [new YAHOO.util.KeyListener(
quiz_edit.repaginatedialog.cfg.setProperty('keylisteners', [new Y.YUI2.util.KeyListener(
document, {keys:[27]}, function(types, args, obj) { quiz_edit.repaginatedialog.hide();
})]);
@@ -127,18 +127,20 @@ function quiz_edit_init(Y) {
}
function quiz_yui_workaround(e) {
YUI().use('yui2-event', function(Y) {
// YUI does not send the button pressed with the form submission, so copy
// the button name to a hidden input.
var submitbutton = YAHOO.util.Event.getTarget(e);
var submitbutton = Y.YUI2.util.Event.getTarget(e);
var input = document.createElement('input');
input.type = 'hidden';
input.name = submitbutton.name;
input.value = 1;
submitbutton.form.appendChild(input);
});
}
// Initialise everything on the quiz settings form.
function quiz_settings_init() {
function quiz_settings_init(Y) {
var repaginatecheckbox = document.getElementById('id_repaginatenow');
if (!repaginatecheckbox) {
// This checkbox does not appear on the create new quiz form.
@@ -146,7 +148,7 @@ function quiz_settings_init() {
}
var qppselect = document.getElementById('id_questionsperpage');
var qppinitialvalue = qppselect.value;
YAHOO.util.Event.addListener([qppselect, 'id_shufflequestions'] , 'change', function() {
Y.YUI2.util.Event.addListener([qppselect, 'id_shufflequestions'] , 'change', function() {
setTimeout(function() { // Annoyingly, this handler runs before the formlib disabledif code, hence the timeout.
if (!repaginatecheckbox.disabled) {
repaginatecheckbox.checked = qppselect.value != qppinitialvalue;
+8 -4
View File
@@ -402,8 +402,6 @@ $questionbank->process_actions($thispageurl, $cm);
// End of process commands =====================================================
$PAGE->requires->yui2_lib('container');
$PAGE->requires->yui2_lib('dragdrop');
$PAGE->requires->skip_link_to('questionbank',
get_string('skipto', 'access', get_string('questionbank', 'question')));
$PAGE->requires->skip_link_to('quizcontentsblock',
@@ -426,8 +424,14 @@ for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
}
$PAGE->requires->data_for_js('quiz_edit_config', $quizeditconfig);
$PAGE->requires->js('/question/qengine.js');
$PAGE->requires->js('/mod/quiz/edit.js');
$PAGE->requires->js_init_call('quiz_edit_init');
$module = array(
'name' => 'mod_quiz_edit',
'fullpath' => '/mod/quiz/edit.js',
'requires' => array('yui2-dom', 'yui2-event', 'yui2-container'),
'strings' => array(),
'async' => false,
);
$PAGE->requires->js_init_call('quiz_edit_init', null, false, $module);
// Print the tabs to switch mode.
if ($quiz_reordertool) {
+10 -3
View File
@@ -165,9 +165,16 @@ class mod_quiz_mod_form extends moodleform_mod {
$pagegroup[] = $mform->createElement('checkbox', 'repaginatenow', '',
get_string('repaginatenow', 'quiz'), array('id' => 'id_repaginatenow'));
$mform->disabledIf('repaginatenow', 'shufflequestions', 'eq', 1);
$PAGE->requires->yui2_lib('event');
$PAGE->requires->js('/mod/quiz/edit.js');
$PAGE->requires->js_init_call('quiz_settings_init');
$PAGE->requires->js('/question/qengine.js');
$module = array(
'name' => 'mod_quiz_edit',
'fullpath' => '/mod/quiz/edit.js',
'requires' => array('yui2-dom', 'yui2-event', 'yui2-container'),
'strings' => array(),
'async' => false,
);
$PAGE->requires->js_init_call('quiz_settings_init', null, false, $module);
}
$mform->addGroup($pagegroup, 'questionsperpagegrp',