changing the left drawer contents in course view

changing the left drawer contents in course view

by peter gee -
Number of replies: 0

i am trying to change the left drawer contents in moodle 4.0 when the user is viewing the course. this view shows a list of the course modules. The url is: `/course/view.php?id=xx`

i have a custom theme that extends the boost theme.

i have found the file/method that i want to overload: which is /course/format/classes/output/local/state/cm.php/cm.php and the method::export_for_template

this left drawer content is not rendered by the navigated page (course/view.php), but rather it is rendered from a call to /lib/ajax/service.php?sesskey=Cwqs0UlcLu&info=core_courseformat_get_state. this call only occurs when the caches have been purged. /lib/ajax/service.php returns json data of the course content hierarchy with a mustache template that is presumably rendered by injecting the content into the DOM by the browser.

what i have tried: my theme has $THEME->rendererfactory = 'theme_overridden_renderer_factory'; and i have a mytheme/renders.php file that in part has :

require_once($CFG->dirroot . '/course/format/classes/output/local/state/cm.php');
class theme_mytheme_core_courseformat_output_local_state_cm extends core_courseformat\output\local\state\cm{
...
}

but that didn't work.

I think the reason for this is because the /lib/ajax/service.php doesn't appear to honour the theming - but i could be wrong here, it is very hard to debug.

what does work

i can overload the mustache template in /theme/mytheme/templates/core_courseformat/local/courseindex/cm.mustache but i want to mutate the data, not change the way it is displayed.  as a hack, i can mutate the data by using javascript to update the DOM, but i would rather not do this.

my question is:

how can i overload the cm::export_for_template method in my template so I can mutate the data shown in the left drawer when in course view?


Average of ratings: -