Extend qtype_description_renderer

Extend qtype_description_renderer

by Till Grohmann -
Number of replies: 2

I want to extend the qtype_description_renderer in my theme.

i tried to put the file in myTheme/classes/output/qtype_description_renderer.php

namespace myTheme\output;

use question_attempt;
use question_display_options;

class qtype_description_renderer extends \qtype_description_renderer {
	
    public function formulation_and_controls(question_attempt $qa, question_display_options $options) {
		$question = $qa->get_question();
		$content = $question->format_questiontext($qa);
		return html_writer::tag('div', $content,
                array('class' => 'qtext customtest'));
    }
}

The class customtest was not added. No error-message was displayed.

Average of ratings: -
In reply to Till Grohmann

Re: Extend qtype_description_renderer

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The namespace looks wrong. It probably needs to be theme_myTheme\output.

Also, it is not normal moodle coding style to use camelcase. Does the auto class-loading work? Would be safer to keep it all lowercase.
In reply to Tim Hunt

Re: Extend qtype_description_renderer

by Till Grohmann -
Thank you very much!
It was the namespace. i haven`t seen it.