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

New Web Service mod_quiz_get_quiz_attempts

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 3.0.3
    • Quiz
    • MOODLE_30_STABLE
    • MDL-53847-master
    • 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"

      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

            jleyva Juan Leyva
            jleyva Juan Leyva
            Tim Hunt Tim Hunt
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 28 minutes
                28m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.