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

New Web Service mod_quiz_get_user_best_grade

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.2
    • Fix Version/s: 3.1
    • Component/s: Quiz, Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Bump your /version.php file to force Moodle to reload the Mobile service
      2. Create a course with a student.
      3. Create a mod_quiz activity with at least one question (self-evaluable)
      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, quizid (the quiz instance value) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=2&wsfunction=mod_quiz_get_user_best_grade&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed

      7. Confirm that
        • You see that the response is a JSON string containing hasgrade equal to false, you don't see any grade returned
      8. Now as student in the Moodle web interface do the quiz and obtain a grade
      9. Run the WS again, check that now hasgrade is equal to true and that you see the grade you obtained (pllease, note that the grade may be scaled)
      10. Now, obtain a token for a teacher user in the same course
      11. Run the curl command adding a new parameter &userid=THE_STUDENT_ID, check that you can see the student grade
      12. Obtain a token for a user in a different course, check that running the curl command return require_login_exception
      Show
      Bump your /version.php file to force Moodle to reload the Mobile service Create a course with a student. Create a mod_quiz activity with at least one question (self-evaluable) 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, quizid (the quiz instance value) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=2&wsfunction=mod_quiz_get_user_best_grade&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed Confirm that You see that the response is a JSON string containing hasgrade equal to false, you don't see any grade returned Now as student in the Moodle web interface do the quiz and obtain a grade Run the WS again, check that now hasgrade is equal to true and that you see the grade you obtained (pllease, note that the grade may be scaled) Now, obtain a token for a teacher user in the same course Run the curl command adding a new parameter &userid=THE_STUDENT_ID, check that you can see the student grade Obtain a token for a user in a different course, check that running the curl command return require_login_exception
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-52785-master

      Description

      Get the best current grade for the given user in a quiz.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  23/May/16