public function __construct(question_bank_view $qbank) {
$this->qbank = $qbank;
$this->init();
+ require_js(array('yui_yahoo','yui_event'));
+ require_js('question/qbank.js');
}
/**
}
protected function get_title() {
- return '<input type="checkbox" disabled="disabled" />';
+ return '<input type="checkbox" disabled="disabled" id="qbheadercheckbox" />';
}
protected function get_title_tip() {
protected function display_content($question, $rowclasses) {
echo '<input title="' . $this->strselect . '" type="checkbox" name="q' .
- $question->id . '" id="checkq' . $question->id . '" value="1" />';
+ $question->id . '" id="checkq' . $question->id . '" value="1"/>';
+ print_js_call('question_bank.init_checkbox_column', array(get_string('selectall'),
+ get_string('deselectall'), 'checkq' . $question->id));
}
public function get_required_fields() {
echo $paging;
echo '</div>';
- echo '<div class="categoryselectallcontainer">';
- if ($caneditall || $canmoveall || $canuseall){
- echo '<a href="javascript:select_all_in(\'TABLE\',null,\'categoryquestions\');">'.$strselectall.'</a> /'.
- ' <a href="javascript:deselect_all_in(\'TABLE\',null,\'categoryquestions\');">'.$strselectnone.'</a>';
- echo '<br />';
- }
- echo "</div>\n";
-
echo '<div class="modulespecificbuttonscontainer">';
if ($caneditall || $canmoveall || $canuseall){
echo '<strong> '.get_string('withselected', 'quiz').':</strong><br />';
--- /dev/null
+// This script is included by question_bank_view in question/editlib.php.
+
+question_bank = {
+ strselectall: '',
+ strdeselectall: '',
+ headercheckbox: null,
+ firstcheckbox: null,
+
+ init_checkbox_column: function(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.
+ YAHOO.util.Event.addListener(question_bank.headercheckbox, 'change', question_bank.header_checkbox_click);
+ },
+
+ header_checkbox_click: function() {
+ if (question_bank.firstcheckbox.checked) {
+ deselect_all_in('TABLE', null, 'categoryquestions');
+ question_bank.headercheckbox.title = question_bank.strselectall;
+ } else {
+ select_all_in('TABLE', null, 'categoryquestions');
+ question_bank.headercheckbox.title = question_bank.strdeselectall;
+ }
+ question_bank.headercheckbox.checked = false;
+ }
+};