{"surveys":[{"id":6,"coursemodule":16,"course":"2","name":"Survey Attitudes","intro":"<p><span style=\"color:rgb(89,89,89);font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:24px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;background-color:rgb(255,255,255);\">Attitudes to Thinking and Learning Survey<\/span><br \/><\/p>","introformat":1,"template":4,"days":0,"timecreated":"1436451446","timemodified":"1436451446","questions":"65,67,68","section":0,"visible":true,"groupmode":0,"groupingid":0}],"warnings":[]}
Some properties are reserved to admins (who posses moodle/course:manageactivities capability)
section
visible
groupmode
groupingid
You need mod/survey:participate capability to see see this activity,
when you miss this capability a warning message (warningcode=2) will be returned
In order to verify the WS really uses this capability:
Go to the Dashboard / ► Courses / ► FIRST-COURSE / ► Users / ► Permissions / ► Override roles
and set the "mod/survey:participate" as Prohibit for Students
Now, when you try to call this WS again (as student) you should receive a warningcode=2
as student, you can also try to pass a course->id you are not enrolled in, in this case you will receive a warningcode=1
{"surveys":[],"warnings":[{"item":"course","itemid":3,"warningcode":"1","message":"No access rights in course context Course or activity not accessible."}]}
When an inexistent course id is specified the WS returns an empty result
Note: Version number is bumped because a new web service is added into the Mobile app service.
Create 2 courses and enroll student1 to the first course (FIRST-COURSE)
add a Survey to the first course
add a Survey to the second course
as student1 call mod_survey_get_surveys_by_courses(array())
when you do not specify any courseid, you will retrieve all Surveys belonging to your enrolled courses
Create a Token for Student1 :
Click on Site administration ► Plugins ► Web services ► Manage tokens
Next, you can do a couple of CURL REST call simulating a WS client as Student
curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_survey_get_surveys_by_courses&wstoken=55a2a34c00e88f0b8765cc16c66b421e' --compressed
The webservice should return this kind of result:
{"surveys":[{"id":6,"coursemodule":16,"course":"2","name":"Survey Attitudes","intro":"<p><span style=\"color:rgb(89,89,89);font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:24px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;background-color:rgb(255,255,255);\">Attitudes to Thinking and Learning Survey<\/span><br \/><\/p>","introformat":1,"template":4,"days":0,"timecreated":"1436451446","timemodified":"1436451446","questions":"65,67,68","section":0,"visible":true,"groupmode":0,"groupingid":0}],"warnings":[]}
Some properties are reserved to admins (who posses moodle/course:manageactivities capability)
section
visible
groupmode
groupingid
You need mod/survey:participate capability to see see this activity,
when you miss this capability a warning message (warningcode=2) will be returned
In order to verify the WS really uses this capability:
Go to the Dashboard / ► Courses / ► FIRST-COURSE / ► Users / ► Permissions / ► Override roles
and set the "mod/survey:participate" as Prohibit for Students
Now, when you try to call this WS again (as student) you should receive a warningcode=2
as student, you can also try to pass a course->id you are not enrolled in, in this case you will receive a warningcode=1
{"surveys":[],"warnings":[{"item":"course","itemid":3,"warningcode":"1","message":"No access rights in course context Course or activity not accessible."}]}
When an inexistent course id is specified the WS returns an empty result