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

Web Services for returning final and lesson attempt grades

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.3
    • Component/s: Lesson, Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. In a course create a lesson with at least one question page and configured to allow multiple attempts
      2. Enrol one user as student in the course where the lesson is.
      3. Attempt the lesson as the student a couple of times (please check as teacher that in the attempts report you see that the student did two attempts)
      4. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      5. Create a Token for the student user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Next, you can do a CURL REST call simulating a WS client with the student user .
        • You need to replace the wstoken, lessonid (the lesson instance value) and the URL of your moodle instance

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

      7. Confirm that you receive correctly the grade and that the grade match with the one in the web interface.
      8. Now, create a token for a teacher in the course and execute again the curl request appending: &userid=X (X is the id of the student user who attempted the lesson)
      9. Confirm that you receive correctly the grade
      10. Now, using again the student wstoken:

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

      11. Check that you see correctly the grade of your first attempt
      12. Execute the curl request again but with lessonattempt=1 and check that you receive the grade for your second attempt
      13. Using the teachers token execute again the curl request appending: &userid=X (X is the id of the student user who attempted the lesson) and check that you see the same information that with the user token
      Show
      In a course create a lesson with at least one question page and configured to allow multiple attempts Enrol one user as student in the course where the lesson is. Attempt the lesson as the student a couple of times (please check as teacher that in the attempts report you see that the student did two attempts) As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student user Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student user . You need to replace the wstoken, lessonid (the lesson instance value) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=9&wsfunction=mod_lesson_get_user_grade&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool" Confirm that you receive correctly the grade and that the grade match with the one in the web interface. Now, create a token for a teacher in the course and execute again the curl request appending: &userid=X (X is the id of the student user who attempted the lesson) Confirm that you receive correctly the grade Now, using again the student wstoken: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'lessonid=9&lessonattempt=0&wsfunction=mod_lesson_get_user_attempt_grade&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true' | python -m "json.tool" Check that you see correctly the grade of your first attempt Execute the curl request again but with lessonattempt=1 and check that you receive the grade for your second attempt Using the teachers token execute again the curl request appending: &userid=X (X is the id of the student user who attempted the lesson) and check that you see the same information that with the user token
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-57657-master

      Description

      We will be needing two web services here:

      • mod_lesson_get_user_grade: For returning user final grades
      • mod_lesson_get_user_attempt_grade: For returning grade information for an attempt

        Attachments

        1. screenshot-1.png
          screenshot-1.png
          20 kB
        2. screenshot-2.png
          screenshot-2.png
          8 kB
        3. screenshot-3.png
          screenshot-3.png
          12 kB

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Dani Palou
              Integrator:
              Dan Poltawski
              Tester:
              David Mudrák (@mudrd8mz)
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Juan Leyva, Jake Dallimore, Jun Pataleta
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/May/17