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

New Web Service mod_quiz_get_quiz_attempts

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a course using separate groups
      2. Create two students: studenta and studentb in two different groups (groupa and groupb)
      3. Create a teacher: teachera enrolled in the groupa group
      4. Create a quiz activity
      5. Start and finish quiz attempts with studenta and studentb
      6. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      7. Create a Token for the teachera user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      8. Next, you can do a CURL REST call simulating a WS client with the teacher user.
        • You need to replace the wstoken, quizid (with the quiz instance id) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=10&userid=106&wsfunction=mod_quiz_get_quiz_attempts&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e&groupid=0' | python -m "json.tool"

        • Confirm that you receive the attempt information for all the students in both groups (by default the teachers can access to all groups)
      9. Now, replace groupid=0 with groupa id and check that you receive only the attempt for the studenta
      10. Now, at course level, remove the capability moodle/site:accessallgroups for the teacher and editingteacher role
      11. Execute the first curl request (the one with groupid=0) you should see only the studenta attempt
      12. If you try to retrieve the attempts for groupid=GROUPB_ID you should see an exception "notingroup"
      Show
      Create a course using separate groups Create two students: studenta and studentb in two different groups (groupa and groupb) Create a teacher: teachera enrolled in the groupa group Create a quiz activity Start and finish quiz attempts with studenta and studentb As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the teachera user: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the teacher user. You need to replace the wstoken, quizid (with the quiz instance id) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=10&userid=106&wsfunction=mod_quiz_get_quiz_attempts&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e&groupid=0' | python -m "json.tool" Confirm that you receive the attempt information for all the students in both groups (by default the teachers can access to all groups) Now, replace groupid=0 with groupa id and check that you receive only the attempt for the studenta Now, at course level, remove the capability moodle/site:accessallgroups for the teacher and editingteacher role Execute the first curl request (the one with groupid=0) you should see only the studenta attempt If you try to retrieve the attempts for groupid=GROUPB_ID you should see an exception "notingroup"
    • Affected Branches:
      MOODLE_30_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-53847-master

      Description

      Retrieve the list of attempts for a given course.

      This Web Service will support groups, is intended for managers/teachers who wants to retrieve a list of users who attempted the quiz.

      Parameters:
      quiz - The quiz instance id
      groupid - Optional, default -1 (determine group), 0 means all groups

      It will return the information in the same format that get_user_attempts

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Tim Hunt Tim Hunt
              Participants:
              Component watchers:
              Tim Hunt, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: