Hi,
has somebody an idea what i do wrong? I try to enroll in a user for a course and I got the following error:
stdClass Object
(
[exception] => moodle_exception
[errorcode] => wsnoinstance
[message] => Manual enrolment plugin instance doesn't exist or is disabled for the course (id = {$a->courseid})
)
I enabled manual enrolment. The webservice create user already work fine, just the user enrole dosen't work.
My Code:
token = $token;
$this->domain = $domain;
}
public function enrolUser($userID, $courseID){
$functionname = "enrol_manual_enrol_users";
$enrolment = new stdClass();
$enrolment -> roleid = 5;
$enrolment -> userid = 10;
$enrolment -> courseid = 1;
$params = array("enrolments" => array($enrolment));
$response = $this->connectToMoodle($functionname, $params);
return print_r($response);
}
private function connectToMoodle($functionname, $params){
$restformat = "json";
header("Content-Type: text/plain");
$serverurl = $this->domain . "/webservice/rest/server.php" . "?wstoken=" . $this->token . "&wsfunction=" . $functionname;
require_once("curl.php");
$curl = new curl;
$restformat = ($restformat == "json")?"&moodlewsrestformat=" . $restformat:"";
$response = $curl->post($serverurl . $restformat, $params);
return json_decode($response);
}
}
?>