Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2361

Re: "Context does not exist" error

$
0
0
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) : 

  1.  copy & paste  the proper $argsxx into the attached script
  2. rename $argsxx to $params 
  3. adjust the values of the parameters marked as required 
  4. remove or comment out (or set values if needed) for parameters marked as optional 
  5. don't forget to adjust the $functionname value
  6. enjoy big grin

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... 


Viewing all articles
Browse latest Browse all 2361

Trending Articles