Thank you, but I have done this in my course format, but it does not work. Besides, I have tried to override course_section_cm_list_item(The function will be called after click editing_right) in topcoll/classes/course_renderer.php, it does not work, too.
All the codes works perfect when refresh the page, but does not work when I click editing_right/editing_left, etc..
Here my codes:
MYFORMAT/classes/course_renderer.php
defined('MOODLE_INTERNAL') || die();
class format_MYFORMAT_course_renderer extends \core_course_renderer {
public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses;
$output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
}
return $output;
}
public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$renderer = $this->page->get_renderer('format_MYFORMAT');
//custom codes for showing activities
}
//other override fucntions
}
MYFORMAT/renderer.php
class format_MYFORMAT_renderer extends format_section_renderer_base {
public function __construct(moodle_page $page, $target) {
parent::__construct($page, $target);
$this->courserenderer = $this->page->get_renderer('format_MYFORMAT', 'course');
$this->courseformat = course_get_format($page->course);
$this->tcsettings = $this->courseformat->get_format_options();
$this->userisediting = $page->user_is_editing();
$this->userallowediting = $page->user_allowed_editing();
}
//other functions
}
Here my codes:
MYFORMAT/classes/course_renderer.php
defined('MOODLE_INTERNAL') || die();
class format_MYFORMAT_course_renderer extends \core_course_renderer {
public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses;
$output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
}
return $output;
}
public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$renderer = $this->page->get_renderer('format_MYFORMAT');
//custom codes for showing activities
}
//other override fucntions
}
MYFORMAT/renderer.php
class format_MYFORMAT_renderer extends format_section_renderer_base {
public function __construct(moodle_page $page, $target) {
parent::__construct($page, $target);
$this->courserenderer = $this->page->get_renderer('format_MYFORMAT', 'course');
$this->courseformat = course_get_format($page->course);
$this->tcsettings = $this->courseformat->get_format_options();
$this->userisediting = $page->user_is_editing();
$this->userallowediting = $page->user_allowed_editing();
}
//other functions
}