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

Several bug fixes in the new lesson web services

XMLWordPrintable

    • MOODLE_33_STABLE
    • MOODLE_33_STABLE
    • MDL-58415-master
    • Hide
      1. Create one lesson activity with two content pages and one question page. There should be a random jump to a content page after the first content page. In the options, enable to display the progress bar and the Menu. Also enable Availability -> Allow lesson to be attempted offline using the mobile app option.
      2. Enable "Mobile services": Plugins ► Web Services ► Mobile
      3. Create a Token for one teacher and one student enrolled in the course:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Next, you can do a couple of CURL REST call simulating a WS client with the the student user .
        • You need to replace the wstoken, courseid and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseids%5B0%5D=17&wsfunction=mod_lesson_get_lessons_by_courses&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool"

      5. Confirm that in the response you see the allowofflineattempts field set to 1.
      6. Now, execute the following curl request to start a new attempt in the lesson (lessonid is the lesson instance value):

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=8&wsfunction=mod_lesson_launch_attempt&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool"

      7. Now, execute the following curl request (pageid is the first page id in the lesson):

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=13&pageid=96&returncontents=1&wsfunction=mod_lesson_get_page_data&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool"

        # Check that in the response, the progress field is an integer value > 0

      8. Now, execute the same curl request but using as pageid the id of the page with the random jump.
      9. Check in the response you don't receive a page field
      10. Now, execute the same curl request but using the pageid of the question page
      11. Check that in the response you see all the possible question responses, including the fields "response, responseformat, answer and answerformat"
      12. Now, launch the script for finishing the attempt using this curl call

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=4&wsfunction=mod_lesson_finish_attempt&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool"

      13. Check that you don't receive any exception
      14. Now, execute this curl request using the question page id

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'review=1&lessonid=13&pageid=96&returncontents=1&wsfunction=mod_lesson_get_page_data&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool"

      15. Check that you receive correctly the question page information (you don't see any errors)
      16. Now, change your $CFG->sessiontime to 60 seconds
      17. Wait a minute an execute the same curl request
      18. You should get an "outoftime" exception
      Show
      Create one lesson activity with two content pages and one question page. There should be a random jump to a content page after the first content page. In the options, enable to display the progress bar and the Menu. Also enable Availability -> Allow lesson to be attempted offline using the mobile app option. Enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for one teacher and one student enrolled in the course: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a couple of CURL REST call simulating a WS client with the the student user . You need to replace the wstoken, courseid and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseids%5B0%5D=17&wsfunction=mod_lesson_get_lessons_by_courses&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool" Confirm that in the response you see the allowofflineattempts field set to 1. Now, execute the following curl request to start a new attempt in the lesson (lessonid is the lesson instance value): curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=8&wsfunction=mod_lesson_launch_attempt&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool" Now, execute the following curl request (pageid is the first page id in the lesson): curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=13&pageid=96&returncontents=1&wsfunction=mod_lesson_get_page_data&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool" # Check that in the response, the progress field is an integer value > 0 Now, execute the same curl request but using as pageid the id of the page with the random jump. Check in the response you don't receive a page field Now, execute the same curl request but using the pageid of the question page Check that in the response you see all the possible question responses, including the fields "response, responseformat, answer and answerformat" Now, launch the script for finishing the attempt using this curl call curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=4&wsfunction=mod_lesson_finish_attempt&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool" Check that you don't receive any exception Now, execute this curl request using the question page id curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'review=1&lessonid=13&pageid=96&returncontents=1&wsfunction=mod_lesson_get_page_data&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool" Check that you receive correctly the question page information (you don't see any errors) Now, change your $CFG->sessiontime to 60 seconds Wait a minute an execute the same curl request You should get an "outoftime" exception

      During development and testing we have detected a few issues that needs addressing

            jleyva Juan Leyva
            jleyva Juan Leyva
            Pau Ferrer Pau Ferrer
            Jun Pataleta Jun Pataleta
            Dani Palou Dani Palou
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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