1 |
efrain |
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 |
* Class for exporting a course competency statistics summary.
|
|
|
19 |
*
|
|
|
20 |
* @package tool_lp
|
|
|
21 |
* @copyright 2016 Damyon Wiese
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
namespace tool_lp\external;
|
|
|
25 |
defined('MOODLE_INTERNAL') || die();
|
|
|
26 |
|
|
|
27 |
use renderer_base;
|
|
|
28 |
use moodle_url;
|
|
|
29 |
use core_competency\external\competency_exporter;
|
|
|
30 |
use core_competency\external\performance_helper;
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Class for exporting a course competency statistics summary.
|
|
|
34 |
*
|
|
|
35 |
* @copyright 2015 Damyon Wiese
|
|
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
37 |
*/
|
|
|
38 |
class course_competency_statistics_exporter extends \core\external\exporter {
|
|
|
39 |
|
|
|
40 |
public static function define_properties() {
|
|
|
41 |
return array(
|
|
|
42 |
'competencycount' => array(
|
|
|
43 |
'type' => PARAM_INT,
|
|
|
44 |
),
|
|
|
45 |
'proficientcompetencycount' => array(
|
|
|
46 |
'type' => PARAM_INT,
|
|
|
47 |
),
|
|
|
48 |
);
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
public static function define_other_properties() {
|
|
|
52 |
return array(
|
|
|
53 |
'proficientcompetencypercentage' => array(
|
|
|
54 |
'type' => PARAM_FLOAT
|
|
|
55 |
),
|
|
|
56 |
'proficientcompetencypercentageformatted' => array(
|
|
|
57 |
'type' => PARAM_RAW
|
|
|
58 |
),
|
|
|
59 |
'leastproficient' => array(
|
|
|
60 |
'type' => competency_exporter::read_properties_definition(),
|
|
|
61 |
'multiple' => true
|
|
|
62 |
),
|
|
|
63 |
'leastproficientcount' => array(
|
|
|
64 |
'type' => PARAM_INT
|
|
|
65 |
),
|
|
|
66 |
'canbegradedincourse' => array(
|
|
|
67 |
'type' => PARAM_BOOL
|
|
|
68 |
),
|
|
|
69 |
'canmanagecoursecompetencies' => array(
|
|
|
70 |
'type' => PARAM_BOOL
|
|
|
71 |
),
|
|
|
72 |
);
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
protected static function define_related() {
|
|
|
76 |
return array('context' => 'context');
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
protected function get_other_values(renderer_base $output) {
|
|
|
80 |
$proficientcompetencypercentage = 0;
|
|
|
81 |
$proficientcompetencypercentageformatted = '';
|
|
|
82 |
if ($this->data->competencycount > 0) {
|
|
|
83 |
$proficientcompetencypercentage = ((float) $this->data->proficientcompetencycount
|
|
|
84 |
/ (float) $this->data->competencycount) * 100.0;
|
|
|
85 |
$proficientcompetencypercentageformatted = format_float($proficientcompetencypercentage);
|
|
|
86 |
}
|
|
|
87 |
$competencies = array();
|
|
|
88 |
$helper = new performance_helper();
|
|
|
89 |
foreach ($this->data->leastproficientcompetencies as $competency) {
|
|
|
90 |
$context = $helper->get_context_from_competency($competency);
|
|
|
91 |
$exporter = new competency_exporter($competency, array('context' => $context));
|
|
|
92 |
$competencies[] = $exporter->export($output);
|
|
|
93 |
}
|
|
|
94 |
return array(
|
|
|
95 |
'proficientcompetencypercentage' => $proficientcompetencypercentage,
|
|
|
96 |
'proficientcompetencypercentageformatted' => $proficientcompetencypercentageformatted,
|
|
|
97 |
'leastproficient' => $competencies,
|
|
|
98 |
'leastproficientcount' => count($competencies),
|
|
|
99 |
'canbegradedincourse' => has_capability('moodle/competency:coursecompetencygradable', $this->related['context']),
|
|
|
100 |
'canmanagecoursecompetencies' => has_capability('moodle/competency:coursecompetencymanage', $this->related['context'])
|
|
|
101 |
);
|
|
|
102 |
}
|
|
|
103 |
}
|