by Patrick Pollet.
Ok, please find attached the code that DO work in Moodle 2.3
This code was generated from the REST sample code available at github https://github.com/moodlehq/sample-ws-clients and my script at http://tracker.moodle.org/browse/CONTRIB-3472 that generates for all current operations the proper nesting of arrays such as this one :
// enrol_manual_enrol_users
$args37= array ( //e_s_s
'enrolments' => array( // e_m_s
array ( //e_s_s
'roleid' => 1, // PARAM_INTEGER VALUE_REQUIRED []
'userid' => 1, // PARAM_INTEGER VALUE_REQUIRED []
'courseid' => 1, // PARAM_INTEGER VALUE_REQUIRED []
'timestart' => 1, // PARAM_INTEGER VALUE_OPTIONAL []
'timeend' => 1, // PARAM_INTEGER VALUE_OPTIONAL []
'suspend' => 1, // PARAM_INTEGER VALUE_OPTIONAL []
),
),
)
;
To customize it for any other operations (either official of OK TECH if you installed it) :
- copy & paste the proper $argsxx into the attached script
- rename $argsxx to $params
- adjust the values of the parameters marked as required
- remove or comment out (or set values if needed) for parameters marked as optional
- don't forget to adjust the $functionname value
- enjoy
Cheers
Edit : I just tested your code (with my values for courseid and userid) and it does also work . The error 'context does not exist' in your place is likely due to an invalid courseid value, or not enough permissions to do the enrolment ... Currently Moodle WS are not very good in error reporting...