问题
I want to extend a theme in Moodle, and want to change the place (on the page) where a question (in a quiz) is displayed.
I have seen the structure of the theme I want to extend. Firstly, I believed that I will have to change the default region
(from regions like $side-pre
and $side-post
etc.) for the block containing the question, for the layout option (like front-page
, standard
, course
etc. ... list of all options here) which represents the page for the quiz.
But I can't find the layout option which represents the page where a question in a quiz is displayed. So can somebody suggest me from the linked table which layout option should I choose, where I can simply change the region where the question is displayed (e.g. if the question is being displayed in the
$side-pre
region, I want to change it such that it is displayed in the$side-post
region)Or is the the wrong way around it? Shall I have to override the
renderer
of the question plugin? If so, how can I find out which part of the renderer controls the default-region where the question block will be displayed?
回答1:
I would use the second option - http://docs.moodle.org/dev/Overriding_a_renderer#Finding_renderers_to_override
In summary
create a theme directory with 2 files
theme/overridetest/config.php
theme/overridetest/renderers.php
In config.php
$THEME->name = 'overridetest';
$THEME->parents = array('standard', 'base');
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
Then in renderers.php have something like this, I'm not sure which function to override so have picked view_page as an example
class theme_overridetest_core_renderer extends core_renderer {
}
include_once($CFG->dirroot . '/mod/quiz/renderer.php');
class theme_overridetest_mod_quiz_renderer extends mod_quiz_renderer {
public function view_page($course, $quiz, $cm, $context, $viewobj) {
$output = '';
// Change the output here.
return $output;
}
}
来源:https://stackoverflow.com/questions/24712304/how-to-change-the-default-region-on-the-page-where-the-block-is-displayed