overriding quiz renderer

overriding quiz renderer

by pitou col -
Number of replies: 3

Hello

I'm trying to override mod/quiz/renderer.php

I've my own theme, and Moodle 3.10

What I've got is : 
- in mytheme/classes/output/mod_quiz/renderer.php :

<?php
namespace theme_iam\output\mod_quiz;
defined('MOODLE_INTERNAL') || die;
class mod_quiz_renderer extends \mod\quiz\renderer {
...

I've try many ways to extends this class, like 
<?php
class renderer extends \mod\quiz\renderer {

but nothing appends. No error (debugging mode on)

I've tried many ways to override, but nothing works. I've read many threads on this forum, and the doc of course, but I can't figure why I'm stuck at this point.

Any help would be great. Thanks.
Average of ratings: -
In reply to pitou col

Re: overriding quiz renderer

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
The Quiz render is not in a defined namespace, its in the global namespace, so try:

namespace theme_iam\output\mod_quiz;
defined('MOODLE_INTERNAL') || die;
class theme_iam_mod_quiz_renderer extends \mod_quiz_renderer {
G
In reply to Gareth J Barnard

Re: overriding quiz renderer

by pitou col -
I've made what you said, but no effects.

Is there any way to see (in the logs ?) what's going on ? I've no error on my screen.
In reply to pitou col

Re: overriding quiz renderer

by pitou col -
ok, finally, I managed to make it work.
Thank you, your mention of global namespace help me, and that thread too (https://moodle.org/mod/forum/discuss.php?d=366307).

So, here is the good code : 

namespace my_theme\output;

class mod_quiz_renderer extends \mod_quiz_renderer {
your code
}

very simple indeed, that was one of my first options, but something else had to go wrong..
Anyway...
thank you