Web services

Unable to manual enrol: enrol_manual_enrol_users

 
Picture of Tim Titchmarsh
Re: Unable to manual enrol: enrol_manual_enrol_users
 

Hi

Unlikely to be permissions with that error message I would think, more likely the names of the parameters. I use:


        write_log("add user to course " .  $moodle_user_id . " " .  $course);

        $moodlcourse = new stdClass();

        $moodlcourse->roleid = 5; // student

        $moodlcourse->userid = $moodle_user_id;

        $moodlcourse->courseid = $course;

        array_push($moodlecourses,$moodlcourse);

        $params = array("enrolments" => $moodlecourses);

        //write_log(var_dump_ret($params));

        MoodleIt("enrol_manual_enrol_users", $params);

What do you have ?

Tim

 
Average of ratings: -
Picture of Hajo Emch
Re: Unable to manual enrol: enrol_manual_enrol_users
 

Hi Tim

thanks for help. 

I use data transfer objects with xml Attributes and had a space after userid. 

Now it works better, but I get: 

 {"exception":"require_login_exception","errorcode":"requireloginerror","message":"Kurs oder Aktivit\u00e4t nicht benutzbar","debuginfo":"Not enrolled"}


I use a call with  https://<my-site>/webservice/rest/server.php?wstoken=<mytoken>&wsfunction=enrol_manual_enrol_users&moodlewsrestformat=json&application/x-www-form-urlencoded=enrolments…

This works for me for example for the method core_course_update_courses 


Do I also have  to submit username and Password?


Hajo 


 
Average of ratings: -
Picture of Hajo Emch
Re: Unable to manual enrol: enrol_manual_enrol_users
 

If I enrol my service user to the course and give him the permission 'Allow role assignments' then it works. 

But I dont want to enrol my service user! Is there a way to enrol students, without enroling the service user?

Thanks for help

 
Average of ratings: -