MDL-61135 mod_quiz: remove YUI question bank dialogue

This commit is contained in:
Ryan Wyllie 2018-02-02 03:54:06 +00:00
parent fff033322a
commit e6743b4b80
8 changed files with 3 additions and 747 deletions

View File

@ -1,49 +0,0 @@
<?php
// 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/>.
/**
* Ajax script to update the contents of the question bank dialogue.
*
* @package mod_quiz
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('AJAX_SCRIPT', true);
require_once(__DIR__ . '/../../config.php');
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
require_once($CFG->dirroot . '/question/editlib.php');
list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) =
question_edit_setup('editq', '/mod/quiz/edit.php', true);
// Get the course object and related bits.
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
require_capability('mod/quiz:manage', $contexts->lowest());
// Create quiz question bank view.
$questionbank = new mod_quiz\question\bank\custom_view($contexts, $thispageurl, $course, $cm, $quiz);
$questionbank->set_quiz_has_attempts(quiz_has_attempts($quiz->id));
// Output.
$output = $PAGE->get_renderer('mod_quiz', 'edit');
$contents = $output->question_bank_contents($questionbank, $pagevars);
echo json_encode(array(
'status' => 'OK',
'contents' => $contents,
));

View File

@ -1,5 +1,8 @@
This files describes API changes in the quiz code.
=== 3.5 ===
* Removed questionbank.ajax.php. Please use the quiz_question_bank fragment instead.
=== 3.3.2 ===
* quiz_refresh_events() Now takes two additional parameters to refine the update to a specific instance. This function

View File

@ -1,231 +0,0 @@
YUI.add('moodle-mod_quiz-quizquestionbank', 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/>.
/**
* Add questions from question bank functionality for a popup in quiz editing page.
*
* @package mod_quiz
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
var CSS = {
QBANKLOADING: 'div.questionbankloading',
ADDQUESTIONLINKS: '.menu [data-action="questionbank"]',
ADDTOQUIZCONTAINER: 'td.addtoquizaction',
PREVIEWCONTAINER: 'td.previewaction',
SEARCHOPTIONS: '#advancedsearch'
};
var PARAMS = {
PAGE: 'addonpage',
HEADER: 'header'
};
var POPUP = function() {
POPUP.superclass.constructor.apply(this, arguments);
};
Y.extend(POPUP, Y.Base, {
loadingDiv: '',
dialogue: null,
addonpage: 0,
searchRegionInitialised: false,
create_dialogue: function() {
// Create a dialogue on the page and hide it.
var config = {
headerContent: '',
bodyContent: Y.one(CSS.QBANKLOADING),
draggable: true,
modal: true,
centered: true,
width: null,
visible: false,
postmethod: 'form',
footerContent: null,
extraClasses: ['mod_quiz_qbank_dialogue']
};
this.dialogue = new M.core.dialogue(config);
this.dialogue.bodyNode.delegate('click', this.link_clicked, 'a[href]', this);
this.dialogue.hide();
this.loadingDiv = this.dialogue.bodyNode.getHTML();
Y.later(100, this, function() {
this.load_content(window.location.search);
});
},
initializer: function() {
if (!Y.one(CSS.QBANKLOADING)) {
return;
}
this.create_dialogue();
Y.one('body').delegate('click', this.display_dialogue, CSS.ADDQUESTIONLINKS, this);
},
display_dialogue: function(e) {
e.preventDefault();
this.dialogue.set('headerContent', e.currentTarget.getData(PARAMS.HEADER));
this.addonpage = e.currentTarget.getData(PARAMS.PAGE);
var controlsDiv = this.dialogue.bodyNode.one('.modulespecificbuttonscontainer');
if (controlsDiv) {
var hidden = controlsDiv.one('input[name=addonpage]');
if (!hidden) {
hidden = controlsDiv.appendChild('<input type="hidden" name="addonpage">');
}
hidden.set('value', this.addonpage);
}
this.initialiseSearchRegion();
this.dialogue.show();
},
load_content: function(queryString) {
Y.log('Starting load.', 'debug', 'moodle-mod_quiz-quizquestionbank');
this.dialogue.bodyNode.append(this.loadingDiv);
// If to support old IE.
if (window.history.replaceState) {
window.history.replaceState(null, '', M.cfg.wwwroot + '/mod/quiz/edit.php' + queryString);
}
Y.io(M.cfg.wwwroot + '/mod/quiz/questionbank.ajax.php' + queryString, {
method: 'GET',
on: {
success: this.load_done,
failure: this.load_failed
},
context: this
});
Y.log('Load request sent.', 'debug', 'moodle-mod_quiz-quizquestionbank');
},
load_done: function(transactionid, response) {
var result = JSON.parse(response.responseText);
if (!result.status || result.status !== 'OK') {
// Because IIS is useless, Moodle can't send proper HTTP response
// codes, so we have to detect failures manually.
this.load_failed(transactionid, response);
return;
}
Y.log('Load completed.', 'debug', 'moodle-mod_quiz-quizquestionbank');
this.dialogue.bodyNode.setHTML(result.contents);
Y.use('moodle-question-chooser', function() {
M.question.init_chooser({});
});
this.dialogue.bodyNode.one('form').delegate('change', this.options_changed, '.searchoptions', this);
if (this.dialogue.visible) {
Y.later(0, this.dialogue, this.dialogue.centerDialogue);
}
M.question.qbankmanager.init();
this.searchRegionInitialised = false;
if (this.dialogue.get('visible')) {
this.initialiseSearchRegion();
}
this.dialogue.fire('widget:contentUpdate');
// TODO MDL-47602 really, the base class should listen for the even fired
// on the previous line, and fix things like makeResponsive.
// However, it does not. So the next two lines are a hack to fix up
// display issues (e.g. overall scrollbars on the page). Once the base class
// is fixed, this comment and the following four lines should be deleted.
if (this.dialogue.get('visible')) {
this.dialogue.hide();
this.dialogue.show();
}
},
load_failed: function() {
Y.log('Load failed.', 'debug', 'moodle-mod_quiz-quizquestionbank');
},
link_clicked: function(e) {
// Add question to quiz. mofify the URL, then let it work as normal.
if (e.currentTarget.ancestor(CSS.ADDTOQUIZCONTAINER)) {
e.currentTarget.set('href', e.currentTarget.get('href') + '&addonpage=' + this.addonpage);
return;
}
// Question preview. Needs to open in a pop-up.
if (e.currentTarget.ancestor(CSS.PREVIEWCONTAINER)) {
window.openpopup(e, {
url: e.currentTarget.get('href'),
name: 'questionpreview',
options: 'height=600,width=800,top=0,left=0,menubar=0,location=0,scrollbars,' +
'resizable,toolbar,status,directories=0,fullscreen=0,dependent'
});
return;
}
// Click on expand/collaspse search-options. Has its own handler.
// We should not interfere.
if (e.currentTarget.ancestor(CSS.SEARCHOPTIONS)) {
return;
}
// Anything else means reload the pop-up contents.
e.preventDefault();
this.load_content(e.currentTarget.get('search'));
},
options_changed: function(e) {
e.preventDefault();
this.load_content('?' + Y.IO.stringify(e.currentTarget.get('form')));
},
initialiseSearchRegion: function() {
if (this.searchRegionInitialised === true) {
return;
}
if (!Y.one(CSS.SEARCHOPTIONS)) {
return;
}
M.util.init_collapsible_region(Y, "advancedsearch", "question_bank_advanced_search",
M.util.get_string('clicktohideshow', 'moodle'));
this.searchRegionInitialised = true;
}
});
M.mod_quiz = M.mod_quiz || {};
M.mod_quiz.quizquestionbank = M.mod_quiz.quizquestionbank || {};
M.mod_quiz.quizquestionbank.init = function() {
return new POPUP();
};
}, '@VERSION@', {
"requires": [
"base",
"event",
"node",
"io",
"io-form",
"yui-later",
"moodle-question-qbankmanager",
"moodle-core-notification-dialogue"
]
});

View File

@ -1 +0,0 @@
YUI.add("moodle-mod_quiz-quizquestionbank",function(e,t){var n={QBANKLOADING:"div.questionbankloading",ADDQUESTIONLINKS:'.menu [data-action="questionbank"]',ADDTOQUIZCONTAINER:"td.addtoquizaction",PREVIEWCONTAINER:"td.previewaction",SEARCHOPTIONS:"#advancedsearch"},r={PAGE:"addonpage",HEADER:"header"},i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,e.Base,{loadingDiv:"",dialogue:null,addonpage:0,searchRegionInitialised:!1,create_dialogue:function(){var t={headerContent:"",bodyContent:e.one(n.QBANKLOADING),draggable:!0,modal:!0,centered:!0,width:null,visible:!1,postmethod:"form",footerContent:null,extraClasses:["mod_quiz_qbank_dialogue"]};this.dialogue=new M.core.dialogue(t),this.dialogue.bodyNode.delegate("click",this.link_clicked,"a[href]",this),this.dialogue.hide(),this.loadingDiv=this.dialogue.bodyNode.getHTML(),e.later(100,this,function(){this.load_content(window.location.search)})},initializer:function(){if(!e.one(n.QBANKLOADING))return;this.create_dialogue(),e.one("body").delegate("click",this.display_dialogue,n.ADDQUESTIONLINKS,this)},display_dialogue:function(e){e.preventDefault(),this.dialogue.set("headerContent",e.currentTarget.getData(r.HEADER)),this.addonpage=e.currentTarget.getData(r.PAGE);var t=this.dialogue.bodyNode.one(".modulespecificbuttonscontainer");if(t){var n=t.one("input[name=addonpage]");n||(n=t.appendChild('<input type="hidden" name="addonpage">')),n.set("value",this.addonpage)}this.initialiseSearchRegion(),this.dialogue.show()},load_content:function(t){this.dialogue.bodyNode.append(this.loadingDiv),window.history.replaceState&&window.history.replaceState(null,"",M.cfg.wwwroot+"/mod/quiz/edit.php"+t),e.io(M.cfg.wwwroot+"/mod/quiz/questionbank.ajax.php"+t,{method:"GET",on:{success:this.load_done,failure:this.load_failed},context:this})},load_done:function(t,n){var r=JSON.parse(n.responseText);if(!r.status||r.status!=="OK"){this.load_failed(t,n);return}this.dialogue.bodyNode.setHTML(r.contents),e.use("moodle-question-chooser",function(){M.question.init_chooser({})}),this.dialogue.bodyNode.one("form").delegate("change",this.options_changed,".searchoptions",this),this.dialogue.visible&&e.later(0,this.dialogue,this.dialogue.centerDialogue),M.question.qbankmanager.init(),this.searchRegionInitialised=!1,this.dialogue.get("visible")&&this.initialiseSearchRegion(),this.dialogue.fire("widget:contentUpdate"),this.dialogue.get("visible")&&(this.dialogue.hide(),this.dialogue.show())},load_failed:function(){},link_clicked:function(e){if(e.currentTarget.ancestor(n.ADDTOQUIZCONTAINER)){e.currentTarget.set("href",e.currentTarget.get("href")+"&addonpage="+this.addonpage);return}if(e.currentTarget.ancestor(n.PREVIEWCONTAINER)){window.openpopup(e,{url:e.currentTarget.get("href"),name:"questionpreview",options:"height=600,width=800,top=0,left=0,menubar=0,location=0,scrollbars,resizable,toolbar,status,directories=0,fullscreen=0,dependent"});return}if(e.currentTarget.ancestor(n.SEARCHOPTIONS))return;e.preventDefault(),this.load_content(e.currentTarget.get("search"))},options_changed:function(t){t.preventDefault(),this.load_content("?"+e.IO.stringify(t.currentTarget.get("form")))},initialiseSearchRegion:function(){if(this.searchRegionInitialised===!0)return;if(!e.one(n.SEARCHOPTIONS))return;M.util.init_collapsible_region(e,"advancedsearch","question_bank_advanced_search",M.util.get_string("clicktohideshow","moodle")),this.searchRegionInitialised=!0}}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.quizquestionbank=M.mod_quiz.quizquestionbank||{},M.mod_quiz.quizquestionbank.init=function(){return new i}},"@VERSION@",{requires:["base","event","node","io","io-form","yui-later","moodle-question-qbankmanager","moodle-core-notification-dialogue"]});

View File

@ -1,227 +0,0 @@
YUI.add('moodle-mod_quiz-quizquestionbank', 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/>.
/**
* Add questions from question bank functionality for a popup in quiz editing page.
*
* @package mod_quiz
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
var CSS = {
QBANKLOADING: 'div.questionbankloading',
ADDQUESTIONLINKS: '.menu [data-action="questionbank"]',
ADDTOQUIZCONTAINER: 'td.addtoquizaction',
PREVIEWCONTAINER: 'td.previewaction',
SEARCHOPTIONS: '#advancedsearch'
};
var PARAMS = {
PAGE: 'addonpage',
HEADER: 'header'
};
var POPUP = function() {
POPUP.superclass.constructor.apply(this, arguments);
};
Y.extend(POPUP, Y.Base, {
loadingDiv: '',
dialogue: null,
addonpage: 0,
searchRegionInitialised: false,
create_dialogue: function() {
// Create a dialogue on the page and hide it.
var config = {
headerContent: '',
bodyContent: Y.one(CSS.QBANKLOADING),
draggable: true,
modal: true,
centered: true,
width: null,
visible: false,
postmethod: 'form',
footerContent: null,
extraClasses: ['mod_quiz_qbank_dialogue']
};
this.dialogue = new M.core.dialogue(config);
this.dialogue.bodyNode.delegate('click', this.link_clicked, 'a[href]', this);
this.dialogue.hide();
this.loadingDiv = this.dialogue.bodyNode.getHTML();
Y.later(100, this, function() {
this.load_content(window.location.search);
});
},
initializer: function() {
if (!Y.one(CSS.QBANKLOADING)) {
return;
}
this.create_dialogue();
Y.one('body').delegate('click', this.display_dialogue, CSS.ADDQUESTIONLINKS, this);
},
display_dialogue: function(e) {
e.preventDefault();
this.dialogue.set('headerContent', e.currentTarget.getData(PARAMS.HEADER));
this.addonpage = e.currentTarget.getData(PARAMS.PAGE);
var controlsDiv = this.dialogue.bodyNode.one('.modulespecificbuttonscontainer');
if (controlsDiv) {
var hidden = controlsDiv.one('input[name=addonpage]');
if (!hidden) {
hidden = controlsDiv.appendChild('<input type="hidden" name="addonpage">');
}
hidden.set('value', this.addonpage);
}
this.initialiseSearchRegion();
this.dialogue.show();
},
load_content: function(queryString) {
this.dialogue.bodyNode.append(this.loadingDiv);
// If to support old IE.
if (window.history.replaceState) {
window.history.replaceState(null, '', M.cfg.wwwroot + '/mod/quiz/edit.php' + queryString);
}
Y.io(M.cfg.wwwroot + '/mod/quiz/questionbank.ajax.php' + queryString, {
method: 'GET',
on: {
success: this.load_done,
failure: this.load_failed
},
context: this
});
},
load_done: function(transactionid, response) {
var result = JSON.parse(response.responseText);
if (!result.status || result.status !== 'OK') {
// Because IIS is useless, Moodle can't send proper HTTP response
// codes, so we have to detect failures manually.
this.load_failed(transactionid, response);
return;
}
this.dialogue.bodyNode.setHTML(result.contents);
Y.use('moodle-question-chooser', function() {
M.question.init_chooser({});
});
this.dialogue.bodyNode.one('form').delegate('change', this.options_changed, '.searchoptions', this);
if (this.dialogue.visible) {
Y.later(0, this.dialogue, this.dialogue.centerDialogue);
}
M.question.qbankmanager.init();
this.searchRegionInitialised = false;
if (this.dialogue.get('visible')) {
this.initialiseSearchRegion();
}
this.dialogue.fire('widget:contentUpdate');
// TODO MDL-47602 really, the base class should listen for the even fired
// on the previous line, and fix things like makeResponsive.
// However, it does not. So the next two lines are a hack to fix up
// display issues (e.g. overall scrollbars on the page). Once the base class
// is fixed, this comment and the following four lines should be deleted.
if (this.dialogue.get('visible')) {
this.dialogue.hide();
this.dialogue.show();
}
},
load_failed: function() {
},
link_clicked: function(e) {
// Add question to quiz. mofify the URL, then let it work as normal.
if (e.currentTarget.ancestor(CSS.ADDTOQUIZCONTAINER)) {
e.currentTarget.set('href', e.currentTarget.get('href') + '&addonpage=' + this.addonpage);
return;
}
// Question preview. Needs to open in a pop-up.
if (e.currentTarget.ancestor(CSS.PREVIEWCONTAINER)) {
window.openpopup(e, {
url: e.currentTarget.get('href'),
name: 'questionpreview',
options: 'height=600,width=800,top=0,left=0,menubar=0,location=0,scrollbars,' +
'resizable,toolbar,status,directories=0,fullscreen=0,dependent'
});
return;
}
// Click on expand/collaspse search-options. Has its own handler.
// We should not interfere.
if (e.currentTarget.ancestor(CSS.SEARCHOPTIONS)) {
return;
}
// Anything else means reload the pop-up contents.
e.preventDefault();
this.load_content(e.currentTarget.get('search'));
},
options_changed: function(e) {
e.preventDefault();
this.load_content('?' + Y.IO.stringify(e.currentTarget.get('form')));
},
initialiseSearchRegion: function() {
if (this.searchRegionInitialised === true) {
return;
}
if (!Y.one(CSS.SEARCHOPTIONS)) {
return;
}
M.util.init_collapsible_region(Y, "advancedsearch", "question_bank_advanced_search",
M.util.get_string('clicktohideshow', 'moodle'));
this.searchRegionInitialised = true;
}
});
M.mod_quiz = M.mod_quiz || {};
M.mod_quiz.quizquestionbank = M.mod_quiz.quizquestionbank || {};
M.mod_quiz.quizquestionbank.init = function() {
return new POPUP();
};
}, '@VERSION@', {
"requires": [
"base",
"event",
"node",
"io",
"io-form",
"yui-later",
"moodle-question-qbankmanager",
"moodle-core-notification-dialogue"
]
});

View File

@ -1,10 +0,0 @@
{
"name": "moodle-mod_quiz-quizquestionbank",
"builds": {
"moodle-mod_quiz-quizquestionbank": {
"jsfiles": [
"quizquestionbank.js"
]
}
}
}

View File

@ -1,215 +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/>.
/**
* Add questions from question bank functionality for a popup in quiz editing page.
*
* @package mod_quiz
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
var CSS = {
QBANKLOADING: 'div.questionbankloading',
ADDQUESTIONLINKS: '.menu [data-action="questionbank"]',
ADDTOQUIZCONTAINER: 'td.addtoquizaction',
PREVIEWCONTAINER: 'td.previewaction',
SEARCHOPTIONS: '#advancedsearch'
};
var PARAMS = {
PAGE: 'addonpage',
HEADER: 'header'
};
var POPUP = function() {
POPUP.superclass.constructor.apply(this, arguments);
};
Y.extend(POPUP, Y.Base, {
loadingDiv: '',
dialogue: null,
addonpage: 0,
searchRegionInitialised: false,
create_dialogue: function() {
// Create a dialogue on the page and hide it.
var config = {
headerContent: '',
bodyContent: Y.one(CSS.QBANKLOADING),
draggable: true,
modal: true,
centered: true,
width: null,
visible: false,
postmethod: 'form',
footerContent: null,
extraClasses: ['mod_quiz_qbank_dialogue']
};
this.dialogue = new M.core.dialogue(config);
this.dialogue.bodyNode.delegate('click', this.link_clicked, 'a[href]', this);
this.dialogue.hide();
this.loadingDiv = this.dialogue.bodyNode.getHTML();
Y.later(100, this, function() {
this.load_content(window.location.search);
});
},
initializer: function() {
if (!Y.one(CSS.QBANKLOADING)) {
return;
}
this.create_dialogue();
Y.one('body').delegate('click', this.display_dialogue, CSS.ADDQUESTIONLINKS, this);
},
display_dialogue: function(e) {
e.preventDefault();
this.dialogue.set('headerContent', e.currentTarget.getData(PARAMS.HEADER));
this.addonpage = e.currentTarget.getData(PARAMS.PAGE);
var controlsDiv = this.dialogue.bodyNode.one('.modulespecificbuttonscontainer');
if (controlsDiv) {
var hidden = controlsDiv.one('input[name=addonpage]');
if (!hidden) {
hidden = controlsDiv.appendChild('<input type="hidden" name="addonpage">');
}
hidden.set('value', this.addonpage);
}
this.initialiseSearchRegion();
this.dialogue.show();
},
load_content: function(queryString) {
Y.log('Starting load.', 'debug', 'moodle-mod_quiz-quizquestionbank');
this.dialogue.bodyNode.append(this.loadingDiv);
// If to support old IE.
if (window.history.replaceState) {
window.history.replaceState(null, '', M.cfg.wwwroot + '/mod/quiz/edit.php' + queryString);
}
Y.io(M.cfg.wwwroot + '/mod/quiz/questionbank.ajax.php' + queryString, {
method: 'GET',
on: {
success: this.load_done,
failure: this.load_failed
},
context: this
});
Y.log('Load request sent.', 'debug', 'moodle-mod_quiz-quizquestionbank');
},
load_done: function(transactionid, response) {
var result = JSON.parse(response.responseText);
if (!result.status || result.status !== 'OK') {
// Because IIS is useless, Moodle can't send proper HTTP response
// codes, so we have to detect failures manually.
this.load_failed(transactionid, response);
return;
}
Y.log('Load completed.', 'debug', 'moodle-mod_quiz-quizquestionbank');
this.dialogue.bodyNode.setHTML(result.contents);
Y.use('moodle-question-chooser', function() {
M.question.init_chooser({});
});
this.dialogue.bodyNode.one('form').delegate('change', this.options_changed, '.searchoptions', this);
if (this.dialogue.visible) {
Y.later(0, this.dialogue, this.dialogue.centerDialogue);
}
M.question.qbankmanager.init();
this.searchRegionInitialised = false;
if (this.dialogue.get('visible')) {
this.initialiseSearchRegion();
}
this.dialogue.fire('widget:contentUpdate');
// TODO MDL-47602 really, the base class should listen for the even fired
// on the previous line, and fix things like makeResponsive.
// However, it does not. So the next two lines are a hack to fix up
// display issues (e.g. overall scrollbars on the page). Once the base class
// is fixed, this comment and the following four lines should be deleted.
if (this.dialogue.get('visible')) {
this.dialogue.hide();
this.dialogue.show();
}
},
load_failed: function() {
Y.log('Load failed.', 'debug', 'moodle-mod_quiz-quizquestionbank');
},
link_clicked: function(e) {
// Add question to quiz. mofify the URL, then let it work as normal.
if (e.currentTarget.ancestor(CSS.ADDTOQUIZCONTAINER)) {
e.currentTarget.set('href', e.currentTarget.get('href') + '&addonpage=' + this.addonpage);
return;
}
// Question preview. Needs to open in a pop-up.
if (e.currentTarget.ancestor(CSS.PREVIEWCONTAINER)) {
window.openpopup(e, {
url: e.currentTarget.get('href'),
name: 'questionpreview',
options: 'height=600,width=800,top=0,left=0,menubar=0,location=0,scrollbars,' +
'resizable,toolbar,status,directories=0,fullscreen=0,dependent'
});
return;
}
// Click on expand/collaspse search-options. Has its own handler.
// We should not interfere.
if (e.currentTarget.ancestor(CSS.SEARCHOPTIONS)) {
return;
}
// Anything else means reload the pop-up contents.
e.preventDefault();
this.load_content(e.currentTarget.get('search'));
},
options_changed: function(e) {
e.preventDefault();
this.load_content('?' + Y.IO.stringify(e.currentTarget.get('form')));
},
initialiseSearchRegion: function() {
if (this.searchRegionInitialised === true) {
return;
}
if (!Y.one(CSS.SEARCHOPTIONS)) {
return;
}
M.util.init_collapsible_region(Y, "advancedsearch", "question_bank_advanced_search",
M.util.get_string('clicktohideshow', 'moodle'));
this.searchRegionInitialised = true;
}
});
M.mod_quiz = M.mod_quiz || {};
M.mod_quiz.quizquestionbank = M.mod_quiz.quizquestionbank || {};
M.mod_quiz.quizquestionbank.init = function() {
return new POPUP();
};

View File

@ -1,14 +0,0 @@
{
"moodle-mod_quiz-quizquestionbank": {
"requires": [
"base",
"event",
"node",
"io",
"io-form",
"yui-later",
"moodle-question-qbankmanager",
"moodle-core-notification-dialogue"
]
}
}