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

New Web Service mod_quiz_get_user_attempts

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.1
    • 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, the course must have at least one section.
      3. Create a mod_quiz activity with at least one question and at least 2 allowed attempts
      4. Log in as the student and do the quiz two times, do not finish the attempt the second time.
      5. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      6. Create a Token for the student user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. 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&status=all&wsfunction=mod_quiz_get_user_attempts&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed

      8. Confirm that
        • You can see a list of your attempts and its current status (one finished, one unfinished)
      9. Add the following parameters to the curl command: &userid=0&status=finished
      10. Check now that the curl command only returns the finished attempt
      11. Do the same but changing status to unfinished
      12. Check now that the curl command only returns the unfinished attempt
      13. Now, create a token for a teacher and replace the wstoken in the curl command
      14. Run the command again with the value userid equal to the student it, check that as a teacher you can see the student user attempts
      Show
      Bump your /version.php file to force Moodle to reload the Mobile service Create a course with a student, the course must have at least one section. Create a mod_quiz activity with at least one question and at least 2 allowed attempts Log in as the student and do the quiz two times, do not finish the attempt the second time. 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&status=all&wsfunction=mod_quiz_get_user_attempts&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed Confirm that You can see a list of your attempts and its current status (one finished, one unfinished) Add the following parameters to the curl command: &userid=0&status=finished Check now that the curl command only returns the finished attempt Do the same but changing status to unfinished Check now that the curl command only returns the unfinished attempt Now, create a token for a teacher and replace the wstoken in the curl command Run the command again with the value userid equal to the student it, check that as a teacher you can see the student user attempts
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-52670-master

      Description

      Return quiz attempts information for the given user:

      Parameteres:

      • quizid
      • userid (default, current user)
      • status (default 'finished')
      • includepreviews (default false)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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