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 |
* External API.
|
|
|
19 |
*
|
|
|
20 |
* @package core_competency
|
|
|
21 |
* @copyright 2016 Frédéric Massart - FMCorz.net
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace core_competency;
|
|
|
26 |
defined('MOODLE_INTERNAL') || die();
|
|
|
27 |
|
|
|
28 |
require_once("$CFG->libdir/grade/grade_scale.php");
|
|
|
29 |
|
|
|
30 |
use context_course;
|
|
|
31 |
use context_module;
|
|
|
32 |
use context_system;
|
|
|
33 |
use context_user;
|
|
|
34 |
use core_competency\external\competency_exporter;
|
|
|
35 |
use core_competency\external\competency_framework_exporter;
|
|
|
36 |
use core_competency\external\course_competency_exporter;
|
|
|
37 |
use core_competency\external\course_module_competency_exporter;
|
|
|
38 |
use core_competency\external\evidence_exporter;
|
|
|
39 |
use core_competency\external\performance_helper;
|
|
|
40 |
use core_competency\external\plan_exporter;
|
|
|
41 |
use core_competency\external\template_exporter;
|
|
|
42 |
use core_competency\external\user_competency_exporter;
|
|
|
43 |
use core_competency\external\user_competency_plan_exporter;
|
|
|
44 |
use core_competency\external\user_evidence_competency_exporter;
|
|
|
45 |
use core_competency\external\user_evidence_exporter;
|
|
|
46 |
use core_external\external_api;
|
|
|
47 |
use core_external\external_function_parameters;
|
|
|
48 |
use core_external\external_multiple_structure;
|
|
|
49 |
use core_external\external_single_structure;
|
|
|
50 |
use core_external\external_value;
|
|
|
51 |
use grade_scale;
|
|
|
52 |
use invalid_parameter_exception;
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* External API class.
|
|
|
56 |
*
|
|
|
57 |
* @package core_competency
|
|
|
58 |
* @copyright 2016 Frédéric Massart - FMCorz.net
|
|
|
59 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
60 |
*/
|
|
|
61 |
class external extends external_api {
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Returns a prepared structure to use a context parameters.
|
|
|
65 |
* @return external_single_structure
|
|
|
66 |
*/
|
|
|
67 |
protected static function get_context_parameters() {
|
|
|
68 |
$id = new external_value(
|
|
|
69 |
PARAM_INT,
|
|
|
70 |
'Context ID. Either use this value, or level and instanceid.',
|
|
|
71 |
VALUE_DEFAULT,
|
|
|
72 |
|
|
|
73 |
);
|
|
|
74 |
$level = new external_value(
|
|
|
75 |
PARAM_ALPHA,
|
|
|
76 |
'Context level. To be used with instanceid.',
|
|
|
77 |
VALUE_DEFAULT,
|
|
|
78 |
''
|
|
|
79 |
);
|
|
|
80 |
$instanceid = new external_value(
|
|
|
81 |
PARAM_INT,
|
|
|
82 |
'Context instance ID. To be used with level',
|
|
|
83 |
VALUE_DEFAULT,
|
|
|
84 |
|
|
|
85 |
);
|
|
|
86 |
return new external_single_structure(array(
|
|
|
87 |
'contextid' => $id,
|
|
|
88 |
'contextlevel' => $level,
|
|
|
89 |
'instanceid' => $instanceid,
|
|
|
90 |
));
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* Returns description of create_competency_framework() parameters.
|
|
|
95 |
*
|
|
|
96 |
* @return external_function_parameters
|
|
|
97 |
*/
|
|
|
98 |
public static function create_competency_framework_parameters() {
|
|
|
99 |
$structure = competency_framework_exporter::get_create_structure();
|
|
|
100 |
$params = array('competencyframework' => $structure);
|
|
|
101 |
return new external_function_parameters($params);
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
/**
|
|
|
105 |
* Create a new competency framework
|
|
|
106 |
*
|
|
|
107 |
* @param array $competencyframework A single param with all the fields for a competency framework.
|
|
|
108 |
* @return \stdClass The new record
|
|
|
109 |
*/
|
|
|
110 |
public static function create_competency_framework($competencyframework) {
|
|
|
111 |
global $PAGE;
|
|
|
112 |
|
|
|
113 |
$params = self::validate_parameters(self::create_competency_framework_parameters(), array(
|
|
|
114 |
'competencyframework' => $competencyframework
|
|
|
115 |
));
|
|
|
116 |
$params = $params['competencyframework'];
|
|
|
117 |
|
|
|
118 |
$context = self::get_context_from_params($params);
|
|
|
119 |
self::validate_context($context);
|
|
|
120 |
$output = $PAGE->get_renderer('core');
|
|
|
121 |
|
|
|
122 |
unset($params['contextlevel']);
|
|
|
123 |
unset($params['instanceid']);
|
|
|
124 |
$params['contextid'] = $context->id;
|
|
|
125 |
|
|
|
126 |
$params = (object) $params;
|
|
|
127 |
$result = api::create_framework($params);
|
|
|
128 |
$exporter = new competency_framework_exporter($result);
|
|
|
129 |
$record = $exporter->export($output);
|
|
|
130 |
return $record;
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
/**
|
|
|
134 |
* Returns description of create_competency_framework() result value.
|
|
|
135 |
*
|
|
|
136 |
* @return external_description
|
|
|
137 |
*/
|
|
|
138 |
public static function create_competency_framework_returns() {
|
|
|
139 |
return competency_framework_exporter::get_read_structure();
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
/**
|
|
|
143 |
* Returns description of read_competency_framework() parameters.
|
|
|
144 |
*
|
|
|
145 |
* @return external_function_parameters
|
|
|
146 |
*/
|
|
|
147 |
public static function read_competency_framework_parameters() {
|
|
|
148 |
$id = new external_value(
|
|
|
149 |
PARAM_INT,
|
|
|
150 |
'Data base record id for the framework',
|
|
|
151 |
VALUE_REQUIRED
|
|
|
152 |
);
|
|
|
153 |
|
|
|
154 |
$params = array(
|
|
|
155 |
'id' => $id,
|
|
|
156 |
);
|
|
|
157 |
return new external_function_parameters($params);
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
/**
|
|
|
161 |
* Read a competency framework by id.
|
|
|
162 |
*
|
|
|
163 |
* @param int $id The id of the framework.
|
|
|
164 |
* @return \stdClass
|
|
|
165 |
*/
|
|
|
166 |
public static function read_competency_framework($id) {
|
|
|
167 |
global $PAGE;
|
|
|
168 |
|
|
|
169 |
$params = self::validate_parameters(self::read_competency_framework_parameters(), array(
|
|
|
170 |
'id' => $id,
|
|
|
171 |
));
|
|
|
172 |
|
|
|
173 |
$framework = api::read_framework($params['id']);
|
|
|
174 |
self::validate_context($framework->get_context());
|
|
|
175 |
$output = $PAGE->get_renderer('core');
|
|
|
176 |
$exporter = new competency_framework_exporter($framework);
|
|
|
177 |
$record = $exporter->export($output);
|
|
|
178 |
return $record;
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
/**
|
|
|
182 |
* Returns description of read_competency_framework() result value.
|
|
|
183 |
*
|
|
|
184 |
* @return external_description
|
|
|
185 |
*/
|
|
|
186 |
public static function read_competency_framework_returns() {
|
|
|
187 |
return competency_framework_exporter::get_read_structure();
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
/**
|
|
|
191 |
* Returns description of competency_viewed() parameters.
|
|
|
192 |
*
|
|
|
193 |
* @return external_function_parameters
|
|
|
194 |
*/
|
|
|
195 |
public static function competency_viewed_parameters() {
|
|
|
196 |
$id = new external_value(
|
|
|
197 |
PARAM_INT,
|
|
|
198 |
'The competency id',
|
|
|
199 |
VALUE_REQUIRED
|
|
|
200 |
);
|
|
|
201 |
$params = array(
|
|
|
202 |
'id' => $id
|
|
|
203 |
);
|
|
|
204 |
return new external_function_parameters($params);
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
/**
|
|
|
208 |
* Log event competency viewed.
|
|
|
209 |
*
|
|
|
210 |
* @param int $id The competency ID.
|
|
|
211 |
* @return boolean
|
|
|
212 |
*/
|
|
|
213 |
public static function competency_viewed($id) {
|
|
|
214 |
$params = self::validate_parameters(self::competency_viewed_parameters(), array(
|
|
|
215 |
'id' => $id
|
|
|
216 |
));
|
|
|
217 |
return api::competency_viewed($params['id']);
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
/**
|
|
|
221 |
* Returns description of competency_viewed() result value.
|
|
|
222 |
*
|
|
|
223 |
* @return external_description
|
|
|
224 |
*/
|
|
|
225 |
public static function competency_viewed_returns() {
|
|
|
226 |
return new external_value(PARAM_BOOL, 'True if the event competency viewed was logged');
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
/**
|
|
|
230 |
* Returns description of duplicate_competency_framework() parameters.
|
|
|
231 |
*
|
|
|
232 |
* @return external_function_parameters
|
|
|
233 |
*/
|
|
|
234 |
public static function duplicate_competency_framework_parameters() {
|
|
|
235 |
$id = new external_value(
|
|
|
236 |
PARAM_INT,
|
|
|
237 |
'Data base record id for the framework',
|
|
|
238 |
VALUE_REQUIRED
|
|
|
239 |
);
|
|
|
240 |
|
|
|
241 |
$params = array(
|
|
|
242 |
'id' => $id,
|
|
|
243 |
);
|
|
|
244 |
return new external_function_parameters($params);
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
/**
|
|
|
248 |
* Duplicate a competency framework
|
|
|
249 |
*
|
|
|
250 |
* @param int $id The competency framework id
|
|
|
251 |
* @return boolean
|
|
|
252 |
*/
|
|
|
253 |
public static function duplicate_competency_framework($id) {
|
|
|
254 |
global $PAGE;
|
|
|
255 |
$params = self::validate_parameters(self::duplicate_competency_framework_parameters(), array(
|
|
|
256 |
'id' => $id,
|
|
|
257 |
));
|
|
|
258 |
|
|
|
259 |
$framework = api::read_framework($params['id']);
|
|
|
260 |
self::validate_context($framework->get_context());
|
|
|
261 |
|
|
|
262 |
$output = $PAGE->get_renderer('core');
|
|
|
263 |
$framework = api::duplicate_framework($params['id']);
|
|
|
264 |
$exporter = new competency_framework_exporter($framework);
|
|
|
265 |
$record = $exporter->export($output);
|
|
|
266 |
return $record;
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
/**
|
|
|
270 |
* Returns description of duplicate_competency_framework() result value.
|
|
|
271 |
*
|
|
|
272 |
* @return external_description
|
|
|
273 |
*/
|
|
|
274 |
public static function duplicate_competency_framework_returns() {
|
|
|
275 |
return competency_framework_exporter::get_read_structure();
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
/**
|
|
|
279 |
* Returns description of delete_competency_framework() parameters.
|
|
|
280 |
*
|
|
|
281 |
* @return external_function_parameters
|
|
|
282 |
*/
|
|
|
283 |
public static function delete_competency_framework_parameters() {
|
|
|
284 |
$id = new external_value(
|
|
|
285 |
PARAM_INT,
|
|
|
286 |
'Data base record id for the framework',
|
|
|
287 |
VALUE_REQUIRED
|
|
|
288 |
);
|
|
|
289 |
|
|
|
290 |
$params = array(
|
|
|
291 |
'id' => $id,
|
|
|
292 |
);
|
|
|
293 |
return new external_function_parameters($params);
|
|
|
294 |
}
|
|
|
295 |
|
|
|
296 |
/**
|
|
|
297 |
* Delete a competency framework
|
|
|
298 |
*
|
|
|
299 |
* @param int $id The competency framework id
|
|
|
300 |
* @return boolean
|
|
|
301 |
*/
|
|
|
302 |
public static function delete_competency_framework($id) {
|
|
|
303 |
$params = self::validate_parameters(self::delete_competency_framework_parameters(), array(
|
|
|
304 |
'id' => $id,
|
|
|
305 |
));
|
|
|
306 |
|
|
|
307 |
$framework = api::read_framework($params['id']);
|
|
|
308 |
self::validate_context($framework->get_context());
|
|
|
309 |
|
|
|
310 |
return api::delete_framework($params['id']);
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
/**
|
|
|
314 |
* Returns description of delete_competency_framework() result value.
|
|
|
315 |
*
|
|
|
316 |
* @return external_description
|
|
|
317 |
*/
|
|
|
318 |
public static function delete_competency_framework_returns() {
|
|
|
319 |
return new external_value(PARAM_BOOL, 'True if the delete was successful');
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
/**
|
|
|
323 |
* Returns description of update_competency_framework() parameters.
|
|
|
324 |
*
|
|
|
325 |
* @return external_function_parameters
|
|
|
326 |
*/
|
|
|
327 |
public static function update_competency_framework_parameters() {
|
|
|
328 |
$structure = competency_framework_exporter::get_update_structure();
|
|
|
329 |
$params = array('competencyframework' => $structure);
|
|
|
330 |
return new external_function_parameters($params);
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
/**
|
|
|
334 |
* Update an existing competency framework
|
|
|
335 |
*
|
|
|
336 |
* @param array $competencyframework An array with all the fields for a competency framework.
|
|
|
337 |
* @return boolean
|
|
|
338 |
*/
|
|
|
339 |
public static function update_competency_framework($competencyframework) {
|
|
|
340 |
|
|
|
341 |
$params = self::validate_parameters(self::update_competency_framework_parameters(), array(
|
|
|
342 |
'competencyframework' => $competencyframework
|
|
|
343 |
));
|
|
|
344 |
$params = $params['competencyframework'];
|
|
|
345 |
|
|
|
346 |
$framework = api::read_framework($params['id']);
|
|
|
347 |
self::validate_context($framework->get_context());
|
|
|
348 |
|
|
|
349 |
$params = (object) $params;
|
|
|
350 |
|
|
|
351 |
return api::update_framework($params);
|
|
|
352 |
}
|
|
|
353 |
|
|
|
354 |
/**
|
|
|
355 |
* Returns description of update_competency_framework() result value.
|
|
|
356 |
*
|
|
|
357 |
* @return external_description
|
|
|
358 |
*/
|
|
|
359 |
public static function update_competency_framework_returns() {
|
|
|
360 |
return new external_value(PARAM_BOOL, 'True if the update was successful');
|
|
|
361 |
}
|
|
|
362 |
|
|
|
363 |
/**
|
|
|
364 |
* Returns description of list_competency_frameworks() parameters.
|
|
|
365 |
*
|
|
|
366 |
* @return external_function_parameters
|
|
|
367 |
*/
|
|
|
368 |
public static function list_competency_frameworks_parameters() {
|
|
|
369 |
$sort = new external_value(
|
|
|
370 |
PARAM_ALPHANUMEXT,
|
|
|
371 |
'Column to sort by.',
|
|
|
372 |
VALUE_DEFAULT,
|
|
|
373 |
'shortname'
|
|
|
374 |
);
|
|
|
375 |
$order = new external_value(
|
|
|
376 |
PARAM_ALPHA,
|
|
|
377 |
'Sort direction. Should be either ASC or DESC',
|
|
|
378 |
VALUE_DEFAULT,
|
|
|
379 |
''
|
|
|
380 |
);
|
|
|
381 |
$skip = new external_value(
|
|
|
382 |
PARAM_INT,
|
|
|
383 |
'Skip this number of records before returning results',
|
|
|
384 |
VALUE_DEFAULT,
|
|
|
385 |
|
|
|
386 |
);
|
|
|
387 |
$limit = new external_value(
|
|
|
388 |
PARAM_INT,
|
|
|
389 |
'Return this number of records at most.',
|
|
|
390 |
VALUE_DEFAULT,
|
|
|
391 |
|
|
|
392 |
);
|
|
|
393 |
$includes = new external_value(
|
|
|
394 |
PARAM_ALPHA,
|
|
|
395 |
'What other contextes to fetch the frameworks from. (children, parents, self)',
|
|
|
396 |
VALUE_DEFAULT,
|
|
|
397 |
'children'
|
|
|
398 |
);
|
|
|
399 |
$onlyvisible = new external_value(
|
|
|
400 |
PARAM_BOOL,
|
|
|
401 |
'Only visible frameworks will be returned if visible true',
|
|
|
402 |
VALUE_DEFAULT,
|
|
|
403 |
false
|
|
|
404 |
);
|
|
|
405 |
$query = new external_value(
|
|
|
406 |
PARAM_RAW,
|
|
|
407 |
'A query string to filter the results',
|
|
|
408 |
VALUE_DEFAULT,
|
|
|
409 |
''
|
|
|
410 |
);
|
|
|
411 |
|
|
|
412 |
$params = array(
|
|
|
413 |
'sort' => $sort,
|
|
|
414 |
'order' => $order,
|
|
|
415 |
'skip' => $skip,
|
|
|
416 |
'limit' => $limit,
|
|
|
417 |
'context' => self::get_context_parameters(),
|
|
|
418 |
'includes' => $includes,
|
|
|
419 |
'onlyvisible' => $onlyvisible,
|
|
|
420 |
'query' => $query,
|
|
|
421 |
);
|
|
|
422 |
return new external_function_parameters($params);
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
/**
|
|
|
426 |
* List the existing competency frameworks
|
|
|
427 |
*
|
|
|
428 |
* @param int $sort
|
|
|
429 |
* @param string $order
|
|
|
430 |
* @param string $skip
|
|
|
431 |
* @param int $limit
|
|
|
432 |
* @param array $context
|
|
|
433 |
* @param bool $includes
|
|
|
434 |
* @param bool $onlyvisible
|
|
|
435 |
* @param string $query
|
|
|
436 |
*
|
|
|
437 |
* @return array
|
|
|
438 |
* @throws \required_capability_exception
|
|
|
439 |
* @throws invalid_parameter_exception
|
|
|
440 |
*/
|
|
|
441 |
public static function list_competency_frameworks($sort, $order, $skip, $limit, $context, $includes, $onlyvisible,
|
|
|
442 |
$query = '') {
|
|
|
443 |
global $PAGE;
|
|
|
444 |
|
|
|
445 |
$params = self::validate_parameters(self::list_competency_frameworks_parameters(), array(
|
|
|
446 |
'sort' => $sort,
|
|
|
447 |
'order' => $order,
|
|
|
448 |
'skip' => $skip,
|
|
|
449 |
'limit' => $limit,
|
|
|
450 |
'context' => $context,
|
|
|
451 |
'includes' => $includes,
|
|
|
452 |
'onlyvisible' => $onlyvisible,
|
|
|
453 |
'query' => $query,
|
|
|
454 |
));
|
|
|
455 |
|
|
|
456 |
$context = self::get_context_from_params($params['context']);
|
|
|
457 |
self::validate_context($context);
|
|
|
458 |
$output = $PAGE->get_renderer('core');
|
|
|
459 |
|
|
|
460 |
if ($params['order'] !== '' && $params['order'] !== 'ASC' && $params['order'] !== 'DESC') {
|
|
|
461 |
throw new invalid_parameter_exception('Invalid order param. Must be ASC, DESC or empty.');
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
$results = api::list_frameworks($params['sort'],
|
|
|
465 |
$params['order'],
|
|
|
466 |
$params['skip'],
|
|
|
467 |
$params['limit'],
|
|
|
468 |
$context,
|
|
|
469 |
$params['includes'],
|
|
|
470 |
$params['onlyvisible'],
|
|
|
471 |
$params['query']);
|
|
|
472 |
$records = array();
|
|
|
473 |
foreach ($results as $result) {
|
|
|
474 |
$exporter = new competency_framework_exporter($result);
|
|
|
475 |
$record = $exporter->export($output);
|
|
|
476 |
array_push($records, $record);
|
|
|
477 |
}
|
|
|
478 |
return $records;
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
/**
|
|
|
482 |
* Returns description of list_competency_frameworks() result value.
|
|
|
483 |
*
|
|
|
484 |
* @return external_description
|
|
|
485 |
*/
|
|
|
486 |
public static function list_competency_frameworks_returns() {
|
|
|
487 |
return new external_multiple_structure(competency_framework_exporter::get_read_structure());
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
/**
|
|
|
491 |
* Returns description of count_competency_frameworks() parameters.
|
|
|
492 |
*
|
|
|
493 |
* @return external_function_parameters
|
|
|
494 |
*/
|
|
|
495 |
public static function count_competency_frameworks_parameters() {
|
|
|
496 |
$includes = new external_value(
|
|
|
497 |
PARAM_ALPHA,
|
|
|
498 |
'What other contextes to fetch the frameworks from. (children, parents, self)',
|
|
|
499 |
VALUE_DEFAULT,
|
|
|
500 |
'children'
|
|
|
501 |
);
|
|
|
502 |
|
|
|
503 |
$params = array(
|
|
|
504 |
'context' => self::get_context_parameters(),
|
|
|
505 |
'includes' => $includes
|
|
|
506 |
);
|
|
|
507 |
return new external_function_parameters($params);
|
|
|
508 |
}
|
|
|
509 |
|
|
|
510 |
/**
|
|
|
511 |
* Count the existing competency frameworks
|
|
|
512 |
*
|
|
|
513 |
* @param array $context
|
|
|
514 |
* @param string $includes
|
|
|
515 |
* @return int
|
|
|
516 |
*/
|
|
|
517 |
public static function count_competency_frameworks($context, $includes) {
|
|
|
518 |
$params = self::validate_parameters(self::count_competency_frameworks_parameters(), array(
|
|
|
519 |
'context' => $context,
|
|
|
520 |
'includes' => $includes
|
|
|
521 |
));
|
|
|
522 |
|
|
|
523 |
$context = self::get_context_from_params($params['context']);
|
|
|
524 |
self::validate_context($context);
|
|
|
525 |
|
|
|
526 |
return api::count_frameworks($context, $params['includes']);
|
|
|
527 |
}
|
|
|
528 |
|
|
|
529 |
/**
|
|
|
530 |
* Returns description of count_competency_frameworks() result value.
|
|
|
531 |
*
|
|
|
532 |
* @return external_description
|
|
|
533 |
*/
|
|
|
534 |
public static function count_competency_frameworks_returns() {
|
|
|
535 |
return new external_value(PARAM_INT, 'The number of competency frameworks found.');
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
/**
|
|
|
539 |
* Returns description of competency_framework_viewed() parameters.
|
|
|
540 |
*
|
|
|
541 |
* @return external_function_parameters
|
|
|
542 |
*/
|
|
|
543 |
public static function competency_framework_viewed_parameters() {
|
|
|
544 |
$id = new external_value(
|
|
|
545 |
PARAM_INT,
|
|
|
546 |
'The competency framework id',
|
|
|
547 |
VALUE_REQUIRED
|
|
|
548 |
);
|
|
|
549 |
|
|
|
550 |
$params = array(
|
|
|
551 |
'id' => $id
|
|
|
552 |
);
|
|
|
553 |
return new external_function_parameters($params);
|
|
|
554 |
}
|
|
|
555 |
|
|
|
556 |
/**
|
|
|
557 |
* Log event competency framework viewed.
|
|
|
558 |
*
|
|
|
559 |
* @param int $id The competency framework ID.
|
|
|
560 |
* @return boolean
|
|
|
561 |
*/
|
|
|
562 |
public static function competency_framework_viewed($id) {
|
|
|
563 |
$params = self::validate_parameters(self::competency_framework_viewed_parameters(), array(
|
|
|
564 |
'id' => $id
|
|
|
565 |
));
|
|
|
566 |
return api::competency_framework_viewed($params['id']);
|
|
|
567 |
|
|
|
568 |
}
|
|
|
569 |
|
|
|
570 |
/**
|
|
|
571 |
* Returns description of competency_framework_viewed() result value.
|
|
|
572 |
*
|
|
|
573 |
* @return external_description
|
|
|
574 |
*/
|
|
|
575 |
public static function competency_framework_viewed_returns() {
|
|
|
576 |
return new external_value(PARAM_BOOL, 'True if the event competency framework was logged');
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
/**
|
|
|
580 |
* Returns description of create_competency() parameters.
|
|
|
581 |
*
|
|
|
582 |
* @return external_function_parameters
|
|
|
583 |
*/
|
|
|
584 |
public static function create_competency_parameters() {
|
|
|
585 |
$structure = competency_exporter::get_create_structure();
|
|
|
586 |
$params = array('competency' => $structure);
|
|
|
587 |
return new external_function_parameters($params);
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
/**
|
|
|
591 |
* Create a new competency
|
|
|
592 |
*
|
|
|
593 |
* @param array $competency All the fields for a competency record (including id)
|
|
|
594 |
* @return array the competency
|
|
|
595 |
*/
|
|
|
596 |
public static function create_competency($competency) {
|
|
|
597 |
global $PAGE;
|
|
|
598 |
|
|
|
599 |
$params = self::validate_parameters(self::create_competency_parameters(), array(
|
|
|
600 |
'competency' => $competency
|
|
|
601 |
));
|
|
|
602 |
|
|
|
603 |
$params = $params['competency'];
|
|
|
604 |
$framework = api::read_framework($params['competencyframeworkid']);
|
|
|
605 |
$context = $framework->get_context();
|
|
|
606 |
self::validate_context($context);
|
|
|
607 |
$output = $PAGE->get_renderer('core');
|
|
|
608 |
|
|
|
609 |
$params = (object) $params;
|
|
|
610 |
$result = api::create_competency($params);
|
|
|
611 |
$exporter = new competency_exporter($result, array('context' => $context));
|
|
|
612 |
$record = $exporter->export($output);
|
|
|
613 |
return $record;
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
/**
|
|
|
617 |
* Returns description of create_competency() result value.
|
|
|
618 |
*
|
|
|
619 |
* @return external_description
|
|
|
620 |
*/
|
|
|
621 |
public static function create_competency_returns() {
|
|
|
622 |
return competency_exporter::get_read_structure();
|
|
|
623 |
}
|
|
|
624 |
|
|
|
625 |
/**
|
|
|
626 |
* Returns description of read_competency() parameters.
|
|
|
627 |
*
|
|
|
628 |
* @return external_function_parameters
|
|
|
629 |
*/
|
|
|
630 |
public static function read_competency_parameters() {
|
|
|
631 |
$id = new external_value(
|
|
|
632 |
PARAM_INT,
|
|
|
633 |
'Data base record id for the competency',
|
|
|
634 |
VALUE_REQUIRED
|
|
|
635 |
);
|
|
|
636 |
|
|
|
637 |
$params = array(
|
|
|
638 |
'id' => $id,
|
|
|
639 |
);
|
|
|
640 |
return new external_function_parameters($params);
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
/**
|
|
|
644 |
* Read a competency by id.
|
|
|
645 |
*
|
|
|
646 |
* @param int $id The id of the competency
|
|
|
647 |
* @return \stdClass
|
|
|
648 |
*/
|
|
|
649 |
public static function read_competency($id) {
|
|
|
650 |
global $PAGE;
|
|
|
651 |
|
|
|
652 |
$params = self::validate_parameters(self::read_competency_parameters(), array(
|
|
|
653 |
'id' => $id,
|
|
|
654 |
));
|
|
|
655 |
|
|
|
656 |
$competency = api::read_competency($params['id']);
|
|
|
657 |
$context = $competency->get_context();
|
|
|
658 |
self::validate_context($context);
|
|
|
659 |
$output = $PAGE->get_renderer('core');
|
|
|
660 |
$exporter = new competency_exporter($competency, array('context' => $context));
|
|
|
661 |
$record = $exporter->export($output);
|
|
|
662 |
return $record;
|
|
|
663 |
}
|
|
|
664 |
|
|
|
665 |
/**
|
|
|
666 |
* Returns description of read_competency() result value.
|
|
|
667 |
*
|
|
|
668 |
* @return external_description
|
|
|
669 |
*/
|
|
|
670 |
public static function read_competency_returns() {
|
|
|
671 |
return competency_exporter::get_read_structure();
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
/**
|
|
|
675 |
* Returns description of delete_competency() parameters.
|
|
|
676 |
*
|
|
|
677 |
* @return external_function_parameters
|
|
|
678 |
*/
|
|
|
679 |
public static function delete_competency_parameters() {
|
|
|
680 |
$id = new external_value(
|
|
|
681 |
PARAM_INT,
|
|
|
682 |
'Data base record id for the competency',
|
|
|
683 |
VALUE_REQUIRED
|
|
|
684 |
);
|
|
|
685 |
|
|
|
686 |
$params = array(
|
|
|
687 |
'id' => $id,
|
|
|
688 |
);
|
|
|
689 |
return new external_function_parameters($params);
|
|
|
690 |
}
|
|
|
691 |
|
|
|
692 |
/**
|
|
|
693 |
* Delete a competency
|
|
|
694 |
*
|
|
|
695 |
* @param int $id The competency id
|
|
|
696 |
* @return boolean
|
|
|
697 |
*/
|
|
|
698 |
public static function delete_competency($id) {
|
|
|
699 |
$params = self::validate_parameters(self::delete_competency_parameters(), array(
|
|
|
700 |
'id' => $id,
|
|
|
701 |
));
|
|
|
702 |
|
|
|
703 |
$competency = api::read_competency($params['id']);
|
|
|
704 |
$context = $competency->get_context();
|
|
|
705 |
self::validate_context($context);
|
|
|
706 |
|
|
|
707 |
return api::delete_competency($params['id']);
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
/**
|
|
|
711 |
* Returns description of delete_competency() result value.
|
|
|
712 |
*
|
|
|
713 |
* @return external_description
|
|
|
714 |
*/
|
|
|
715 |
public static function delete_competency_returns() {
|
|
|
716 |
return new external_value(PARAM_BOOL, 'True if the delete was successful');
|
|
|
717 |
}
|
|
|
718 |
|
|
|
719 |
/**
|
|
|
720 |
* Returns description of update_competency() parameters.
|
|
|
721 |
*
|
|
|
722 |
* @return external_function_parameters
|
|
|
723 |
*/
|
|
|
724 |
public static function update_competency_parameters() {
|
|
|
725 |
$structure = competency_exporter::get_update_structure();
|
|
|
726 |
$params = array('competency' => $structure);
|
|
|
727 |
return new external_function_parameters($params);
|
|
|
728 |
}
|
|
|
729 |
|
|
|
730 |
/**
|
|
|
731 |
* Update an existing competency
|
|
|
732 |
*
|
|
|
733 |
* @param array $competency The array of competency fields (id is required).
|
|
|
734 |
* @return boolean
|
|
|
735 |
*/
|
|
|
736 |
public static function update_competency($competency) {
|
|
|
737 |
$params = self::validate_parameters(self::update_competency_parameters(), array(
|
|
|
738 |
'competency' => $competency
|
|
|
739 |
));
|
|
|
740 |
$params = $params['competency'];
|
|
|
741 |
|
|
|
742 |
$competency = api::read_competency($params['id']);
|
|
|
743 |
self::validate_context($competency->get_context());
|
|
|
744 |
|
|
|
745 |
$params = (object) $params;
|
|
|
746 |
|
|
|
747 |
return api::update_competency($params);
|
|
|
748 |
}
|
|
|
749 |
|
|
|
750 |
/**
|
|
|
751 |
* Returns description of update_competency_framework() result value.
|
|
|
752 |
*
|
|
|
753 |
* @return external_description
|
|
|
754 |
*/
|
|
|
755 |
public static function update_competency_returns() {
|
|
|
756 |
return new external_value(PARAM_BOOL, 'True if the update was successful');
|
|
|
757 |
}
|
|
|
758 |
|
|
|
759 |
/**
|
|
|
760 |
* Returns description of list_competencies() parameters.
|
|
|
761 |
*
|
|
|
762 |
* @return external_function_parameters
|
|
|
763 |
*/
|
|
|
764 |
public static function list_competencies_parameters() {
|
|
|
765 |
$filters = new external_multiple_structure(new external_single_structure(
|
|
|
766 |
array(
|
|
|
767 |
'column' => new external_value(PARAM_ALPHANUMEXT, 'Column name to filter by'),
|
|
|
768 |
'value' => new external_value(PARAM_TEXT, 'Value to filter by. Must be exact match')
|
|
|
769 |
)
|
|
|
770 |
));
|
|
|
771 |
$sort = new external_value(
|
|
|
772 |
PARAM_ALPHANUMEXT,
|
|
|
773 |
'Column to sort by.',
|
|
|
774 |
VALUE_DEFAULT,
|
|
|
775 |
''
|
|
|
776 |
);
|
|
|
777 |
$order = new external_value(
|
|
|
778 |
PARAM_ALPHA,
|
|
|
779 |
'Sort direction. Should be either ASC or DESC',
|
|
|
780 |
VALUE_DEFAULT,
|
|
|
781 |
''
|
|
|
782 |
);
|
|
|
783 |
$skip = new external_value(
|
|
|
784 |
PARAM_INT,
|
|
|
785 |
'Skip this number of records before returning results',
|
|
|
786 |
VALUE_DEFAULT,
|
|
|
787 |
|
|
|
788 |
);
|
|
|
789 |
$limit = new external_value(
|
|
|
790 |
PARAM_INT,
|
|
|
791 |
'Return this number of records at most.',
|
|
|
792 |
VALUE_DEFAULT,
|
|
|
793 |
|
|
|
794 |
);
|
|
|
795 |
|
|
|
796 |
$params = array(
|
|
|
797 |
'filters' => $filters,
|
|
|
798 |
'sort' => $sort,
|
|
|
799 |
'order' => $order,
|
|
|
800 |
'skip' => $skip,
|
|
|
801 |
'limit' => $limit
|
|
|
802 |
);
|
|
|
803 |
return new external_function_parameters($params);
|
|
|
804 |
}
|
|
|
805 |
|
|
|
806 |
/**
|
|
|
807 |
* List the existing competency.
|
|
|
808 |
*
|
|
|
809 |
* @param string $filters
|
|
|
810 |
* @param int $sort
|
|
|
811 |
* @param string $order
|
|
|
812 |
* @param string $skip
|
|
|
813 |
* @param int $limit
|
|
|
814 |
*
|
|
|
815 |
* @return array
|
|
|
816 |
* @throws \required_capability_exception
|
|
|
817 |
* @throws invalid_parameter_exception
|
|
|
818 |
*/
|
|
|
819 |
public static function list_competencies($filters, $sort, $order, $skip, $limit) {
|
|
|
820 |
global $PAGE;
|
|
|
821 |
|
|
|
822 |
$params = self::validate_parameters(self::list_competencies_parameters(), array(
|
|
|
823 |
'filters' => $filters,
|
|
|
824 |
'sort' => $sort,
|
|
|
825 |
'order' => $order,
|
|
|
826 |
'skip' => $skip,
|
|
|
827 |
'limit' => $limit
|
|
|
828 |
));
|
|
|
829 |
|
|
|
830 |
if ($params['order'] !== '' && $params['order'] !== 'ASC' && $params['order'] !== 'DESC') {
|
|
|
831 |
throw new invalid_parameter_exception('Invalid order param. Must be ASC, DESC or empty.');
|
|
|
832 |
}
|
|
|
833 |
|
|
|
834 |
$safefilters = array();
|
|
|
835 |
$validcolumns = array('id', 'shortname', 'description', 'sortorder', 'idnumber',
|
|
|
836 |
'parentid', 'competencyframeworkid');
|
|
|
837 |
foreach ($params['filters'] as $filter) {
|
|
|
838 |
if (!in_array($filter['column'], $validcolumns)) {
|
|
|
839 |
throw new invalid_parameter_exception('Filter column was invalid');
|
|
|
840 |
}
|
|
|
841 |
$safefilters[$filter['column']] = $filter['value'];
|
|
|
842 |
}
|
|
|
843 |
|
|
|
844 |
$context = null;
|
|
|
845 |
if (isset($safefilters['competencyframeworkid'])) {
|
|
|
846 |
$framework = api::read_framework($safefilters['competencyframeworkid']);
|
|
|
847 |
$context = $framework->get_context();
|
|
|
848 |
} else {
|
|
|
849 |
$context = context_system::instance();
|
|
|
850 |
}
|
|
|
851 |
|
|
|
852 |
self::validate_context($context);
|
|
|
853 |
$output = $PAGE->get_renderer('core');
|
|
|
854 |
|
|
|
855 |
$results = api::list_competencies(
|
|
|
856 |
$safefilters,
|
|
|
857 |
$params['sort'],
|
|
|
858 |
$params['order'],
|
|
|
859 |
$params['skip'],
|
|
|
860 |
$params['limit']
|
|
|
861 |
);
|
|
|
862 |
|
|
|
863 |
$records = array();
|
|
|
864 |
foreach ($results as $result) {
|
|
|
865 |
$exporter = new competency_exporter($result, array('context' => $context));
|
|
|
866 |
$record = $exporter->export($output);
|
|
|
867 |
array_push($records, $record);
|
|
|
868 |
}
|
|
|
869 |
return $records;
|
|
|
870 |
}
|
|
|
871 |
|
|
|
872 |
/**
|
|
|
873 |
* Returns description of list_competencies() result value.
|
|
|
874 |
*
|
|
|
875 |
* @return external_description
|
|
|
876 |
*/
|
|
|
877 |
public static function list_competencies_returns() {
|
|
|
878 |
return new external_multiple_structure(competency_exporter::get_read_structure());
|
|
|
879 |
}
|
|
|
880 |
|
|
|
881 |
/**
|
|
|
882 |
* Returns description of search_competencies() parameters.
|
|
|
883 |
*
|
|
|
884 |
* @return external_function_parameters
|
|
|
885 |
*/
|
|
|
886 |
public static function search_competencies_parameters() {
|
|
|
887 |
$searchtext = new external_value(
|
|
|
888 |
PARAM_RAW,
|
|
|
889 |
'Text to search for',
|
|
|
890 |
VALUE_REQUIRED
|
|
|
891 |
);
|
|
|
892 |
$frameworkid = new external_value(
|
|
|
893 |
PARAM_INT,
|
|
|
894 |
'Competency framework id',
|
|
|
895 |
VALUE_REQUIRED
|
|
|
896 |
);
|
|
|
897 |
|
|
|
898 |
$params = array(
|
|
|
899 |
'searchtext' => $searchtext,
|
|
|
900 |
'competencyframeworkid' => $frameworkid
|
|
|
901 |
);
|
|
|
902 |
return new external_function_parameters($params);
|
|
|
903 |
}
|
|
|
904 |
|
|
|
905 |
/**
|
|
|
906 |
* List the existing competency frameworks
|
|
|
907 |
*
|
|
|
908 |
* @param string $searchtext Text to search.
|
|
|
909 |
* @param int $competencyframeworkid Framework id.
|
|
|
910 |
*
|
|
|
911 |
* @return array
|
|
|
912 |
*/
|
|
|
913 |
public static function search_competencies($searchtext, $competencyframeworkid) {
|
|
|
914 |
global $PAGE;
|
|
|
915 |
|
|
|
916 |
$params = self::validate_parameters(self::search_competencies_parameters(), array(
|
|
|
917 |
'searchtext' => $searchtext,
|
|
|
918 |
'competencyframeworkid' => $competencyframeworkid
|
|
|
919 |
));
|
|
|
920 |
|
|
|
921 |
$framework = api::read_framework($params['competencyframeworkid']);
|
|
|
922 |
$context = $framework->get_context();
|
|
|
923 |
self::validate_context($context);
|
|
|
924 |
$output = $PAGE->get_renderer('core');
|
|
|
925 |
|
|
|
926 |
$results = api::search_competencies($params['searchtext'], $params['competencyframeworkid']);
|
|
|
927 |
$records = array();
|
|
|
928 |
foreach ($results as $result) {
|
|
|
929 |
$exporter = new competency_exporter($result, array('context' => $context));
|
|
|
930 |
$record = $exporter->export($output);
|
|
|
931 |
|
|
|
932 |
array_push($records, $record);
|
|
|
933 |
}
|
|
|
934 |
|
|
|
935 |
return $records;
|
|
|
936 |
}
|
|
|
937 |
|
|
|
938 |
/**
|
|
|
939 |
* Returns description of search_competencies() result value.
|
|
|
940 |
*
|
|
|
941 |
* @return external_description
|
|
|
942 |
*/
|
|
|
943 |
public static function search_competencies_returns() {
|
|
|
944 |
return new external_multiple_structure(competency_exporter::get_read_structure());
|
|
|
945 |
}
|
|
|
946 |
|
|
|
947 |
/**
|
|
|
948 |
* Returns description of count_competencies() parameters.
|
|
|
949 |
*
|
|
|
950 |
* @return external_function_parameters
|
|
|
951 |
*/
|
|
|
952 |
public static function count_competencies_parameters() {
|
|
|
953 |
$filters = new external_multiple_structure(new external_single_structure(
|
|
|
954 |
array(
|
|
|
955 |
'column' => new external_value(PARAM_ALPHANUMEXT, 'Column name to filter by'),
|
|
|
956 |
'value' => new external_value(PARAM_TEXT, 'Value to filter by. Must be exact match')
|
|
|
957 |
)
|
|
|
958 |
));
|
|
|
959 |
|
|
|
960 |
$params = array(
|
|
|
961 |
'filters' => $filters,
|
|
|
962 |
);
|
|
|
963 |
return new external_function_parameters($params);
|
|
|
964 |
}
|
|
|
965 |
|
|
|
966 |
/**
|
|
|
967 |
* Count the existing competency frameworks.
|
|
|
968 |
*
|
|
|
969 |
* @param string $filters Filters to use.
|
|
|
970 |
* @return boolean
|
|
|
971 |
*/
|
|
|
972 |
public static function count_competencies($filters) {
|
|
|
973 |
$params = self::validate_parameters(self::count_competencies_parameters(), array(
|
|
|
974 |
'filters' => $filters
|
|
|
975 |
));
|
|
|
976 |
|
|
|
977 |
$safefilters = array();
|
|
|
978 |
$validcolumns = array('id', 'shortname', 'description', 'sortorder', 'idnumber', 'parentid', 'competencyframeworkid');
|
|
|
979 |
foreach ($params['filters'] as $filter) {
|
|
|
980 |
if (!in_array($filter['column'], $validcolumns)) {
|
|
|
981 |
throw new invalid_parameter_exception('Filter column was invalid');
|
|
|
982 |
}
|
|
|
983 |
$safefilters[$filter['column']] = $filter['value'];
|
|
|
984 |
}
|
|
|
985 |
|
|
|
986 |
$context = null;
|
|
|
987 |
if (isset($safefilters['competencyframeworkid'])) {
|
|
|
988 |
$framework = api::read_framework($safefilters['competencyframeworkid']);
|
|
|
989 |
$context = $framework->get_context();
|
|
|
990 |
} else {
|
|
|
991 |
$context = context_system::instance();
|
|
|
992 |
}
|
|
|
993 |
|
|
|
994 |
self::validate_context($context);
|
|
|
995 |
|
|
|
996 |
return api::count_competencies($safefilters);
|
|
|
997 |
}
|
|
|
998 |
|
|
|
999 |
/**
|
|
|
1000 |
* Returns description of count_competencies() result value.
|
|
|
1001 |
*
|
|
|
1002 |
* @return external_description
|
|
|
1003 |
*/
|
|
|
1004 |
public static function count_competencies_returns() {
|
|
|
1005 |
return new external_value(PARAM_INT, 'The number of competencies found.');
|
|
|
1006 |
}
|
|
|
1007 |
|
|
|
1008 |
/**
|
|
|
1009 |
* Returns description of set_parent_competency() parameters.
|
|
|
1010 |
*
|
|
|
1011 |
* @return external_function_parameters
|
|
|
1012 |
*/
|
|
|
1013 |
public static function set_parent_competency_parameters() {
|
|
|
1014 |
$competencyid = new external_value(
|
|
|
1015 |
PARAM_INT,
|
|
|
1016 |
'The competency id',
|
|
|
1017 |
VALUE_REQUIRED
|
|
|
1018 |
);
|
|
|
1019 |
$parentid = new external_value(
|
|
|
1020 |
PARAM_INT,
|
|
|
1021 |
'The new competency parent id',
|
|
|
1022 |
VALUE_REQUIRED
|
|
|
1023 |
);
|
|
|
1024 |
$params = array(
|
|
|
1025 |
'competencyid' => $competencyid,
|
|
|
1026 |
'parentid' => $parentid
|
|
|
1027 |
);
|
|
|
1028 |
return new external_function_parameters($params);
|
|
|
1029 |
}
|
|
|
1030 |
|
|
|
1031 |
/**
|
|
|
1032 |
* Move the competency to a new parent.
|
|
|
1033 |
*
|
|
|
1034 |
* @param int $competencyid Competency id.
|
|
|
1035 |
* @param int $parentid Parent id.
|
|
|
1036 |
*
|
|
|
1037 |
* @return bool
|
|
|
1038 |
*/
|
|
|
1039 |
public static function set_parent_competency($competencyid, $parentid) {
|
|
|
1040 |
$params = self::validate_parameters(self::set_parent_competency_parameters(), array(
|
|
|
1041 |
'competencyid' => $competencyid,
|
|
|
1042 |
'parentid' => $parentid
|
|
|
1043 |
));
|
|
|
1044 |
|
|
|
1045 |
$competency = api::read_competency($params['competencyid']);
|
|
|
1046 |
self::validate_context($competency->get_context());
|
|
|
1047 |
|
|
|
1048 |
return api::set_parent_competency($params['competencyid'], $params['parentid']);
|
|
|
1049 |
}
|
|
|
1050 |
|
|
|
1051 |
/**
|
|
|
1052 |
* Returns description of set_parent_competency() result value.
|
|
|
1053 |
*
|
|
|
1054 |
* @return external_description
|
|
|
1055 |
*/
|
|
|
1056 |
public static function set_parent_competency_returns() {
|
|
|
1057 |
return new external_value(PARAM_BOOL, 'True if the update was successful');
|
|
|
1058 |
}
|
|
|
1059 |
|
|
|
1060 |
/**
|
|
|
1061 |
* Returns description of move_up_competency() parameters.
|
|
|
1062 |
*
|
|
|
1063 |
* @return external_function_parameters
|
|
|
1064 |
*/
|
|
|
1065 |
public static function move_up_competency_parameters() {
|
|
|
1066 |
$competencyid = new external_value(
|
|
|
1067 |
PARAM_INT,
|
|
|
1068 |
'The competency id',
|
|
|
1069 |
VALUE_REQUIRED
|
|
|
1070 |
);
|
|
|
1071 |
$params = array(
|
|
|
1072 |
'id' => $competencyid,
|
|
|
1073 |
);
|
|
|
1074 |
return new external_function_parameters($params);
|
|
|
1075 |
}
|
|
|
1076 |
|
|
|
1077 |
/**
|
|
|
1078 |
* Change the sort order of a competency.
|
|
|
1079 |
*
|
|
|
1080 |
* @param int $competencyid Competency id.
|
|
|
1081 |
* @return boolean
|
|
|
1082 |
*/
|
|
|
1083 |
public static function move_up_competency($competencyid) {
|
|
|
1084 |
$params = self::validate_parameters(self::move_up_competency_parameters(), array(
|
|
|
1085 |
'id' => $competencyid,
|
|
|
1086 |
));
|
|
|
1087 |
|
|
|
1088 |
$competency = api::read_competency($params['id']);
|
|
|
1089 |
self::validate_context($competency->get_context());
|
|
|
1090 |
|
|
|
1091 |
return api::move_up_competency($params['id']);
|
|
|
1092 |
}
|
|
|
1093 |
|
|
|
1094 |
/**
|
|
|
1095 |
* Returns description of move_up_competency() result value.
|
|
|
1096 |
*
|
|
|
1097 |
* @return external_description
|
|
|
1098 |
*/
|
|
|
1099 |
public static function move_up_competency_returns() {
|
|
|
1100 |
return new external_value(PARAM_BOOL, 'True if the update was successful');
|
|
|
1101 |
}
|
|
|
1102 |
|
|
|
1103 |
/**
|
|
|
1104 |
* Returns description of move_down_competency() parameters.
|
|
|
1105 |
*
|
|
|
1106 |
* @return external_function_parameters
|
|
|
1107 |
*/
|
|
|
1108 |
public static function move_down_competency_parameters() {
|
|
|
1109 |
$competencyid = new external_value(
|
|
|
1110 |
PARAM_INT,
|
|
|
1111 |
'The competency id',
|
|
|
1112 |
VALUE_REQUIRED
|
|
|
1113 |
);
|
|
|
1114 |
$params = array(
|
|
|
1115 |
'id' => $competencyid,
|
|
|
1116 |
);
|
|
|
1117 |
return new external_function_parameters($params);
|
|
|
1118 |
}
|
|
|
1119 |
|
|
|
1120 |
/**
|
|
|
1121 |
* Change the sort order of a competency.
|
|
|
1122 |
*
|
|
|
1123 |
* @param int $competencyid Competency id.
|
|
|
1124 |
* @return boolean
|
|
|
1125 |
*/
|
|
|
1126 |
public static function move_down_competency($competencyid) {
|
|
|
1127 |
$params = self::validate_parameters(self::move_down_competency_parameters(), array(
|
|
|
1128 |
'id' => $competencyid,
|
|
|
1129 |
));
|
|
|
1130 |
|
|
|
1131 |
$competency = api::read_competency($params['id']);
|
|
|
1132 |
self::validate_context($competency->get_context());
|
|
|
1133 |
|
|
|
1134 |
return api::move_down_competency($params['id']);
|
|
|
1135 |
}
|
|
|
1136 |
|
|
|
1137 |
/**
|
|
|
1138 |
* Returns description of move_down_competency() result value.
|
|
|
1139 |
*
|
|
|
1140 |
* @return external_description
|
|
|
1141 |
*/
|
|
|
1142 |
public static function move_down_competency_returns() {
|
|
|
1143 |
return new external_value(PARAM_BOOL, 'True if the update was successful');
|
|
|
1144 |
}
|
|
|
1145 |
|
|
|
1146 |
/**
|
|
|
1147 |
* Returns description of count_courses_using_competency() parameters.
|
|
|
1148 |
*
|
|
|
1149 |
* @return external_function_parameters
|
|
|
1150 |
*/
|
|
|
1151 |
public static function count_courses_using_competency_parameters() {
|
|
|
1152 |
$competencyid = new external_value(
|
|
|
1153 |
PARAM_INT,
|
|
|
1154 |
'The competency id',
|
|
|
1155 |
VALUE_REQUIRED
|
|
|
1156 |
);
|
|
|
1157 |
$params = array(
|
|
|
1158 |
'id' => $competencyid,
|
|
|
1159 |
);
|
|
|
1160 |
return new external_function_parameters($params);
|
|
|
1161 |
}
|
|
|
1162 |
|
|
|
1163 |
/**
|
|
|
1164 |
* Count the courses (visible to this user) that use this competency.
|
|
|
1165 |
*
|
|
|
1166 |
* @param int $competencyid Competency id.
|
|
|
1167 |
* @return int
|
|
|
1168 |
*/
|
|
|
1169 |
public static function count_courses_using_competency($competencyid) {
|
|
|
1170 |
$params = self::validate_parameters(self::count_courses_using_competency_parameters(), array(
|
|
|
1171 |
'id' => $competencyid,
|
|
|
1172 |
));
|
|
|
1173 |
|
|
|
1174 |
$competency = api::read_competency($params['id']);
|
|
|
1175 |
self::validate_context($competency->get_context());
|
|
|
1176 |
|
|
|
1177 |
return api::count_courses_using_competency($params['id']);
|
|
|
1178 |
}
|
|
|
1179 |
|
|
|
1180 |
/**
|
|
|
1181 |
* Returns description of count_courses_using_competency() result value.
|
|
|
1182 |
*
|
|
|
1183 |
* @return external_description
|
|
|
1184 |
*/
|
|
|
1185 |
public static function count_courses_using_competency_returns() {
|
|
|
1186 |
return new external_value(PARAM_INT, 'The number of courses using this competency');
|
|
|
1187 |
}
|
|
|
1188 |
|
|
|
1189 |
/**
|
|
|
1190 |
* Returns description of count_competencies_in_course() parameters.
|
|
|
1191 |
*
|
|
|
1192 |
* @return external_function_parameters
|
|
|
1193 |
*/
|
|
|
1194 |
public static function count_competencies_in_course_parameters() {
|
|
|
1195 |
$courseid = new external_value(
|
|
|
1196 |
PARAM_INT,
|
|
|
1197 |
'The course id',
|
|
|
1198 |
VALUE_REQUIRED
|
|
|
1199 |
);
|
|
|
1200 |
$params = array(
|
|
|
1201 |
'id' => $courseid,
|
|
|
1202 |
);
|
|
|
1203 |
return new external_function_parameters($params);
|
|
|
1204 |
}
|
|
|
1205 |
|
|
|
1206 |
/**
|
|
|
1207 |
* Count the competencies (visible to this user) in this course.
|
|
|
1208 |
*
|
|
|
1209 |
* @param int $courseid The course id to check.
|
|
|
1210 |
* @return int
|
|
|
1211 |
*/
|
|
|
1212 |
public static function count_competencies_in_course($courseid) {
|
|
|
1213 |
$params = self::validate_parameters(self::count_competencies_in_course_parameters(), array(
|
|
|
1214 |
'id' => $courseid,
|
|
|
1215 |
));
|
|
|
1216 |
|
|
|
1217 |
self::validate_context(context_course::instance($params['id']));
|
|
|
1218 |
|
|
|
1219 |
return api::count_competencies_in_course($params['id']);
|
|
|
1220 |
}
|
|
|
1221 |
|
|
|
1222 |
/**
|
|
|
1223 |
* Returns description of count_competencies_in_course() result value.
|
|
|
1224 |
*
|
|
|
1225 |
* @return external_description
|
|
|
1226 |
*/
|
|
|
1227 |
public static function count_competencies_in_course_returns() {
|
|
|
1228 |
return new external_value(PARAM_INT, 'The number of competencies in this course.');
|
|
|
1229 |
}
|
|
|
1230 |
|
|
|
1231 |
/**
|
|
|
1232 |
* Returns description of list_course_module_competencies() parameters.
|
|
|
1233 |
*
|
|
|
1234 |
* @return external_function_parameters
|
|
|
1235 |
*/
|
|
|
1236 |
public static function list_course_module_competencies_parameters() {
|
|
|
1237 |
$cmid = new external_value(
|
|
|
1238 |
PARAM_INT,
|
|
|
1239 |
'The course module id',
|
|
|
1240 |
VALUE_REQUIRED
|
|
|
1241 |
);
|
|
|
1242 |
$params = array(
|
|
|
1243 |
'cmid' => $cmid
|
|
|
1244 |
);
|
|
|
1245 |
return new external_function_parameters($params);
|
|
|
1246 |
}
|
|
|
1247 |
|
|
|
1248 |
/**
|
|
|
1249 |
* List the course modules using this competency (visible to this user) in this course.
|
|
|
1250 |
*
|
|
|
1251 |
* @param int $cmid The course module id to check.
|
|
|
1252 |
* @return array
|
|
|
1253 |
*/
|
|
|
1254 |
public static function list_course_module_competencies($cmid) {
|
|
|
1255 |
global $PAGE;
|
|
|
1256 |
|
|
|
1257 |
$params = self::validate_parameters(self::list_course_module_competencies_parameters(), array(
|
|
|
1258 |
'cmid' => $cmid
|
|
|
1259 |
));
|
|
|
1260 |
|
|
|
1261 |
$context = context_module::instance($params['cmid']);
|
|
|
1262 |
self::validate_context($context);
|
|
|
1263 |
|
|
|
1264 |
$output = $PAGE->get_renderer('core');
|
|
|
1265 |
|
|
|
1266 |
$apiresult = api::list_course_module_competencies($params['cmid']);
|
|
|
1267 |
$result = array();
|
|
|
1268 |
|
|
|
1269 |
foreach ($apiresult as $cmrecord) {
|
|
|
1270 |
$one = new \stdClass();
|
|
|
1271 |
$exporter = new competency_exporter($cmrecord['competency'], ['context' => $context]);
|
|
|
1272 |
$one->competency = $exporter->export($output);
|
|
|
1273 |
$exporter = new course_module_competency_exporter($cmrecord['coursemodulecompetency'], ['context' => $context]);
|
|
|
1274 |
$one->coursemodulecompetency = $exporter->export($output);
|
|
|
1275 |
|
|
|
1276 |
$result[] = (array) $one;
|
|
|
1277 |
}
|
|
|
1278 |
|
|
|
1279 |
return $result;
|
|
|
1280 |
}
|
|
|
1281 |
|
|
|
1282 |
/**
|
|
|
1283 |
* Returns description of list_course_module_competencies() result value.
|
|
|
1284 |
*
|
|
|
1285 |
* @return external_description
|
|
|
1286 |
*/
|
|
|
1287 |
public static function list_course_module_competencies_returns() {
|
|
|
1288 |
return new external_multiple_structure(
|
|
|
1289 |
new external_single_structure(array(
|
|
|
1290 |
'competency' => competency_exporter::get_read_structure(),
|
|
|
1291 |
'coursemodulecompetency' => course_module_competency_exporter::get_read_structure()
|
|
|
1292 |
))
|
|
|
1293 |
);
|
|
|
1294 |
}
|
|
|
1295 |
|
|
|
1296 |
/**
|
|
|
1297 |
* Returns description of list_course_competencies() parameters.
|
|
|
1298 |
*
|
|
|
1299 |
* @return external_function_parameters
|
|
|
1300 |
*/
|
|
|
1301 |
public static function list_course_competencies_parameters() {
|
|
|
1302 |
$courseid = new external_value(
|
|
|
1303 |
PARAM_INT,
|
|
|
1304 |
'The course id',
|
|
|
1305 |
VALUE_REQUIRED
|
|
|
1306 |
);
|
|
|
1307 |
$params = array(
|
|
|
1308 |
'id' => $courseid,
|
|
|
1309 |
);
|
|
|
1310 |
return new external_function_parameters($params);
|
|
|
1311 |
}
|
|
|
1312 |
|
|
|
1313 |
/**
|
|
|
1314 |
* Returns description of count_course_module_competencies() parameters.
|
|
|
1315 |
*
|
|
|
1316 |
* @return external_function_parameters
|
|
|
1317 |
*/
|
|
|
1318 |
public static function count_course_module_competencies_parameters() {
|
|
|
1319 |
$cmid = new external_value(
|
|
|
1320 |
PARAM_INT,
|
|
|
1321 |
'The course module id',
|
|
|
1322 |
VALUE_REQUIRED
|
|
|
1323 |
);
|
|
|
1324 |
$params = array(
|
|
|
1325 |
'cmid' => $cmid
|
|
|
1326 |
);
|
|
|
1327 |
return new external_function_parameters($params);
|
|
|
1328 |
}
|
|
|
1329 |
|
|
|
1330 |
/**
|
|
|
1331 |
* List the course modules using this competency (visible to this user) in this course.
|
|
|
1332 |
*
|
|
|
1333 |
* @param int $cmid The course module id to check.
|
|
|
1334 |
* @return array
|
|
|
1335 |
*/
|
|
|
1336 |
public static function count_course_module_competencies($cmid) {
|
|
|
1337 |
$params = self::validate_parameters(self::count_course_module_competencies_parameters(), array(
|
|
|
1338 |
'cmid' => $cmid
|
|
|
1339 |
));
|
|
|
1340 |
|
|
|
1341 |
$context = context_module::instance($params['cmid']);
|
|
|
1342 |
self::validate_context($context);
|
|
|
1343 |
|
|
|
1344 |
return api::count_course_module_competencies($params['cmid']);
|
|
|
1345 |
}
|
|
|
1346 |
|
|
|
1347 |
/**
|
|
|
1348 |
* Returns description of count_course_module_competencies() result value.
|
|
|
1349 |
*
|
|
|
1350 |
* @return external_description
|
|
|
1351 |
*/
|
|
|
1352 |
public static function count_course_module_competencies_returns() {
|
|
|
1353 |
return new external_value(PARAM_INT, 'The number of competencies found.');
|
|
|
1354 |
}
|
|
|
1355 |
|
|
|
1356 |
/**
|
|
|
1357 |
* List the competencies (visible to this user) in this course.
|
|
|
1358 |
*
|
|
|
1359 |
* @param int $courseid The course id to check.
|
|
|
1360 |
* @return array
|
|
|
1361 |
*/
|
|
|
1362 |
public static function list_course_competencies($courseid) {
|
|
|
1363 |
global $PAGE;
|
|
|
1364 |
|
|
|
1365 |
$params = self::validate_parameters(self::list_course_competencies_parameters(), array(
|
|
|
1366 |
'id' => $courseid,
|
|
|
1367 |
));
|
|
|
1368 |
|
|
|
1369 |
$coursecontext = context_course::instance($params['id']);
|
|
|
1370 |
self::validate_context($coursecontext);
|
|
|
1371 |
|
|
|
1372 |
$output = $PAGE->get_renderer('core');
|
|
|
1373 |
|
|
|
1374 |
$competencies = api::list_course_competencies($params['id']);
|
|
|
1375 |
$result = array();
|
|
|
1376 |
|
|
|
1377 |
$contextcache = array();
|
|
|
1378 |
$helper = new performance_helper();
|
|
|
1379 |
foreach ($competencies as $competency) {
|
|
|
1380 |
$context = $helper->get_context_from_competency($competency['competency']);
|
|
|
1381 |
$exporter = new competency_exporter($competency['competency'], array('context' => $context));
|
|
|
1382 |
$competencyrecord = $exporter->export($output);
|
|
|
1383 |
$exporter = new course_competency_exporter($competency['coursecompetency']);
|
|
|
1384 |
$coursecompetencyrecord = $exporter->export($output);
|
|
|
1385 |
|
|
|
1386 |
$result[] = array(
|
|
|
1387 |
'competency' => $competencyrecord,
|
|
|
1388 |
'coursecompetency' => $coursecompetencyrecord
|
|
|
1389 |
);
|
|
|
1390 |
}
|
|
|
1391 |
|
|
|
1392 |
return $result;
|
|
|
1393 |
}
|
|
|
1394 |
|
|
|
1395 |
/**
|
|
|
1396 |
* Returns description of list_course_competencies() result value.
|
|
|
1397 |
*
|
|
|
1398 |
* @return external_description
|
|
|
1399 |
*/
|
|
|
1400 |
public static function list_course_competencies_returns() {
|
|
|
1401 |
return new external_multiple_structure(
|
|
|
1402 |
new external_single_structure(array(
|
|
|
1403 |
'competency' => competency_exporter::get_read_structure(),
|
|
|
1404 |
'coursecompetency' => course_competency_exporter::get_read_structure()
|
|
|
1405 |
))
|
|
|
1406 |
);
|
|
|
1407 |
}
|
|
|
1408 |
|
|
|
1409 |
/**
|
|
|
1410 |
* Returns description of add_competency_to_course() parameters.
|
|
|
1411 |
*
|
|
|
1412 |
* @return external_function_parameters
|
|
|
1413 |
*/
|
|
|
1414 |
public static function add_competency_to_course_parameters() {
|
|
|
1415 |
$courseid = new external_value(
|
|
|
1416 |
PARAM_INT,
|
|
|
1417 |
'The course id',
|
|
|
1418 |
VALUE_REQUIRED
|
|
|
1419 |
);
|
|
|
1420 |
$competencyid = new external_value(
|
|
|
1421 |
PARAM_INT,
|
|
|
1422 |
'The competency id',
|
|
|
1423 |
VALUE_REQUIRED
|
|
|
1424 |
);
|
|
|
1425 |
$params = array(
|
|
|
1426 |
'courseid' => $courseid,
|
|
|
1427 |
'competencyid' => $competencyid,
|
|
|
1428 |
);
|
|
|
1429 |
return new external_function_parameters($params);
|
|
|
1430 |
}
|
|
|
1431 |
|
|
|
1432 |
/**
|
|
|
1433 |
* Count the competencies (visible to this user) in this course.
|
|
|
1434 |
*
|
|
|
1435 |
* @param int $courseid The course id to check.
|
|
|
1436 |
* @param int $competencyid Competency id.
|
|
|
1437 |
* @return int
|
|
|
1438 |
*/
|
|
|
1439 |
public static function add_competency_to_course($courseid, $competencyid) {
|
|
|
1440 |
$params = self::validate_parameters(self::add_competency_to_course_parameters(), array(
|
|
|
1441 |
'courseid' => $courseid,
|
|
|
1442 |
'competencyid' => $competencyid,
|
|
|
1443 |
));
|
|
|
1444 |
self::validate_context(context_course::instance($params['courseid']));
|
|
|
1445 |
return api::add_competency_to_course($params['courseid'], $params['competencyid']);
|
|
|
1446 |
}
|
|
|
1447 |
|
|
|
1448 |
/**
|
|
|
1449 |
* Returns description of add_competency_to_course() result value.
|
|
|
1450 |
*
|
|
|
1451 |
* @return external_description
|
|
|
1452 |
*/
|
|
|
1453 |
public static function add_competency_to_course_returns() {
|
|
|
1454 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
1455 |
}
|
|
|
1456 |
|
|
|
1457 |
/**
|
|
|
1458 |
* Returns description of remove_competency_from_course() parameters.
|
|
|
1459 |
*
|
|
|
1460 |
* @return external_function_parameters
|
|
|
1461 |
*/
|
|
|
1462 |
public static function remove_competency_from_course_parameters() {
|
|
|
1463 |
$courseid = new external_value(
|
|
|
1464 |
PARAM_INT,
|
|
|
1465 |
'The course id',
|
|
|
1466 |
VALUE_REQUIRED
|
|
|
1467 |
);
|
|
|
1468 |
$competencyid = new external_value(
|
|
|
1469 |
PARAM_INT,
|
|
|
1470 |
'The competency id',
|
|
|
1471 |
VALUE_REQUIRED
|
|
|
1472 |
);
|
|
|
1473 |
$params = array(
|
|
|
1474 |
'courseid' => $courseid,
|
|
|
1475 |
'competencyid' => $competencyid,
|
|
|
1476 |
);
|
|
|
1477 |
return new external_function_parameters($params);
|
|
|
1478 |
}
|
|
|
1479 |
|
|
|
1480 |
/**
|
|
|
1481 |
* Count the competencies (visible to this user) in this course.
|
|
|
1482 |
*
|
|
|
1483 |
* @param int $courseid The course id to check.
|
|
|
1484 |
* @param int $competencyid Competency id.
|
|
|
1485 |
* @return int
|
|
|
1486 |
*/
|
|
|
1487 |
public static function remove_competency_from_course($courseid, $competencyid) {
|
|
|
1488 |
$params = self::validate_parameters(self::remove_competency_from_course_parameters(), array(
|
|
|
1489 |
'courseid' => $courseid,
|
|
|
1490 |
'competencyid' => $competencyid,
|
|
|
1491 |
));
|
|
|
1492 |
self::validate_context(context_course::instance($params['courseid']));
|
|
|
1493 |
return api::remove_competency_from_course($params['courseid'], $params['competencyid']);
|
|
|
1494 |
}
|
|
|
1495 |
|
|
|
1496 |
/**
|
|
|
1497 |
* Returns description of remove_competency_from_course() result value.
|
|
|
1498 |
*
|
|
|
1499 |
* @return external_description
|
|
|
1500 |
*/
|
|
|
1501 |
public static function remove_competency_from_course_returns() {
|
|
|
1502 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
1503 |
}
|
|
|
1504 |
|
|
|
1505 |
/**
|
|
|
1506 |
* Returns description of reorder_course_competency() parameters.
|
|
|
1507 |
*
|
|
|
1508 |
* @return external_function_parameters
|
|
|
1509 |
*/
|
|
|
1510 |
public static function reorder_course_competency_parameters() {
|
|
|
1511 |
$courseid = new external_value(
|
|
|
1512 |
PARAM_INT,
|
|
|
1513 |
'The course id',
|
|
|
1514 |
VALUE_REQUIRED
|
|
|
1515 |
);
|
|
|
1516 |
$competencyidfrom = new external_value(
|
|
|
1517 |
PARAM_INT,
|
|
|
1518 |
'The competency id we are moving',
|
|
|
1519 |
VALUE_REQUIRED
|
|
|
1520 |
);
|
|
|
1521 |
$competencyidto = new external_value(
|
|
|
1522 |
PARAM_INT,
|
|
|
1523 |
'The competency id we are moving to',
|
|
|
1524 |
VALUE_REQUIRED
|
|
|
1525 |
);
|
|
|
1526 |
$params = array(
|
|
|
1527 |
'courseid' => $courseid,
|
|
|
1528 |
'competencyidfrom' => $competencyidfrom,
|
|
|
1529 |
'competencyidto' => $competencyidto,
|
|
|
1530 |
);
|
|
|
1531 |
return new external_function_parameters($params);
|
|
|
1532 |
}
|
|
|
1533 |
|
|
|
1534 |
/**
|
|
|
1535 |
* Change the order of course competencies.
|
|
|
1536 |
*
|
|
|
1537 |
* @param int $courseid The course id
|
|
|
1538 |
* @param int $competencyidfrom The competency to move.
|
|
|
1539 |
* @param int $competencyidto The competency to move to.
|
|
|
1540 |
* @return bool
|
|
|
1541 |
*/
|
|
|
1542 |
public static function reorder_course_competency($courseid, $competencyidfrom, $competencyidto) {
|
|
|
1543 |
$params = self::validate_parameters(self::reorder_course_competency_parameters(), array(
|
|
|
1544 |
'courseid' => $courseid,
|
|
|
1545 |
'competencyidfrom' => $competencyidfrom,
|
|
|
1546 |
'competencyidto' => $competencyidto,
|
|
|
1547 |
));
|
|
|
1548 |
self::validate_context(context_course::instance($params['courseid']));
|
|
|
1549 |
return api::reorder_course_competency($params['courseid'], $params['competencyidfrom'], $params['competencyidto']);
|
|
|
1550 |
}
|
|
|
1551 |
|
|
|
1552 |
/**
|
|
|
1553 |
* Returns description of reorder_course_competency() result value.
|
|
|
1554 |
*
|
|
|
1555 |
* @return external_description
|
|
|
1556 |
*/
|
|
|
1557 |
public static function reorder_course_competency_returns() {
|
|
|
1558 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
1559 |
}
|
|
|
1560 |
|
|
|
1561 |
/**
|
|
|
1562 |
* Returns description of reorder_template_competency() parameters.
|
|
|
1563 |
*
|
|
|
1564 |
* @return external_function_parameters
|
|
|
1565 |
*/
|
|
|
1566 |
public static function reorder_template_competency_parameters() {
|
|
|
1567 |
$templateid = new external_value(
|
|
|
1568 |
PARAM_INT,
|
|
|
1569 |
'The template id',
|
|
|
1570 |
VALUE_REQUIRED
|
|
|
1571 |
);
|
|
|
1572 |
$competencyidfrom = new external_value(
|
|
|
1573 |
PARAM_INT,
|
|
|
1574 |
'The competency id we are moving',
|
|
|
1575 |
VALUE_REQUIRED
|
|
|
1576 |
);
|
|
|
1577 |
$competencyidto = new external_value(
|
|
|
1578 |
PARAM_INT,
|
|
|
1579 |
'The competency id we are moving to',
|
|
|
1580 |
VALUE_REQUIRED
|
|
|
1581 |
);
|
|
|
1582 |
$params = array(
|
|
|
1583 |
'templateid' => $templateid,
|
|
|
1584 |
'competencyidfrom' => $competencyidfrom,
|
|
|
1585 |
'competencyidto' => $competencyidto,
|
|
|
1586 |
);
|
|
|
1587 |
return new external_function_parameters($params);
|
|
|
1588 |
}
|
|
|
1589 |
|
|
|
1590 |
/**
|
|
|
1591 |
* Change the order of template competencies.
|
|
|
1592 |
*
|
|
|
1593 |
* @param int $templateid The template id
|
|
|
1594 |
* @param int $competencyidfrom The competency to move.
|
|
|
1595 |
* @param int $competencyidto The competency to move to.
|
|
|
1596 |
* @return bool
|
|
|
1597 |
*/
|
|
|
1598 |
public static function reorder_template_competency($templateid, $competencyidfrom, $competencyidto) {
|
|
|
1599 |
$params = self::validate_parameters(self::reorder_template_competency_parameters(), array(
|
|
|
1600 |
'templateid' => $templateid,
|
|
|
1601 |
'competencyidfrom' => $competencyidfrom,
|
|
|
1602 |
'competencyidto' => $competencyidto,
|
|
|
1603 |
));
|
|
|
1604 |
|
|
|
1605 |
$template = api::read_template($params['templateid']);
|
|
|
1606 |
self::validate_context($template->get_context());
|
|
|
1607 |
|
|
|
1608 |
return api::reorder_template_competency($params['templateid'], $params['competencyidfrom'], $params['competencyidto']);
|
|
|
1609 |
}
|
|
|
1610 |
|
|
|
1611 |
/**
|
|
|
1612 |
* Returns description of reorder_template_competency() result value.
|
|
|
1613 |
*
|
|
|
1614 |
* @return external_description
|
|
|
1615 |
*/
|
|
|
1616 |
public static function reorder_template_competency_returns() {
|
|
|
1617 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
1618 |
}
|
|
|
1619 |
|
|
|
1620 |
/**
|
|
|
1621 |
* Returns description of create_template() parameters.
|
|
|
1622 |
*
|
|
|
1623 |
* @return external_function_parameters
|
|
|
1624 |
*/
|
|
|
1625 |
public static function create_template_parameters() {
|
|
|
1626 |
$structure = template_exporter::get_create_structure();
|
|
|
1627 |
$params = array('template' => $structure);
|
|
|
1628 |
return new external_function_parameters($params);
|
|
|
1629 |
}
|
|
|
1630 |
|
|
|
1631 |
/**
|
|
|
1632 |
* Create a new learning plan template
|
|
|
1633 |
*
|
|
|
1634 |
* @param array $template The list of fields for the template.
|
|
|
1635 |
* @return \stdClass Record of new template.
|
|
|
1636 |
*/
|
|
|
1637 |
public static function create_template($template) {
|
|
|
1638 |
global $PAGE;
|
|
|
1639 |
|
|
|
1640 |
$params = self::validate_parameters(self::create_template_parameters(), array('template' => $template));
|
|
|
1641 |
$params = $params['template'];
|
|
|
1642 |
$context = self::get_context_from_params($params);
|
|
|
1643 |
self::validate_context($context);
|
|
|
1644 |
$output = $PAGE->get_renderer('core');
|
|
|
1645 |
|
|
|
1646 |
unset($params['contextlevel']);
|
|
|
1647 |
unset($params['instanceid']);
|
|
|
1648 |
$params = (object) $params;
|
|
|
1649 |
$params->contextid = $context->id;
|
|
|
1650 |
|
|
|
1651 |
$result = api::create_template($params);
|
|
|
1652 |
$exporter = new template_exporter($result);
|
|
|
1653 |
$record = $exporter->export($output);
|
|
|
1654 |
return $record;
|
|
|
1655 |
}
|
|
|
1656 |
|
|
|
1657 |
/**
|
|
|
1658 |
* Returns description of create_template() result value.
|
|
|
1659 |
*
|
|
|
1660 |
* @return external_description
|
|
|
1661 |
*/
|
|
|
1662 |
public static function create_template_returns() {
|
|
|
1663 |
return template_exporter::get_read_structure();
|
|
|
1664 |
}
|
|
|
1665 |
|
|
|
1666 |
/**
|
|
|
1667 |
* Returns description of read_template() parameters.
|
|
|
1668 |
*
|
|
|
1669 |
* @return external_function_parameters
|
|
|
1670 |
*/
|
|
|
1671 |
public static function read_template_parameters() {
|
|
|
1672 |
$id = new external_value(
|
|
|
1673 |
PARAM_INT,
|
|
|
1674 |
'Data base record id for the template',
|
|
|
1675 |
VALUE_REQUIRED
|
|
|
1676 |
);
|
|
|
1677 |
|
|
|
1678 |
$params = array(
|
|
|
1679 |
'id' => $id,
|
|
|
1680 |
);
|
|
|
1681 |
return new external_function_parameters($params);
|
|
|
1682 |
}
|
|
|
1683 |
|
|
|
1684 |
/**
|
|
|
1685 |
* Read a learning plan template by id.
|
|
|
1686 |
*
|
|
|
1687 |
* @param int $id The id of the template.
|
|
|
1688 |
* @return \stdClass
|
|
|
1689 |
*/
|
|
|
1690 |
public static function read_template($id) {
|
|
|
1691 |
global $PAGE;
|
|
|
1692 |
|
|
|
1693 |
$params = self::validate_parameters(self::read_template_parameters(), array('id' => $id));
|
|
|
1694 |
$template = api::read_template($params['id']);
|
|
|
1695 |
self::validate_context($template->get_context());
|
|
|
1696 |
$output = $PAGE->get_renderer('core');
|
|
|
1697 |
|
|
|
1698 |
$exporter = new template_exporter($template);
|
|
|
1699 |
$record = $exporter->export($output);
|
|
|
1700 |
return $record;
|
|
|
1701 |
}
|
|
|
1702 |
|
|
|
1703 |
/**
|
|
|
1704 |
* Returns description of read_template() result value.
|
|
|
1705 |
*
|
|
|
1706 |
* @return external_description
|
|
|
1707 |
*/
|
|
|
1708 |
public static function read_template_returns() {
|
|
|
1709 |
return template_exporter::get_read_structure();
|
|
|
1710 |
}
|
|
|
1711 |
|
|
|
1712 |
/**
|
|
|
1713 |
* Returns description of delete_template() parameters.
|
|
|
1714 |
*
|
|
|
1715 |
* @return external_function_parameters
|
|
|
1716 |
*/
|
|
|
1717 |
public static function delete_template_parameters() {
|
|
|
1718 |
$id = new external_value(
|
|
|
1719 |
PARAM_INT,
|
|
|
1720 |
'Data base record id for the template',
|
|
|
1721 |
VALUE_REQUIRED
|
|
|
1722 |
);
|
|
|
1723 |
|
|
|
1724 |
$deleteplans = new external_value(
|
|
|
1725 |
PARAM_BOOL,
|
|
|
1726 |
'Boolean to indicate if plans must be deleted',
|
|
|
1727 |
VALUE_REQUIRED
|
|
|
1728 |
);
|
|
|
1729 |
|
|
|
1730 |
$params = array(
|
|
|
1731 |
'id' => $id,
|
|
|
1732 |
'deleteplans' => $deleteplans
|
|
|
1733 |
);
|
|
|
1734 |
return new external_function_parameters($params);
|
|
|
1735 |
}
|
|
|
1736 |
|
|
|
1737 |
/**
|
|
|
1738 |
* Delete a learning plan template
|
|
|
1739 |
*
|
|
|
1740 |
* @param int $id The learning plan template id
|
|
|
1741 |
* @param boolean $deleteplans True to delete the plans associated to template or false to unlink them
|
|
|
1742 |
* @return boolean
|
|
|
1743 |
*/
|
|
|
1744 |
public static function delete_template($id, $deleteplans = true) {
|
|
|
1745 |
$params = self::validate_parameters(self::delete_template_parameters(), array(
|
|
|
1746 |
'id' => $id,
|
|
|
1747 |
'deleteplans' => $deleteplans,
|
|
|
1748 |
));
|
|
|
1749 |
|
|
|
1750 |
$template = api::read_template($params['id']);
|
|
|
1751 |
self::validate_context($template->get_context());
|
|
|
1752 |
|
|
|
1753 |
return api::delete_template($params['id'], $params['deleteplans']);
|
|
|
1754 |
}
|
|
|
1755 |
|
|
|
1756 |
/**
|
|
|
1757 |
* Returns description of delete_template() result value.
|
|
|
1758 |
*
|
|
|
1759 |
* @return external_description
|
|
|
1760 |
*/
|
|
|
1761 |
public static function delete_template_returns() {
|
|
|
1762 |
return new external_value(PARAM_BOOL, 'True if the delete was successful');
|
|
|
1763 |
}
|
|
|
1764 |
|
|
|
1765 |
/**
|
|
|
1766 |
* Returns description of update_template() parameters.
|
|
|
1767 |
*
|
|
|
1768 |
* @return external_function_parameters
|
|
|
1769 |
*/
|
|
|
1770 |
public static function update_template_parameters() {
|
|
|
1771 |
$structure = template_exporter::get_update_structure();
|
|
|
1772 |
$params = array('template' => $structure);
|
|
|
1773 |
return new external_function_parameters($params);
|
|
|
1774 |
}
|
|
|
1775 |
|
|
|
1776 |
/**
|
|
|
1777 |
* Update an existing learning plan template
|
|
|
1778 |
*
|
|
|
1779 |
* @param array $template The list of fields for the template.
|
|
|
1780 |
* @return boolean
|
|
|
1781 |
*/
|
|
|
1782 |
public static function update_template($template) {
|
|
|
1783 |
|
|
|
1784 |
$params = self::validate_parameters(self::update_template_parameters(), array('template' => $template));
|
|
|
1785 |
$params = $params['template'];
|
|
|
1786 |
$template = api::read_template($params['id']);
|
|
|
1787 |
self::validate_context($template->get_context());
|
|
|
1788 |
|
|
|
1789 |
$params = (object) $params;
|
|
|
1790 |
|
|
|
1791 |
return api::update_template($params);
|
|
|
1792 |
}
|
|
|
1793 |
|
|
|
1794 |
/**
|
|
|
1795 |
* Returns description of update_template() result value.
|
|
|
1796 |
*
|
|
|
1797 |
* @return external_description
|
|
|
1798 |
*/
|
|
|
1799 |
public static function update_template_returns() {
|
|
|
1800 |
return new external_value(PARAM_BOOL, 'True if the update was successful');
|
|
|
1801 |
}
|
|
|
1802 |
|
|
|
1803 |
/**
|
|
|
1804 |
* Returns description of duplicate_template() parameters.
|
|
|
1805 |
*
|
|
|
1806 |
* @return external_function_parameters
|
|
|
1807 |
*/
|
|
|
1808 |
public static function duplicate_template_parameters() {
|
|
|
1809 |
$templateid = new external_value(
|
|
|
1810 |
PARAM_INT,
|
|
|
1811 |
'The template id',
|
|
|
1812 |
VALUE_REQUIRED
|
|
|
1813 |
);
|
|
|
1814 |
|
|
|
1815 |
$params = array(
|
|
|
1816 |
'id' => $templateid
|
|
|
1817 |
);
|
|
|
1818 |
return new external_function_parameters($params);
|
|
|
1819 |
}
|
|
|
1820 |
|
|
|
1821 |
/**
|
|
|
1822 |
* Duplicate a learning plan template.
|
|
|
1823 |
*
|
|
|
1824 |
* @param int $id the id of the learning plan template to duplicate
|
|
|
1825 |
* @return boolean Record of new template.
|
|
|
1826 |
*/
|
|
|
1827 |
public static function duplicate_template($id) {
|
|
|
1828 |
global $PAGE;
|
|
|
1829 |
|
|
|
1830 |
$params = self::validate_parameters(self::duplicate_template_parameters(), array('id' => $id));
|
|
|
1831 |
|
|
|
1832 |
$template = api::read_template($params['id']);
|
|
|
1833 |
self::validate_context($template->get_context());
|
|
|
1834 |
$output = $PAGE->get_renderer('core');
|
|
|
1835 |
|
|
|
1836 |
$result = api::duplicate_template($params['id']);
|
|
|
1837 |
$exporter = new template_exporter($result);
|
|
|
1838 |
return $exporter->export($output);
|
|
|
1839 |
}
|
|
|
1840 |
|
|
|
1841 |
/**
|
|
|
1842 |
* Returns description of duplicate_template() result value.
|
|
|
1843 |
*
|
|
|
1844 |
* @return external_description
|
|
|
1845 |
*/
|
|
|
1846 |
public static function duplicate_template_returns() {
|
|
|
1847 |
return template_exporter::get_read_structure();
|
|
|
1848 |
}
|
|
|
1849 |
|
|
|
1850 |
/**
|
|
|
1851 |
* Returns description of list_templates() parameters.
|
|
|
1852 |
*
|
|
|
1853 |
* @return external_function_parameters
|
|
|
1854 |
*/
|
|
|
1855 |
public static function list_templates_parameters() {
|
|
|
1856 |
$sort = new external_value(
|
|
|
1857 |
PARAM_ALPHANUMEXT,
|
|
|
1858 |
'Column to sort by.',
|
|
|
1859 |
VALUE_DEFAULT,
|
|
|
1860 |
''
|
|
|
1861 |
);
|
|
|
1862 |
$order = new external_value(
|
|
|
1863 |
PARAM_ALPHA,
|
|
|
1864 |
'Sort direction. Should be either ASC or DESC',
|
|
|
1865 |
VALUE_DEFAULT,
|
|
|
1866 |
''
|
|
|
1867 |
);
|
|
|
1868 |
$skip = new external_value(
|
|
|
1869 |
PARAM_INT,
|
|
|
1870 |
'Skip this number of records before returning results',
|
|
|
1871 |
VALUE_DEFAULT,
|
|
|
1872 |
|
|
|
1873 |
);
|
|
|
1874 |
$limit = new external_value(
|
|
|
1875 |
PARAM_INT,
|
|
|
1876 |
'Return this number of records at most.',
|
|
|
1877 |
VALUE_DEFAULT,
|
|
|
1878 |
|
|
|
1879 |
);
|
|
|
1880 |
$includes = new external_value(
|
|
|
1881 |
PARAM_ALPHA,
|
|
|
1882 |
'What other contexts to fetch the templates from. (children, parents, self)',
|
|
|
1883 |
VALUE_DEFAULT,
|
|
|
1884 |
'children'
|
|
|
1885 |
);
|
|
|
1886 |
$onlyvisible = new external_value(
|
|
|
1887 |
PARAM_BOOL,
|
|
|
1888 |
'If should list only visible templates',
|
|
|
1889 |
VALUE_DEFAULT,
|
|
|
1890 |
false
|
|
|
1891 |
);
|
|
|
1892 |
|
|
|
1893 |
$params = array(
|
|
|
1894 |
'sort' => $sort,
|
|
|
1895 |
'order' => $order,
|
|
|
1896 |
'skip' => $skip,
|
|
|
1897 |
'limit' => $limit,
|
|
|
1898 |
'context' => self::get_context_parameters(),
|
|
|
1899 |
'includes' => $includes,
|
|
|
1900 |
'onlyvisible' => $onlyvisible
|
|
|
1901 |
);
|
|
|
1902 |
return new external_function_parameters($params);
|
|
|
1903 |
}
|
|
|
1904 |
|
|
|
1905 |
/**
|
|
|
1906 |
* List the existing learning plan templates
|
|
|
1907 |
*
|
|
|
1908 |
* @param string $sort Field to sort by.
|
|
|
1909 |
* @param string $order Sort order.
|
|
|
1910 |
* @param int $skip Limitstart.
|
|
|
1911 |
* @param int $limit Number of rows to return.
|
|
|
1912 |
* @param array $context
|
|
|
1913 |
* @param bool $includes
|
|
|
1914 |
* @param bool $onlyvisible
|
|
|
1915 |
*
|
|
|
1916 |
* @return array
|
|
|
1917 |
*/
|
|
|
1918 |
public static function list_templates($sort, $order, $skip, $limit, $context, $includes, $onlyvisible) {
|
|
|
1919 |
global $PAGE;
|
|
|
1920 |
|
|
|
1921 |
$params = self::validate_parameters(self::list_templates_parameters(), array(
|
|
|
1922 |
'sort' => $sort,
|
|
|
1923 |
'order' => $order,
|
|
|
1924 |
'skip' => $skip,
|
|
|
1925 |
'limit' => $limit,
|
|
|
1926 |
'context' => $context,
|
|
|
1927 |
'includes' => $includes,
|
|
|
1928 |
'onlyvisible' => $onlyvisible
|
|
|
1929 |
));
|
|
|
1930 |
|
|
|
1931 |
$context = self::get_context_from_params($params['context']);
|
|
|
1932 |
self::validate_context($context);
|
|
|
1933 |
$output = $PAGE->get_renderer('core');
|
|
|
1934 |
|
|
|
1935 |
if ($params['order'] !== '' && $params['order'] !== 'ASC' && $params['order'] !== 'DESC') {
|
|
|
1936 |
throw new invalid_parameter_exception('Invalid order param. Must be ASC, DESC or empty.');
|
|
|
1937 |
}
|
|
|
1938 |
|
|
|
1939 |
$results = api::list_templates($params['sort'],
|
|
|
1940 |
$params['order'],
|
|
|
1941 |
$params['skip'],
|
|
|
1942 |
$params['limit'],
|
|
|
1943 |
$context,
|
|
|
1944 |
$params['includes'],
|
|
|
1945 |
$params['onlyvisible']);
|
|
|
1946 |
$records = array();
|
|
|
1947 |
foreach ($results as $result) {
|
|
|
1948 |
$exporter = new template_exporter($result);
|
|
|
1949 |
$record = $exporter->export($output);
|
|
|
1950 |
array_push($records, $record);
|
|
|
1951 |
}
|
|
|
1952 |
return $records;
|
|
|
1953 |
}
|
|
|
1954 |
|
|
|
1955 |
/**
|
|
|
1956 |
* Returns description of list_templates() result value.
|
|
|
1957 |
*
|
|
|
1958 |
* @return external_description
|
|
|
1959 |
*/
|
|
|
1960 |
public static function list_templates_returns() {
|
|
|
1961 |
return new external_multiple_structure(template_exporter::get_read_structure());
|
|
|
1962 |
}
|
|
|
1963 |
|
|
|
1964 |
/**
|
|
|
1965 |
* Returns description of count_templates() parameters.
|
|
|
1966 |
*
|
|
|
1967 |
* @return external_function_parameters
|
|
|
1968 |
*/
|
|
|
1969 |
public static function count_templates_parameters() {
|
|
|
1970 |
$includes = new external_value(
|
|
|
1971 |
PARAM_ALPHA,
|
|
|
1972 |
'What other contextes to fetch the frameworks from. (children, parents, self)',
|
|
|
1973 |
VALUE_DEFAULT,
|
|
|
1974 |
'children'
|
|
|
1975 |
);
|
|
|
1976 |
|
|
|
1977 |
$params = array(
|
|
|
1978 |
'context' => self::get_context_parameters(),
|
|
|
1979 |
'includes' => $includes
|
|
|
1980 |
);
|
|
|
1981 |
return new external_function_parameters($params);
|
|
|
1982 |
}
|
|
|
1983 |
|
|
|
1984 |
/**
|
|
|
1985 |
* Count the existing learning plan templates
|
|
|
1986 |
*
|
|
|
1987 |
* @param array $context
|
|
|
1988 |
* @param string $includes
|
|
|
1989 |
* @return int
|
|
|
1990 |
*/
|
|
|
1991 |
public static function count_templates($context, $includes) {
|
|
|
1992 |
$params = self::validate_parameters(self::count_templates_parameters(), array(
|
|
|
1993 |
'context' => $context,
|
|
|
1994 |
'includes' => $includes
|
|
|
1995 |
));
|
|
|
1996 |
$context = self::get_context_from_params($params['context']);
|
|
|
1997 |
self::validate_context($context);
|
|
|
1998 |
|
|
|
1999 |
return api::count_templates($context, $includes);
|
|
|
2000 |
}
|
|
|
2001 |
|
|
|
2002 |
/**
|
|
|
2003 |
* Returns description of count_templates() result value.
|
|
|
2004 |
*
|
|
|
2005 |
* @return external_description
|
|
|
2006 |
*/
|
|
|
2007 |
public static function count_templates_returns() {
|
|
|
2008 |
return new external_value(PARAM_INT, 'The number of learning plan templates found.');
|
|
|
2009 |
}
|
|
|
2010 |
|
|
|
2011 |
/**
|
|
|
2012 |
* Returns description of count_templates_using_competency() parameters.
|
|
|
2013 |
*
|
|
|
2014 |
* @return external_function_parameters
|
|
|
2015 |
*/
|
|
|
2016 |
public static function count_templates_using_competency_parameters() {
|
|
|
2017 |
$competencyid = new external_value(
|
|
|
2018 |
PARAM_INT,
|
|
|
2019 |
'The competency id',
|
|
|
2020 |
VALUE_REQUIRED
|
|
|
2021 |
);
|
|
|
2022 |
$params = array(
|
|
|
2023 |
'id' => $competencyid,
|
|
|
2024 |
);
|
|
|
2025 |
return new external_function_parameters($params);
|
|
|
2026 |
}
|
|
|
2027 |
|
|
|
2028 |
/**
|
|
|
2029 |
* Count the learning plan templates (visible to this user) that use this competency.
|
|
|
2030 |
*
|
|
|
2031 |
* @param int $competencyid Competency id.
|
|
|
2032 |
* @return int
|
|
|
2033 |
*/
|
|
|
2034 |
public static function count_templates_using_competency($competencyid) {
|
|
|
2035 |
$params = self::validate_parameters(self::count_templates_using_competency_parameters(), array(
|
|
|
2036 |
'id' => $competencyid,
|
|
|
2037 |
));
|
|
|
2038 |
|
|
|
2039 |
$competency = api::read_competency($params['id']);
|
|
|
2040 |
self::validate_context($competency->get_context());
|
|
|
2041 |
|
|
|
2042 |
return api::count_templates_using_competency($params['id']);
|
|
|
2043 |
}
|
|
|
2044 |
|
|
|
2045 |
/**
|
|
|
2046 |
* Returns description of count_templates_using_competency() result value.
|
|
|
2047 |
*
|
|
|
2048 |
* @return external_description
|
|
|
2049 |
*/
|
|
|
2050 |
public static function count_templates_using_competency_returns() {
|
|
|
2051 |
return new external_value(PARAM_INT, 'The number of learning plan templates using this competency');
|
|
|
2052 |
}
|
|
|
2053 |
|
|
|
2054 |
/**
|
|
|
2055 |
* Returns description of list_templates_using_competency() parameters.
|
|
|
2056 |
*
|
|
|
2057 |
* @return external_function_parameters
|
|
|
2058 |
*/
|
|
|
2059 |
public static function list_templates_using_competency_parameters() {
|
|
|
2060 |
$competencyid = new external_value(
|
|
|
2061 |
PARAM_INT,
|
|
|
2062 |
'The competency id',
|
|
|
2063 |
VALUE_REQUIRED
|
|
|
2064 |
);
|
|
|
2065 |
$params = array(
|
|
|
2066 |
'id' => $competencyid,
|
|
|
2067 |
);
|
|
|
2068 |
return new external_function_parameters($params);
|
|
|
2069 |
}
|
|
|
2070 |
|
|
|
2071 |
/**
|
|
|
2072 |
* List the learning plan templates (visible to this user) that use this competency.
|
|
|
2073 |
*
|
|
|
2074 |
* @param int $competencyid Competency id.
|
|
|
2075 |
* @return array
|
|
|
2076 |
*/
|
|
|
2077 |
public static function list_templates_using_competency($competencyid) {
|
|
|
2078 |
global $PAGE;
|
|
|
2079 |
|
|
|
2080 |
$params = self::validate_parameters(self::list_templates_using_competency_parameters(), array(
|
|
|
2081 |
'id' => $competencyid,
|
|
|
2082 |
));
|
|
|
2083 |
|
|
|
2084 |
$competency = api::read_competency($params['id']);
|
|
|
2085 |
self::validate_context($competency->get_context());
|
|
|
2086 |
$output = $PAGE->get_renderer('core');
|
|
|
2087 |
|
|
|
2088 |
$templates = api::list_templates_using_competency($params['id']);
|
|
|
2089 |
$records = array();
|
|
|
2090 |
|
|
|
2091 |
foreach ($templates as $template) {
|
|
|
2092 |
$exporter = new template_exporter($template);
|
|
|
2093 |
$record = $exporter->export($output);
|
|
|
2094 |
$records[] = $record;
|
|
|
2095 |
}
|
|
|
2096 |
|
|
|
2097 |
return $records;
|
|
|
2098 |
}
|
|
|
2099 |
|
|
|
2100 |
/**
|
|
|
2101 |
* Returns description of list_templates_using_competency() result value.
|
|
|
2102 |
*
|
|
|
2103 |
* @return external_description
|
|
|
2104 |
*/
|
|
|
2105 |
public static function list_templates_using_competency_returns() {
|
|
|
2106 |
return new external_multiple_structure(template_exporter::get_read_structure());
|
|
|
2107 |
}
|
|
|
2108 |
|
|
|
2109 |
/**
|
|
|
2110 |
* Returns description of count_competencies_in_template() parameters.
|
|
|
2111 |
*
|
|
|
2112 |
* @return external_function_parameters
|
|
|
2113 |
*/
|
|
|
2114 |
public static function count_competencies_in_template_parameters() {
|
|
|
2115 |
$templateid = new external_value(
|
|
|
2116 |
PARAM_INT,
|
|
|
2117 |
'The template id',
|
|
|
2118 |
VALUE_REQUIRED
|
|
|
2119 |
);
|
|
|
2120 |
$params = array(
|
|
|
2121 |
'id' => $templateid,
|
|
|
2122 |
);
|
|
|
2123 |
return new external_function_parameters($params);
|
|
|
2124 |
}
|
|
|
2125 |
|
|
|
2126 |
/**
|
|
|
2127 |
* Count the competencies (visible to this user) in this learning plan template.
|
|
|
2128 |
*
|
|
|
2129 |
* @param int $templateid The template id to check
|
|
|
2130 |
* @return int
|
|
|
2131 |
*/
|
|
|
2132 |
public static function count_competencies_in_template($templateid) {
|
|
|
2133 |
$params = self::validate_parameters(self::count_competencies_in_template_parameters(), array(
|
|
|
2134 |
'id' => $templateid,
|
|
|
2135 |
));
|
|
|
2136 |
$template = api::read_template($params['id']);
|
|
|
2137 |
self::validate_context($template->get_context());
|
|
|
2138 |
|
|
|
2139 |
return api::count_competencies_in_template($params['id']);
|
|
|
2140 |
}
|
|
|
2141 |
|
|
|
2142 |
/**
|
|
|
2143 |
* Returns description of count_competencies_in_template() result value.
|
|
|
2144 |
*
|
|
|
2145 |
* @return external_description
|
|
|
2146 |
*/
|
|
|
2147 |
public static function count_competencies_in_template_returns() {
|
|
|
2148 |
return new external_value(PARAM_INT, 'The number of competencies in this learning plan template.');
|
|
|
2149 |
}
|
|
|
2150 |
|
|
|
2151 |
/**
|
|
|
2152 |
* Returns description of list_competencies_in_template() parameters.
|
|
|
2153 |
*
|
|
|
2154 |
* @return external_function_parameters
|
|
|
2155 |
*/
|
|
|
2156 |
public static function list_competencies_in_template_parameters() {
|
|
|
2157 |
$templateid = new external_value(
|
|
|
2158 |
PARAM_INT,
|
|
|
2159 |
'The template id',
|
|
|
2160 |
VALUE_REQUIRED
|
|
|
2161 |
);
|
|
|
2162 |
$params = array(
|
|
|
2163 |
'id' => $templateid,
|
|
|
2164 |
);
|
|
|
2165 |
return new external_function_parameters($params);
|
|
|
2166 |
}
|
|
|
2167 |
|
|
|
2168 |
/**
|
|
|
2169 |
* List the competencies (visible to this user) in this learning plan template.
|
|
|
2170 |
*
|
|
|
2171 |
* @param int $templateid Template id.
|
|
|
2172 |
* @return array
|
|
|
2173 |
*/
|
|
|
2174 |
public static function list_competencies_in_template($templateid) {
|
|
|
2175 |
global $PAGE;
|
|
|
2176 |
|
|
|
2177 |
$params = self::validate_parameters(self::list_competencies_in_template_parameters(), array(
|
|
|
2178 |
'id' => $templateid,
|
|
|
2179 |
));
|
|
|
2180 |
|
|
|
2181 |
$template = api::read_template($params['id']);
|
|
|
2182 |
self::validate_context($template->get_context());
|
|
|
2183 |
$output = $PAGE->get_renderer('core');
|
|
|
2184 |
|
|
|
2185 |
$competencies = api::list_competencies_in_template($params['id']);
|
|
|
2186 |
$results = array();
|
|
|
2187 |
|
|
|
2188 |
$helper = new performance_helper();
|
|
|
2189 |
foreach ($competencies as $competency) {
|
|
|
2190 |
$context = $helper->get_context_from_competency($competency);
|
|
|
2191 |
$exporter = new competency_exporter($competency, array('context' => $context));
|
|
|
2192 |
$record = $exporter->export($output);
|
|
|
2193 |
array_push($results, $record);
|
|
|
2194 |
}
|
|
|
2195 |
return $results;
|
|
|
2196 |
}
|
|
|
2197 |
|
|
|
2198 |
/**
|
|
|
2199 |
* Returns description of list_competencies_in_template() result value.
|
|
|
2200 |
*
|
|
|
2201 |
* @return external_description
|
|
|
2202 |
*/
|
|
|
2203 |
public static function list_competencies_in_template_returns() {
|
|
|
2204 |
return new external_multiple_structure(competency_exporter::get_read_structure());
|
|
|
2205 |
}
|
|
|
2206 |
|
|
|
2207 |
/**
|
|
|
2208 |
* Returns description of add_competency_to_template() parameters.
|
|
|
2209 |
*
|
|
|
2210 |
* @return external_function_parameters
|
|
|
2211 |
*/
|
|
|
2212 |
public static function add_competency_to_template_parameters() {
|
|
|
2213 |
$templateid = new external_value(
|
|
|
2214 |
PARAM_INT,
|
|
|
2215 |
'The template id',
|
|
|
2216 |
VALUE_REQUIRED
|
|
|
2217 |
);
|
|
|
2218 |
$competencyid = new external_value(
|
|
|
2219 |
PARAM_INT,
|
|
|
2220 |
'The competency id',
|
|
|
2221 |
VALUE_REQUIRED
|
|
|
2222 |
);
|
|
|
2223 |
$params = array(
|
|
|
2224 |
'templateid' => $templateid,
|
|
|
2225 |
'competencyid' => $competencyid,
|
|
|
2226 |
);
|
|
|
2227 |
return new external_function_parameters($params);
|
|
|
2228 |
}
|
|
|
2229 |
|
|
|
2230 |
/**
|
|
|
2231 |
* Count the competencies (visible to this user) in this template.
|
|
|
2232 |
*
|
|
|
2233 |
* @param int $templateid Template id.
|
|
|
2234 |
* @param int $competencyid Competency id.
|
|
|
2235 |
* @return int
|
|
|
2236 |
*/
|
|
|
2237 |
public static function add_competency_to_template($templateid, $competencyid) {
|
|
|
2238 |
global $PAGE;
|
|
|
2239 |
$params = self::validate_parameters(self::add_competency_to_template_parameters(), array(
|
|
|
2240 |
'templateid' => $templateid,
|
|
|
2241 |
'competencyid' => $competencyid,
|
|
|
2242 |
));
|
|
|
2243 |
|
|
|
2244 |
$template = api::read_template($params['templateid']);
|
|
|
2245 |
self::validate_context($template->get_context());
|
|
|
2246 |
|
|
|
2247 |
return api::add_competency_to_template($params['templateid'], $params['competencyid']);
|
|
|
2248 |
}
|
|
|
2249 |
|
|
|
2250 |
/**
|
|
|
2251 |
* Returns description of add_competency_to_template() result value.
|
|
|
2252 |
*
|
|
|
2253 |
* @return external_description
|
|
|
2254 |
*/
|
|
|
2255 |
public static function add_competency_to_template_returns() {
|
|
|
2256 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
2257 |
}
|
|
|
2258 |
|
|
|
2259 |
/**
|
|
|
2260 |
* Returns description of add_competency_to_plan() parameters.
|
|
|
2261 |
*
|
|
|
2262 |
* @return external_function_parameters
|
|
|
2263 |
*/
|
|
|
2264 |
public static function add_competency_to_plan_parameters() {
|
|
|
2265 |
$planid = new external_value(
|
|
|
2266 |
PARAM_INT,
|
|
|
2267 |
'The plan id',
|
|
|
2268 |
VALUE_REQUIRED
|
|
|
2269 |
);
|
|
|
2270 |
$competencyid = new external_value(
|
|
|
2271 |
PARAM_INT,
|
|
|
2272 |
'The competency id',
|
|
|
2273 |
VALUE_REQUIRED
|
|
|
2274 |
);
|
|
|
2275 |
$params = array(
|
|
|
2276 |
'planid' => $planid,
|
|
|
2277 |
'competencyid' => $competencyid,
|
|
|
2278 |
);
|
|
|
2279 |
return new external_function_parameters($params);
|
|
|
2280 |
}
|
|
|
2281 |
|
|
|
2282 |
/**
|
|
|
2283 |
* add competency to a learning plan.
|
|
|
2284 |
*
|
|
|
2285 |
* @param int $planid Plan id.
|
|
|
2286 |
* @param int $competencyid Competency id.
|
|
|
2287 |
* @return int
|
|
|
2288 |
*/
|
|
|
2289 |
public static function add_competency_to_plan($planid, $competencyid) {
|
|
|
2290 |
$params = self::validate_parameters(self::add_competency_to_plan_parameters(), array(
|
|
|
2291 |
'planid' => $planid,
|
|
|
2292 |
'competencyid' => $competencyid,
|
|
|
2293 |
));
|
|
|
2294 |
|
|
|
2295 |
$plan = api::read_plan($params['planid']);
|
|
|
2296 |
self::validate_context($plan->get_context());
|
|
|
2297 |
|
|
|
2298 |
return api::add_competency_to_plan($params['planid'], $params['competencyid']);
|
|
|
2299 |
}
|
|
|
2300 |
|
|
|
2301 |
/**
|
|
|
2302 |
* Returns description of add_competency_to_plan() result value.
|
|
|
2303 |
*
|
|
|
2304 |
* @return external_description
|
|
|
2305 |
*/
|
|
|
2306 |
public static function add_competency_to_plan_returns() {
|
|
|
2307 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
2308 |
}
|
|
|
2309 |
|
|
|
2310 |
/**
|
|
|
2311 |
* Returns description of remove_competency_from_plan() parameters.
|
|
|
2312 |
*
|
|
|
2313 |
* @return external_function_parameters
|
|
|
2314 |
*/
|
|
|
2315 |
public static function remove_competency_from_plan_parameters() {
|
|
|
2316 |
$planid = new external_value(
|
|
|
2317 |
PARAM_INT,
|
|
|
2318 |
'The plan id',
|
|
|
2319 |
VALUE_REQUIRED
|
|
|
2320 |
);
|
|
|
2321 |
$competencyid = new external_value(
|
|
|
2322 |
PARAM_INT,
|
|
|
2323 |
'The competency id',
|
|
|
2324 |
VALUE_REQUIRED
|
|
|
2325 |
);
|
|
|
2326 |
$params = array(
|
|
|
2327 |
'planid' => $planid,
|
|
|
2328 |
'competencyid' => $competencyid,
|
|
|
2329 |
);
|
|
|
2330 |
return new external_function_parameters($params);
|
|
|
2331 |
}
|
|
|
2332 |
|
|
|
2333 |
/**
|
|
|
2334 |
* Remove a competency from plan.
|
|
|
2335 |
*
|
|
|
2336 |
* @param int $planid Plan id.
|
|
|
2337 |
* @param int $competencyid Competency id.
|
|
|
2338 |
* @return int
|
|
|
2339 |
*/
|
|
|
2340 |
public static function remove_competency_from_plan($planid, $competencyid) {
|
|
|
2341 |
$params = self::validate_parameters(self::remove_competency_from_plan_parameters(), array(
|
|
|
2342 |
'planid' => $planid,
|
|
|
2343 |
'competencyid' => $competencyid,
|
|
|
2344 |
));
|
|
|
2345 |
$plan = api::read_plan($params['planid']);
|
|
|
2346 |
self::validate_context($plan->get_context());
|
|
|
2347 |
|
|
|
2348 |
return api::remove_competency_from_plan($params['planid'], $params['competencyid']);
|
|
|
2349 |
}
|
|
|
2350 |
|
|
|
2351 |
/**
|
|
|
2352 |
* Returns description of remove_competency_from_plan() result value.
|
|
|
2353 |
*
|
|
|
2354 |
* @return external_description
|
|
|
2355 |
*/
|
|
|
2356 |
public static function remove_competency_from_plan_returns() {
|
|
|
2357 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
2358 |
}
|
|
|
2359 |
|
|
|
2360 |
/**
|
|
|
2361 |
* Returns description of remove_competency_from_template() parameters.
|
|
|
2362 |
*
|
|
|
2363 |
* @return external_function_parameters
|
|
|
2364 |
*/
|
|
|
2365 |
public static function remove_competency_from_template_parameters() {
|
|
|
2366 |
$templateid = new external_value(
|
|
|
2367 |
PARAM_INT,
|
|
|
2368 |
'The template id',
|
|
|
2369 |
VALUE_REQUIRED
|
|
|
2370 |
);
|
|
|
2371 |
$competencyid = new external_value(
|
|
|
2372 |
PARAM_INT,
|
|
|
2373 |
'The competency id',
|
|
|
2374 |
VALUE_REQUIRED
|
|
|
2375 |
);
|
|
|
2376 |
$params = array(
|
|
|
2377 |
'templateid' => $templateid,
|
|
|
2378 |
'competencyid' => $competencyid,
|
|
|
2379 |
);
|
|
|
2380 |
return new external_function_parameters($params);
|
|
|
2381 |
}
|
|
|
2382 |
|
|
|
2383 |
/**
|
|
|
2384 |
* Returns description of reorder_plan_competency() parameters.
|
|
|
2385 |
*
|
|
|
2386 |
* @return external_function_parameters
|
|
|
2387 |
*/
|
|
|
2388 |
public static function reorder_plan_competency_parameters() {
|
|
|
2389 |
$planid = new external_value(
|
|
|
2390 |
PARAM_INT,
|
|
|
2391 |
'The plan id',
|
|
|
2392 |
VALUE_REQUIRED
|
|
|
2393 |
);
|
|
|
2394 |
$competencyidfrom = new external_value(
|
|
|
2395 |
PARAM_INT,
|
|
|
2396 |
'The competency id we are moving',
|
|
|
2397 |
VALUE_REQUIRED
|
|
|
2398 |
);
|
|
|
2399 |
$competencyidto = new external_value(
|
|
|
2400 |
PARAM_INT,
|
|
|
2401 |
'The competency id we are moving to',
|
|
|
2402 |
VALUE_REQUIRED
|
|
|
2403 |
);
|
|
|
2404 |
$params = array(
|
|
|
2405 |
'planid' => $planid,
|
|
|
2406 |
'competencyidfrom' => $competencyidfrom,
|
|
|
2407 |
'competencyidto' => $competencyidto,
|
|
|
2408 |
);
|
|
|
2409 |
return new external_function_parameters($params);
|
|
|
2410 |
}
|
|
|
2411 |
|
|
|
2412 |
/**
|
|
|
2413 |
* Change the order of plan competencies.
|
|
|
2414 |
*
|
|
|
2415 |
* @param int $planid The plan id
|
|
|
2416 |
* @param int $competencyidfrom The competency to move.
|
|
|
2417 |
* @param int $competencyidto The competency to move to.
|
|
|
2418 |
* @return bool
|
|
|
2419 |
*/
|
|
|
2420 |
public static function reorder_plan_competency($planid, $competencyidfrom, $competencyidto) {
|
|
|
2421 |
$params = self::validate_parameters(self::reorder_plan_competency_parameters(), array(
|
|
|
2422 |
'planid' => $planid,
|
|
|
2423 |
'competencyidfrom' => $competencyidfrom,
|
|
|
2424 |
'competencyidto' => $competencyidto,
|
|
|
2425 |
));
|
|
|
2426 |
|
|
|
2427 |
$plan = api::read_plan($params['planid']);
|
|
|
2428 |
self::validate_context($plan->get_context());
|
|
|
2429 |
|
|
|
2430 |
return api::reorder_plan_competency($params['planid'], $params['competencyidfrom'], $params['competencyidto']);
|
|
|
2431 |
}
|
|
|
2432 |
|
|
|
2433 |
/**
|
|
|
2434 |
* Returns description of reorder_plan_competency() result value.
|
|
|
2435 |
*
|
|
|
2436 |
* @return external_description
|
|
|
2437 |
*/
|
|
|
2438 |
public static function reorder_plan_competency_returns() {
|
|
|
2439 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
2440 |
}
|
|
|
2441 |
|
|
|
2442 |
/**
|
|
|
2443 |
* Returns description of external function parameters.
|
|
|
2444 |
*
|
|
|
2445 |
* @return external_function_parameters
|
|
|
2446 |
*/
|
|
|
2447 |
public static function user_competency_cancel_review_request_parameters() {
|
|
|
2448 |
return new external_function_parameters(array(
|
|
|
2449 |
'userid' => new external_value(PARAM_INT, 'The user ID'),
|
|
|
2450 |
'competencyid' => new external_value(PARAM_INT, 'The competency ID'),
|
|
|
2451 |
));
|
|
|
2452 |
}
|
|
|
2453 |
|
|
|
2454 |
/**
|
|
|
2455 |
* External function user_competency_cancel_review_request.
|
|
|
2456 |
*
|
|
|
2457 |
* @param int $userid The user ID.
|
|
|
2458 |
* @param int $competencyid The competency ID.
|
|
|
2459 |
* @return boolean
|
|
|
2460 |
*/
|
|
|
2461 |
public static function user_competency_cancel_review_request($userid, $competencyid) {
|
|
|
2462 |
$params = self::validate_parameters(self::user_competency_cancel_review_request_parameters(), array(
|
|
|
2463 |
'userid' => $userid,
|
|
|
2464 |
'competencyid' => $competencyid
|
|
|
2465 |
));
|
|
|
2466 |
|
|
|
2467 |
$context = context_user::instance($params['userid']);
|
|
|
2468 |
self::validate_context($context);
|
|
|
2469 |
|
|
|
2470 |
return api::user_competency_cancel_review_request($userid, $competencyid);
|
|
|
2471 |
}
|
|
|
2472 |
|
|
|
2473 |
/**
|
|
|
2474 |
* Returns description of external function result value.
|
|
|
2475 |
*
|
|
|
2476 |
* @return external_function_parameters
|
|
|
2477 |
*/
|
|
|
2478 |
public static function user_competency_cancel_review_request_returns() {
|
|
|
2479 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
2480 |
}
|
|
|
2481 |
|
|
|
2482 |
/**
|
|
|
2483 |
* Returns description of external function parameters.
|
|
|
2484 |
*
|
|
|
2485 |
* @return external_function_parameters
|
|
|
2486 |
*/
|
|
|
2487 |
public static function user_competency_request_review_parameters() {
|
|
|
2488 |
return new external_function_parameters(array(
|
|
|
2489 |
'userid' => new external_value(PARAM_INT, 'The user ID'),
|
|
|
2490 |
'competencyid' => new external_value(PARAM_INT, 'The competency ID'),
|
|
|
2491 |
));
|
|
|
2492 |
}
|
|
|
2493 |
|
|
|
2494 |
/**
|
|
|
2495 |
* External function user_competency_request_review.
|
|
|
2496 |
*
|
|
|
2497 |
* @param int $userid The user ID.
|
|
|
2498 |
* @param int $competencyid The competency ID.
|
|
|
2499 |
* @return boolean
|
|
|
2500 |
*/
|
|
|
2501 |
public static function user_competency_request_review($userid, $competencyid) {
|
|
|
2502 |
$params = self::validate_parameters(self::user_competency_request_review_parameters(), array(
|
|
|
2503 |
'userid' => $userid,
|
|
|
2504 |
'competencyid' => $competencyid,
|
|
|
2505 |
));
|
|
|
2506 |
|
|
|
2507 |
$context = context_user::instance($params['userid']);
|
|
|
2508 |
self::validate_context($context);
|
|
|
2509 |
|
|
|
2510 |
return api::user_competency_request_review($userid, $competencyid);
|
|
|
2511 |
}
|
|
|
2512 |
|
|
|
2513 |
/**
|
|
|
2514 |
* Returns description of external function result value.
|
|
|
2515 |
*
|
|
|
2516 |
* @return external_function_parameters
|
|
|
2517 |
*/
|
|
|
2518 |
public static function user_competency_request_review_returns() {
|
|
|
2519 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
2520 |
}
|
|
|
2521 |
|
|
|
2522 |
/**
|
|
|
2523 |
* Returns description of external function parameters.
|
|
|
2524 |
*
|
|
|
2525 |
* @return external_function_parameters
|
|
|
2526 |
*/
|
|
|
2527 |
public static function user_competency_start_review_parameters() {
|
|
|
2528 |
return new external_function_parameters(array(
|
|
|
2529 |
'userid' => new external_value(PARAM_INT, 'The user ID'),
|
|
|
2530 |
'competencyid' => new external_value(PARAM_INT, 'The competency ID'),
|
|
|
2531 |
));
|
|
|
2532 |
}
|
|
|
2533 |
|
|
|
2534 |
/**
|
|
|
2535 |
* External function user_competency_start_review.
|
|
|
2536 |
*
|
|
|
2537 |
* @param int $userid The user ID.
|
|
|
2538 |
* @param int $competencyid The competency ID.
|
|
|
2539 |
* @return boolean
|
|
|
2540 |
*/
|
|
|
2541 |
public static function user_competency_start_review($userid, $competencyid) {
|
|
|
2542 |
$params = self::validate_parameters(self::user_competency_start_review_parameters(), array(
|
|
|
2543 |
'userid' => $userid,
|
|
|
2544 |
'competencyid' => $competencyid
|
|
|
2545 |
));
|
|
|
2546 |
|
|
|
2547 |
$context = context_user::instance($params['userid']);
|
|
|
2548 |
self::validate_context($context);
|
|
|
2549 |
|
|
|
2550 |
return api::user_competency_start_review($userid, $competencyid);
|
|
|
2551 |
}
|
|
|
2552 |
|
|
|
2553 |
/**
|
|
|
2554 |
* Returns description of external function result value.
|
|
|
2555 |
*
|
|
|
2556 |
* @return external_function_parameters
|
|
|
2557 |
*/
|
|
|
2558 |
public static function user_competency_start_review_returns() {
|
|
|
2559 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
2560 |
}
|
|
|
2561 |
|
|
|
2562 |
/**
|
|
|
2563 |
* Returns description of external function parameters.
|
|
|
2564 |
*
|
|
|
2565 |
* @return external_function_parameters
|
|
|
2566 |
*/
|
|
|
2567 |
public static function user_competency_stop_review_parameters() {
|
|
|
2568 |
return new external_function_parameters(array(
|
|
|
2569 |
'userid' => new external_value(PARAM_INT, 'The user ID'),
|
|
|
2570 |
'competencyid' => new external_value(PARAM_INT, 'The competency ID'),
|
|
|
2571 |
));
|
|
|
2572 |
}
|
|
|
2573 |
|
|
|
2574 |
/**
|
|
|
2575 |
* External function user_competency_stop_review.
|
|
|
2576 |
*
|
|
|
2577 |
* @param int $userid The user ID.
|
|
|
2578 |
* @param int $competencyid The competency ID.
|
|
|
2579 |
* @return boolean
|
|
|
2580 |
*/
|
|
|
2581 |
public static function user_competency_stop_review($userid, $competencyid) {
|
|
|
2582 |
$params = self::validate_parameters(self::user_competency_stop_review_parameters(), array(
|
|
|
2583 |
'userid' => $userid,
|
|
|
2584 |
'competencyid' => $competencyid
|
|
|
2585 |
));
|
|
|
2586 |
|
|
|
2587 |
$context = context_user::instance($params['userid']);
|
|
|
2588 |
self::validate_context($context);
|
|
|
2589 |
|
|
|
2590 |
return api::user_competency_stop_review($userid, $competencyid);
|
|
|
2591 |
}
|
|
|
2592 |
|
|
|
2593 |
/**
|
|
|
2594 |
* Returns description of external function result value.
|
|
|
2595 |
*
|
|
|
2596 |
* @return external_function_parameters
|
|
|
2597 |
*/
|
|
|
2598 |
public static function user_competency_stop_review_returns() {
|
|
|
2599 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
2600 |
}
|
|
|
2601 |
|
|
|
2602 |
/**
|
|
|
2603 |
* Returns description of template_has_related_data() parameters.
|
|
|
2604 |
*
|
|
|
2605 |
* @return external_function_parameters
|
|
|
2606 |
*/
|
|
|
2607 |
public static function template_has_related_data_parameters() {
|
|
|
2608 |
$templateid = new external_value(
|
|
|
2609 |
PARAM_INT,
|
|
|
2610 |
'The template id',
|
|
|
2611 |
VALUE_REQUIRED
|
|
|
2612 |
);
|
|
|
2613 |
$params = array(
|
|
|
2614 |
'id' => $templateid,
|
|
|
2615 |
);
|
|
|
2616 |
return new external_function_parameters($params);
|
|
|
2617 |
}
|
|
|
2618 |
|
|
|
2619 |
/**
|
|
|
2620 |
* Check if template has related data.
|
|
|
2621 |
*
|
|
|
2622 |
* @param int $templateid Template id.
|
|
|
2623 |
* @return boolean
|
|
|
2624 |
*/
|
|
|
2625 |
public static function template_has_related_data($templateid) {
|
|
|
2626 |
$params = self::validate_parameters(self::template_has_related_data_parameters(), array(
|
|
|
2627 |
'id' => $templateid,
|
|
|
2628 |
));
|
|
|
2629 |
|
|
|
2630 |
$template = api::read_template($params['id']);
|
|
|
2631 |
self::validate_context($template->get_context());
|
|
|
2632 |
|
|
|
2633 |
return api::template_has_related_data($params['id']);
|
|
|
2634 |
}
|
|
|
2635 |
|
|
|
2636 |
/**
|
|
|
2637 |
* Returns description of template_has_related_data() result value.
|
|
|
2638 |
*
|
|
|
2639 |
* @return external_description
|
|
|
2640 |
*/
|
|
|
2641 |
public static function template_has_related_data_returns() {
|
|
|
2642 |
return new external_value(PARAM_BOOL, 'True if the template has related data');
|
|
|
2643 |
}
|
|
|
2644 |
|
|
|
2645 |
/**
|
|
|
2646 |
* Count the competencies (visible to this user) in this learning plan template.
|
|
|
2647 |
*
|
|
|
2648 |
* @param int $templateid Template id.
|
|
|
2649 |
* @param int $competencyid Competency id.
|
|
|
2650 |
* @return int
|
|
|
2651 |
*/
|
|
|
2652 |
public static function remove_competency_from_template($templateid, $competencyid) {
|
|
|
2653 |
$params = self::validate_parameters(self::remove_competency_from_template_parameters(), array(
|
|
|
2654 |
'templateid' => $templateid,
|
|
|
2655 |
'competencyid' => $competencyid,
|
|
|
2656 |
));
|
|
|
2657 |
$template = api::read_template($params['templateid']);
|
|
|
2658 |
self::validate_context($template->get_context());
|
|
|
2659 |
|
|
|
2660 |
return api::remove_competency_from_template($params['templateid'], $params['competencyid']);
|
|
|
2661 |
}
|
|
|
2662 |
|
|
|
2663 |
/**
|
|
|
2664 |
* Returns description of remove_competency_from_template() result value.
|
|
|
2665 |
*
|
|
|
2666 |
* @return external_description
|
|
|
2667 |
*/
|
|
|
2668 |
public static function remove_competency_from_template_returns() {
|
|
|
2669 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
2670 |
}
|
|
|
2671 |
|
|
|
2672 |
/**
|
|
|
2673 |
* Returns description of create_plan() parameters.
|
|
|
2674 |
*
|
|
|
2675 |
* @return external_function_parameters
|
|
|
2676 |
*/
|
|
|
2677 |
public static function create_plan_parameters() {
|
|
|
2678 |
$structure = plan_exporter::get_create_structure();
|
|
|
2679 |
$params = array('plan' => $structure);
|
|
|
2680 |
return new external_function_parameters($params);
|
|
|
2681 |
}
|
|
|
2682 |
|
|
|
2683 |
/**
|
|
|
2684 |
* Create a new learning plan.
|
|
|
2685 |
*
|
|
|
2686 |
* @param array $plan List of fields for the plan.
|
|
|
2687 |
* @return array New plan record.
|
|
|
2688 |
*/
|
|
|
2689 |
public static function create_plan($plan) {
|
|
|
2690 |
global $PAGE;
|
|
|
2691 |
|
|
|
2692 |
$params = self::validate_parameters(self::create_plan_parameters(), array('plan' => $plan));
|
|
|
2693 |
$params = $params['plan'];
|
|
|
2694 |
|
|
|
2695 |
$context = context_user::instance($params['userid']);
|
|
|
2696 |
self::validate_context($context);
|
|
|
2697 |
$output = $PAGE->get_renderer('core');
|
|
|
2698 |
|
|
|
2699 |
$params = (object) $params;
|
|
|
2700 |
|
|
|
2701 |
$result = api::create_plan($params);
|
|
|
2702 |
$exporter = new plan_exporter($result, array('template' => null));
|
|
|
2703 |
return $exporter->export($output);
|
|
|
2704 |
}
|
|
|
2705 |
|
|
|
2706 |
/**
|
|
|
2707 |
* Returns description of create_plan() result value.
|
|
|
2708 |
*
|
|
|
2709 |
* @return external_description
|
|
|
2710 |
*/
|
|
|
2711 |
public static function create_plan_returns() {
|
|
|
2712 |
return plan_exporter::get_read_structure();
|
|
|
2713 |
}
|
|
|
2714 |
|
|
|
2715 |
/**
|
|
|
2716 |
* Returns description of update_plan() parameters.
|
|
|
2717 |
*
|
|
|
2718 |
* @return external_function_parameters
|
|
|
2719 |
*/
|
|
|
2720 |
public static function update_plan_parameters() {
|
|
|
2721 |
$structure = plan_exporter::get_update_structure();
|
|
|
2722 |
$params = array('plan' => $structure);
|
|
|
2723 |
return new external_function_parameters($params);
|
|
|
2724 |
}
|
|
|
2725 |
|
|
|
2726 |
/**
|
|
|
2727 |
* Updates a new learning plan.
|
|
|
2728 |
*
|
|
|
2729 |
* @param array $plan Fields for the plan (id is required)
|
|
|
2730 |
* @return mixed
|
|
|
2731 |
*/
|
|
|
2732 |
public static function update_plan($plan) {
|
|
|
2733 |
global $PAGE;
|
|
|
2734 |
|
|
|
2735 |
$params = self::validate_parameters(self::update_plan_parameters(), array('plan' => $plan));
|
|
|
2736 |
|
|
|
2737 |
$params = $params['plan'];
|
|
|
2738 |
|
|
|
2739 |
$plan = api::read_plan($params['id']);
|
|
|
2740 |
self::validate_context($plan->get_context());
|
|
|
2741 |
$output = $PAGE->get_renderer('core');
|
|
|
2742 |
|
|
|
2743 |
$params = (object) $params;
|
|
|
2744 |
$result = api::update_plan($params);
|
|
|
2745 |
$exporter = new plan_exporter($result, ['template' => $plan->get_template()]);
|
|
|
2746 |
return $exporter->export($output);
|
|
|
2747 |
}
|
|
|
2748 |
|
|
|
2749 |
/**
|
|
|
2750 |
* Returns description of update_plan() result value.
|
|
|
2751 |
*
|
|
|
2752 |
* @return external_description
|
|
|
2753 |
*/
|
|
|
2754 |
public static function update_plan_returns() {
|
|
|
2755 |
return plan_exporter::get_read_structure();
|
|
|
2756 |
}
|
|
|
2757 |
|
|
|
2758 |
/**
|
|
|
2759 |
* Returns description of complete_plan() parameters.
|
|
|
2760 |
*
|
|
|
2761 |
* @return external_function_parameters
|
|
|
2762 |
*/
|
|
|
2763 |
public static function complete_plan_parameters() {
|
|
|
2764 |
$planid = new external_value(
|
|
|
2765 |
PARAM_INT,
|
|
|
2766 |
'The plan id',
|
|
|
2767 |
VALUE_REQUIRED
|
|
|
2768 |
);
|
|
|
2769 |
$params = array('planid' => $planid);
|
|
|
2770 |
return new external_function_parameters($params);
|
|
|
2771 |
}
|
|
|
2772 |
|
|
|
2773 |
/**
|
|
|
2774 |
* Complete Learning plan.
|
|
|
2775 |
*
|
|
|
2776 |
* @param int $planid plan id (id is required)
|
|
|
2777 |
* @return boolean
|
|
|
2778 |
*/
|
|
|
2779 |
public static function complete_plan($planid) {
|
|
|
2780 |
$params = self::validate_parameters(self::complete_plan_parameters(), array(
|
|
|
2781 |
'planid' => $planid
|
|
|
2782 |
));
|
|
|
2783 |
|
|
|
2784 |
return api::complete_plan($params['planid']);
|
|
|
2785 |
}
|
|
|
2786 |
|
|
|
2787 |
/**
|
|
|
2788 |
* Returns description of complete_plan() result value.
|
|
|
2789 |
*
|
|
|
2790 |
* @return external_description
|
|
|
2791 |
*/
|
|
|
2792 |
public static function complete_plan_returns() {
|
|
|
2793 |
return new external_value(PARAM_BOOL, 'True if completing learning plan was successful');
|
|
|
2794 |
}
|
|
|
2795 |
|
|
|
2796 |
/**
|
|
|
2797 |
* Returns description of reopen_plan() parameters.
|
|
|
2798 |
*
|
|
|
2799 |
* @return external_function_parameters
|
|
|
2800 |
*/
|
|
|
2801 |
public static function reopen_plan_parameters() {
|
|
|
2802 |
$planid = new external_value(
|
|
|
2803 |
PARAM_INT,
|
|
|
2804 |
'The plan id',
|
|
|
2805 |
VALUE_REQUIRED
|
|
|
2806 |
);
|
|
|
2807 |
$params = array('planid' => $planid);
|
|
|
2808 |
return new external_function_parameters($params);
|
|
|
2809 |
}
|
|
|
2810 |
|
|
|
2811 |
/**
|
|
|
2812 |
* Reopen Learning plan.
|
|
|
2813 |
*
|
|
|
2814 |
* @param int $planid plan id (id is required)
|
|
|
2815 |
* @return boolean
|
|
|
2816 |
*/
|
|
|
2817 |
public static function reopen_plan($planid) {
|
|
|
2818 |
$params = self::validate_parameters(self::reopen_plan_parameters(), array(
|
|
|
2819 |
'planid' => $planid
|
|
|
2820 |
));
|
|
|
2821 |
|
|
|
2822 |
return api::reopen_plan($params['planid']);
|
|
|
2823 |
}
|
|
|
2824 |
|
|
|
2825 |
/**
|
|
|
2826 |
* Returns description of reopen_plan() result value.
|
|
|
2827 |
*
|
|
|
2828 |
* @return external_description
|
|
|
2829 |
*/
|
|
|
2830 |
public static function reopen_plan_returns() {
|
|
|
2831 |
return new external_value(PARAM_BOOL, 'True if reopening learning plan was successful');
|
|
|
2832 |
}
|
|
|
2833 |
|
|
|
2834 |
/**
|
|
|
2835 |
* Returns description of read_plan() parameters.
|
|
|
2836 |
*
|
|
|
2837 |
* @return external_function_parameters
|
|
|
2838 |
*/
|
|
|
2839 |
public static function read_plan_parameters() {
|
|
|
2840 |
$id = new external_value(
|
|
|
2841 |
PARAM_INT,
|
|
|
2842 |
'Data base record id for the plan',
|
|
|
2843 |
VALUE_REQUIRED
|
|
|
2844 |
);
|
|
|
2845 |
return new external_function_parameters(array('id' => $id));
|
|
|
2846 |
}
|
|
|
2847 |
|
|
|
2848 |
/**
|
|
|
2849 |
* Read a plan by id.
|
|
|
2850 |
*
|
|
|
2851 |
* @param int $id The id of the plan.
|
|
|
2852 |
* @return \stdClass
|
|
|
2853 |
*/
|
|
|
2854 |
public static function read_plan($id) {
|
|
|
2855 |
global $PAGE;
|
|
|
2856 |
|
|
|
2857 |
$params = self::validate_parameters(self::read_plan_parameters(), array(
|
|
|
2858 |
'id' => $id,
|
|
|
2859 |
));
|
|
|
2860 |
|
|
|
2861 |
$plan = api::read_plan($params['id']);
|
|
|
2862 |
self::validate_context($plan->get_context());
|
|
|
2863 |
$output = $PAGE->get_renderer('core');
|
|
|
2864 |
|
|
|
2865 |
$exporter = new plan_exporter($plan, array('template' => $plan->get_template()));
|
|
|
2866 |
$record = $exporter->export($output);
|
|
|
2867 |
return external_api::clean_returnvalue(self::read_plan_returns(), $record);
|
|
|
2868 |
}
|
|
|
2869 |
|
|
|
2870 |
/**
|
|
|
2871 |
* Returns description of read_plan() result value.
|
|
|
2872 |
*
|
|
|
2873 |
* @return external_description
|
|
|
2874 |
*/
|
|
|
2875 |
public static function read_plan_returns() {
|
|
|
2876 |
return plan_exporter::get_read_structure();
|
|
|
2877 |
}
|
|
|
2878 |
|
|
|
2879 |
/**
|
|
|
2880 |
* Returns description of delete_plan() parameters.
|
|
|
2881 |
*
|
|
|
2882 |
* @return external_function_parameters
|
|
|
2883 |
*/
|
|
|
2884 |
public static function delete_plan_parameters() {
|
|
|
2885 |
$id = new external_value(
|
|
|
2886 |
PARAM_INT,
|
|
|
2887 |
'Data base record id for the learning plan',
|
|
|
2888 |
VALUE_REQUIRED
|
|
|
2889 |
);
|
|
|
2890 |
|
|
|
2891 |
$params = array(
|
|
|
2892 |
'id' => $id,
|
|
|
2893 |
);
|
|
|
2894 |
return new external_function_parameters($params);
|
|
|
2895 |
}
|
|
|
2896 |
|
|
|
2897 |
/**
|
|
|
2898 |
* Delete a plan.
|
|
|
2899 |
*
|
|
|
2900 |
* @param int $id The plan id
|
|
|
2901 |
* @return boolean
|
|
|
2902 |
*/
|
|
|
2903 |
public static function delete_plan($id) {
|
|
|
2904 |
$params = self::validate_parameters(self::delete_plan_parameters(), array(
|
|
|
2905 |
'id' => $id,
|
|
|
2906 |
));
|
|
|
2907 |
|
|
|
2908 |
$plan = api::read_plan($params['id']);
|
|
|
2909 |
self::validate_context($plan->get_context());
|
|
|
2910 |
|
|
|
2911 |
return external_api::clean_returnvalue(self::delete_plan_returns(), api::delete_plan($params['id']));
|
|
|
2912 |
}
|
|
|
2913 |
|
|
|
2914 |
/**
|
|
|
2915 |
* Returns description of delete_plan() result value.
|
|
|
2916 |
*
|
|
|
2917 |
* @return external_description
|
|
|
2918 |
*/
|
|
|
2919 |
public static function delete_plan_returns() {
|
|
|
2920 |
return new external_value(PARAM_BOOL, 'True if the delete was successful');
|
|
|
2921 |
}
|
|
|
2922 |
|
|
|
2923 |
/**
|
|
|
2924 |
* Returns description of external function parameters.
|
|
|
2925 |
*
|
|
|
2926 |
* @return external_function_parameters
|
|
|
2927 |
*/
|
|
|
2928 |
public static function plan_cancel_review_request_parameters() {
|
|
|
2929 |
return new external_function_parameters(array(
|
|
|
2930 |
'id' => new external_value(PARAM_INT, 'The plan ID'),
|
|
|
2931 |
));
|
|
|
2932 |
}
|
|
|
2933 |
|
|
|
2934 |
/**
|
|
|
2935 |
* External function plan_cancel_review_request.
|
|
|
2936 |
*
|
|
|
2937 |
* @param int $id The plan ID.
|
|
|
2938 |
* @return boolean
|
|
|
2939 |
*/
|
|
|
2940 |
public static function plan_cancel_review_request($id) {
|
|
|
2941 |
$params = self::validate_parameters(self::plan_cancel_review_request_parameters(), array(
|
|
|
2942 |
'id' => $id
|
|
|
2943 |
));
|
|
|
2944 |
|
|
|
2945 |
$plan = api::read_plan($id);
|
|
|
2946 |
self::validate_context($plan->get_context());
|
|
|
2947 |
|
|
|
2948 |
return api::plan_cancel_review_request($plan);
|
|
|
2949 |
}
|
|
|
2950 |
|
|
|
2951 |
/**
|
|
|
2952 |
* Returns description of external function result value.
|
|
|
2953 |
*
|
|
|
2954 |
* @return external_function_parameters
|
|
|
2955 |
*/
|
|
|
2956 |
public static function plan_cancel_review_request_returns() {
|
|
|
2957 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
2958 |
}
|
|
|
2959 |
|
|
|
2960 |
/**
|
|
|
2961 |
* Returns description of external function parameters.
|
|
|
2962 |
*
|
|
|
2963 |
* @return external_function_parameters
|
|
|
2964 |
*/
|
|
|
2965 |
public static function plan_request_review_parameters() {
|
|
|
2966 |
return new external_function_parameters(array(
|
|
|
2967 |
'id' => new external_value(PARAM_INT, 'The plan ID'),
|
|
|
2968 |
));
|
|
|
2969 |
}
|
|
|
2970 |
|
|
|
2971 |
/**
|
|
|
2972 |
* External function plan_request_review.
|
|
|
2973 |
*
|
|
|
2974 |
* @param int $id The plan ID.
|
|
|
2975 |
* @return boolean
|
|
|
2976 |
*/
|
|
|
2977 |
public static function plan_request_review($id) {
|
|
|
2978 |
$params = self::validate_parameters(self::plan_request_review_parameters(), array(
|
|
|
2979 |
'id' => $id
|
|
|
2980 |
));
|
|
|
2981 |
|
|
|
2982 |
$plan = api::read_plan($id);
|
|
|
2983 |
self::validate_context($plan->get_context());
|
|
|
2984 |
|
|
|
2985 |
return api::plan_request_review($plan);
|
|
|
2986 |
}
|
|
|
2987 |
|
|
|
2988 |
/**
|
|
|
2989 |
* Returns description of external function result value.
|
|
|
2990 |
*
|
|
|
2991 |
* @return external_function_parameters
|
|
|
2992 |
*/
|
|
|
2993 |
public static function plan_request_review_returns() {
|
|
|
2994 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
2995 |
}
|
|
|
2996 |
|
|
|
2997 |
/**
|
|
|
2998 |
* Returns description of external function parameters.
|
|
|
2999 |
*
|
|
|
3000 |
* @return external_function_parameters
|
|
|
3001 |
*/
|
|
|
3002 |
public static function plan_start_review_parameters() {
|
|
|
3003 |
return new external_function_parameters(array(
|
|
|
3004 |
'id' => new external_value(PARAM_INT, 'The plan ID'),
|
|
|
3005 |
));
|
|
|
3006 |
}
|
|
|
3007 |
|
|
|
3008 |
/**
|
|
|
3009 |
* External function plan_start_review.
|
|
|
3010 |
*
|
|
|
3011 |
* @param int $id The plan ID.
|
|
|
3012 |
* @return boolean
|
|
|
3013 |
*/
|
|
|
3014 |
public static function plan_start_review($id) {
|
|
|
3015 |
$params = self::validate_parameters(self::plan_start_review_parameters(), array(
|
|
|
3016 |
'id' => $id
|
|
|
3017 |
));
|
|
|
3018 |
|
|
|
3019 |
$plan = api::read_plan($id);
|
|
|
3020 |
self::validate_context($plan->get_context());
|
|
|
3021 |
|
|
|
3022 |
return api::plan_start_review($plan);
|
|
|
3023 |
}
|
|
|
3024 |
|
|
|
3025 |
/**
|
|
|
3026 |
* Returns description of external function result value.
|
|
|
3027 |
*
|
|
|
3028 |
* @return external_function_parameters
|
|
|
3029 |
*/
|
|
|
3030 |
public static function plan_start_review_returns() {
|
|
|
3031 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
3032 |
}
|
|
|
3033 |
|
|
|
3034 |
/**
|
|
|
3035 |
* Returns description of external function parameters.
|
|
|
3036 |
*
|
|
|
3037 |
* @return external_function_parameters
|
|
|
3038 |
*/
|
|
|
3039 |
public static function plan_stop_review_parameters() {
|
|
|
3040 |
return new external_function_parameters(array(
|
|
|
3041 |
'id' => new external_value(PARAM_INT, 'The plan ID'),
|
|
|
3042 |
));
|
|
|
3043 |
}
|
|
|
3044 |
|
|
|
3045 |
/**
|
|
|
3046 |
* External function plan_stop_review.
|
|
|
3047 |
*
|
|
|
3048 |
* @param int $id The plan ID.
|
|
|
3049 |
* @return boolean
|
|
|
3050 |
*/
|
|
|
3051 |
public static function plan_stop_review($id) {
|
|
|
3052 |
$params = self::validate_parameters(self::plan_stop_review_parameters(), array(
|
|
|
3053 |
'id' => $id
|
|
|
3054 |
));
|
|
|
3055 |
|
|
|
3056 |
$plan = api::read_plan($id);
|
|
|
3057 |
self::validate_context($plan->get_context());
|
|
|
3058 |
|
|
|
3059 |
return api::plan_stop_review($plan);
|
|
|
3060 |
}
|
|
|
3061 |
|
|
|
3062 |
/**
|
|
|
3063 |
* Returns description of external function result value.
|
|
|
3064 |
*
|
|
|
3065 |
* @return external_function_parameters
|
|
|
3066 |
*/
|
|
|
3067 |
public static function plan_stop_review_returns() {
|
|
|
3068 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
3069 |
}
|
|
|
3070 |
|
|
|
3071 |
/**
|
|
|
3072 |
* Returns description of external function parameters.
|
|
|
3073 |
*
|
|
|
3074 |
* @return external_function_parameters
|
|
|
3075 |
*/
|
|
|
3076 |
public static function approve_plan_parameters() {
|
|
|
3077 |
return new external_function_parameters(array(
|
|
|
3078 |
'id' => new external_value(PARAM_INT, 'The plan ID'),
|
|
|
3079 |
));
|
|
|
3080 |
}
|
|
|
3081 |
|
|
|
3082 |
/**
|
|
|
3083 |
* External function approve_plan.
|
|
|
3084 |
*
|
|
|
3085 |
* @param int $id The plan ID.
|
|
|
3086 |
* @return boolean
|
|
|
3087 |
*/
|
|
|
3088 |
public static function approve_plan($id) {
|
|
|
3089 |
$params = self::validate_parameters(self::approve_plan_parameters(), array(
|
|
|
3090 |
'id' => $id,
|
|
|
3091 |
));
|
|
|
3092 |
|
|
|
3093 |
$plan = api::read_plan($id);
|
|
|
3094 |
self::validate_context($plan->get_context());
|
|
|
3095 |
|
|
|
3096 |
return api::approve_plan($plan);
|
|
|
3097 |
}
|
|
|
3098 |
|
|
|
3099 |
/**
|
|
|
3100 |
* Returns description of external function result value.
|
|
|
3101 |
*
|
|
|
3102 |
* @return external_function_parameters
|
|
|
3103 |
*/
|
|
|
3104 |
public static function approve_plan_returns() {
|
|
|
3105 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
3106 |
}
|
|
|
3107 |
|
|
|
3108 |
/**
|
|
|
3109 |
* Returns description of external function parameters.
|
|
|
3110 |
*
|
|
|
3111 |
* @return external_function_parameters
|
|
|
3112 |
*/
|
|
|
3113 |
public static function unapprove_plan_parameters() {
|
|
|
3114 |
return new external_function_parameters(array(
|
|
|
3115 |
'id' => new external_value(PARAM_INT, 'The plan ID'),
|
|
|
3116 |
));
|
|
|
3117 |
}
|
|
|
3118 |
|
|
|
3119 |
/**
|
|
|
3120 |
* External function unapprove_plan.
|
|
|
3121 |
*
|
|
|
3122 |
* @param int $id The plan ID.
|
|
|
3123 |
* @return boolean
|
|
|
3124 |
*/
|
|
|
3125 |
public static function unapprove_plan($id) {
|
|
|
3126 |
$params = self::validate_parameters(self::unapprove_plan_parameters(), array(
|
|
|
3127 |
'id' => $id,
|
|
|
3128 |
));
|
|
|
3129 |
|
|
|
3130 |
$plan = api::read_plan($id);
|
|
|
3131 |
self::validate_context($plan->get_context());
|
|
|
3132 |
|
|
|
3133 |
return api::unapprove_plan($plan);
|
|
|
3134 |
}
|
|
|
3135 |
|
|
|
3136 |
/**
|
|
|
3137 |
* Returns description of external function result value.
|
|
|
3138 |
*
|
|
|
3139 |
* @return external_function_parameters
|
|
|
3140 |
*/
|
|
|
3141 |
public static function unapprove_plan_returns() {
|
|
|
3142 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
3143 |
}
|
|
|
3144 |
|
|
|
3145 |
/**
|
|
|
3146 |
* External function parameters structure.
|
|
|
3147 |
*
|
|
|
3148 |
* @return external_description
|
|
|
3149 |
*/
|
|
|
3150 |
public static function list_plan_competencies_parameters() {
|
|
|
3151 |
return new external_function_parameters(array(
|
|
|
3152 |
'id' => new external_value(PARAM_INT, 'The plan ID.')
|
|
|
3153 |
));
|
|
|
3154 |
}
|
|
|
3155 |
|
|
|
3156 |
/**
|
|
|
3157 |
* List plan competencies.
|
|
|
3158 |
* @param int $id The plan ID.
|
|
|
3159 |
* @return array
|
|
|
3160 |
*/
|
|
|
3161 |
public static function list_plan_competencies($id) {
|
|
|
3162 |
global $PAGE;
|
|
|
3163 |
|
|
|
3164 |
$params = self::validate_parameters(self::list_plan_competencies_parameters(), array('id' => $id));
|
|
|
3165 |
$id = $params['id'];
|
|
|
3166 |
$plan = api::read_plan($id);
|
|
|
3167 |
$usercontext = $plan->get_context();
|
|
|
3168 |
self::validate_context($usercontext);
|
|
|
3169 |
$output = $PAGE->get_renderer('core');
|
|
|
3170 |
|
|
|
3171 |
$result = api::list_plan_competencies($plan);
|
|
|
3172 |
|
|
|
3173 |
if ($plan->get('status') == plan::STATUS_COMPLETE) {
|
|
|
3174 |
$ucproperty = 'usercompetencyplan';
|
|
|
3175 |
} else {
|
|
|
3176 |
$ucproperty = 'usercompetency';
|
|
|
3177 |
}
|
|
|
3178 |
|
|
|
3179 |
$helper = new performance_helper();
|
|
|
3180 |
foreach ($result as $key => $r) {
|
|
|
3181 |
$context = $helper->get_context_from_competency($r->competency);
|
|
|
3182 |
$scale = $helper->get_scale_from_competency($r->competency);
|
|
|
3183 |
|
|
|
3184 |
$exporter = new competency_exporter($r->competency, array('context' => $context));
|
|
|
3185 |
$r->competency = $exporter->export($output);
|
|
|
3186 |
|
|
|
3187 |
if ($r->usercompetency) {
|
|
|
3188 |
$exporter = new user_competency_exporter($r->usercompetency, array('scale' => $scale));
|
|
|
3189 |
$r->usercompetency = $exporter->export($output);
|
|
|
3190 |
unset($r->usercompetencyplan);
|
|
|
3191 |
} else {
|
|
|
3192 |
$exporter = new user_competency_plan_exporter($r->usercompetencyplan, array('scale' => $scale));
|
|
|
3193 |
$r->usercompetencyplan = $exporter->export($output);
|
|
|
3194 |
unset($r->usercompetency);
|
|
|
3195 |
}
|
|
|
3196 |
}
|
|
|
3197 |
return $result;
|
|
|
3198 |
}
|
|
|
3199 |
|
|
|
3200 |
/**
|
|
|
3201 |
* External function return structure.
|
|
|
3202 |
*
|
|
|
3203 |
* @return external_description
|
|
|
3204 |
*/
|
|
|
3205 |
public static function list_plan_competencies_returns() {
|
|
|
3206 |
$uc = user_competency_exporter::get_read_structure();
|
|
|
3207 |
$ucp = user_competency_plan_exporter::get_read_structure();
|
|
|
3208 |
|
|
|
3209 |
$uc->required = VALUE_OPTIONAL;
|
|
|
3210 |
$ucp->required = VALUE_OPTIONAL;
|
|
|
3211 |
|
|
|
3212 |
return new external_multiple_structure(
|
|
|
3213 |
new external_single_structure(array(
|
|
|
3214 |
'competency' => competency_exporter::get_read_structure(),
|
|
|
3215 |
'usercompetency' => $uc,
|
|
|
3216 |
'usercompetencyplan' => $ucp
|
|
|
3217 |
))
|
|
|
3218 |
);
|
|
|
3219 |
}
|
|
|
3220 |
|
|
|
3221 |
/**
|
|
|
3222 |
* Returns description of external function parameters.
|
|
|
3223 |
*
|
|
|
3224 |
* @return external_function_parameters
|
|
|
3225 |
*/
|
|
|
3226 |
public static function list_user_plans_parameters() {
|
|
|
3227 |
return new external_function_parameters(array(
|
|
|
3228 |
'userid' => new external_value(PARAM_INT, 'The user ID'),
|
|
|
3229 |
));
|
|
|
3230 |
}
|
|
|
3231 |
|
|
|
3232 |
/**
|
|
|
3233 |
* External function list_user_plans.
|
|
|
3234 |
*
|
|
|
3235 |
* @param int $userid The user ID.
|
|
|
3236 |
* @return boolean
|
|
|
3237 |
*/
|
|
|
3238 |
public static function list_user_plans($userid) {
|
|
|
3239 |
global $PAGE;
|
|
|
3240 |
$params = self::validate_parameters(self::list_user_plans_parameters(), array(
|
|
|
3241 |
'userid' => $userid
|
|
|
3242 |
));
|
|
|
3243 |
|
|
|
3244 |
$context = context_user::instance($params['userid']);
|
|
|
3245 |
self::validate_context($context);
|
|
|
3246 |
$output = $PAGE->get_renderer('core');
|
|
|
3247 |
|
|
|
3248 |
$response = array();
|
|
|
3249 |
$plans = api::list_user_plans($params['userid']);
|
|
|
3250 |
foreach ($plans as $plan) {
|
|
|
3251 |
$exporter = new plan_exporter($plan, array('template' => $plan->get_template()));
|
|
|
3252 |
$response[] = $exporter->export($output);
|
|
|
3253 |
}
|
|
|
3254 |
|
|
|
3255 |
return $response;
|
|
|
3256 |
}
|
|
|
3257 |
|
|
|
3258 |
/**
|
|
|
3259 |
* Returns description of external function result value.
|
|
|
3260 |
*
|
|
|
3261 |
* @return external_function_parameters
|
|
|
3262 |
*/
|
|
|
3263 |
public static function list_user_plans_returns() {
|
|
|
3264 |
return new external_multiple_structure(
|
|
|
3265 |
plan_exporter::get_read_structure()
|
|
|
3266 |
);
|
|
|
3267 |
}
|
|
|
3268 |
|
|
|
3269 |
/**
|
|
|
3270 |
* Returns description of external function parameters.
|
|
|
3271 |
*
|
|
|
3272 |
* @return external_description
|
|
|
3273 |
*/
|
|
|
3274 |
public static function read_user_evidence_parameters() {
|
|
|
3275 |
return new external_function_parameters(array(
|
|
|
3276 |
'id' => new external_value(PARAM_INT, 'The user evidence ID.'),
|
|
|
3277 |
));
|
|
|
3278 |
}
|
|
|
3279 |
|
|
|
3280 |
/**
|
|
|
3281 |
* Delete a user evidence.
|
|
|
3282 |
*
|
|
|
3283 |
* @param int $id The evidence id
|
|
|
3284 |
* @return boolean
|
|
|
3285 |
*/
|
|
|
3286 |
public static function read_user_evidence($id) {
|
|
|
3287 |
global $PAGE;
|
|
|
3288 |
$params = self::validate_parameters(self::read_user_evidence_parameters(), array('id' => $id));
|
|
|
3289 |
|
|
|
3290 |
$userevidence = api::read_user_evidence($params['id']);
|
|
|
3291 |
$context = $userevidence->get_context();
|
|
|
3292 |
self::validate_context($context);
|
|
|
3293 |
$output = $PAGE->get_renderer('core');
|
|
|
3294 |
|
|
|
3295 |
$exporter = new user_evidence_exporter($userevidence, array('context' => $context,
|
|
|
3296 |
'competencies' => $userevidence->get_competencies()));
|
|
|
3297 |
return $exporter->export($output);
|
|
|
3298 |
}
|
|
|
3299 |
|
|
|
3300 |
/**
|
|
|
3301 |
* Returns description of external function result value.
|
|
|
3302 |
*
|
|
|
3303 |
* @return external_description
|
|
|
3304 |
*/
|
|
|
3305 |
public static function read_user_evidence_returns() {
|
|
|
3306 |
return user_evidence_exporter::get_read_structure();
|
|
|
3307 |
}
|
|
|
3308 |
|
|
|
3309 |
/**
|
|
|
3310 |
* Returns description of external function parameters.
|
|
|
3311 |
*
|
|
|
3312 |
* @return external_function_parameters
|
|
|
3313 |
*/
|
|
|
3314 |
public static function delete_user_evidence_parameters() {
|
|
|
3315 |
return new external_function_parameters(array(
|
|
|
3316 |
'id' => new external_value(PARAM_INT, 'The user evidence ID.'),
|
|
|
3317 |
));
|
|
|
3318 |
}
|
|
|
3319 |
|
|
|
3320 |
/**
|
|
|
3321 |
* Delete a user evidence.
|
|
|
3322 |
*
|
|
|
3323 |
* @param int $id The evidence id
|
|
|
3324 |
* @return boolean
|
|
|
3325 |
*/
|
|
|
3326 |
public static function delete_user_evidence($id) {
|
|
|
3327 |
$params = self::validate_parameters(self::delete_user_evidence_parameters(), array('id' => $id));
|
|
|
3328 |
|
|
|
3329 |
$userevidence = api::read_user_evidence($params['id']);
|
|
|
3330 |
self::validate_context($userevidence->get_context());
|
|
|
3331 |
|
|
|
3332 |
return api::delete_user_evidence($userevidence->get('id'));
|
|
|
3333 |
}
|
|
|
3334 |
|
|
|
3335 |
/**
|
|
|
3336 |
* Returns description of external function result value.
|
|
|
3337 |
*
|
|
|
3338 |
* @return external_description
|
|
|
3339 |
*/
|
|
|
3340 |
public static function delete_user_evidence_returns() {
|
|
|
3341 |
return new external_value(PARAM_BOOL, 'True if the delete was successful');
|
|
|
3342 |
}
|
|
|
3343 |
|
|
|
3344 |
/**
|
|
|
3345 |
* Returns description of external function parameters.
|
|
|
3346 |
*
|
|
|
3347 |
* @return external_function_parameters
|
|
|
3348 |
*/
|
|
|
3349 |
public static function create_user_evidence_competency_parameters() {
|
|
|
3350 |
return new external_function_parameters(array(
|
|
|
3351 |
'userevidenceid' => new external_value(PARAM_INT, 'The user evidence ID.'),
|
|
|
3352 |
'competencyid' => new external_value(PARAM_INT, 'The competency ID.'),
|
|
|
3353 |
));
|
|
|
3354 |
}
|
|
|
3355 |
|
|
|
3356 |
/**
|
|
|
3357 |
* Delete a user evidence competency relationship.
|
|
|
3358 |
*
|
|
|
3359 |
* @param int $userevidenceid The user evidence id.
|
|
|
3360 |
* @param int $competencyid The competency id.
|
|
|
3361 |
* @return boolean
|
|
|
3362 |
*/
|
|
|
3363 |
public static function create_user_evidence_competency($userevidenceid, $competencyid) {
|
|
|
3364 |
global $PAGE;
|
|
|
3365 |
$params = self::validate_parameters(self::create_user_evidence_competency_parameters(), array(
|
|
|
3366 |
'userevidenceid' => $userevidenceid,
|
|
|
3367 |
'competencyid' => $competencyid,
|
|
|
3368 |
));
|
|
|
3369 |
|
|
|
3370 |
$userevidence = api::read_user_evidence($params['userevidenceid']);
|
|
|
3371 |
self::validate_context($userevidence->get_context());
|
|
|
3372 |
|
|
|
3373 |
$relation = api::create_user_evidence_competency($userevidence, $competencyid);
|
|
|
3374 |
$exporter = new user_evidence_competency_exporter($relation);
|
|
|
3375 |
return $exporter->export($PAGE->get_renderer('core'));
|
|
|
3376 |
}
|
|
|
3377 |
|
|
|
3378 |
/**
|
|
|
3379 |
* Returns description of external function result value.
|
|
|
3380 |
*
|
|
|
3381 |
* @return external_description
|
|
|
3382 |
*/
|
|
|
3383 |
public static function create_user_evidence_competency_returns() {
|
|
|
3384 |
return user_evidence_competency_exporter::get_read_structure();
|
|
|
3385 |
}
|
|
|
3386 |
|
|
|
3387 |
/**
|
|
|
3388 |
* Returns description of external function parameters.
|
|
|
3389 |
*
|
|
|
3390 |
* @return external_function_parameters
|
|
|
3391 |
*/
|
|
|
3392 |
public static function delete_user_evidence_competency_parameters() {
|
|
|
3393 |
return new external_function_parameters(array(
|
|
|
3394 |
'userevidenceid' => new external_value(PARAM_INT, 'The user evidence ID.'),
|
|
|
3395 |
'competencyid' => new external_value(PARAM_INT, 'The competency ID.'),
|
|
|
3396 |
));
|
|
|
3397 |
}
|
|
|
3398 |
|
|
|
3399 |
/**
|
|
|
3400 |
* Delete a user evidence competency relationship.
|
|
|
3401 |
*
|
|
|
3402 |
* @param int $userevidenceid The user evidence id.
|
|
|
3403 |
* @param int $competencyid The competency id.
|
|
|
3404 |
* @return boolean
|
|
|
3405 |
*/
|
|
|
3406 |
public static function delete_user_evidence_competency($userevidenceid, $competencyid) {
|
|
|
3407 |
$params = self::validate_parameters(self::delete_user_evidence_competency_parameters(), array(
|
|
|
3408 |
'userevidenceid' => $userevidenceid,
|
|
|
3409 |
'competencyid' => $competencyid,
|
|
|
3410 |
));
|
|
|
3411 |
|
|
|
3412 |
$userevidence = api::read_user_evidence($params['userevidenceid']);
|
|
|
3413 |
self::validate_context($userevidence->get_context());
|
|
|
3414 |
|
|
|
3415 |
return api::delete_user_evidence_competency($userevidence, $params['competencyid']);
|
|
|
3416 |
}
|
|
|
3417 |
|
|
|
3418 |
/**
|
|
|
3419 |
* Returns description of external function result value.
|
|
|
3420 |
*
|
|
|
3421 |
* @return external_description
|
|
|
3422 |
*/
|
|
|
3423 |
public static function delete_user_evidence_competency_returns() {
|
|
|
3424 |
return new external_value(PARAM_BOOL, 'True if the delete was successful');
|
|
|
3425 |
}
|
|
|
3426 |
|
|
|
3427 |
/**
|
|
|
3428 |
* Returns description of external function parameters.
|
|
|
3429 |
*
|
|
|
3430 |
* @return external_function_parameters
|
|
|
3431 |
*/
|
|
|
3432 |
public static function request_review_of_user_evidence_linked_competencies_parameters() {
|
|
|
3433 |
return new external_function_parameters(array(
|
|
|
3434 |
'id' => new external_value(PARAM_INT, 'The user evidence ID.')
|
|
|
3435 |
));
|
|
|
3436 |
}
|
|
|
3437 |
|
|
|
3438 |
/**
|
|
|
3439 |
* Send user evidence competencies to review.
|
|
|
3440 |
*
|
|
|
3441 |
* @param int $id The user evidence id.
|
|
|
3442 |
* @return boolean
|
|
|
3443 |
*/
|
|
|
3444 |
public static function request_review_of_user_evidence_linked_competencies($id) {
|
|
|
3445 |
$params = self::validate_parameters(self::request_review_of_user_evidence_linked_competencies_parameters(), array(
|
|
|
3446 |
'id' => $id
|
|
|
3447 |
));
|
|
|
3448 |
|
|
|
3449 |
$userevidence = api::read_user_evidence($id);
|
|
|
3450 |
self::validate_context($userevidence->get_context());
|
|
|
3451 |
|
|
|
3452 |
return api::request_review_of_user_evidence_linked_competencies($id);
|
|
|
3453 |
}
|
|
|
3454 |
|
|
|
3455 |
/**
|
|
|
3456 |
* Returns description of external function result value.
|
|
|
3457 |
*
|
|
|
3458 |
* @return external_description
|
|
|
3459 |
*/
|
|
|
3460 |
public static function request_review_of_user_evidence_linked_competencies_returns() {
|
|
|
3461 |
return new external_value(PARAM_BOOL, 'True if all competencies were send to review');
|
|
|
3462 |
}
|
|
|
3463 |
|
|
|
3464 |
|
|
|
3465 |
/**
|
|
|
3466 |
* Returns the description of the get_scale_values() parameters.
|
|
|
3467 |
*
|
|
|
3468 |
* @return external_function_parameters.
|
|
|
3469 |
*/
|
|
|
3470 |
public static function get_scale_values_parameters() {
|
|
|
3471 |
$scaleid = new external_value(
|
|
|
3472 |
PARAM_INT,
|
|
|
3473 |
'The scale id',
|
|
|
3474 |
VALUE_REQUIRED
|
|
|
3475 |
);
|
|
|
3476 |
$params = array('scaleid' => $scaleid);
|
|
|
3477 |
return new external_function_parameters($params);
|
|
|
3478 |
}
|
|
|
3479 |
|
|
|
3480 |
/**
|
|
|
3481 |
* Get the values associated with a scale.
|
|
|
3482 |
*
|
|
|
3483 |
* @param int $scaleid Scale ID
|
|
|
3484 |
* @return array Values for a scale.
|
|
|
3485 |
*/
|
|
|
3486 |
public static function get_scale_values($scaleid) {
|
|
|
3487 |
global $DB;
|
|
|
3488 |
$params = self::validate_parameters(self::get_scale_values_parameters(),
|
|
|
3489 |
array(
|
|
|
3490 |
'scaleid' => $scaleid,
|
|
|
3491 |
)
|
|
|
3492 |
);
|
|
|
3493 |
$context = context_system::instance();
|
|
|
3494 |
self::validate_context($context);
|
|
|
3495 |
// The following section is not learning plan specific and so has not been moved to the api.
|
|
|
3496 |
// Retrieve the scale value from the database.
|
|
|
3497 |
$scale = grade_scale::fetch(array('id' => $scaleid));
|
|
|
3498 |
$scalevalues = $scale->load_items();
|
|
|
3499 |
foreach ($scalevalues as $key => $value) {
|
|
|
3500 |
// Add a key (make the first value 1).
|
|
|
3501 |
$scalevalues[$key] = array(
|
|
|
3502 |
'id' => $key + 1,
|
|
|
3503 |
'name' => \core_external\util::format_string($value, $context->id)
|
|
|
3504 |
);
|
|
|
3505 |
}
|
|
|
3506 |
return $scalevalues;
|
|
|
3507 |
}
|
|
|
3508 |
|
|
|
3509 |
/**
|
|
|
3510 |
* Returns description of get_scale_values() result value.
|
|
|
3511 |
*
|
|
|
3512 |
* @return external_multiple_structure
|
|
|
3513 |
*/
|
|
|
3514 |
public static function get_scale_values_returns() {
|
|
|
3515 |
return new external_multiple_structure(
|
|
|
3516 |
new external_single_structure(array(
|
|
|
3517 |
'id' => new external_value(PARAM_INT, 'Scale value ID'),
|
|
|
3518 |
'name' => new external_value(PARAM_RAW, 'Scale value name')
|
|
|
3519 |
))
|
|
|
3520 |
);
|
|
|
3521 |
}
|
|
|
3522 |
|
|
|
3523 |
|
|
|
3524 |
/**
|
|
|
3525 |
* Returns the description of the add_related_competency_parameters() parameters.
|
|
|
3526 |
*
|
|
|
3527 |
* @return external_function_parameters.
|
|
|
3528 |
*/
|
|
|
3529 |
public static function add_related_competency_parameters() {
|
|
|
3530 |
$competencyid = new external_value(
|
|
|
3531 |
PARAM_INT,
|
|
|
3532 |
'The competency id',
|
|
|
3533 |
VALUE_REQUIRED
|
|
|
3534 |
);
|
|
|
3535 |
$relatedcompetencyid = new external_value(
|
|
|
3536 |
PARAM_INT,
|
|
|
3537 |
'The related competency id',
|
|
|
3538 |
VALUE_REQUIRED
|
|
|
3539 |
);
|
|
|
3540 |
$params = array(
|
|
|
3541 |
'competencyid' => $competencyid,
|
|
|
3542 |
'relatedcompetencyid' => $relatedcompetencyid
|
|
|
3543 |
);
|
|
|
3544 |
return new external_function_parameters($params);
|
|
|
3545 |
}
|
|
|
3546 |
|
|
|
3547 |
/**
|
|
|
3548 |
* Adds a related competency.
|
|
|
3549 |
*
|
|
|
3550 |
* @param int $competencyid
|
|
|
3551 |
* @param int $relatedcompetencyid
|
|
|
3552 |
* @return bool
|
|
|
3553 |
*/
|
|
|
3554 |
public static function add_related_competency($competencyid, $relatedcompetencyid) {
|
|
|
3555 |
$params = self::validate_parameters(self::add_related_competency_parameters(), array(
|
|
|
3556 |
'competencyid' => $competencyid,
|
|
|
3557 |
'relatedcompetencyid' => $relatedcompetencyid
|
|
|
3558 |
));
|
|
|
3559 |
$competency = api::read_competency($params['competencyid']);
|
|
|
3560 |
self::validate_context($competency->get_context());
|
|
|
3561 |
|
|
|
3562 |
return api::add_related_competency($params['competencyid'], $params['relatedcompetencyid']);
|
|
|
3563 |
}
|
|
|
3564 |
|
|
|
3565 |
/**
|
|
|
3566 |
* Returns description of add_related_competency_returns() result value.
|
|
|
3567 |
*
|
|
|
3568 |
* @return \core_external\external_description
|
|
|
3569 |
*/
|
|
|
3570 |
public static function add_related_competency_returns() {
|
|
|
3571 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
3572 |
}
|
|
|
3573 |
|
|
|
3574 |
/**
|
|
|
3575 |
* Returns the description of the remove_related_competency_parameters() parameters.
|
|
|
3576 |
*
|
|
|
3577 |
* @return external_function_parameters.
|
|
|
3578 |
*/
|
|
|
3579 |
public static function remove_related_competency_parameters() {
|
|
|
3580 |
$competencyid = new external_value(
|
|
|
3581 |
PARAM_INT,
|
|
|
3582 |
'The competency id',
|
|
|
3583 |
VALUE_REQUIRED
|
|
|
3584 |
);
|
|
|
3585 |
$relatedcompetencyid = new external_value(
|
|
|
3586 |
PARAM_INT,
|
|
|
3587 |
'The related competency id',
|
|
|
3588 |
VALUE_REQUIRED
|
|
|
3589 |
);
|
|
|
3590 |
$params = array(
|
|
|
3591 |
'competencyid' => $competencyid,
|
|
|
3592 |
'relatedcompetencyid' => $relatedcompetencyid
|
|
|
3593 |
);
|
|
|
3594 |
return new external_function_parameters($params);
|
|
|
3595 |
}
|
|
|
3596 |
|
|
|
3597 |
/**
|
|
|
3598 |
* Removes a related competency.
|
|
|
3599 |
*
|
|
|
3600 |
* @param int $competencyid
|
|
|
3601 |
* @param int $relatedcompetencyid
|
|
|
3602 |
* @return bool
|
|
|
3603 |
*/
|
|
|
3604 |
public static function remove_related_competency($competencyid, $relatedcompetencyid) {
|
|
|
3605 |
$params = self::validate_parameters(self::remove_related_competency_parameters(), array(
|
|
|
3606 |
'competencyid' => $competencyid,
|
|
|
3607 |
'relatedcompetencyid' => $relatedcompetencyid
|
|
|
3608 |
));
|
|
|
3609 |
$competency = api::read_competency($params['competencyid']);
|
|
|
3610 |
self::validate_context($competency->get_context());
|
|
|
3611 |
|
|
|
3612 |
return api::remove_related_competency($params['competencyid'], $params['relatedcompetencyid']);
|
|
|
3613 |
}
|
|
|
3614 |
|
|
|
3615 |
/**
|
|
|
3616 |
* Returns description of remove_related_competency_returns() result value.
|
|
|
3617 |
*
|
|
|
3618 |
* @return \core_external\external_description
|
|
|
3619 |
*/
|
|
|
3620 |
public static function remove_related_competency_returns() {
|
|
|
3621 |
return new external_value(PARAM_BOOL, 'True if successful.');
|
|
|
3622 |
}
|
|
|
3623 |
|
|
|
3624 |
/**
|
|
|
3625 |
* Returns description of update_ruleoutcome_course_competency() parameters.
|
|
|
3626 |
*
|
|
|
3627 |
* @return external_function_parameters
|
|
|
3628 |
*/
|
|
|
3629 |
public static function set_course_competency_ruleoutcome_parameters() {
|
|
|
3630 |
$coursecompetencyid = new external_value(
|
|
|
3631 |
PARAM_INT,
|
|
|
3632 |
'Data base record id for the course competency',
|
|
|
3633 |
VALUE_REQUIRED
|
|
|
3634 |
);
|
|
|
3635 |
|
|
|
3636 |
$ruleoutcome = new external_value(
|
|
|
3637 |
PARAM_INT,
|
|
|
3638 |
'Ruleoutcome value',
|
|
|
3639 |
VALUE_REQUIRED
|
|
|
3640 |
);
|
|
|
3641 |
|
|
|
3642 |
$params = array(
|
|
|
3643 |
'coursecompetencyid' => $coursecompetencyid,
|
|
|
3644 |
'ruleoutcome' => $ruleoutcome,
|
|
|
3645 |
);
|
|
|
3646 |
return new external_function_parameters($params);
|
|
|
3647 |
}
|
|
|
3648 |
|
|
|
3649 |
/**
|
|
|
3650 |
* Change the ruleoutcome of a course competency.
|
|
|
3651 |
*
|
|
|
3652 |
* @param int $coursecompetencyid The course competency id
|
|
|
3653 |
* @param int $ruleoutcome The ruleoutcome value
|
|
|
3654 |
* @return bool
|
|
|
3655 |
*/
|
|
|
3656 |
public static function set_course_competency_ruleoutcome($coursecompetencyid, $ruleoutcome) {
|
|
|
3657 |
$params = self::validate_parameters(self::set_course_competency_ruleoutcome_parameters(), array(
|
|
|
3658 |
'coursecompetencyid' => $coursecompetencyid,
|
|
|
3659 |
'ruleoutcome' => $ruleoutcome,
|
|
|
3660 |
));
|
|
|
3661 |
|
|
|
3662 |
$coursecompetency = new course_competency($params['coursecompetencyid']);
|
|
|
3663 |
self::validate_context(context_course::instance($coursecompetency->get('courseid')));
|
|
|
3664 |
|
|
|
3665 |
return api::set_course_competency_ruleoutcome($coursecompetency, $params['ruleoutcome']);
|
|
|
3666 |
}
|
|
|
3667 |
|
|
|
3668 |
/**
|
|
|
3669 |
* Returns description of update_ruleoutcome_course_competency() result value.
|
|
|
3670 |
*
|
|
|
3671 |
* @return external_value
|
|
|
3672 |
*/
|
|
|
3673 |
public static function set_course_competency_ruleoutcome_returns() {
|
|
|
3674 |
return new external_value(PARAM_BOOL, 'True if the update was successful');
|
|
|
3675 |
}
|
|
|
3676 |
|
|
|
3677 |
|
|
|
3678 |
/**
|
|
|
3679 |
* Returns description of external function parameters.
|
|
|
3680 |
*
|
|
|
3681 |
* @return external_function_parameters
|
|
|
3682 |
*/
|
|
|
3683 |
public static function grade_competency_parameters() {
|
|
|
3684 |
$userid = new external_value(
|
|
|
3685 |
PARAM_INT,
|
|
|
3686 |
'User ID',
|
|
|
3687 |
VALUE_REQUIRED
|
|
|
3688 |
);
|
|
|
3689 |
$competencyid = new external_value(
|
|
|
3690 |
PARAM_INT,
|
|
|
3691 |
'Competency ID',
|
|
|
3692 |
VALUE_REQUIRED
|
|
|
3693 |
);
|
|
|
3694 |
$grade = new external_value(
|
|
|
3695 |
PARAM_INT,
|
|
|
3696 |
'New grade',
|
|
|
3697 |
VALUE_REQUIRED
|
|
|
3698 |
);
|
|
|
3699 |
$note = new external_value(
|
|
|
3700 |
PARAM_NOTAGS,
|
|
|
3701 |
'A note to attach to the evidence',
|
|
|
3702 |
VALUE_DEFAULT
|
|
|
3703 |
);
|
|
|
3704 |
|
|
|
3705 |
$params = array(
|
|
|
3706 |
'userid' => $userid,
|
|
|
3707 |
'competencyid' => $competencyid,
|
|
|
3708 |
'grade' => $grade,
|
|
|
3709 |
'note' => $note,
|
|
|
3710 |
);
|
|
|
3711 |
return new external_function_parameters($params);
|
|
|
3712 |
}
|
|
|
3713 |
|
|
|
3714 |
/**
|
|
|
3715 |
* Grade a competency.
|
|
|
3716 |
*
|
|
|
3717 |
* @param int $userid The user ID.
|
|
|
3718 |
* @param int $competencyid The competency id
|
|
|
3719 |
* @param int $grade The new grade value
|
|
|
3720 |
* @param string $note A note to attach to the evidence
|
|
|
3721 |
* @return bool
|
|
|
3722 |
*/
|
|
|
3723 |
public static function grade_competency($userid, $competencyid, $grade, $note = null) {
|
|
|
3724 |
global $USER, $PAGE;
|
|
|
3725 |
$params = self::validate_parameters(self::grade_competency_parameters(), array(
|
|
|
3726 |
'userid' => $userid,
|
|
|
3727 |
'competencyid' => $competencyid,
|
|
|
3728 |
'grade' => $grade,
|
|
|
3729 |
'note' => $note
|
|
|
3730 |
));
|
|
|
3731 |
|
|
|
3732 |
$uc = api::get_user_competency($params['userid'], $params['competencyid']);
|
|
|
3733 |
self::validate_context($uc->get_context());
|
|
|
3734 |
|
|
|
3735 |
$output = $PAGE->get_renderer('core');
|
|
|
3736 |
$evidence = api::grade_competency(
|
|
|
3737 |
$uc->get('userid'),
|
|
|
3738 |
$uc->get('competencyid'),
|
|
|
3739 |
$params['grade'],
|
|
|
3740 |
$params['note']
|
|
|
3741 |
);
|
|
|
3742 |
|
|
|
3743 |
$scale = $uc->get_competency()->get_scale();
|
|
|
3744 |
$exporter = new evidence_exporter($evidence, [
|
|
|
3745 |
'actionuser' => $USER,
|
|
|
3746 |
'scale' => $scale,
|
|
|
3747 |
'usercompetency' => $uc,
|
|
|
3748 |
'usercompetencyplan' => null,
|
|
|
3749 |
'context' => $evidence->get_context()
|
|
|
3750 |
]);
|
|
|
3751 |
return $exporter->export($output);
|
|
|
3752 |
}
|
|
|
3753 |
|
|
|
3754 |
/**
|
|
|
3755 |
* Returns description of external function result value.
|
|
|
3756 |
*
|
|
|
3757 |
* @return external_value
|
|
|
3758 |
*/
|
|
|
3759 |
public static function grade_competency_returns() {
|
|
|
3760 |
return evidence_exporter::get_read_structure();
|
|
|
3761 |
}
|
|
|
3762 |
|
|
|
3763 |
/**
|
|
|
3764 |
* Returns description of grade_competency_in_plan() parameters.
|
|
|
3765 |
*
|
|
|
3766 |
* @return external_function_parameters
|
|
|
3767 |
*/
|
|
|
3768 |
public static function grade_competency_in_plan_parameters() {
|
|
|
3769 |
$planid = new external_value(
|
|
|
3770 |
PARAM_INT,
|
|
|
3771 |
'Plan id',
|
|
|
3772 |
VALUE_REQUIRED
|
|
|
3773 |
);
|
|
|
3774 |
$competencyid = new external_value(
|
|
|
3775 |
PARAM_INT,
|
|
|
3776 |
'Competency id',
|
|
|
3777 |
VALUE_REQUIRED
|
|
|
3778 |
);
|
|
|
3779 |
$grade = new external_value(
|
|
|
3780 |
PARAM_INT,
|
|
|
3781 |
'New grade',
|
|
|
3782 |
VALUE_REQUIRED
|
|
|
3783 |
);
|
|
|
3784 |
$note = new external_value(
|
|
|
3785 |
PARAM_NOTAGS,
|
|
|
3786 |
'A note to attach to the evidence',
|
|
|
3787 |
VALUE_DEFAULT
|
|
|
3788 |
);
|
|
|
3789 |
|
|
|
3790 |
$params = array(
|
|
|
3791 |
'planid' => $planid,
|
|
|
3792 |
'competencyid' => $competencyid,
|
|
|
3793 |
'grade' => $grade,
|
|
|
3794 |
'note' => $note
|
|
|
3795 |
);
|
|
|
3796 |
return new external_function_parameters($params);
|
|
|
3797 |
}
|
|
|
3798 |
|
|
|
3799 |
/**
|
|
|
3800 |
* Grade a competency in a plan.
|
|
|
3801 |
*
|
|
|
3802 |
* @param int $planid The plan id
|
|
|
3803 |
* @param int $competencyid The competency id
|
|
|
3804 |
* @param int $grade The new grade value
|
|
|
3805 |
* @param string $note A note to add to the evidence
|
|
|
3806 |
* @return bool
|
|
|
3807 |
*/
|
|
|
3808 |
public static function grade_competency_in_plan($planid, $competencyid, $grade, $note = null) {
|
|
|
3809 |
global $USER, $PAGE;
|
|
|
3810 |
|
|
|
3811 |
$params = self::validate_parameters(self::grade_competency_in_plan_parameters(), array(
|
|
|
3812 |
'planid' => $planid,
|
|
|
3813 |
'competencyid' => $competencyid,
|
|
|
3814 |
'grade' => $grade,
|
|
|
3815 |
'note' => $note
|
|
|
3816 |
));
|
|
|
3817 |
|
|
|
3818 |
$plan = new plan($params['planid']);
|
|
|
3819 |
$context = $plan->get_context();
|
|
|
3820 |
self::validate_context($context);
|
|
|
3821 |
$output = $PAGE->get_renderer('core');
|
|
|
3822 |
|
|
|
3823 |
$evidence = api::grade_competency_in_plan(
|
|
|
3824 |
$plan->get('id'),
|
|
|
3825 |
$params['competencyid'],
|
|
|
3826 |
$params['grade'],
|
|
|
3827 |
$params['note']
|
|
|
3828 |
);
|
|
|
3829 |
$competency = api::read_competency($params['competencyid']);
|
|
|
3830 |
$scale = $competency->get_scale();
|
|
|
3831 |
$exporter = new evidence_exporter($evidence, [
|
|
|
3832 |
'actionuser' => $USER,
|
|
|
3833 |
'scale' => $scale,
|
|
|
3834 |
'usercompetency' => null,
|
|
|
3835 |
'usercompetencyplan' => null,
|
|
|
3836 |
'context' => $evidence->get_context()
|
|
|
3837 |
]);
|
|
|
3838 |
return $exporter->export($output);
|
|
|
3839 |
}
|
|
|
3840 |
|
|
|
3841 |
/**
|
|
|
3842 |
* Returns description of grade_competency_in_plan() result value.
|
|
|
3843 |
*
|
|
|
3844 |
* @return external_value
|
|
|
3845 |
*/
|
|
|
3846 |
public static function grade_competency_in_plan_returns() {
|
|
|
3847 |
return evidence_exporter::get_read_structure();
|
|
|
3848 |
}
|
|
|
3849 |
|
|
|
3850 |
/**
|
|
|
3851 |
* Returns description of user_competency_viewed() parameters.
|
|
|
3852 |
*
|
|
|
3853 |
* @return external_function_parameters
|
|
|
3854 |
*/
|
|
|
3855 |
public static function user_competency_viewed_parameters() {
|
|
|
3856 |
$usercompetencyid = new external_value(
|
|
|
3857 |
PARAM_INT,
|
|
|
3858 |
'The user competency id',
|
|
|
3859 |
VALUE_REQUIRED
|
|
|
3860 |
);
|
|
|
3861 |
$params = array(
|
|
|
3862 |
'usercompetencyid' => $usercompetencyid
|
|
|
3863 |
);
|
|
|
3864 |
return new external_function_parameters($params);
|
|
|
3865 |
}
|
|
|
3866 |
|
|
|
3867 |
/**
|
|
|
3868 |
* Log user competency viewed event.
|
|
|
3869 |
*
|
|
|
3870 |
* @param int $usercompetencyid The user competency ID.
|
|
|
3871 |
* @return boolean
|
|
|
3872 |
*/
|
|
|
3873 |
public static function user_competency_viewed($usercompetencyid) {
|
|
|
3874 |
$params = self::validate_parameters(self::user_competency_viewed_parameters(), array(
|
|
|
3875 |
'usercompetencyid' => $usercompetencyid
|
|
|
3876 |
));
|
|
|
3877 |
|
|
|
3878 |
$uc = api::get_user_competency_by_id($params['usercompetencyid']);
|
|
|
3879 |
$result = api::user_competency_viewed($uc);
|
|
|
3880 |
|
|
|
3881 |
return $result;
|
|
|
3882 |
}
|
|
|
3883 |
|
|
|
3884 |
/**
|
|
|
3885 |
* Returns description of user_competency_viewed() result value.
|
|
|
3886 |
*
|
|
|
3887 |
* @return external_description
|
|
|
3888 |
*/
|
|
|
3889 |
public static function user_competency_viewed_returns() {
|
|
|
3890 |
return new external_value(PARAM_BOOL, 'True if the event user competency viewed was logged');
|
|
|
3891 |
}
|
|
|
3892 |
|
|
|
3893 |
/**
|
|
|
3894 |
* Returns description of user_competency_viewed_in_plan() parameters.
|
|
|
3895 |
*
|
|
|
3896 |
* @return external_function_parameters
|
|
|
3897 |
*/
|
|
|
3898 |
public static function user_competency_viewed_in_plan_parameters() {
|
|
|
3899 |
$competencyid = new external_value(
|
|
|
3900 |
PARAM_INT,
|
|
|
3901 |
'The competency id',
|
|
|
3902 |
VALUE_REQUIRED
|
|
|
3903 |
);
|
|
|
3904 |
$userid = new external_value(
|
|
|
3905 |
PARAM_INT,
|
|
|
3906 |
'The user id',
|
|
|
3907 |
VALUE_REQUIRED
|
|
|
3908 |
);
|
|
|
3909 |
$planid = new external_value(
|
|
|
3910 |
PARAM_INT,
|
|
|
3911 |
'The plan id',
|
|
|
3912 |
VALUE_REQUIRED
|
|
|
3913 |
);
|
|
|
3914 |
$params = array(
|
|
|
3915 |
'competencyid' => $competencyid,
|
|
|
3916 |
'userid' => $userid,
|
|
|
3917 |
'planid' => $planid
|
|
|
3918 |
);
|
|
|
3919 |
return new external_function_parameters($params);
|
|
|
3920 |
}
|
|
|
3921 |
|
|
|
3922 |
/**
|
|
|
3923 |
* Log user competency viewed in plan event.
|
|
|
3924 |
*
|
|
|
3925 |
* @param int $competencyid The competency ID.
|
|
|
3926 |
* @param int $userid The user ID.
|
|
|
3927 |
* @param int $planid The plan ID.
|
|
|
3928 |
* @return boolean
|
|
|
3929 |
*/
|
|
|
3930 |
public static function user_competency_viewed_in_plan($competencyid, $userid, $planid) {
|
|
|
3931 |
$params = self::validate_parameters(self::user_competency_viewed_in_plan_parameters(), array(
|
|
|
3932 |
'competencyid' => $competencyid,
|
|
|
3933 |
'userid' => $userid,
|
|
|
3934 |
'planid' => $planid
|
|
|
3935 |
));
|
|
|
3936 |
$pl = api::get_plan_competency($params['planid'], $params['competencyid']);
|
|
|
3937 |
$result = api::user_competency_viewed_in_plan($pl->usercompetency, $params['planid']);
|
|
|
3938 |
|
|
|
3939 |
return $result;
|
|
|
3940 |
}
|
|
|
3941 |
|
|
|
3942 |
/**
|
|
|
3943 |
* Returns description of user_competency_viewed_in_plan() result value.
|
|
|
3944 |
*
|
|
|
3945 |
* @return external_description
|
|
|
3946 |
*/
|
|
|
3947 |
public static function user_competency_viewed_in_plan_returns() {
|
|
|
3948 |
return new external_value(PARAM_BOOL, 'True if the event user competency viewed in plan was logged');
|
|
|
3949 |
}
|
|
|
3950 |
|
|
|
3951 |
/**
|
|
|
3952 |
* Returns description of user_competency_viewed_in_course() parameters.
|
|
|
3953 |
*
|
|
|
3954 |
* @return external_function_parameters
|
|
|
3955 |
*/
|
|
|
3956 |
public static function user_competency_viewed_in_course_parameters() {
|
|
|
3957 |
$competencyid = new external_value(
|
|
|
3958 |
PARAM_INT,
|
|
|
3959 |
'The competency id',
|
|
|
3960 |
VALUE_REQUIRED
|
|
|
3961 |
);
|
|
|
3962 |
$userid = new external_value(
|
|
|
3963 |
PARAM_INT,
|
|
|
3964 |
'The user id',
|
|
|
3965 |
VALUE_REQUIRED
|
|
|
3966 |
);
|
|
|
3967 |
$courseid = new external_value(
|
|
|
3968 |
PARAM_INT,
|
|
|
3969 |
'The course id',
|
|
|
3970 |
VALUE_REQUIRED
|
|
|
3971 |
);
|
|
|
3972 |
$params = array(
|
|
|
3973 |
'competencyid' => $competencyid,
|
|
|
3974 |
'userid' => $userid,
|
|
|
3975 |
'courseid' => $courseid
|
|
|
3976 |
);
|
|
|
3977 |
return new external_function_parameters($params);
|
|
|
3978 |
}
|
|
|
3979 |
|
|
|
3980 |
/**
|
|
|
3981 |
* Log user competency viewed in course event.
|
|
|
3982 |
*
|
|
|
3983 |
* @param int $competencyid The competency ID.
|
|
|
3984 |
* @param int $userid The user ID.
|
|
|
3985 |
* @param int $courseid The course ID.
|
|
|
3986 |
* @return boolean
|
|
|
3987 |
*/
|
|
|
3988 |
public static function user_competency_viewed_in_course($competencyid, $userid, $courseid) {
|
|
|
3989 |
$params = self::validate_parameters(self::user_competency_viewed_in_course_parameters(), array(
|
|
|
3990 |
'competencyid' => $competencyid,
|
|
|
3991 |
'userid' => $userid,
|
|
|
3992 |
'courseid' => $courseid
|
|
|
3993 |
));
|
|
|
3994 |
$ucc = api::get_user_competency_in_course($params['courseid'], $params['userid'], $params['competencyid']);
|
|
|
3995 |
$result = api::user_competency_viewed_in_course($ucc);
|
|
|
3996 |
|
|
|
3997 |
return $result;
|
|
|
3998 |
}
|
|
|
3999 |
|
|
|
4000 |
/**
|
|
|
4001 |
* Returns description of user_competency_viewed_in_course() result value.
|
|
|
4002 |
*
|
|
|
4003 |
* @return external_description
|
|
|
4004 |
*/
|
|
|
4005 |
public static function user_competency_viewed_in_course_returns() {
|
|
|
4006 |
return new external_value(PARAM_BOOL, 'True if the event user competency viewed in course was logged');
|
|
|
4007 |
}
|
|
|
4008 |
|
|
|
4009 |
/**
|
|
|
4010 |
* Returns description of user_competency_plan_viewed() parameters.
|
|
|
4011 |
*
|
|
|
4012 |
* @return external_function_parameters
|
|
|
4013 |
*/
|
|
|
4014 |
public static function user_competency_plan_viewed_parameters() {
|
|
|
4015 |
$competencyid = new external_value(
|
|
|
4016 |
PARAM_INT,
|
|
|
4017 |
'The competency id',
|
|
|
4018 |
VALUE_REQUIRED
|
|
|
4019 |
);
|
|
|
4020 |
$userid = new external_value(
|
|
|
4021 |
PARAM_INT,
|
|
|
4022 |
'The user id',
|
|
|
4023 |
VALUE_REQUIRED
|
|
|
4024 |
);
|
|
|
4025 |
$planid = new external_value(
|
|
|
4026 |
PARAM_INT,
|
|
|
4027 |
'The plan id',
|
|
|
4028 |
VALUE_REQUIRED
|
|
|
4029 |
);
|
|
|
4030 |
$params = array(
|
|
|
4031 |
'competencyid' => $competencyid,
|
|
|
4032 |
'userid' => $userid,
|
|
|
4033 |
'planid' => $planid
|
|
|
4034 |
);
|
|
|
4035 |
return new external_function_parameters($params);
|
|
|
4036 |
}
|
|
|
4037 |
|
|
|
4038 |
/**
|
|
|
4039 |
* Log user competency plan viewed event.
|
|
|
4040 |
*
|
|
|
4041 |
* @param int $competencyid The competency ID.
|
|
|
4042 |
* @param int $userid The user ID.
|
|
|
4043 |
* @param int $planid The plan ID.
|
|
|
4044 |
* @return boolean
|
|
|
4045 |
*/
|
|
|
4046 |
public static function user_competency_plan_viewed($competencyid, $userid, $planid) {
|
|
|
4047 |
$params = self::validate_parameters(self::user_competency_viewed_in_plan_parameters(), array(
|
|
|
4048 |
'competencyid' => $competencyid,
|
|
|
4049 |
'userid' => $userid,
|
|
|
4050 |
'planid' => $planid
|
|
|
4051 |
));
|
|
|
4052 |
$pl = api::get_plan_competency($params['planid'], $params['competencyid']);
|
|
|
4053 |
$result = api::user_competency_plan_viewed($pl->usercompetencyplan);
|
|
|
4054 |
|
|
|
4055 |
return $result;
|
|
|
4056 |
}
|
|
|
4057 |
|
|
|
4058 |
/**
|
|
|
4059 |
* Returns description of user_competency_plan_viewed() result value.
|
|
|
4060 |
*
|
|
|
4061 |
* @return external_description
|
|
|
4062 |
*/
|
|
|
4063 |
public static function user_competency_plan_viewed_returns() {
|
|
|
4064 |
return new external_value(PARAM_BOOL, 'True if the event user competency plan viewed was logged');
|
|
|
4065 |
}
|
|
|
4066 |
|
|
|
4067 |
/**
|
|
|
4068 |
* Returns description of grade_competency_in_course() parameters.
|
|
|
4069 |
*
|
|
|
4070 |
* @return external_function_parameters
|
|
|
4071 |
*/
|
|
|
4072 |
public static function grade_competency_in_course_parameters() {
|
|
|
4073 |
$courseid = new external_value(
|
|
|
4074 |
PARAM_INT,
|
|
|
4075 |
'Course id',
|
|
|
4076 |
VALUE_REQUIRED
|
|
|
4077 |
);
|
|
|
4078 |
$userid = new external_value(
|
|
|
4079 |
PARAM_INT,
|
|
|
4080 |
'User id',
|
|
|
4081 |
VALUE_REQUIRED
|
|
|
4082 |
);
|
|
|
4083 |
$competencyid = new external_value(
|
|
|
4084 |
PARAM_INT,
|
|
|
4085 |
'Competency id',
|
|
|
4086 |
VALUE_REQUIRED
|
|
|
4087 |
);
|
|
|
4088 |
$grade = new external_value(
|
|
|
4089 |
PARAM_INT,
|
|
|
4090 |
'New grade',
|
|
|
4091 |
VALUE_REQUIRED
|
|
|
4092 |
);
|
|
|
4093 |
$note = new external_value(
|
|
|
4094 |
PARAM_NOTAGS,
|
|
|
4095 |
'A note to attach to the evidence',
|
|
|
4096 |
VALUE_DEFAULT
|
|
|
4097 |
);
|
|
|
4098 |
|
|
|
4099 |
$params = array(
|
|
|
4100 |
'courseid' => $courseid,
|
|
|
4101 |
'userid' => $userid,
|
|
|
4102 |
'competencyid' => $competencyid,
|
|
|
4103 |
'grade' => $grade,
|
|
|
4104 |
'note' => $note,
|
|
|
4105 |
);
|
|
|
4106 |
return new external_function_parameters($params);
|
|
|
4107 |
}
|
|
|
4108 |
|
|
|
4109 |
/**
|
|
|
4110 |
* Grade a competency in a course.
|
|
|
4111 |
*
|
|
|
4112 |
* @param int $courseid The course id
|
|
|
4113 |
* @param int $userid The user id
|
|
|
4114 |
* @param int $competencyid The competency id
|
|
|
4115 |
* @param int $grade The new grade value
|
|
|
4116 |
* @param string $note A note to add to the evidence
|
|
|
4117 |
* @return bool
|
|
|
4118 |
*/
|
|
|
4119 |
public static function grade_competency_in_course($courseid, $userid, $competencyid, $grade, $note = null) {
|
|
|
4120 |
global $USER, $PAGE, $DB;
|
|
|
4121 |
|
|
|
4122 |
$params = self::validate_parameters(self::grade_competency_in_course_parameters(), array(
|
|
|
4123 |
'courseid' => $courseid,
|
|
|
4124 |
'userid' => $userid,
|
|
|
4125 |
'competencyid' => $competencyid,
|
|
|
4126 |
'grade' => $grade,
|
|
|
4127 |
'note' => $note
|
|
|
4128 |
));
|
|
|
4129 |
|
|
|
4130 |
$course = $DB->get_record('course', array('id' => $params['courseid']));
|
|
|
4131 |
$context = context_course::instance($course->id);
|
|
|
4132 |
self::validate_context($context);
|
|
|
4133 |
$output = $PAGE->get_renderer('core');
|
|
|
4134 |
|
|
|
4135 |
$evidence = api::grade_competency_in_course(
|
|
|
4136 |
$params['courseid'],
|
|
|
4137 |
$params['userid'],
|
|
|
4138 |
$params['competencyid'],
|
|
|
4139 |
$params['grade'],
|
|
|
4140 |
$params['note']
|
|
|
4141 |
);
|
|
|
4142 |
$competency = api::read_competency($params['competencyid']);
|
|
|
4143 |
$scale = $competency->get_scale();
|
|
|
4144 |
$exporter = new evidence_exporter($evidence, array(
|
|
|
4145 |
'actionuser' => $USER,
|
|
|
4146 |
'scale' => $scale,
|
|
|
4147 |
'usercompetency' => null,
|
|
|
4148 |
'usercompetencyplan' => null,
|
|
|
4149 |
'context' => $evidence->get_context(),
|
|
|
4150 |
));
|
|
|
4151 |
return $exporter->export($output);
|
|
|
4152 |
}
|
|
|
4153 |
|
|
|
4154 |
/**
|
|
|
4155 |
* Returns description of grade_competency_in_course() result value.
|
|
|
4156 |
*
|
|
|
4157 |
* @return external_value
|
|
|
4158 |
*/
|
|
|
4159 |
public static function grade_competency_in_course_returns() {
|
|
|
4160 |
return evidence_exporter::get_read_structure();
|
|
|
4161 |
}
|
|
|
4162 |
|
|
|
4163 |
/**
|
|
|
4164 |
* Returns description of unlink_plan_from_template_() parameters.
|
|
|
4165 |
*
|
|
|
4166 |
* @return external_function_parameters
|
|
|
4167 |
*/
|
|
|
4168 |
public static function unlink_plan_from_template_parameters() {
|
|
|
4169 |
$planid = new external_value(
|
|
|
4170 |
PARAM_INT,
|
|
|
4171 |
'Data base record id for the plan',
|
|
|
4172 |
VALUE_REQUIRED
|
|
|
4173 |
);
|
|
|
4174 |
|
|
|
4175 |
$params = array(
|
|
|
4176 |
'planid' => $planid,
|
|
|
4177 |
);
|
|
|
4178 |
return new external_function_parameters($params);
|
|
|
4179 |
}
|
|
|
4180 |
|
|
|
4181 |
/**
|
|
|
4182 |
* Unlink the plan from the template.
|
|
|
4183 |
*
|
|
|
4184 |
* @param int $planid The plan id
|
|
|
4185 |
* @return bool
|
|
|
4186 |
*/
|
|
|
4187 |
public static function unlink_plan_from_template($planid) {
|
|
|
4188 |
$params = self::validate_parameters(self::unlink_plan_from_template_parameters(), array(
|
|
|
4189 |
'planid' => $planid,
|
|
|
4190 |
));
|
|
|
4191 |
|
|
|
4192 |
$plan = new plan($params['planid']);
|
|
|
4193 |
self::validate_context($plan->get_context());
|
|
|
4194 |
|
|
|
4195 |
return api::unlink_plan_from_template($plan);
|
|
|
4196 |
}
|
|
|
4197 |
|
|
|
4198 |
/**
|
|
|
4199 |
* Returns description of unlink_plan_from_template_() result value.
|
|
|
4200 |
*
|
|
|
4201 |
* @return external_value
|
|
|
4202 |
*/
|
|
|
4203 |
public static function unlink_plan_from_template_returns() {
|
|
|
4204 |
return new external_value(PARAM_BOOL, 'True if the unlink was successful');
|
|
|
4205 |
}
|
|
|
4206 |
|
|
|
4207 |
/**
|
|
|
4208 |
* Returns description of template_viewed() parameters.
|
|
|
4209 |
*
|
|
|
4210 |
* @return external_function_parameters
|
|
|
4211 |
*/
|
|
|
4212 |
public static function template_viewed_parameters() {
|
|
|
4213 |
$id = new external_value(
|
|
|
4214 |
PARAM_INT,
|
|
|
4215 |
'Data base record id for the template',
|
|
|
4216 |
VALUE_REQUIRED
|
|
|
4217 |
);
|
|
|
4218 |
|
|
|
4219 |
$params = array(
|
|
|
4220 |
'id' => $id,
|
|
|
4221 |
);
|
|
|
4222 |
return new external_function_parameters($params);
|
|
|
4223 |
}
|
|
|
4224 |
|
|
|
4225 |
/**
|
|
|
4226 |
* Log the template viewed event.
|
|
|
4227 |
*
|
|
|
4228 |
* @param int $id the template id
|
|
|
4229 |
* @return array of warnings and status result
|
|
|
4230 |
* @throws moodle_exception
|
|
|
4231 |
*/
|
|
|
4232 |
public static function template_viewed($id) {
|
|
|
4233 |
$params = self::validate_parameters(self::view_book_parameters(), array(
|
|
|
4234 |
'id' => $id
|
|
|
4235 |
));
|
|
|
4236 |
|
|
|
4237 |
$template = api::read_template($params['id']);
|
|
|
4238 |
self::validate_context($template->get_context());
|
|
|
4239 |
|
|
|
4240 |
return api::template_viewed($params['id']);
|
|
|
4241 |
}
|
|
|
4242 |
|
|
|
4243 |
/**
|
|
|
4244 |
* Returns description of template_viewed() result value.
|
|
|
4245 |
*
|
|
|
4246 |
* @return external_value
|
|
|
4247 |
*/
|
|
|
4248 |
public static function template_viewed_returns() {
|
|
|
4249 |
return new external_value(PARAM_BOOL, 'True if the log of the view was successful');
|
|
|
4250 |
}
|
|
|
4251 |
|
|
|
4252 |
/**
|
|
|
4253 |
* Returns description of update_course_competency_settings() parameters.
|
|
|
4254 |
*
|
|
|
4255 |
* @return external_function_parameters
|
|
|
4256 |
*/
|
|
|
4257 |
public static function update_course_competency_settings_parameters() {
|
|
|
4258 |
$courseid = new external_value(
|
|
|
4259 |
PARAM_INT,
|
|
|
4260 |
'Course id for the course to update',
|
|
|
4261 |
VALUE_REQUIRED
|
|
|
4262 |
);
|
|
|
4263 |
$pushratingstouserplans = new external_value(
|
|
|
4264 |
PARAM_BOOL,
|
|
|
4265 |
'New value of the setting',
|
|
|
4266 |
VALUE_REQUIRED
|
|
|
4267 |
);
|
|
|
4268 |
$settings = new external_single_structure(array(
|
|
|
4269 |
'pushratingstouserplans' => $pushratingstouserplans
|
|
|
4270 |
));
|
|
|
4271 |
$params = array(
|
|
|
4272 |
'courseid' => $courseid,
|
|
|
4273 |
'settings' => $settings,
|
|
|
4274 |
);
|
|
|
4275 |
return new external_function_parameters($params);
|
|
|
4276 |
}
|
|
|
4277 |
|
|
|
4278 |
/**
|
|
|
4279 |
* Update the course competency settings
|
|
|
4280 |
*
|
|
|
4281 |
* @param int $courseid the course id
|
|
|
4282 |
* @param stdClass $settings The list of settings (currently only pushratingstouserplans).
|
|
|
4283 |
* @throws moodle_exception
|
|
|
4284 |
*/
|
|
|
4285 |
public static function update_course_competency_settings($courseid, $settings) {
|
|
|
4286 |
$params = self::validate_parameters(self::update_course_competency_settings_parameters(), array(
|
|
|
4287 |
'courseid' => $courseid,
|
|
|
4288 |
'settings' => $settings
|
|
|
4289 |
));
|
|
|
4290 |
|
|
|
4291 |
$context = context_course::instance($params['courseid']);
|
|
|
4292 |
self::validate_context($context);
|
|
|
4293 |
$result = api::update_course_competency_settings($params['courseid'], $params['settings']);
|
|
|
4294 |
|
|
|
4295 |
return $result;
|
|
|
4296 |
}
|
|
|
4297 |
|
|
|
4298 |
/**
|
|
|
4299 |
* Returns description of update_course_competency_settings() result value.
|
|
|
4300 |
*
|
|
|
4301 |
* @return external_value
|
|
|
4302 |
*/
|
|
|
4303 |
public static function update_course_competency_settings_returns() {
|
|
|
4304 |
return new external_value(PARAM_BOOL, 'True if the update was successful.');
|
|
|
4305 |
}
|
|
|
4306 |
|
|
|
4307 |
/**
|
|
|
4308 |
* Returns description of external function parameters.
|
|
|
4309 |
*
|
|
|
4310 |
* @return external_function_parameters
|
|
|
4311 |
*/
|
|
|
4312 |
public static function delete_evidence_parameters() {
|
|
|
4313 |
return new external_function_parameters(array(
|
|
|
4314 |
'id' => new external_value(PARAM_INT, 'The evidence ID'),
|
|
|
4315 |
));
|
|
|
4316 |
}
|
|
|
4317 |
|
|
|
4318 |
/**
|
|
|
4319 |
* External function delete_evidence.
|
|
|
4320 |
*
|
|
|
4321 |
* @param int $id The evidence ID.
|
|
|
4322 |
* @return boolean
|
|
|
4323 |
*/
|
|
|
4324 |
public static function delete_evidence($id) {
|
|
|
4325 |
$params = self::validate_parameters(self::delete_evidence_parameters(), array(
|
|
|
4326 |
'id' => $id
|
|
|
4327 |
));
|
|
|
4328 |
|
|
|
4329 |
$evidence = api::read_evidence($params['id']);
|
|
|
4330 |
$uc = api::get_user_competency_by_id($evidence->get('usercompetencyid'));
|
|
|
4331 |
self::validate_context($uc->get_context());
|
|
|
4332 |
|
|
|
4333 |
return api::delete_evidence($evidence);
|
|
|
4334 |
}
|
|
|
4335 |
|
|
|
4336 |
/**
|
|
|
4337 |
* Returns description of external function result value.
|
|
|
4338 |
*
|
|
|
4339 |
* @return external_function_parameters
|
|
|
4340 |
*/
|
|
|
4341 |
public static function delete_evidence_returns() {
|
|
|
4342 |
return new external_value(PARAM_BOOL, 'The success');
|
|
|
4343 |
}
|
|
|
4344 |
|
|
|
4345 |
}
|