|
46 | 46 | // Fix course format if it is no longer installed.
|
47 | 47 | $format = course_get_format($course);
|
48 | 48 | $course->format = $format->get_format();
|
| 49 | +$format->set_sectionid($section->id); |
49 | 50 |
|
50 | 51 | // When the course format doesn't support sections, redirect to course page.
|
51 | 52 | if (!course_format_uses_sections($course->format)) {
|
|
62 | 63 |
|
63 | 64 | // Must set layout before getting section info. See MDL-47555.
|
64 | 65 | $PAGE->set_pagelayout('course');
|
65 |
| -$PAGE->add_body_class('limitedwidth'); |
| 66 | +$PAGE->add_body_classes(['limitedwidth', 'single-section-page']); |
66 | 67 |
|
67 | 68 | // Get section details and check it exists.
|
68 | 69 | $modinfo = get_fast_modinfo($course);
|
69 |
| -$coursesections = $modinfo->get_section_info($section->section, MUST_EXIST); |
| 70 | +$sectioninfo = $modinfo->get_section_info($section->section, MUST_EXIST); |
70 | 71 |
|
71 | 72 | // Check user is allowed to see it.
|
72 |
| -if (!$coursesections->uservisible) { |
| 73 | +if (!$sectioninfo->uservisible) { |
73 | 74 | // Check if coursesection has conditions affecting availability and if
|
74 | 75 | // so, output availability info.
|
75 |
| - if ($coursesections->visible && $coursesections->availableinfo) { |
76 |
| - $sectionname = get_section_name($course, $coursesections); |
| 76 | + if ($sectioninfo->visible && $sectioninfo->availableinfo) { |
| 77 | + $sectionname = get_section_name($course, $sectioninfo); |
77 | 78 | $message = get_string('notavailablecourse', '', $sectionname);
|
78 | 79 | redirect(course_get_url($course), $message, null, \core\output\notification::NOTIFY_ERROR);
|
79 | 80 | } else {
|
|
84 | 85 | }
|
85 | 86 | }
|
86 | 87 |
|
87 |
| -$PAGE->set_pagetype('course-view-' . $course->format); |
| 88 | +$PAGE->set_pagetype('section-view-' . $course->format); |
88 | 89 | $PAGE->set_other_editing_capability('moodle/course:update');
|
89 | 90 | $PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
90 | 91 | $PAGE->set_other_editing_capability('moodle/course:activityvisibility');
|
|
141 | 142 | $PAGE->add_header_action($bulkbutton);
|
142 | 143 | }
|
143 | 144 |
|
144 |
| -$PAGE->set_heading($course->fullname); |
| 145 | +// Add to the header the control menu for the section. |
| 146 | +if ($format->show_editor()) { |
| 147 | + $sectionclass = new \core_courseformat\output\local\content\section($format, $sectioninfo); |
| 148 | + $renderable = $sectionclass->export_for_template($renderer); |
| 149 | + $controlmenuhtml = $renderable->controlmenu->menu; |
| 150 | + $PAGE->add_header_action($controlmenuhtml); |
| 151 | + $sectionheading = $OUTPUT->render($format->inplace_editable_render_section_name($sectioninfo, false)); |
| 152 | + $PAGE->set_heading($sectionheading, false, false); |
| 153 | +} else { |
| 154 | + $PAGE->set_heading($sectiontitle); |
| 155 | +} |
| 156 | + |
| 157 | +$PAGE->set_secondary_navigation(false); |
| 158 | + |
145 | 159 | echo $OUTPUT->header();
|
146 | 160 |
|
147 | 161 | // Show communication room status notification.
|
|
168 | 182 | // Include course AJAX.
|
169 | 183 | include_course_ajax($course, $modinfo->get_used_module_names());
|
170 | 184 |
|
171 |
| -$format->set_sectionid($section->id); |
172 | 185 | $outputclass = $format->get_output_classname('content');
|
173 | 186 | $widget = new $outputclass($format);
|
174 | 187 | echo $renderer->render($widget);
|
|
0 commit comments