How to change the default region on the page where the block is displayed?

寵の児 提交于 2019-12-12 02:58:03

问题


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.

  1. 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)

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!