Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
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 renderers for the bulk activity completion stuff. 19 * 20 * @package core_course 21 * @copyright 2017 Adrian Greeve 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die; 26 27 require_once($CFG->dirroot.'/course/renderer.php'); 28 29 /** 30 * Main renderer for the bulk activity completion stuff. 31 * 32 * @package core_course 33 * @copyright 2017 Adrian Greeve 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class core_course_bulk_activity_completion_renderer extends plugin_renderer_base { 37 38 /** 39 * Render the navigation tabs for the completion page. 40 * 41 * @deprecated since Moodle 4.0 42 * @param int|stdClass $courseorid the course object or id. 43 * @param String $page the tab to focus. 44 * @return string html 45 */ 46 public function navigation($courseorid, $page) { 47 debugging('navigation() has been deprecated as the tabs navigation structure in the completion page ' . 48 'has been replaced with tertiary navigation. Please use render_course_completion_action_bar() instead.', 49 DEBUG_DEVELOPER); 50 51 $tabs = core_completion\manager::get_available_completion_tabs($courseorid); 52 if (count($tabs) > 1) { 53 return $this->tabtree($tabs, $page); 54 } else { 55 return ''; 56 } 57 } 58 59 /** 60 * Render the bulk completion tab. 61 * 62 * @param Array|stdClass $data the context data to pass to the template. 63 * @return bool|string 64 */ 65 public function bulkcompletion($data) { 66 return parent::render_from_template('core_course/bulkactivitycompletion', $data); 67 } 68 69 /** 70 * Render the default completion tab. 71 * 72 * @param array|stdClass $data the context data to pass to the template. 73 * @param array $modules The modules that have been sent through the form. 74 * @param moodleform $form The current form that has been sent. 75 * @return bool|string 76 */ 77 public function defaultcompletion($data, $modules, $form) { 78 $course = get_course($data->courseid); 79 foreach ($data->modules as $module) { 80 // If the user can manage this module, then the activity completion form needs to be returned too, without the 81 // cancel button (so only "Save changes" button is displayed). 82 if ($module->canmanage) { 83 // Only create the form if it's different from the one that has been sent. 84 $modform = $form; 85 if (empty($form) || !in_array($module->id, array_keys($modules))) { 86 $modform = new \core_completion_defaultedit_form( 87 null, 88 [ 89 'course' => $course, 90 'modules' => [ 91 $module->id => $module, 92 ], 93 'displaycancel' => false, 94 'forceuniqueid' => true, 95 ], 96 ); 97 $module->modulecollapsed = true; 98 } 99 $module->formhtml = $modform->render(); 100 } 101 } 102 $data->issite = $course->id == SITEID; 103 104 return parent::render_from_template('core_course/defaultactivitycompletion', $data); 105 } 106 107 /** 108 * Renders the form for bulk editing activities completion 109 * 110 * @param moodleform $form 111 * @param array $activities 112 * @return string 113 */ 114 public function edit_bulk_completion($form, $activities) { 115 ob_start(); 116 $form->display(); 117 $formhtml = ob_get_contents(); 118 ob_end_clean(); 119 120 $data = (object)[ 121 'form' => $formhtml, 122 'activities' => array_values($activities), 123 'activitiescount' => count($activities), 124 ]; 125 return parent::render_from_template('core_course/editbulkactivitycompletion', $data); 126 } 127 128 /** 129 * Renders the form for editing default completion 130 * 131 * @param moodleform $form 132 * @param array $modules 133 * @return string 134 * @deprecated since Moodle 4.3 MDL-78528 135 * @todo MDL-78711 This will be deleted in Moodle 4.7 136 */ 137 public function edit_default_completion($form, $modules) { 138 debugging('edit_default_completion() is deprecated and will be removed.', DEBUG_DEVELOPER); 139 140 ob_start(); 141 $form->display(); 142 $formhtml = ob_get_contents(); 143 ob_end_clean(); 144 145 $data = (object)[ 146 'form' => $formhtml, 147 'modules' => array_values($modules), 148 'modulescount' => count($modules), 149 ]; 150 return parent::render_from_template('core_course/editdefaultcompletion', $data); 151 } 152 153 /** 154 * Renders the course completion action bar. 155 * 156 * @param \core_course\output\completion_action_bar $actionbar 157 * @return string The HTML output 158 */ 159 public function render_course_completion_action_bar(\core_course\output\completion_action_bar $actionbar): string { 160 $data = $actionbar->export_for_template($this->output); 161 return $this->output->render_from_template('core_course/completion_action_bar', $data); 162 } 163 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body