Custom Layout for quiz activity

Custom Layout for quiz activity

by Rithesh BK -
Number of replies: 3
Can we create custom layout for quiz page? .
Average of ratings: -
In reply to Rithesh BK

Re: Custom Layout for quiz activity

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In reply to Tim Hunt

Re: Custom Layout for quiz activity

by Leonard Houx -

Probably a silly question, but isn't what you need to override the layout, not a render override but a 'layout override' (if such a thing is possible/specifiable)? I had understood the render files were for bits of content, not where they go. If you can move block positions with the render files, could someone explain how? smile

In reply to Leonard Houx

Re: Custom Layout for quiz activity

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

In the case of the quiz renderer, some of the 'bits of content' are entire pages. E.g. https://github.com/moodle/moodle/blob/master/mod/quiz/renderer.php#L48. You can see that that big chunk has been made by sticking together smaller chunks, so you can choose which bits to override.

However, that still does not control the overall layout. That comes from the theme/mytheme/layout/whatever.php files. 

A theme can have as many different layout files as it likes (controlled by the $THEME->layouts array in the theme config.php file.) You may be able to get the different layouts you want just by changing that array.

Alternatively, you may need to add some if statements in one of your layouts. For example, a theme I am involved with now only has one layout.php file, which contains this code near the top:

// Certain modules have left navigation rather than right.

$leftblocks = $sidepre;

switch($PAGE->pagetype) {

    case 'mod-oucontent-view' :

    case 'mod-quiz-attempt' :

        $extraclasses[] = 'osep-leftblocks';

        $leftblocks = true;

}

Then, later on, it does different things depending on whether $leftblocks is true.