{"lessons":[{"id":1,"coursemodule":13,"course":"2","name":"LESSON How serve a chicken","intro":"<p>How serve a chicken<br \/><\/p>","introformat":1,"practice":false,"modattempts":true,"usepassword":true,"password":"AABBCC","dependency":0,"conditions":"O:8:\"stdClass\":3:{s:9:\"timespent\";i:0;s:9:\"completed\";i:0;s:15:\"gradebetterthan\";i:0;}","grade":100,"custom":true,"ongoing":true,"usemaxgrade":0,"maxanswers":4,"maxattempts":3,"review":true,"nextpagedefault":0,"feedback":false,"minquestions":0,"maxpages":0,"timelimit":"1800","retake":false,"activitylink":7,"mediafile":"\/tacchino.jpg","mediaheight":480,"mediawidth":640,"mediaclose":0,"slideshow":false,"width":640,"height":480,"bgcolor":"#FFFFFF","displayleft":true,"displayleftif":0,"progressbar":true,"highscores":0,"maxhighscores":10,"available":"1435672500","deadline":"1441029300","timemodified":"1435676397","completionendreached":"0","completiontimespent":"0","section":0,"visible":true,"groupmode":0,"groupingid":0}],"warnings":[]}
Some properties are reserved to admins (who posses moodle/lesson:manage capability)
section
visible
groupmode
groupingid
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
{"lessons":[],"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
add a Lesson to the first course
add a Lesson to the second course
as student1 call mod_lesson_get_lessons_by_courses(array())
when you do not specify any courseid, you will retrieve all Lessons belonging to your enrolled courses
Create a Token for the Student and the 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_lesson_get_lessons_by_courses&wstoken=55a2a34c00e88f0b8765cc16c66b421e' --compressed
The webservice should return this kind of result:
{"lessons":[{"id":1,"coursemodule":13,"course":"2","name":"LESSON How serve a chicken","intro":"<p>How serve a chicken<br \/><\/p>","introformat":1,"practice":false,"modattempts":true,"usepassword":true,"password":"AABBCC","dependency":0,"conditions":"O:8:\"stdClass\":3:{s:9:\"timespent\";i:0;s:9:\"completed\";i:0;s:15:\"gradebetterthan\";i:0;}","grade":100,"custom":true,"ongoing":true,"usemaxgrade":0,"maxanswers":4,"maxattempts":3,"review":true,"nextpagedefault":0,"feedback":false,"minquestions":0,"maxpages":0,"timelimit":"1800","retake":false,"activitylink":7,"mediafile":"\/tacchino.jpg","mediaheight":480,"mediawidth":640,"mediaclose":0,"slideshow":false,"width":640,"height":480,"bgcolor":"#FFFFFF","displayleft":true,"displayleftif":0,"progressbar":true,"highscores":0,"maxhighscores":10,"available":"1435672500","deadline":"1441029300","timemodified":"1435676397","completionendreached":"0","completiontimespent":"0","section":0,"visible":true,"groupmode":0,"groupingid":0}],"warnings":[]}
Some properties are reserved to admins (who posses moodle/lesson:manage capability)
section
visible
groupmode
groupingid
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
{"lessons":[],"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