Web services allow external software components to interact with the component.
Synopsis: This function lets you remotely modify any configuration parameter of the synchronisation tool.
| Key | Values |
|---|---|
| fileuploadlocation | file name |
| filedeletelocation | file name |
| filedeleteidentifier | id, shortname, idnumber |
| fileexistlocation | file name |
| existfileidentifier | id, shortname, idnumber |
| fileresetlocation | file name |
| fileresetidentifier | id, shortname, idnumber |
| forceupdate | 0 or 1 |
| Key | Values |
|---|---|
| filelocation | file name |
| primaryidentity | id, idnumber, username, email |
| Key | Values |
|---|---|
| filelocation | file name |
| courseidentifier | id, idnumber, shortname |
| useridentifier | id, idnumber, username, email |
| Key | Values |
|---|---|
| filelocation | file name |
| useridentifier | id, idnumber, username, email |
| cohortidentifier | id, idnumber |
| autocreate | 0 or 1 |
| syncdelete | 0 or 1 |
Synopsis: This function moves a file previously uploaded to the draft area to its final location in the synchronisation tool's file system.
Example implementation in PHP:
$path = '<location_of_the_file>';
$params = array('token' => '<valid_token>',
'itemid' => 0,
'filearea' => 'draft');
$uploadurl = '<moodle_url>/webservice/upload.php';
$ch = curl_init($uploadurl);
$curlfile = new CURLFile($path, 'x-application/zip', basename($path));
$params['resourcefile'] = $curlfile;
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
echo "Firing CUrl $uploadurl ... \n";
if (!$result = curl_exec($ch)) {
echo "CURL Error : ".curl_error($ch)."\n";
return;
}
$result = json_decode($result);
$filerec = array_pop($result);
// Now commit the file.
$params = array('wstoken' => '<valid_token>',
'wsfunction' => 'tool_sync_commit_file',
'moodlewsrestformat' => 'json',
'draftitemid' => $filerec->itemid);
$commiturl = '<moodle_url>/webservice/rest/server.php';
$this->send($commiturl, $params);
Synopsis: Triggers the appropriate synchronisation processing based on the current configuration of the tool.
Synopsis: Deploys a course based on an existing course archive or a backup available in the file system.
(*) Syntax under experimentation / documentation to be developed
For an operation driven from the outside, here is the complete sequence of operations to perform:
This service is intended to complete or take over from the standard Moodle web services, when the latter lack API unification, in particular regarding the primary identifiers of Moodle's main business objects.
This service plan will add missing functions to the standard API, or offer an alternative signature for functions that do not make it possible to use external or alternative identifiers on the business objects to be handled.
In general, it is agreed to be able to provide all possible identification entries on the following bases:
| Entity | Possible identifiers |
|---|
Course | id, shortname, idnumber | User | id, username(@mnethostid), idnumber, email | Cohort | id, idnumber | Course group | id, CourseID@name | Role | id, shortname |
Back to the technical guide - Back to the component index - Back to the catalogue