Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [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 * Singleview report generic functions 19 * 20 * @package gradereport_singleview 21 * @copyright 2023 Ilya Tregubov 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 /** 26 * Returns link to singleview report for the current element 27 * 28 * @param context_course $context Course context 29 * @param int $courseid Course ID 30 * @param array $element An array representing an element in the grade_tree 31 * @param grade_plugin_return $gpr A grade_plugin_return object 32 * @param string $mode Mode - gradeitem or user 33 * @param ?stdClass $templatecontext Template context 34 * @return stdClass|null 35 */ 36 function gradereport_singleview_get_report_link(context_course $context, int $courseid, 37 array $element, grade_plugin_return $gpr, string $mode, ?stdClass $templatecontext): ?stdClass { 38 39 $reportstring = grade_helper::get_lang_string('singleviewreport_' . $mode, 'gradereport_singleview'); 40 if (!isset($templatecontext)) { 41 $templatecontext = new stdClass(); 42 } 43 44 if ($mode == 'gradeitem') { 45 // View all grades items. 46 // FIXME: MDL-52678 This is extremely hacky we should have an API for inserting grade column links. 47 if (get_capability_info('gradereport/singleview:view')) { 48 if (has_all_capabilities(['gradereport/singleview:view', 'moodle/grade:viewall', 49 'moodle/grade:edit'], $context)) { 50 51 $url = new moodle_url('/grade/report/singleview/index.php', [ 52 'id' => $courseid, 53 'item' => 'grade', 54 'itemid' => $element['object']->id 55 ]); 56 $gpr->add_url_params($url); 57 $templatecontext->reporturl0 = html_writer::link($url, $reportstring, 58 ['class' => 'dropdown-item', 'aria-label' => $reportstring, 'role' => 'menuitem']); 59 return $templatecontext; 60 } 61 } 62 } else if ($mode == 'user') { 63 // FIXME: MDL-52678 This get_capability_info is hacky and we should have an API for inserting grade row links instead. 64 $canseesingleview = false; 65 if (get_capability_info('gradereport/singleview:view')) { 66 $canseesingleview = has_all_capabilities(['gradereport/singleview:view', 67 'moodle/grade:viewall', 'moodle/grade:edit'], $context); 68 } 69 70 if ($canseesingleview) { 71 $url = new moodle_url('/grade/report/singleview/index.php', 72 ['id' => $courseid, 'itemid' => $element['userid'], 'item' => 'user']); 73 $gpr->add_url_params($url); 74 $templatecontext->reporturl0 = html_writer::link($url, $reportstring, 75 ['class' => 'dropdown-item', 'aria-label' => $reportstring, 'role' => 'menuitem']); 76 return $templatecontext; 77 } 78 } 79 return null; 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body