See Release Notes
Long Term Support Release
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/>. 16 17 /** 18 * Contains the default activity list from a section. 19 * 20 * @package core_courseformat 21 * @copyright 2020 Ferran Recio <ferran@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core_courseformat\output\local\content\section; 26 27 use core\output\named_templatable; 28 use core_courseformat\base as course_format; 29 use core_courseformat\output\local\courseformat_named_templatable; 30 use moodle_url; 31 use renderable; 32 use section_info; 33 use stdClass; 34 35 /** 36 * Base class to render a section activity list. 37 * 38 * @package core_courseformat 39 * @copyright 2020 Ferran Recio <ferran@moodle.com> 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class cmlist implements named_templatable, renderable { 43 44 use courseformat_named_templatable; 45 46 /** @var course_format the course format class */ 47 protected $format; 48 49 /** @var section_info the course section class */ 50 protected $section; 51 52 /** @var array optional display options */ 53 protected $displayoptions; 54 55 /** @var string the item output class name */ 56 protected $itemclass; 57 58 /** @var optional move here output class */ 59 protected $movehereclass; 60 61 /** 62 * Constructor. 63 * 64 * @param course_format $format the course format 65 * @param section_info $section the section info 66 * @param array $displayoptions optional extra display options 67 */ 68 public function __construct(course_format $format, section_info $section, array $displayoptions = []) { 69 $this->format = $format; 70 $this->section = $section; 71 $this->displayoptions = $displayoptions; 72 73 // Get the necessary classes. 74 $this->itemclass = $format->get_output_classname('content\\section\\cmitem'); 75 } 76 77 /** 78 * Export this data so it can be used as the context for a mustache template. 79 * 80 * @param renderer_base $output typically, the renderer that's calling this function 81 * @return array data context for a mustache template 82 */ 83 public function export_for_template(\renderer_base $output): stdClass { 84 global $USER; 85 86 $format = $this->format; 87 $section = $this->section; 88 $course = $format->get_course(); 89 $modinfo = $format->get_modinfo(); 90 $user = $USER; 91 92 $data = new stdClass(); 93 $data->cms = []; 94 95 // By default, non-ajax controls are disabled but in some places like the frontpage 96 // it is necessary to display them. This is a temporal solution while JS is still 97 // optional for course editing. 98 $showmovehere = ismoving($course->id); 99 100 if ($showmovehere) { 101 $data->hascms = true; 102 $data->showmovehere = true; 103 $data->strmovefull = strip_tags(get_string("movefull", "", "'$user->activitycopyname'")); 104 $data->movetosectionurl = new moodle_url('/course/mod.php', ['movetosection' => $section->id, 'sesskey' => sesskey()]); 105 $data->movingstr = strip_tags(get_string('activityclipboard', '', $user->activitycopyname)); 106 $data->cancelcopyurl = new moodle_url('/course/mod.php', ['cancelcopy' => 'true', 'sesskey' => sesskey()]); 107 } 108 109 if (empty($modinfo->sections[$section->section])) { 110 return $data; 111 } 112 113 foreach ($modinfo->sections[$section->section] as $modnumber) { 114 $mod = $modinfo->cms[$modnumber]; 115 // If the old non-ajax move is necessary, we do not print the selected cm. 116 if ($showmovehere && $USER->activitycopy == $mod->id) { 117 continue; 118 } 119 if ($mod->is_visible_on_course_page()) { 120 $item = new $this->itemclass($format, $section, $mod, $this->displayoptions); 121 $data->cms[] = (object)[ 122 'cmitem' => $item->export_for_template($output), 123 'moveurl' => new moodle_url('/course/mod.php', array('moveto' => $modnumber, 'sesskey' => sesskey())), 124 ]; 125 } 126 } 127 128 if (!empty($data->cms)) { 129 $data->hascms = true; 130 } 131 132 return $data; 133 } 134 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body