Commit 91898889 authored by Frederic Massart's avatar Frederic Massart Committed by Dan Poltawski
Browse files

MDL-55797 mod_quiz: Convert question chooser to template

Part of MDL-55071
parent 891750bc
...@@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
use \mod_quiz\structure; use \mod_quiz\structure;
use \html_writer; use \html_writer;
use renderable;
/** /**
* Renderer outputting the quiz editing UI. * Renderer outputting the quiz editing UI.
...@@ -102,7 +103,6 @@ class edit_renderer extends \plugin_renderer_base { ...@@ -102,7 +103,6 @@ class edit_renderer extends \plugin_renderer_base {
// Include the question chooser. // Include the question chooser.
$output .= $this->question_chooser(); $output .= $this->question_chooser();
$this->page->requires->yui_module('moodle-mod_quiz-questionchooser', 'M.mod_quiz.init_questionchooser');
} }
return $output; return $output;
...@@ -932,13 +932,23 @@ class edit_renderer extends \plugin_renderer_base { ...@@ -932,13 +932,23 @@ class edit_renderer extends \plugin_renderer_base {
return html_writer::span($output, 'instancemaxmarkcontainer'); 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. * Render the question type chooser dialogue.
* @return string HTML to output. * @return string HTML to output.
*/ */
public function question_chooser() { public function question_chooser() {
$container = html_writer::div(print_choose_qtype_to_add_form(array(), null, false), '', $chooser = \mod_quiz\output\question_chooser::get($this->page->course, [], null);
array('id' => 'qtypechoicecontainer')); $container = html_writer::div($this->render($chooser), '', array('id' => 'qtypechoicecontainer'));
return html_writer::div($container, 'createnewquestion'); return html_writer::div($container, 'createnewquestion');
} }
......
<?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 {
}
{{!
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}}
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
var CSS = { var CSS = {
ADDNEWQUESTIONBUTTONS: '.menu [data-action="addquestion"]', ADDNEWQUESTIONBUTTONS: '.menu [data-action="addquestion"]',
CREATENEWQUESTION: 'div.createnewquestion', CREATENEWQUESTION: 'div.createnewquestion',
CHOOSERDIALOGUE: 'div.chooserdialogue', CHOOSERDIALOGUE: 'div.chooserdialoguebody',
CHOOSERHEADER: 'div.choosertitle' CHOOSERHEADER: 'div.choosertitle'
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment