-
Notifications
You must be signed in to change notification settings - Fork 0
/
locallib.php
28 lines (25 loc) · 975 Bytes
/
locallib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**
* Call a assessment manager web service function.
* By default it return the documentation.
*
* @param $functionname the web service function name
* @param $params the parameter of the function
*/
function call($functionname = 'documentation', $params = array()) {
global $CFG;
$token = $CFG->genius_api_token_incoming;
$domainname = $CFG->wwwroot;
$qworker = true;
$restformat = 'xml';
/// REST CALL
$serverurl = $domainname . '/blocks/geniusapis/rest/server.php'. '?token=' . $token . '&wsfunction='.$functionname;
require_once('./curl.php');
$curl = new curl;
// if rest format == 'xml', then we do not add the param for backward compatibility with Moodle < 2.2
$restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'';
$resp = $curl->post($serverurl . $restformat . '&qworker=' . $qworker, $params);
print_r($functionname . ': ');
print_r($resp);
print_r('<br/><br/>');
}