mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-32729 Question: Convert remaining Questionbank code to YUI3
This commit is contained in:
parent
ac32c27e24
commit
0b98f8e8e0
@ -441,16 +441,9 @@ 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/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);
|
||||
$PAGE->requires->strings_for_js(array('selectall', 'deselectall'), 'moodle');
|
||||
$PAGE->requires->yui_module('moodle-question-qbankmanager', 'M.question.qbankmanager.init',
|
||||
array('checkq' . $question->id));
|
||||
$this->firstrow = false;
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* JavaScript belonging to question_bank_view.
|
||||
*
|
||||
* This script is included by question_bank_view and other parts of question/editlib.php.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @subpackage questionbank
|
||||
* @copyright 2009 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
question_bank = {
|
||||
strselectall: '',
|
||||
strdeselectall: '',
|
||||
headercheckbox: null,
|
||||
firstcheckbox: null,
|
||||
|
||||
init_checkbox_column: function(Y, strselectall, strdeselectall, firstcbid) {
|
||||
question_bank.strselectall = strselectall;
|
||||
question_bank.strdeselectall = strdeselectall;
|
||||
|
||||
// Find the header checkbox, and initialise it.
|
||||
question_bank.headercheckbox = document.getElementById('qbheadercheckbox');
|
||||
question_bank.headercheckbox.disabled = false;
|
||||
question_bank.headercheckbox.title = strselectall;
|
||||
|
||||
// Find the first real checkbox.
|
||||
question_bank.firstcheckbox = document.getElementById(firstcbid);
|
||||
|
||||
// Add the event handler.
|
||||
Y.YUI2.util.Event.addListener(question_bank.headercheckbox, 'click', question_bank.header_checkbox_click);
|
||||
},
|
||||
|
||||
header_checkbox_click: function() {
|
||||
if (question_bank.firstcheckbox.checked) {
|
||||
select_all_in_element_with_id('categoryquestions', '');
|
||||
question_bank.headercheckbox.title = question_bank.strselectall;
|
||||
} else {
|
||||
select_all_in_element_with_id('categoryquestions', 'checked');
|
||||
question_bank.headercheckbox.title = question_bank.strdeselectall;
|
||||
}
|
||||
question_bank.headercheckbox.checked = false;
|
||||
}
|
||||
};
|
107
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-debug.js
vendored
Normal file
107
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-debug.js
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
YUI.add('moodle-question-qbankmanager', function (Y, NAME) {
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Question Bank Management.
|
||||
*
|
||||
* @package question
|
||||
* @copyright 2014 Andrew Nicols
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Questionbank Management.
|
||||
*
|
||||
* @module moodle-question-qbankmanager
|
||||
*/
|
||||
|
||||
/**
|
||||
* Question Bank Management.
|
||||
*
|
||||
* @class M.question.qbankmanager
|
||||
*/
|
||||
|
||||
var manager = {
|
||||
/**
|
||||
* A reference to the header checkbox.
|
||||
*
|
||||
* @property _header
|
||||
* @type Node
|
||||
* @private
|
||||
*/
|
||||
_header: null,
|
||||
|
||||
/**
|
||||
* The ID of the first checkbox on the page.
|
||||
*
|
||||
* @property _firstCheckboxId
|
||||
* @type String
|
||||
* @private
|
||||
*/
|
||||
_firstCheckboxId: null,
|
||||
|
||||
/**
|
||||
* Set up the Question Bank Manager.
|
||||
*
|
||||
* @method init
|
||||
* @param {String} firstCheckboxId The ID of the first checkbox on the page.
|
||||
*/
|
||||
init: function(firstCheckboxId) {
|
||||
// Find the header checkbox, and set the initial values.
|
||||
this._header = Y.one('#qbheadercheckbox');
|
||||
this._header.setAttrs({
|
||||
disabled: false,
|
||||
title: M.util.get_string('selectall', 'moodle')
|
||||
});
|
||||
|
||||
this._header.on('click', this._headerClick, this);
|
||||
|
||||
// Store the first checkbox details.
|
||||
this._firstCheckboxId = firstCheckboxId;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle toggling of the header checkbox.
|
||||
*
|
||||
* @method _headerClick
|
||||
* @private
|
||||
*/
|
||||
_headerClick: function() {
|
||||
// Get the list of questions we affect.
|
||||
var categoryQuestions = Y.one('#categoryquestions')
|
||||
.all('[type=checkbox],[type=radio]');
|
||||
|
||||
// We base the state of all of the questions on the state of the first.
|
||||
firstCheckbox = Y.one('#' + this._firstCheckboxId);
|
||||
|
||||
if (firstCheckbox.get('checked')) {
|
||||
categoryQuestions.set('checked', false);
|
||||
this._header.setAttribute('title', M.util.get_string('selectall', 'moodle'));
|
||||
} else {
|
||||
categoryQuestions.set('checked', true);
|
||||
this._header.setAttribute('title', M.util.get_string('deselectall', 'moodle'));
|
||||
}
|
||||
|
||||
this._header.set('checked', false);
|
||||
}
|
||||
};
|
||||
|
||||
M.question = M.question || {};
|
||||
M.question.qbankmanager = M.question.qbankmanager || manager;
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["node", "selector-css3"]});
|
1
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-min.js
vendored
Normal file
1
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
YUI.add("moodle-question-qbankmanager",function(e,t){var n={_header:null,_firstCheckboxId:null,init:function(t){this._header=e.one("#qbheadercheckbox"),this._header.setAttrs({disabled:!1,title:M.util.get_string("selectall","moodle")}),this._header.on("click",this._headerClick,this),this._firstCheckboxId=t},_headerClick:function(){var t=e.one("#categoryquestions").all("[type=checkbox],[type=radio]");firstCheckbox=e.one("#"+this._firstCheckboxId),firstCheckbox.get("checked")?(t.set("checked",!1),this._header.setAttribute("title",M.util.get_string("selectall","moodle"))):(t.set("checked",!0),this._header.setAttribute("title",M.util.get_string("deselectall","moodle"))),this._header.set("checked",!1)}};M.question=M.question||{},M.question.qbankmanager=M.question.qbankmanager||n},"@VERSION@",{requires:["node","selector-css3"]});
|
107
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager.js
vendored
Normal file
107
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager.js
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
YUI.add('moodle-question-qbankmanager', function (Y, NAME) {
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Question Bank Management.
|
||||
*
|
||||
* @package question
|
||||
* @copyright 2014 Andrew Nicols
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Questionbank Management.
|
||||
*
|
||||
* @module moodle-question-qbankmanager
|
||||
*/
|
||||
|
||||
/**
|
||||
* Question Bank Management.
|
||||
*
|
||||
* @class M.question.qbankmanager
|
||||
*/
|
||||
|
||||
var manager = {
|
||||
/**
|
||||
* A reference to the header checkbox.
|
||||
*
|
||||
* @property _header
|
||||
* @type Node
|
||||
* @private
|
||||
*/
|
||||
_header: null,
|
||||
|
||||
/**
|
||||
* The ID of the first checkbox on the page.
|
||||
*
|
||||
* @property _firstCheckboxId
|
||||
* @type String
|
||||
* @private
|
||||
*/
|
||||
_firstCheckboxId: null,
|
||||
|
||||
/**
|
||||
* Set up the Question Bank Manager.
|
||||
*
|
||||
* @method init
|
||||
* @param {String} firstCheckboxId The ID of the first checkbox on the page.
|
||||
*/
|
||||
init: function(firstCheckboxId) {
|
||||
// Find the header checkbox, and set the initial values.
|
||||
this._header = Y.one('#qbheadercheckbox');
|
||||
this._header.setAttrs({
|
||||
disabled: false,
|
||||
title: M.util.get_string('selectall', 'moodle')
|
||||
});
|
||||
|
||||
this._header.on('click', this._headerClick, this);
|
||||
|
||||
// Store the first checkbox details.
|
||||
this._firstCheckboxId = firstCheckboxId;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle toggling of the header checkbox.
|
||||
*
|
||||
* @method _headerClick
|
||||
* @private
|
||||
*/
|
||||
_headerClick: function() {
|
||||
// Get the list of questions we affect.
|
||||
var categoryQuestions = Y.one('#categoryquestions')
|
||||
.all('[type=checkbox],[type=radio]');
|
||||
|
||||
// We base the state of all of the questions on the state of the first.
|
||||
firstCheckbox = Y.one('#' + this._firstCheckboxId);
|
||||
|
||||
if (firstCheckbox.get('checked')) {
|
||||
categoryQuestions.set('checked', false);
|
||||
this._header.setAttribute('title', M.util.get_string('selectall', 'moodle'));
|
||||
} else {
|
||||
categoryQuestions.set('checked', true);
|
||||
this._header.setAttribute('title', M.util.get_string('deselectall', 'moodle'));
|
||||
}
|
||||
|
||||
this._header.set('checked', false);
|
||||
}
|
||||
};
|
||||
|
||||
M.question = M.question || {};
|
||||
M.question.qbankmanager = M.question.qbankmanager || manager;
|
||||
|
||||
|
||||
}, '@VERSION@', {"requires": ["node", "selector-css3"]});
|
10
question/yui/src/qbankmanager/build.json
Normal file
10
question/yui/src/qbankmanager/build.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "moodle-question-qbankmanager",
|
||||
"builds": {
|
||||
"moodle-question-qbankmanager": {
|
||||
"jsfiles": [
|
||||
"qbankmanager.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
102
question/yui/src/qbankmanager/js/qbankmanager.js
vendored
Normal file
102
question/yui/src/qbankmanager/js/qbankmanager.js
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Question Bank Management.
|
||||
*
|
||||
* @package question
|
||||
* @copyright 2014 Andrew Nicols
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Questionbank Management.
|
||||
*
|
||||
* @module moodle-question-qbankmanager
|
||||
*/
|
||||
|
||||
/**
|
||||
* Question Bank Management.
|
||||
*
|
||||
* @class M.question.qbankmanager
|
||||
*/
|
||||
|
||||
var manager = {
|
||||
/**
|
||||
* A reference to the header checkbox.
|
||||
*
|
||||
* @property _header
|
||||
* @type Node
|
||||
* @private
|
||||
*/
|
||||
_header: null,
|
||||
|
||||
/**
|
||||
* The ID of the first checkbox on the page.
|
||||
*
|
||||
* @property _firstCheckboxId
|
||||
* @type String
|
||||
* @private
|
||||
*/
|
||||
_firstCheckboxId: null,
|
||||
|
||||
/**
|
||||
* Set up the Question Bank Manager.
|
||||
*
|
||||
* @method init
|
||||
* @param {String} firstCheckboxId The ID of the first checkbox on the page.
|
||||
*/
|
||||
init: function(firstCheckboxId) {
|
||||
// Find the header checkbox, and set the initial values.
|
||||
this._header = Y.one('#qbheadercheckbox');
|
||||
this._header.setAttrs({
|
||||
disabled: false,
|
||||
title: M.util.get_string('selectall', 'moodle')
|
||||
});
|
||||
|
||||
this._header.on('click', this._headerClick, this);
|
||||
|
||||
// Store the first checkbox details.
|
||||
this._firstCheckboxId = firstCheckboxId;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle toggling of the header checkbox.
|
||||
*
|
||||
* @method _headerClick
|
||||
* @private
|
||||
*/
|
||||
_headerClick: function() {
|
||||
// Get the list of questions we affect.
|
||||
var categoryQuestions = Y.one('#categoryquestions')
|
||||
.all('[type=checkbox],[type=radio]');
|
||||
|
||||
// We base the state of all of the questions on the state of the first.
|
||||
firstCheckbox = Y.one('#' + this._firstCheckboxId);
|
||||
|
||||
if (firstCheckbox.get('checked')) {
|
||||
categoryQuestions.set('checked', false);
|
||||
this._header.setAttribute('title', M.util.get_string('selectall', 'moodle'));
|
||||
} else {
|
||||
categoryQuestions.set('checked', true);
|
||||
this._header.setAttribute('title', M.util.get_string('deselectall', 'moodle'));
|
||||
}
|
||||
|
||||
this._header.set('checked', false);
|
||||
}
|
||||
};
|
||||
|
||||
M.question = M.question || {};
|
||||
M.question.qbankmanager = M.question.qbankmanager || manager;
|
8
question/yui/src/qbankmanager/meta/qbankmanager.json
Normal file
8
question/yui/src/qbankmanager/meta/qbankmanager.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"moodle-question-qbankmanager": {
|
||||
"requires": [
|
||||
"node",
|
||||
"selector-css3"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user