mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-55797 mod_quiz: Convert question chooser to template
Part of MDL-55071
This commit is contained in:
parent
891750bcfa
commit
9189888989
@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use \mod_quiz\structure;
|
||||
use \html_writer;
|
||||
use renderable;
|
||||
|
||||
/**
|
||||
* Renderer outputting the quiz editing UI.
|
||||
@ -102,7 +103,6 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
|
||||
// Include the question chooser.
|
||||
$output .= $this->question_chooser();
|
||||
$this->page->requires->yui_module('moodle-mod_quiz-questionchooser', 'M.mod_quiz.init_questionchooser');
|
||||
}
|
||||
|
||||
return $output;
|
||||
@ -932,13 +932,23 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
return html_writer::span($output, 'instancemaxmarkcontainer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the question chooser.
|
||||
*
|
||||
* @param renderable
|
||||
* @return string
|
||||
*/
|
||||
public function render_question_chooser(renderable $chooser) {
|
||||
return $this->render_from_template('mod_quiz/question_chooser', $chooser->export_for_template($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the question type chooser dialogue.
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function question_chooser() {
|
||||
$container = html_writer::div(print_choose_qtype_to_add_form(array(), null, false), '',
|
||||
array('id' => 'qtypechoicecontainer'));
|
||||
$chooser = \mod_quiz\output\question_chooser::get($this->page->course, [], null);
|
||||
$container = html_writer::div($this->render($chooser), '', array('id' => 'qtypechoicecontainer'));
|
||||
return html_writer::div($container, 'createnewquestion');
|
||||
}
|
||||
|
||||
|
36
mod/quiz/classes/output/question_chooser.php
Normal file
36
mod/quiz/classes/output/question_chooser.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* The question_chooser renderable.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @copyright 2016 Frédéric Massart - FMCorz.net
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_quiz\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The question_chooser renderable class.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @copyright 2016 Frédéric Massart - FMCorz.net
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class question_chooser extends \core_question\output\qbank_chooser {
|
||||
}
|
29
mod/quiz/templates/question_chooser.mustache
Normal file
29
mod/quiz/templates/question_chooser.mustache
Normal file
@ -0,0 +1,29 @@
|
||||
{{!
|
||||
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 chooser.
|
||||
}}
|
||||
{{> core/chooser }}
|
||||
{{#js}}
|
||||
require([
|
||||
'core/yui'
|
||||
], function(Y) {
|
||||
Y.use('moodle-mod_quiz-questionchooser', function() {
|
||||
M.mod_quiz.init_questionchooser();
|
||||
});
|
||||
});
|
||||
{{/js}}
|
@ -3,7 +3,7 @@ YUI.add('moodle-mod_quiz-questionchooser', function (Y, NAME) {
|
||||
var CSS = {
|
||||
ADDNEWQUESTIONBUTTONS: '.menu [data-action="addquestion"]',
|
||||
CREATENEWQUESTION: 'div.createnewquestion',
|
||||
CHOOSERDIALOGUE: 'div.chooserdialogue',
|
||||
CHOOSERDIALOGUE: 'div.chooserdialoguebody',
|
||||
CHOOSERHEADER: 'div.choosertitle'
|
||||
};
|
||||
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-mod_quiz-questionchooser",function(e,t){var n={ADDNEWQUESTIONBUTTONS:'.menu [data-action="addquestion"]',CREATENEWQUESTION:"div.createnewquestion",CHOOSERDIALOGUE:"div.chooserdialogue",CHOOSERHEADER:"div.choosertitle"},r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,M.core.chooserdialogue,{initializer:function(){e.one("body").delegate("click",this.display_dialogue,n.ADDNEWQUESTIONBUTTONS,this)},display_dialogue:function(t){t.preventDefault();var r=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERDIALOGUE),i=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERHEADER);this.container===null&&(this.setup_chooser_dialogue(r,i,{}),this.prepare_chooser());var s=e.QueryString.parse(t.currentTarget.get("search").substring(1)),o=this.container.one("form");this.parameters_to_hidden_input(s,o,"returnurl"),this.parameters_to_hidden_input(s,o,"cmid"),this.parameters_to_hidden_input(s,o,"category"),this.parameters_to_hidden_input(s,o,"addonpage"),this.parameters_to_hidden_input(s,o,"appendqnumstring"),this.display_chooser(t)},parameters_to_hidden_input:function(e,t,n){var r;e.hasOwnProperty(n)?r=e[n]:r="";var i=t.one("input[name="+n+"]");i||(i=t.appendChild('<input type="hidden">'),i.set("name",n)),i.set("value",r)}},{NAME:"mod_quiz-questionchooser"}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.init_questionchooser=function(){return M.mod_quiz.question_chooser=new r({}),M.mod_quiz.question_chooser}},"@VERSION@",{requires:["moodle-core-chooserdialogue","moodle-mod_quiz-util","querystring-parse"]});
|
||||
YUI.add("moodle-mod_quiz-questionchooser",function(e,t){var n={ADDNEWQUESTIONBUTTONS:'.menu [data-action="addquestion"]',CREATENEWQUESTION:"div.createnewquestion",CHOOSERDIALOGUE:"div.chooserdialoguebody",CHOOSERHEADER:"div.choosertitle"},r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,M.core.chooserdialogue,{initializer:function(){e.one("body").delegate("click",this.display_dialogue,n.ADDNEWQUESTIONBUTTONS,this)},display_dialogue:function(t){t.preventDefault();var r=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERDIALOGUE),i=e.one(n.CREATENEWQUESTION+" "+n.CHOOSERHEADER);this.container===null&&(this.setup_chooser_dialogue(r,i,{}),this.prepare_chooser());var s=e.QueryString.parse(t.currentTarget.get("search").substring(1)),o=this.container.one("form");this.parameters_to_hidden_input(s,o,"returnurl"),this.parameters_to_hidden_input(s,o,"cmid"),this.parameters_to_hidden_input(s,o,"category"),this.parameters_to_hidden_input(s,o,"addonpage"),this.parameters_to_hidden_input(s,o,"appendqnumstring"),this.display_chooser(t)},parameters_to_hidden_input:function(e,t,n){var r;e.hasOwnProperty(n)?r=e[n]:r="";var i=t.one("input[name="+n+"]");i||(i=t.appendChild('<input type="hidden">'),i.set("name",n)),i.set("value",r)}},{NAME:"mod_quiz-questionchooser"}),M.mod_quiz=M.mod_quiz||{},M.mod_quiz.init_questionchooser=function(){return M.mod_quiz.question_chooser=new r({}),M.mod_quiz.question_chooser}},"@VERSION@",{requires:["moodle-core-chooserdialogue","moodle-mod_quiz-util","querystring-parse"]});
|
||||
|
@ -3,7 +3,7 @@ YUI.add('moodle-mod_quiz-questionchooser', function (Y, NAME) {
|
||||
var CSS = {
|
||||
ADDNEWQUESTIONBUTTONS: '.menu [data-action="addquestion"]',
|
||||
CREATENEWQUESTION: 'div.createnewquestion',
|
||||
CHOOSERDIALOGUE: 'div.chooserdialogue',
|
||||
CHOOSERDIALOGUE: 'div.chooserdialoguebody',
|
||||
CHOOSERHEADER: 'div.choosertitle'
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
var CSS = {
|
||||
ADDNEWQUESTIONBUTTONS: '.menu [data-action="addquestion"]',
|
||||
CREATENEWQUESTION: 'div.createnewquestion',
|
||||
CHOOSERDIALOGUE: 'div.chooserdialogue',
|
||||
CHOOSERDIALOGUE: 'div.chooserdialoguebody',
|
||||
CHOOSERHEADER: 'div.choosertitle'
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user