Hi guys; good morning from Madrid.
I am having problems with the function as web service, called "moodle_role_assign" in my moodle 2.0.2+; the problem is the following:
When the user is already enrolled in the course and I can see it through the participants block or through "the Block settings/course Administration/enrolled users" I haven't got any problem with the function "moodle_role_assign" because, I am able to see clearly how It has just worked out and the role has just been assigned to the user which has been choosen; here you are the source:
<?php
require_once("config.php");
require_once "Zend/XmlRpc/Client.php";
$assignments = array(
array('roleid'=>'3','userid'=>'3721','contextid'=>'88')
);
$asignaciones = array($assignments);
$params = array('assignments' =>$assignments);
$token='283e113ff4b047d0aa4f11832695c444';
$serverurl = $CFG->wwwroot.'/webservice/xmlrpc/server.php?wstoken='.$token;
$xmlrpcclient = new Zend_XmlRpc_Client($serverurl);
$function='moodle_role_assign';
try{
$createduser = $xmlrpcclient->call($function, $params);
}catch(Exception $e) {
var_dump($e);
}
var_dump($createduser);
?>
The problem comes when the person, who is wanted to be enrolled, isn't even user in the course yet. In this case the call to the function "moodle_role_assign" keeps not returning any error as the above case, but after being called I can not see the user neither in the participants block nir enrolled users and eventually the users is not enrolled in the course so It seems that it isn't working well but I don´t know why, moreover I can not watch any debug trace because the function, as i said, doesn´t throw any fault or exception.
Does Someboy know anything about this matter? Maybe I forgot doing something more in the source.
Hugs and thanks a lot for all.
Regards.