MDL-51040 cbe: Improve the competency breakdown report
This report now opens the user_competency_summary_in_couse in a popup when clicking on any cell in the report. The report is refreshed when the popup is closed.
This commit is contained in:
committed by
Frederic Massart
parent
3fb067a203
commit
e07c2ef62a
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This is the external API for this report.
|
||||
*
|
||||
* @package report_competency
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace report_competency;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/externallib.php");
|
||||
|
||||
use context_course;
|
||||
use external_api;
|
||||
use external_function_parameters;
|
||||
use external_multiple_structure;
|
||||
use external_single_structure;
|
||||
use external_value;
|
||||
use tool_lp\external\competency_exporter;
|
||||
use tool_lp\external\course_summary_exporter;
|
||||
use tool_lp\external\user_competency_exporter;
|
||||
use tool_lp\external\user_summary_exporter;
|
||||
|
||||
/**
|
||||
* This is the external API for this report.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class external extends external_api {
|
||||
|
||||
/**
|
||||
* Returns description of data_for_competency_frameworks_manage_page() parameters.
|
||||
*
|
||||
* @return \external_function_parameters
|
||||
*/
|
||||
public static function data_for_report_parameters() {
|
||||
$courseid = new external_value(
|
||||
PARAM_INT,
|
||||
'The course id',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$groupid = new external_value(
|
||||
PARAM_INT,
|
||||
'The group id',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$onlyactive = new external_value(
|
||||
PARAM_BOOL,
|
||||
'Only active users',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$params = array(
|
||||
'courseid' => $courseid,
|
||||
'groupid' => $groupid,
|
||||
'onlyactive' => $onlyactive,
|
||||
);
|
||||
return new external_function_parameters($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the data required to render the report.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param int $groupid The group id
|
||||
* @param boolean $onlyactive Only show active enrolments
|
||||
* @return \stdClass
|
||||
*/
|
||||
public static function data_for_report($courseid, $groupid, $onlyactive) {
|
||||
global $PAGE;
|
||||
|
||||
$params = self::validate_parameters(
|
||||
self::data_for_report_parameters(),
|
||||
array(
|
||||
'courseid' => $courseid,
|
||||
'groupid' => $groupid,
|
||||
'onlyactive' => $onlyactive
|
||||
)
|
||||
);
|
||||
$context = context_course::instance($courseid);
|
||||
self::validate_context($context);
|
||||
|
||||
$renderable = new output\report($params['courseid'], $params['groupid'], $params['onlyactive']);
|
||||
$renderer = $PAGE->get_renderer('report_competency');
|
||||
|
||||
$data = $renderable->export_for_template($renderer);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of data_for_report() result value.
|
||||
*
|
||||
* @return \external_description
|
||||
*/
|
||||
public static function data_for_report_returns() {
|
||||
return new external_single_structure(array (
|
||||
'courseid' => new external_value(PARAM_INT, 'Course id'),
|
||||
'groupid' => new external_value(PARAM_INT, 'Group id'),
|
||||
'onlyactive' => new external_value(PARAM_BOOL, 'Only include active enrolments'),
|
||||
'competencies' => new external_multiple_structure(
|
||||
competency_exporter::get_read_structure()
|
||||
),
|
||||
'course' => course_summary_exporter::get_read_structure(),
|
||||
'pluginbaseurl' => new external_value(PARAM_LOCALURL, 'Url to the tool_lp plugin folder on this Moodle site'),
|
||||
'usercompetencies' => new external_multiple_structure(
|
||||
new external_single_structure(array(
|
||||
'user' => user_summary_exporter::get_read_structure(),
|
||||
'usercompetencies' => new external_multiple_structure(
|
||||
user_competency_exporter::get_read_structure()
|
||||
)
|
||||
))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user