Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
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 namespace report_competency; 18 19 use context_course; 20 use core_competency\external\user_competency_course_exporter; 21 use core_course\external\course_summary_exporter; 22 use core_external\external_api; 23 use core_external\external_function_parameters; 24 use core_external\external_multiple_structure; 25 use core_external\external_single_structure; 26 use core_external\external_value; 27 use core_user\external\user_summary_exporter; 28 use tool_lp\external\competency_summary_exporter; 29 30 /** 31 * This is the external API for this report. 32 * 33 * @package report_competency 34 * @copyright 2015 Damyon Wiese 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class external extends external_api { 38 39 /** 40 * Returns description of data_for_competency_frameworks_manage_page() parameters. 41 * 42 * @return external_function_parameters 43 */ 44 public static function data_for_report_parameters() { 45 $courseid = new external_value( 46 PARAM_INT, 47 'The course id', 48 VALUE_REQUIRED 49 ); 50 $userid = new external_value( 51 PARAM_INT, 52 'The user id', 53 VALUE_REQUIRED 54 ); 55 $moduleid = new external_value( 56 PARAM_INT, 57 'The module id', 58 VALUE_REQUIRED 59 ); 60 $params = array( 61 'courseid' => $courseid, 62 'userid' => $userid, 63 'moduleid' => $moduleid, 64 ); 65 return new external_function_parameters($params); 66 } 67 68 /** 69 * Loads the data required to render the report. 70 * 71 * @param int $courseid The course id 72 * @param int $userid The user id 73 * @param int $moduleid The module id 74 * @return \stdClass 75 */ 76 public static function data_for_report($courseid, $userid, $moduleid) { 77 global $PAGE; 78 79 $params = self::validate_parameters( 80 self::data_for_report_parameters(), 81 array( 82 'courseid' => $courseid, 83 'userid' => $userid, 84 'moduleid' => $moduleid 85 ) 86 ); 87 $context = context_course::instance($params['courseid']); 88 self::validate_context($context); 89 if (!is_enrolled($context, $params['userid'], 'moodle/competency:coursecompetencygradable')) { 90 throw new coding_exception('invaliduser'); 91 } 92 93 $renderable = new output\report($params['courseid'], $params['userid'], $params['moduleid']); 94 $renderer = $PAGE->get_renderer('report_competency'); 95 96 $data = $renderable->export_for_template($renderer); 97 98 return $data; 99 } 100 101 /** 102 * Returns description of data_for_report() result value. 103 * 104 * @return external_description 105 */ 106 public static function data_for_report_returns() { 107 return new external_single_structure(array ( 108 'courseid' => new external_value(PARAM_INT, 'Course id'), 109 'user' => user_summary_exporter::get_read_structure(), 110 'course' => course_summary_exporter::get_read_structure(), 111 'usercompetencies' => new external_multiple_structure( 112 new external_single_structure(array( 113 'usercompetencycourse' => user_competency_course_exporter::get_read_structure(), 114 'competency' => competency_summary_exporter::get_read_structure() 115 )) 116 ), 117 'pushratingstouserplans' => new external_value(PARAM_BOOL, 'True if rating is push to user plans') 118 )); 119 } 120 121 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body