Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-50544

mod_lesson_get_lessons_by_courses

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.9
    • Web Services
    • MOODLE_29_STABLE
    • MDL-50544-master
    • Hide

      Note: Version number is bumped because a new web service is added into the Mobile app service.

      1. Create 2 courses and enroll student1 to the first course
      2. add a Lesson to the first course
      3. add a Lesson to the second course
      4. as student1 call mod_lesson_get_lessons_by_courses(array())
      5. when you do not specify any courseid, you will retrieve all Lessons belonging to your enrolled courses
      1. Create a Token for the Student and the Student1 :
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      2. 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

      1. 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":[]}
      

      1. Some properties are reserved to admins (who posses moodle/lesson:manage capability)
        section
        visible
        groupmode
        groupingid
      1. 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."}]}
        

      2. When an inexistent course id is specified the WS returns an empty result
      Show
      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

      Retrieve a list of lessons from several courses

            jleyva Juan Leyva
            ccito Costantino Cito
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.