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

Add web service for creating quiz overrides

XMLWordPrintable

    • MOODLE_403_STABLE
    • MOODLE_404_STABLE
    • mdl-80300-main-refactor
    • Hide

      Since this is a refactor of the quiz override CRUD process, I have included instructions that cover these from a UI perspective. Validation checks are not part of the manual testing since this is covered by unit tests.

      Environment Setup

      1. Create a test course size XS (1 test student created)
      2. Under Settings -> Groups -> Group mode set to Separate groups
      3. Under participants -> Dropdown -> Groups click auto create groups.
      4. Enter Group/member count = 1 and submit
      5. Edit course and add a quiz module
      6. Add a single question - question does not matter

      Test CRUD - user override + calendar events

      1. In the quiz, select More -> Overrides
      2. Click Add a user override
      3. Select a user
      4. Check enable next to "Open the quiz" and enter a time.
      5. Check enable next to "Close the quiz" and enter a time that is later than the "open the quiz" time.
      6. Save, and confirm quiz opens and quiz closes times are shown as you entered them.
      7. Login as this user in a separate browser session
      8. Navigate to the quiz
      9. Confirm the quiz front page has the overwritten open and close times displayed.
      10. Open the calendar and confirm there is an override opens and override closes event
      11. As the admin user, edit the user override settings by pressing Revert to quiz defaults, and only enter a quiz open time change
      12. Confirm as the test user, the quiz front page only says there is a time limit change
      13. Check the calendar as the test user, confirm there are now only 1 event for the quiz open time
      14. As the admin user, delete the override.
      15. As the test user, confirm the quiz page now shows the default front page
      16. As the test user, confirm the calendar now shows no events for this quiz

      Test CRUD - group override + calendar events

      1. In the course, under More -> overrides select the groups dropdown.
      2. Press add a group override.
      3. Select Group A
      4. Check enable next to "Open the quiz" and enter a time.
      5. Check enable next to "Close the quiz" and enter a time that is later than the "open the quiz" time.
      6. Login as a user from Group A in a separate browser session.
      7. Navigate to the quiz and confirm you see the overwritten settings just created.
      8. Check the calendar, and confirm there are two events, one for open and one for closes
      9. As the admin user, edit the override by pressing "Revert to quiz defaults", then only enter a time open and save.
      10. As the user from the group, confirm that the quiz now displays only a new open time.
      11. As the user from the group, check the calendar and confirm there is now only 1 event.
      12. As the admin user, delete the override.
      13. As the user from the group, confirm that the quiz now displays the default settings.
      14. As the user from the group, confirm that their calendar has no entries.

      Test User and Group override applied to same user

      1. Add a user override for the user with only the time open changed
      2. Add a group override for the group the user is in with only the time close changed
      3. Login as the test user, and confirm that the quiz displays both the overwritten open and closing times.
      4. Delete both the user and group overrides

      Webservice tests

      1. Setup the webservices attached to a user with administrator permissions, and obtain a token
        • Add an external/custom service from /admin/settings.php?section=externalservices
        • Add the functions: mod_quiz_delete_overrides, mod_quiz_get_overrides, mod_quiz_save_overrides
        • Make sure the service is enabled and you have permission to use it
        • Create a new token from /admin/webservice/tokens.php
      2. In each of the following tests, replace the following:
        1. Replace the base URL with your instance URL
        2. Replace TOKEN with your webservice token
        3. Replace QUIZID with the quiz instance id (query the mdl_quiz table to find the id)
        4. Replace USERID with the user id
      3. Execute this CURL request to create a quiz override (replacing the values as specified in step 3)

        curl --request POST \
          --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_save_overrides' \
          --header 'Content-Type: multipart/form-data' \
          --form 'data[quizid]=QUIZID' \
          --form 'data[overrides][0][userid]=USERID' \
          --form 'data[overrides][0][timeclose]=10' \
          --insecure
        

      4. Confirm you receive a JSON response with an "ids" array that contains a single ID value.
      5. Note down the ID recieved
      6. Execute this CURL request to get all the quiz overrides (replacing the values as specified in step 3)

        curl --request POST \
          --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_get_overrides' \
          --header 'Content-Type: multipart/form-data' \
          --form quizid=QUIZID \
          --insecure
        

      7. Confirm you receive an JSON response with an "overrides" array, which contains one object with the ID matching what was returned in the previous CURL request.
      8. Execute this CURL request to update the quiz override, replacing PREVIOUSGETID with the ID noted previously. (as well as replacing the values as specified in step 3)

         curl --request POST \
          --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_save_overrides' \
          --header 'Content-Type: multipart/form-data' \
          --form 'data[quizid]=QUIZID' \
          --form 'data[overrides][0][timeclose]=200' \
          --form 'data[overrides][0][id]=PREVIOUSGETID' \
          --form 'data[overrides][0][userid]=USERID' \
          --insecure
        

      9. Confirm you receive a JSON response with an "ids" array that contains the single ID value (equal to PREVIOUSGETID noted previously).
      10. Execute this CURL request to delete the quiz override,  replacing PREVIOUSGETID with the ID noticed in step 8 (as well as replacing the values as specified in step 3)

         curl --request POST \
          --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_delete_overrides' \
          --header 'Content-Type: multipart/form-data' \
          --form 'data[quizid]=QUIZID' \
          --form 'data[ids][0]=PREVIOUSGETID' \
          --insecure
        

      Show
      Since this is a refactor of the quiz override CRUD process, I have included instructions that cover these from a UI perspective. Validation checks are not part of the manual testing since this is covered by unit tests. Environment Setup Create a test course size XS (1 test student created) Under Settings -> Groups -> Group mode set to Separate groups Under participants -> Dropdown -> Groups click auto create groups. Enter Group/member count = 1 and submit Edit course and add a quiz module Add a single question - question does not matter Test CRUD - user override + calendar events In the quiz, select More -> Overrides Click Add a user override Select a user Check enable next to "Open the quiz" and enter a time. Check enable next to "Close the quiz" and enter a time that is later than the "open the quiz" time. Save , and confirm quiz opens and quiz closes times are shown as you entered them. Login as this user in a separate browser session Navigate to the quiz Confirm the quiz front page has the overwritten open and close times displayed. Open the calendar and confirm there is an override opens and override closes event As the admin user, edit the user override settings by pressing Revert to quiz defaults, and only enter a quiz open time change Confirm as the test user, the quiz front page only says there is a time limit change Check the calendar as the test user, confirm there are now only 1 event for the quiz open time As the admin user, delete the override. As the test user, confirm the quiz page now shows the default front page As the test user, confirm the calendar now shows no events for this quiz Test CRUD - group override + calendar events In the course, under More -> overrides select the groups dropdown. Press add a group override. Select Group A Check enable next to "Open the quiz" and enter a time. Check enable next to "Close the quiz" and enter a time that is later than the "open the quiz" time. Login as a user from Group A in a separate browser session. Navigate to the quiz and confirm you see the overwritten settings just created. Check the calendar, and confirm there are two events, one for open and one for closes As the admin user, edit the override by pressing "Revert to quiz defaults", then only enter a time open and save . As the user from the group, confirm that the quiz now displays only a new open time. As the user from the group, check the calendar and confirm there is now only 1 event. As the admin user, delete the override. As the user from the group, confirm that the quiz now displays the default settings. As the user from the group, confirm that their calendar has no entries. Test User and Group override applied to same user Add a user override for the user with only the time open changed Add a group override for the group the user is in with only the time close changed Login as the test user, and confirm that the quiz displays both the overwritten open and closing times. Delete both the user and group overrides Webservice tests Setup the webservices attached to a user with administrator permissions, and obtain a token Add an external/custom service from /admin/settings.php?section=externalservices Add the functions: mod_quiz_delete_overrides, mod_quiz_get_overrides, mod_quiz_save_overrides Make sure the service is enabled and you have permission to use it Create a new token from /admin/webservice/tokens.php In each of the following tests, replace the following: Replace the base URL with your instance URL Replace TOKEN with your webservice token Replace QUIZID with the quiz instance id (query the mdl_quiz table to find the id) Replace USERID with the user id Execute this CURL request to create a quiz override (replacing the values as specified in step 3) curl --request POST \ --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_save_overrides' \ --header 'Content-Type: multipart/form-data' \ --form 'data[quizid]=QUIZID' \ --form 'data[overrides][0][userid]=USERID' \ --form 'data[overrides][0][timeclose]=10' \ --insecure Confirm you receive a JSON response with an "ids" array that contains a single ID value. Note down the ID recieved Execute this CURL request to get all the quiz overrides (replacing the values as specified in step 3) curl --request POST \ --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_get_overrides' \ --header 'Content-Type: multipart/form-data' \ --form quizid=QUIZID \ --insecure Confirm you receive an JSON response with an "overrides" array, which contains one object with the ID matching what was returned in the previous CURL request. Execute this CURL request to update the quiz override, replacing PREVIOUSGETID with the ID noted previously. (as well as replacing the values as specified in step 3) curl --request POST \ --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_save_overrides' \ --header 'Content-Type: multipart/form-data' \ --form 'data[quizid]=QUIZID' \ --form 'data[overrides][0][timeclose]=200' \ --form 'data[overrides][0][id]=PREVIOUSGETID' \ --form 'data[overrides][0][userid]=USERID' \ --insecure Confirm you receive a JSON response with an "ids" array that contains the single ID value (equal to PREVIOUSGETID noted previously). Execute this CURL request to delete the quiz override,  replacing PREVIOUSGETID with the ID noticed in step 8 (as well as replacing the values as specified in step 3) curl --request POST \ --url 'https://mdl-80300-master.localhost/webservice/rest/server.php?wstoken=TOKEN&moodlewsrestformat=json&wsfunction=mod_quiz_delete_overrides' \ --header 'Content-Type: multipart/form-data' \ --form 'data[quizid]=QUIZID' \ --form 'data[ids][0]=PREVIOUSGETID' \ --insecure

      In our case we have an external application that manages a process of students requesting extensions for their assessments. Once approved the app call moodle to create an extension.

      That  works well with mod_assign and core mod_assign_save_user_extensions web service.

      Now the client tries to add quiz assessments to the app and  realised that there is no core WS for quiz overrides. 

      We can create a custom plugin, but I think it's better to have a new core web service.

            matthewhilton Matthew Hilton
            dmitriim Dmitrii Metelkin
            Alexander Van der Bellen Alexander Van der Bellen
            Andrew Lyons Andrew Lyons
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            25 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 17 minutes
                1d 17m

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