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

New Web Service mod_quiz_get_user_attempts

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • 3.1
    • 3.0.1
    • Quiz, Web Services
    • MOODLE_30_STABLE
    • MOODLE_31_STABLE
    • MDL-52670-master
    • 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

      Return quiz attempts information for the given user:

      Parameteres:

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

            jleyva Juan Leyva
            jleyva Juan Leyva
            Tim Hunt Tim Hunt
            David Monllaó David Monllaó
            cameron1729 cameron1729
            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.