/** * course_toc constructor. * @param null $course */ function __construct($course = null) { global $COURSE; if (empty($course)) { $course = $COURSE; } $supportedformats = ['weeks', 'topics']; if (!in_array($course->format, $supportedformats)) { return; } else { $this->formatsupportstoc = true; } $this->format = course_get_format($course); $this->course = $this->format->get_course(); // Has additional fields. course_create_sections_if_missing($course, range(0, $this->course->numsections)); $this->set_modules(); $this->set_chapters(); $this->set_footer(); }