MDL-33726 course: don't list labels in section summary
[moodle.git] / course / format / renderer.php
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17 /**
18  * Base renderer for outputting course formats.
19  *
20  * @package core
21  * @copyright 2012 Dan Poltawski
22  * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23  * @since Moodle 2.3
24  */
26 defined('MOODLE_INTERNAL') || die();
29 /**
30  * This is a convenience renderer which can be used by section based formats
31  * to reduce code duplication. It is not necessary for all course formats to
32  * use this and its likely to change in future releases.
33  *
34  * @package core
35  * @copyright 2012 Dan Poltawski
36  * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37  * @since Moodle 2.3
38  */
39 abstract class format_section_renderer_base extends plugin_renderer_base {
41     /**
42      * Generate the starting container html for a list of sections
43      * @return string HTML to output.
44      */
45     abstract protected function start_section_list();
47     /**
48      * Generate the closing container html for a list of sections
49      * @return string HTML to output.
50      */
51     abstract protected function end_section_list();
53     /**
54      * Generate the title for this section page
55      * @return string the page title
56      */
57     abstract protected function page_title();
59     /**
60      * Generate the section title
61      *
62      * @param stdClass $section The course_section entry from DB
63      * @param stdClass $course The course entry from DB
64      * @return string HTML to output.
65      */
66     public function section_title($section, $course) {
67         $title = get_section_name($course, $section);
68         if ($section->section != 0 && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
69             $title = html_writer::link(course_get_url($course, $section->section), $title);
70         }
71         return $title;
72     }
74     /**
75      * Generate the content to displayed on the right part of a section
76      * before course modules are included
77      *
78      * @param stdClass $section The course_section entry from DB
79      * @param stdClass $course The course entry from DB
80      * @param bool $onsectionpage true if being printed on a section page
81      * @return string HTML to output.
82      */
83     protected function section_right_content($section, $course, $onsectionpage) {
84         $o = $this->output->spacer();
86         if ($section->section != 0) {
87             $controls = $this->section_edit_controls($course, $section, $onsectionpage);
88             if (!empty($controls)) {
89                 $o = implode('<br />', $controls);
90             }
91         }
93         return $o;
94     }
96     /**
97      * Generate the content to displayed on the left part of a section
98      * before course modules are included
99      *
100      * @param stdClass $section The course_section entry from DB
101      * @param stdClass $course The course entry from DB
102      * @param bool $onsectionpage true if being printed on a section page
103      * @return string HTML to output.
104      */
105     protected function section_left_content($section, $course, $onsectionpage) {
106         $o = $this->output->spacer();
108         if ($section->section != 0) {
109             // Only in the non-general sections.
110             if ($this->is_section_current($section, $course)) {
111                 $o = get_accesshide(get_string('currentsection', 'format_'.$course->format));
112             }
113         }
115         return $o;
116     }
118     /**
119      * Generate the display of the header part of a section before
120      * course modules are included
121      *
122      * @param stdClass $section The course_section entry from DB
123      * @param stdClass $course The course entry from DB
124      * @param bool $onsectionpage true if being printed on a single-section page
125      * @return string HTML to output.
126      */
127     protected function section_header($section, $course, $onsectionpage) {
128         global $PAGE;
130         $o = '';
131         $currenttext = '';
132         $sectionstyle = '';
134         if ($section->section != 0) {
135             // Only in the non-general sections.
136             if (!$section->visible) {
137                 $sectionstyle = ' hidden';
138             } else if ($this->is_section_current($section, $course)) {
139                 $sectionstyle = ' current';
140             }
141         }
143         $o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
144             'class' => 'section main clearfix'.$sectionstyle));
146         $leftcontent = $this->section_left_content($section, $course, $onsectionpage);
147         $o.= html_writer::tag('div', $leftcontent, array('class' => 'left side'));
149         $rightcontent = $this->section_right_content($section, $course, $onsectionpage);
150         $o.= html_writer::tag('div', $rightcontent, array('class' => 'right side'));
151         $o.= html_writer::start_tag('div', array('class' => 'content'));
153         if (!$onsectionpage) {
154             $o.= $this->output->heading($this->section_title($section, $course), 3, 'sectionname');
155         }
157         $o.= html_writer::start_tag('div', array('class' => 'summary'));
158         $o.= $this->format_summary_text($section);
160         $context = context_course::instance($course->id);
161         if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) {
162             $url = new moodle_url('/course/editsection.php', array('id'=>$section->id));
164             if ($onsectionpage) {
165                 $url->param('sectionreturn', 1);
166             }
168             $o.= html_writer::link($url,
169                 html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/edit'), 'class' => 'iconsmall edit')),
170                 array('title' => get_string('editsummary')));
171         }
172         $o.= html_writer::end_tag('div');
174         $o .= $this->section_availability_message($section);
176         return $o;
177     }
179     /**
180      * Generate the display of the footer part of a section
181      *
182      * @return string HTML to output.
183      */
184     protected function section_footer() {
185         $o = html_writer::end_tag('div');
186         $o.= html_writer::end_tag('li');
188         return $o;
189     }
191     /**
192      * Generate the edit controls of a section
193      *
194      * @param stdClass $course The course entry from DB
195      * @param stdClass $section The course_section entry from DB
196      * @param bool $onsectionpage true if being printed on a section page
197      * @return array of links with edit controls
198      */
199     protected function section_edit_controls($course, $section, $onsectionpage = false) {
200         global $PAGE;
202         if (!$PAGE->user_is_editing()) {
203             return array();
204         }
206         if (!has_capability('moodle/course:update', context_course::instance($course->id))) {
207             return array();
208         }
210         if ($onsectionpage) {
211             $baseurl = course_get_url($course, $section->section);
212         } else {
213             $baseurl = course_get_url($course);
214         }
215         $baseurl->param('sesskey', sesskey());
217         $controls = array();
219         $url = clone($baseurl);
220         if ($section->visible) { // Show the hide/show eye.
221             $strhidefromothers = get_string('hidefromothers', 'format_'.$course->format);
222             $url->param('hide', $section->section);
223             $controls[] = html_writer::link($url,
224                 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/hide'),
225                 'class' => 'icon hide', 'alt' => $strhidefromothers)),
226                 array('title' => $strhidefromothers, 'class' => 'editing_showhide'));
227         } else {
228             $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
229             $url->param('show',  $section->section);
230             $controls[] = html_writer::link($url,
231                 html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/show'),
232                 'class' => 'icon hide', 'alt' => $strshowfromothers)),
233                 array('title' => $strshowfromothers, 'class' => 'editing_showhide'));
234         }
236         if (!$onsectionpage) {
237             $url = clone($baseurl);
238             if ($section->section > 1) { // Add a arrow to move section up.
239                 $url->param('section', $section->section);
240                 $url->param('move', -1);
241                 $strmoveup = get_string('moveup');
243                 $controls[] = html_writer::link($url,
244                     html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/up'),
245                     'class' => 'icon up', 'alt' => $strmoveup)),
246                     array('title' => $strmoveup, 'class' => 'moveup'));
247             }
249             $url = clone($baseurl);
250             if ($section->section < $course->numsections) { // Add a arrow to move section down.
251                 $url->param('section', $section->section);
252                 $url->param('move', 1);
253                 $strmovedown =  get_string('movedown');
255                 $controls[] = html_writer::link($url,
256                     html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/down'),
257                     'class' => 'icon down', 'alt' => $strmovedown)),
258                     array('title' => $strmovedown, 'class' => 'movedown'));
259             }
260         }
262         return $controls;
263     }
265     /**
266      * Generate a summary of a section for display on the 'coruse index page'
267      *
268      * @param stdClass $section The course_section entry from DB
269      * @param stdClass $course The course entry from DB
270      * @param array    $mods course modules indexed by id (from get_all_mods)
271      * @return string HTML to output.
272      */
273     protected function section_summary($section, $course, $mods) {
274         // If section is hidden then display grey section link
275         $classattr = 'section-summary clearfix';
276         If (!$section->visible) {
277             $classattr .= ' dimmed_text';
278         }
280         $o = '';
281         $o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
282             'class' => $classattr));
284         $title = get_section_name($course, $section);
285         $o.= html_writer::start_tag('a', array('href' => course_get_url($course, $section->section)));
286         $o.= $this->output->heading($title, 3, 'header section-title');
287         $o.= html_writer::end_tag('a');
289         $o.= html_writer::start_tag('div', array('class' => 'summarytext'));
290         $o.= $this->format_summary_text($section);
291         $o.= html_writer::end_tag('div');
292         $o.= $this->section_activity_summary($section, $mods);
294         $o.= $this->section_availability_message($section);
296         $o.= html_writer::end_tag('li');
298         return $o;
299     }
301     /**
302      * Generate a summary of the activites in a section
303      *
304      * @param stdClass $section The course_section entry from DB
305      * @param array    $mods course modules indexed by id (from get_all_mods)
306      * @return string HTML to output.
307      */
308     private function section_activity_summary($section, $mods) {
309         if (empty($section->sequence)) {
310             return '';
311         }
313         // Generate array with count of activities in this section:
314         $sectionmods = array();
315         $modsequence = explode(',', $section->sequence);
316         foreach ($modsequence as $cmid) {
317             $thismod = $mods[$cmid];
319             if ($thismod->modname == 'label') {
320                 // Labels are special (not interesting for students)!
321                 continue;
322             }
324             if ($thismod->uservisible) {
325                 if (isset($sectionmods[$thismod->modname])) {
326                     $sectionmods[$thismod->modname]['count']++;
327                 } else {
328                     $sectionmods[$thismod->modname]['name'] = $thismod->modplural;
329                     $sectionmods[$thismod->modname]['count'] = 1;
330                 }
331             }
332         }
334         if (empty($sectionmods)) {
335             // No sections
336             return '';
337         }
339         // Output section activities summary:
340         $o = '';
341         $o.= html_writer::start_tag('div', array('class' => 'section-summary-activities mdl-right'));
342         foreach ($sectionmods as $mod) {
343             $o.= html_writer::start_tag('span', array('class' => 'activity-count'));
344             $o.= $mod['name'].': '.$mod['count'];
345             $o.= html_writer::end_tag('span');
346         }
347         $o.= html_writer::end_tag('div');
348         return $o;
349     }
351     /**
352      * If section is not visible to current user, display the message about that
353      * ('Not available until...', that sort of thing). Otherwise, returns blank.
354      *
355      * @param stdClass $section The course_section entry from DB
356      * @return string HTML to output
357      */
358     protected function section_availability_message($section) {
359         $o = '';
360         if (!$section->uservisible || $section->availableinfo) {
361             $o .= html_writer::start_tag('div', array('class' => 'availabilityinfo'));
362             if (!empty($section->availableinfo)) {
363                 $o .= $section->availableinfo;
364             } else {
365                 $o .= get_string('notavailable');
366             }
367             $o .= html_writer::end_tag('div');
368         }
369         return $o;
370     }
372     /**
373      * Show if something is on on the course clipboard (moving around)
374      *
375      * @param stdClass $course The course entry from DB
376      * @param int $sectionno The section number in the coruse which is being dsiplayed
377      * @return string HTML to output.
378      */
379     protected function course_activity_clipboard($course, $sectionno = 0) {
380         global $USER;
382         $o = '';
383         // If currently moving a file then show the current clipboard.
384         if (ismoving($course->id)) {
385             $url = new moodle_url('/course/mod.php',
386                 array('sesskey' => sesskey(),
387                       'cancelcopy' => true,
388                       'sr' => $sectionno,
389                 )
390             );
392             $strcancel= get_string('cancel');
394             $o.= html_writer::start_tag('li', array('class' => 'clipboard'));
395             $o.= strip_tags(get_string('activityclipboard', '', $USER->activitycopyname));
396             $o.= ' ('.html_writer::link($url, get_string('cancel')).')';
397             $o.= html_writer::end_tag('li');
398         }
400         return $o;
401     }
403     /**
404      * Generate next/previous section links for naviation
405      *
406      * @param stdClass $course The course entry from DB
407      * @param array $sections The course_sections entries from the DB
408      * @param int $sectionno The section number in the coruse which is being dsiplayed
409      * @return array associative array with previous and next section link
410      */
411     protected function get_nav_links($course, $sections, $sectionno) {
412         // FIXME: This is really evil and should by using the navigation API.
413         $canviewhidden = has_capability('moodle/course:viewhiddensections', context_course::instance($course->id))
414             or !$course->hiddensections;
416         $links = array('previous' => '', 'next' => '');
417         $back = $sectionno - 1;
418         while ($back > 0 and empty($links['previous'])) {
419             if ($canviewhidden || $sections[$back]->visible) {
420                 $params = array();
421                 if (!$sections[$back]->visible) {
422                     $params = array('class' => 'dimmed_text');
423                 }
424                 $previouslink = html_writer::tag('span', $this->output->larrow(), array('class' => 'larrow'));
425                 $previouslink .= get_section_name($course, $sections[$back]);
426                 $links['previous'] = html_writer::link(course_get_url($course, $back), $previouslink, $params);
427             }
428             $back--;
429         }
431         $forward = $sectionno + 1;
432         while ($forward <= $course->numsections and empty($links['next'])) {
433             if ($canviewhidden || $sections[$forward]->visible) {
434                 $params = array();
435                 if (!$sections[$forward]->visible) {
436                     $params = array('class' => 'dimmed_text');
437                 }
438                 $nextlink = get_section_name($course, $sections[$forward]);
439                 $nextlink .= html_writer::tag('span', $this->output->rarrow(), array('class' => 'rarrow'));
440                 $links['next'] = html_writer::link(course_get_url($course, $forward), $nextlink, $params);
441             }
442             $forward++;
443         }
445         return $links;
446     }
448     /**
449      * Generate the header html of a stealth section
450      *
451      * @param int $sectionno The section number in the coruse which is being dsiplayed
452      * @return string HTML to output.
453      */
454     protected function stealth_section_header($sectionno) {
455         $o = '';
456         $o.= html_writer::start_tag('li', array('id' => 'section-'.$sectionno, 'class' => 'section main clearfix orphaned hidden'));
457         $o.= html_writer::tag('div', '', array('class' => 'left side'));
458         $o.= html_writer::tag('div', '', array('class' => 'right side'));
459         $o.= html_writer::start_tag('div', array('class' => 'content'));
460         $o.= $this->output->heading(get_string('orphanedactivities'), 3, 'sectionname');
461         return $o;
462     }
464     /**
465      * Generate footer html of a stealth section
466      *
467      * @return string HTML to output.
468      */
469     protected function stealth_section_footer() {
470         $o = html_writer::end_tag('div');
471         $o.= html_writer::end_tag('li');
472         return $o;
473     }
475     /**
476      * Generate the html for a hidden section
477      *
478      * @param int $sectionno The section number in the coruse which is being dsiplayed
479      * @return string HTML to output.
480      */
481     protected function section_hidden($sectionno) {
482         $o = '';
483         $o.= html_writer::start_tag('li', array('id' => 'section-'.$sectionno, 'class' => 'section main clearfix hidden'));
484         $o.= html_writer::tag('div', '', array('class' => 'left side'));
485         $o.= html_writer::tag('div', '', array('class' => 'right side'));
486         $o.= html_writer::start_tag('div', array('class' => 'content'));
487         $o.= get_string('notavailable');
488         $o.= html_writer::end_tag('div');
489         $o.= html_writer::end_tag('li');
490         return $o;
491     }
493     /**
494      * Output the html for a single section page .
495      *
496      * @param stdClass $course The course entry from DB
497      * @param array $sections The course_sections entries from the DB
498      * @param array $mods used for print_section()
499      * @param array $modnames used for print_section()
500      * @param array $modnamesused used for print_section()
501      * @param int $displaysection The section number in the course which is being displayed
502      */
503     public function print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection) {
504         global $PAGE;
506         // Can we view the section in question?
507         $context = context_course::instance($course->id);
508         $canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
510         if (!isset($sections[$displaysection])) {
511             // This section doesn't exist
512             print_error('unknowncoursesection', 'error', null, $course->fullname);
513             return;
514         }
516         if (!$sections[$displaysection]->visible && !$canviewhidden) {
517             if (!$course->hiddensections) {
518                 echo $this->start_section_list();
519                 echo $this->section_hidden($displaysection);
520                 echo $this->end_section_list();
521             }
522             // Can't view this section.
523             return;
524         }
526         // General section if non-empty.
527         $thissection = $sections[0];
528         if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
529             echo $this->start_section_list();
530             echo $this->section_header($thissection, $course, true);
531             print_section($course, $thissection, $mods, $modnamesused, true);
532             if ($PAGE->user_is_editing()) {
533                 print_section_add_menus($course, 0, $modnames);
534             }
535             echo $this->section_footer();
536             echo $this->end_section_list();
537         }
539         // Start single-section div
540         echo html_writer::start_tag('div', array('class' => 'single-section'));
542         // Title with section navigation links.
543         $sectionnavlinks = $this->get_nav_links($course, $sections, $displaysection);
544         $sectiontitle = '';
545         $sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation header headingblock'));
546         $sectiontitle .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
547         $sectiontitle .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
548         // Title attributes
549         $titleattr = 'mdl-align title';
550         if (!$sections[$displaysection]->visible) {
551             $titleattr .= ' dimmed_text';
552         }
553         $sectiontitle .= html_writer::tag('div', get_section_name($course, $sections[$displaysection]), array('class' => $titleattr));
554         $sectiontitle .= html_writer::end_tag('div');
555         echo $sectiontitle;
557         // Copy activity clipboard..
558         echo $this->course_activity_clipboard($course, $displaysection);
560         // Now the list of sections..
561         echo $this->start_section_list();
563         // The requested section page.
564         $thissection = $sections[$displaysection];
565         echo $this->section_header($thissection, $course, true);
566         // Show completion help icon.
567         $completioninfo = new completion_info($course);
568         echo $completioninfo->display_help_icon();
570         print_section($course, $thissection, $mods, $modnamesused, true, '100%', false, true);
571         if ($PAGE->user_is_editing()) {
572             print_section_add_menus($course, $displaysection, $modnames);
573         }
574         echo $this->section_footer();
575         echo $this->end_section_list();
577         // Display section bottom navigation.
578         $courselink = html_writer::link(course_get_url($course), get_string('returntomaincoursepage'));
579         $sectionbottomnav = '';
580         $sectionbottomnav .= html_writer::start_tag('div', array('class' => 'section-navigation mdl-bottom'));
581         $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
582         $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
583         $sectionbottomnav .= html_writer::tag('div', $courselink, array('class' => 'mdl-align'));
584         $sectionbottomnav .= html_writer::end_tag('div');
585         echo $sectionbottomnav;
587         // close single-section div.
588         echo html_writer::end_tag('div');
589     }
591     /**
592      * Output the html for a multiple section page
593      *
594      * @param stdClass $course The course entry from DB
595      * @param array $sections The course_sections entries from the DB
596      * @param array $mods used for print_section()
597      * @param array $modnames used for print_section()
598      * @param array $modnamesused used for print_section()
599      */
600     public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused) {
601         global $PAGE;
603         $context = context_course::instance($course->id);
604         // Title with completion help icon.
605         $completioninfo = new completion_info($course);
606         echo $completioninfo->display_help_icon();
607         echo $this->output->heading($this->page_title(), 2, 'accesshide');
609         // Copy activity clipboard..
610         echo $this->course_activity_clipboard($course);
612         // Now the list of sections..
613         echo $this->start_section_list();
615         // General section if non-empty.
616         $thissection = $sections[0];
617         unset($sections[0]);
618         if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
619             echo $this->section_header($thissection, $course, true);
620             print_section($course, $thissection, $mods, $modnamesused, true);
621             if ($PAGE->user_is_editing()) {
622                 print_section_add_menus($course, 0, $modnames);
623             }
624             echo $this->section_footer();
625         }
627         $canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
628         for ($section = 1; $section <= $course->numsections; $section++) {
629             if (!empty($sections[$section])) {
630                 $thissection = $sections[$section];
631             } else {
632                 // This will create a course section if it doesn't exist..
633                 $thissection = get_course_section($section, $course->id);
635                 // The returned section is only a bare database object rather than
636                 // a section_info object - we will need at least the uservisible
637                 // field in it.
638                 $thissection->uservisible = true;
639                 $thissection->availableinfo = null;
640                 $thissection->showavailability = 0;
641             }
642             // Show the section if the user is permitted to access it, OR if it's not available
643             // but showavailability is turned on
644             $showsection = $thissection->uservisible ||
645                     ($thissection->visible && !$thissection->available && $thissection->showavailability);
646             if (!$showsection) {
647                 // Hidden section message is overridden by 'unavailable' control
648                 // (showavailability option).
649                 if (!$course->hiddensections && $thissection->available) {
650                     echo $this->section_hidden($section);
651                 }
653                 unset($sections[$section]);
654                 continue;
655             }
657             if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
658                 // Display section summary only.
659                 echo $this->section_summary($thissection, $course, $mods);
660             } else {
661                 echo $this->section_header($thissection, $course, false);
662                 if ($thissection->uservisible) {
663                     print_section($course, $thissection, $mods, $modnamesused);
664                     if ($PAGE->user_is_editing()) {
665                         print_section_add_menus($course, $section, $modnames);
666                     }
667                 }
668                 echo $this->section_footer();
669             }
671             unset($sections[$section]);
672         }
674         if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
675             // Print stealth sections if present.
676             $modinfo = get_fast_modinfo($course);
677             foreach ($sections as $section => $thissection) {
678                 if (empty($modinfo->sections[$section])) {
679                     continue;
680                 }
681                 echo $this->stealth_section_header($section);
682                 print_section($course, $thissection, $mods, $modnamesused);
683                 echo $this->stealth_section_footer();
684             }
686             echo $this->end_section_list();
688             echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
690             // Increase number of sections.
691             $straddsection = get_string('increasesections', 'moodle');
692             $url = new moodle_url('/course/changenumsections.php',
693                 array('courseid' => $course->id,
694                       'increase' => true,
695                       'sesskey' => sesskey()));
696             $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
697             echo html_writer::link($url, $icon.get_accesshide($straddsection), array('class' => 'increase-sections'));
699             if ($course->numsections > 0) {
700                 // Reduce number of sections sections.
701                 $strremovesection = get_string('reducesections', 'moodle');
702                 $url = new moodle_url('/course/changenumsections.php',
703                     array('courseid' => $course->id,
704                           'increase' => false,
705                           'sesskey' => sesskey()));
706                 $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
707                 echo html_writer::link($url, $icon.get_accesshide($strremovesection), array('class' => 'reduce-sections'));
708             }
710             echo html_writer::end_tag('div');
711         } else {
712             echo $this->end_section_list();
713         }
715     }
717     /**
718      * Generate html for a section summary text
719      *
720      * @param stdClass $section The course_section entry from DB
721      * @return string HTML to output.
722      */
723     protected function format_summary_text($section) {
724         $context = context_course::instance($section->course);
725         $summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php',
726             $context->id, 'course', 'section', $section->id);
728         $options = new stdClass();
729         $options->noclean = true;
730         $options->overflowdiv = true;
731         return format_text($summarytext, $section->summaryformat, $options);
732     }
734     /**
735      * Is the section passed in the current section? (Note this isn't strictly
736      * a renderering method, but neater here).
737      *
738      * @param stdClass $course The course entry from DB
739      * @param stdClass $section The course_section entry from the DB
740      * @return bool true if the section is current
741      */
742     protected function is_section_current($section, $course) {
743         return ($course->marker == $section->section);
744     }