-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathenrol_users.php
36 lines (28 loc) · 1.09 KB
/
enrol_users.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
29
30
31
32
33
34
35
<?php
/*
Erro retornado
"debuginfo":"Missing required key in single structure: enrolments"
*/
/// Connection
$token = 'ed874e6d9f51239e180f49f4d926d50f';
$domainname = 'http://localhost/moodle';
$functionname = 'enrol_manual_enrol_users';
$restformat = 'json';
//////// enrol_manual_enrol_users ////////
/// Paramètres
$enrolment = new stdClass();
$enrolment->roleid = 5; //estudante(student) -> 5; moderador(teacher) -> 4; professor(editingteacher) -> 3;
$enrolment->userid = 2;
$enrolment->courseid = 4;
$enrolments = array( $enrolment);
$params = array('enrolments' => $enrolments);
print_r($params);
header('Content-Type: text/plain');
$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $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, $params);
print_r($resp);
?>