Problems with core_calendar_get_calendar_events

Problems with core_calendar_get_calendar_events

by Eike Rand -
Number of replies: 3

Hi there,

I need some help with my web services.

I am trying to get the dates of a quiz out of a course. In the first place, i tried to get the dates by using core_course_get_contents(). The course, including the quiz, was shown correctly, but the "available from" and "available to" values were "0". I am not sure if this is because the service is not completly implemented, yet or I did something wrong?

 

Then I tried to get the calendar of this course by using the core_calendar_get_calendar_events() function. But I have no clue how to pass the parameters to this function and I can't find any examples how to do this. I get

""exception":"invalid_parameter_exception","errorcode":"invalidparameter" "Unexpected keys (courseids) detected in parameter array."".

Does anybody know how to pass the parameters correctly to the function via REST? I want to get all events of a course between febraury and august.

 

Thank you very much,

Eike.

Average of ratings: -
In reply to Eike Rand

Re: Problems with core_calendar_get_calendar_events

by Juan Leyva -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Regarding calendar_events, please, check:

https://github.com/moodlehq/sample-ws-clients

Also:

https://github.com/moodlehq/moodlemobile/blob/master/plugins/events/main.js#L84

You have sample parameters passing in Administration / Plugins / Web Services / API Documentation

Regarding availability, from the code (seems that some configurations should be enabled):

//availability date (also send to user who can see hidden module when the showavailabilyt is ON)
 168                          if ($canupdatecourse or ($CFG->enableavailability && $canviewhidden && $cm->showavailability)) {
 169                              $module['availablefrom'] = $cm->availablefrom;
 170                              $module['availableuntil'] = $cm->availableuntil;
 171                          }
In reply to Eike Rand

Re: Problems with core_calendar_get_calendar_events

by Bill Antonia -

http://<server.domain.com>/moodle/webservice/rest/server.php?wstoken=<averylongstringforatoken>&wsfunction=core_calendar_get_calendar_events&events[courseids][0]=<courseid>&options[timestart]=1391212800&options[timeend]=1409529599

Replace the following to suit your system: <server.domain.com> <averylongstringforatoken> <courseid>

The values 1391212800 and 1409529599 are Unix timestamps for 1 Feb 2014 at 00:00:00 and 31 Aug 2014 and 23:59:59

The brackets [ and ] are usually url encoded to %5B and %5D

Many of the settings are optional, hope this helps.

Average of ratings: Useful (1)
In reply to Bill Antonia

Re: Problems with core_calendar_get_calendar_events

by Eike Rand -

Yes, that helps a lot! Thank you very much. smile

-> Problem solved