Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 17... Línea 17...
17
namespace core_courseformat\output\local;
17
namespace core_courseformat\output\local;
Línea 18... Línea 18...
18
 
18
 
19
use core\output\named_templatable;
19
use core\output\named_templatable;
20
use core_courseformat\base as course_format;
20
use core_courseformat\base as course_format;
-
 
21
use course_modinfo;
21
use course_modinfo;
22
use section_info;
Línea 22... Línea 23...
22
use renderable;
23
use renderable;
23
 
24
 
24
/**
25
/**
Línea 88... Línea 89...
88
        $data = (object)[
89
        $data = (object)[
89
            'title' => $format->page_title(), // This method should be in the course_format class.
90
            'title' => $format->page_title(), // This method should be in the course_format class.
90
            'initialsection' => $initialsection,
91
            'initialsection' => $initialsection,
91
            'sections' => $sections,
92
            'sections' => $sections,
92
            'format' => $format->get_format(),
93
            'format' => $format->get_format(),
93
            'sectionreturn' => null,
94
            'sectionreturn' => 'null', // Mustache templates don't display NULL, so pass a string value.
-
 
95
            'pagesectionid' => $this->format->get_sectionid() ?? 'null', // Pass a string value if NULL.
94
        ];
96
        ];
Línea 95... Línea 97...
95
 
97
 
96
        // The single section format has extra navigation.
98
        // The single section format has extra navigation.
97
        if ($this->format->get_sectionid()) {
99
        if ($this->format->get_sectionid()) {
Línea 140... Línea 142...
140
    }
142
    }
Línea 141... Línea 143...
141
 
143
 
142
    /**
144
    /**
143
     * Export sections array data.
145
     * Export sections array data.
144
     *
146
     *
145
     * @param renderer_base $output typically, the renderer that's calling this function
147
     * @param \renderer_base $output typically, the renderer that's calling this function
146
     * @return array data context for a mustache template
148
     * @return array data context for a mustache template
147
     */
149
     */
Línea 148... Línea 150...
148
    protected function export_sections(\renderer_base $output): array {
150
    protected function export_sections(\renderer_base $output): array {
Línea 152... Línea 154...
152
        $modinfo = $this->format->get_modinfo();
154
        $modinfo = $this->format->get_modinfo();
Línea 153... Línea 155...
153
 
155
 
154
        // Generate section list.
156
        // Generate section list.
155
        $sections = [];
157
        $sections = [];
156
        $stealthsections = [];
-
 
157
        $numsections = $format->get_last_section_number();
158
        $stealthsections = [];
158
        foreach ($this->get_sections_to_display($modinfo) as $sectionnum => $thissection) {
159
        foreach ($this->get_sections_to_display($modinfo) as $sectionnum => $thissection) {
159
            // The course/view.php check the section existence but the output can be called
160
            // The course/view.php check the section existence but the output can be called
160
            // from other parts so we need to check it.
161
            // from other parts so we need to check it.
161
            if (!$thissection) {
162
            if (!$thissection) {
162
                throw new \moodle_exception('unknowncoursesection', 'error', course_get_url($course),
163
                throw new \moodle_exception('unknowncoursesection', 'error', course_get_url($course),
163
                    format_string($course->fullname));
164
                    format_string($course->fullname));
Línea -... Línea 165...
-
 
165
            }
-
 
166
 
-
 
167
            if (!$format->is_section_visible($thissection)) {
-
 
168
                continue;
-
 
169
            }
164
            }
170
 
Línea 165... Línea 171...
165
 
171
            /** @var \core_courseformat\output\local\content\section $section */
166
            $section = new $this->sectionclass($format, $thissection);
172
            $section = new $this->sectionclass($format, $thissection);
167
 
173
 
168
            if ($sectionnum > $numsections) {
174
            if ($section->is_stealth()) {
169
                // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below.
175
                // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below.
170
                if (!empty($modinfo->sections[$sectionnum])) {
176
                if (!empty($modinfo->sections[$sectionnum])) {
171
                    $stealthsections[] = $section->export_for_template($output);
177
                    $stealthsections[] = $section->export_for_template($output);
Línea 172... Línea -...
172
                }
-
 
173
                continue;
-
 
174
            }
-
 
175
 
-
 
176
            if (!$format->is_section_visible($thissection)) {
178
                }
177
                continue;
179
                continue;
178
            }
180
            }
179
 
181
 
180
            $sections[] = $section->export_for_template($output);
182
            $sections[] = $section->export_for_template($output);
Línea 192... Línea 194...
192
     * or a list of them.
194
     * or a list of them.
193
     *
195
     *
194
     * @param course_modinfo $modinfo the current course modinfo object
196
     * @param course_modinfo $modinfo the current course modinfo object
195
     * @return section_info[] an array of section_info to display
197
     * @return section_info[] an array of section_info to display
196
     */
198
     */
197
    private function get_sections_to_display(course_modinfo $modinfo): array {
199
    protected function get_sections_to_display(course_modinfo $modinfo): array {
198
        $singlesectionid = $this->format->get_sectionid();
200
        $singlesectionid = $this->format->get_sectionid();
199
        if ($singlesectionid) {
201
        if ($singlesectionid) {
200
            return [
202
            return [
201
                $modinfo->get_section_info_by_id($singlesectionid),
203
                $modinfo->get_section_info_by_id($singlesectionid),
202
            ];
204
            ];