MDL-34741 use 2in3 in question bank
This commit is contained in:
+21
-11
@@ -407,9 +407,16 @@ class question_bank_checkbox_column extends question_bank_column_base {
|
||||
echo '<input title="' . $this->strselect . '" type="checkbox" name="q' .
|
||||
$question->id . '" id="checkq' . $question->id . '" value="1"/>';
|
||||
if ($this->firstrow) {
|
||||
$PAGE->requires->js('/question/qbank.js');
|
||||
$PAGE->requires->js_function_call('question_bank.init_checkbox_column', array(get_string('selectall'),
|
||||
get_string('deselectall'), 'checkq' . $question->id));
|
||||
$PAGE->requires->js('/question/qengine.js');
|
||||
$module = array(
|
||||
'name' => 'qbank',
|
||||
'fullpath' => '/question/qbank.js',
|
||||
'requires' => array('yui2-dom', 'yui2-event', 'yui2-container'),
|
||||
'strings' => array(),
|
||||
'async' => false,
|
||||
);
|
||||
$PAGE->requires->js_init_call('question_bank.init_checkbox_column', array(get_string('selectall'),
|
||||
get_string('deselectall'), 'checkq' . $question->id), false, $module);
|
||||
$this->firstrow = false;
|
||||
}
|
||||
}
|
||||
@@ -887,8 +894,6 @@ class question_bank_view {
|
||||
$this->init_column_types();
|
||||
$this->init_columns($this->wanted_columns());
|
||||
$this->init_sort();
|
||||
|
||||
$PAGE->requires->yui2_lib('container');
|
||||
}
|
||||
|
||||
protected function wanted_columns() {
|
||||
@@ -1185,8 +1190,6 @@ class question_bank_view {
|
||||
return;
|
||||
}
|
||||
|
||||
$PAGE->requires->js('/question/qbank.js');
|
||||
|
||||
// Category selection form
|
||||
echo $OUTPUT->heading(get_string('questionbank', 'question'), 2);
|
||||
|
||||
@@ -1744,7 +1747,7 @@ function require_login_in_context($contextorid = null){
|
||||
*/
|
||||
function print_choose_qtype_to_add_form($hiddenparams, array $allowedqtypes = null) {
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
$PAGE->requires->js('/question/qbank.js');
|
||||
|
||||
echo '<div id="chooseqtypehead" class="hd">' . "\n";
|
||||
echo $OUTPUT->heading(get_string('chooseqtypetoadd', 'question'), 3);
|
||||
echo "</div>\n";
|
||||
@@ -1780,7 +1783,16 @@ function print_choose_qtype_to_add_form($hiddenparams, array $allowedqtypes = nu
|
||||
echo '<input type="submit" id="chooseqtypecancel" name="addcancel" value="' . get_string('cancel') . '" />' . "\n";
|
||||
echo "</div></form>\n";
|
||||
echo "</div>\n";
|
||||
$PAGE->requires->js_init_call('qtype_chooser.init', array('chooseqtype'));
|
||||
|
||||
$PAGE->requires->js('/question/qengine.js');
|
||||
$module = array(
|
||||
'name' => 'qbank',
|
||||
'fullpath' => '/question/qbank.js',
|
||||
'requires' => array('yui2-dom', 'yui2-event', 'yui2-container'),
|
||||
'strings' => array(),
|
||||
'async' => false,
|
||||
);
|
||||
$PAGE->requires->js_init_call('qtype_chooser.init', array('chooseqtype'), false, $module);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1821,8 +1833,6 @@ function create_new_question_button($categoryid, $params, $caption, $tooltip = '
|
||||
$url = new moodle_url('/question/addquestion.php', $params);
|
||||
echo $OUTPUT->single_button($url, $caption, 'get', array('disabled'=>$disabled, 'title'=>$tooltip));
|
||||
|
||||
$PAGE->requires->yui2_lib('dragdrop');
|
||||
$PAGE->requires->yui2_lib('container');
|
||||
if (!$choiceformprinted) {
|
||||
echo '<div id="qtypechoicecontainer">';
|
||||
print_choose_qtype_to_add_form(array());
|
||||
|
||||
+26
-19
@@ -31,7 +31,7 @@ question_bank = {
|
||||
headercheckbox: null,
|
||||
firstcheckbox: null,
|
||||
|
||||
init_checkbox_column: function(strselectall, strdeselectall, firstcbid) {
|
||||
init_checkbox_column: function(Y, strselectall, strdeselectall, firstcbid) {
|
||||
question_bank.strselectall = strselectall;
|
||||
question_bank.strdeselectall = strdeselectall;
|
||||
|
||||
@@ -44,7 +44,7 @@ question_bank = {
|
||||
question_bank.firstcheckbox = document.getElementById(firstcbid);
|
||||
|
||||
// Add the event handler.
|
||||
YAHOO.util.Event.addListener(question_bank.headercheckbox, 'click', question_bank.header_checkbox_click);
|
||||
Y.YUI2.util.Event.addListener(question_bank.headercheckbox, 'click', question_bank.header_checkbox_click);
|
||||
},
|
||||
|
||||
header_checkbox_click: function() {
|
||||
@@ -66,48 +66,53 @@ qtype_chooser = {
|
||||
labels: [],
|
||||
container: null,
|
||||
submitbutton: null,
|
||||
yui3: null,
|
||||
|
||||
init: function(Y, boxid) {
|
||||
// Store Y reference.
|
||||
qtype_chooser.yui3 = Y;
|
||||
// Find the radio buttons.
|
||||
qtype_chooser.radiobuttons = YAHOO.util.Dom.getElementsBy(
|
||||
qtype_chooser.radiobuttons = Y.YUI2.util.Dom.getElementsBy(
|
||||
function(el) { return el.type == 'radio'; }, 'input' , boxid);
|
||||
qtype_chooser.labels = YAHOO.util.Dom.getElementsByClassName('qtypeoption', 'div', boxid);
|
||||
qtype_chooser.labels = Y.YUI2.util.Dom.getElementsByClassName('qtypeoption', 'div', boxid);
|
||||
|
||||
// Find the submit button.
|
||||
qtype_chooser.submitbutton = document.getElementById(boxid + '_submit');
|
||||
qtype_chooser.enable_disable_submit();
|
||||
|
||||
// Add the event handlers.
|
||||
YAHOO.util.Event.addListener(boxid, 'click', qtype_chooser.enable_disable_submit);
|
||||
YAHOO.util.Event.addListener(boxid, 'key_down', qtype_chooser.enable_disable_submit);
|
||||
YAHOO.util.Event.addListener(boxid, 'key_up', qtype_chooser.enable_disable_submit);
|
||||
YAHOO.util.Event.addListener(boxid, 'dblclick', function(e) {
|
||||
Y.YUI2.util.Event.addListener(boxid, 'click', qtype_chooser.enable_disable_submit);
|
||||
Y.YUI2.util.Event.addListener(boxid, 'key_down', qtype_chooser.enable_disable_submit);
|
||||
Y.YUI2.util.Event.addListener(boxid, 'key_up', qtype_chooser.enable_disable_submit);
|
||||
Y.YUI2.util.Event.addListener(boxid, 'dblclick', function(e) {
|
||||
if (!qtype_chooser.submitbutton.disabled) {
|
||||
M.core_scroll_manager.save_scroll_pos(Y, Y.one(qtype_chooser.submitbutton));
|
||||
qtype_chooser.submitbutton.form.submit();
|
||||
}
|
||||
});
|
||||
|
||||
YAHOO.util.Event.onDOMReady(qtype_chooser.init_container);
|
||||
Y.YUI2.util.Event.onDOMReady(qtype_chooser.init_container);
|
||||
Y.on('submit', function(e) {
|
||||
M.core_scroll_manager.save_scroll_pos(Y, Y.one(qtype_chooser.submitbutton));
|
||||
}, qtype_chooser.submitbutton.form);
|
||||
},
|
||||
|
||||
enable_disable_submit: function() {
|
||||
var Y = qtype_chooser.yui3;
|
||||
var ok = false;
|
||||
for (var i = 0; i < qtype_chooser.radiobuttons.length; i++) {
|
||||
if (qtype_chooser.radiobuttons[i].checked) {
|
||||
ok = true;
|
||||
YAHOO.util.Dom.addClass(qtype_chooser.labels[i], 'selected');
|
||||
Y.YUI2.util.Dom.addClass(qtype_chooser.labels[i], 'selected');
|
||||
} else {
|
||||
YAHOO.util.Dom.removeClass(qtype_chooser.labels[i], 'selected');
|
||||
Y.YUI2.util.Dom.removeClass(qtype_chooser.labels[i], 'selected');
|
||||
}
|
||||
}
|
||||
qtype_chooser.submitbutton.disabled = !ok;
|
||||
},
|
||||
|
||||
init_container: function() {
|
||||
var Y = qtype_chooser.yui3;
|
||||
if (!document.getElementById('qtypechoicecontainer')) {
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +120,7 @@ qtype_chooser = {
|
||||
qtypechoicecontainer.style.display = 'block';
|
||||
qtypechoicecontainer.parentNode.removeChild(qtypechoicecontainer);
|
||||
document.body.appendChild(qtypechoicecontainer);
|
||||
qtype_chooser.container = new YAHOO.widget.Dialog(qtypechoicecontainer, {
|
||||
qtype_chooser.container = new Y.YUI2.widget.Dialog(qtypechoicecontainer, {
|
||||
constraintoviewport: true,
|
||||
visible: false,
|
||||
modal: true,
|
||||
@@ -128,36 +133,38 @@ qtype_chooser = {
|
||||
});
|
||||
qtype_chooser.container.render();
|
||||
|
||||
YAHOO.util.Event.addListener('chooseqtypecancel', 'click', qtype_chooser.cancel_popup);
|
||||
Y.YUI2.util.Event.addListener('chooseqtypecancel', 'click', qtype_chooser.cancel_popup);
|
||||
|
||||
var addforms = YAHOO.util.Dom.getElementsBy(function(el) {
|
||||
var addforms = Y.YUI2.util.Dom.getElementsBy(function(el) {
|
||||
return /question\/addquestion\.php/.test(el.action); }, 'form', document.body);
|
||||
for (var i = 0; i < addforms.length; i++) {
|
||||
YAHOO.util.Event.addListener(addforms[i], 'submit', qtype_chooser.add_button_click);
|
||||
Y.YUI2.util.Event.addListener(addforms[i], 'submit', qtype_chooser.add_button_click);
|
||||
}
|
||||
},
|
||||
|
||||
add_button_click: function(e) {
|
||||
var Y = qtype_chooser.yui3;
|
||||
var form = document.getElementById('qtypeformdiv');
|
||||
|
||||
var oldhidden = YAHOO.util.Dom.getElementsBy(
|
||||
var oldhidden = Y.YUI2.util.Dom.getElementsBy(
|
||||
function(el) { return el.type == 'hidden'; }, 'input', form);
|
||||
for (var i = 0; i < oldhidden.length; i++) {
|
||||
oldhidden[i].parentNode.removeChild(oldhidden[i]);
|
||||
}
|
||||
|
||||
var wantedhidden = YAHOO.util.Dom.getElementsBy(
|
||||
var wantedhidden = Y.YUI2.util.Dom.getElementsBy(
|
||||
function(el) { return el.type == 'hidden'; }, 'input', this);
|
||||
for (i = 0; i < wantedhidden.length; i++) {
|
||||
form.appendChild(wantedhidden[i].cloneNode(true));
|
||||
}
|
||||
|
||||
qtype_chooser.container.show();
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
Y.YUI2.util.Event.preventDefault(e);
|
||||
},
|
||||
|
||||
cancel_popup: function(e) {
|
||||
var Y = qtype_chooser.yui3;
|
||||
qtype_chooser.container.hide();
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
Y.YUI2.util.Event.preventDefault(e);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user