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

New Web Service mod_choice_delete_choice_responses

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9.2
    • Fix Version/s: 3.0
    • Component/s: Choice
    • Labels:
    • Testing Instructions:
      Hide

      Note: Version number is bumped because a new web service is added into the Mobile app service and the module.

      1. Create a course with a choice activity with multiple possible answers
      2. Set the Allow update option to true
      3. Enrol two users (student and editing teacher) in the course
      4. As the student, complete the choice selection two options
      5. Enable the Mobile service in Site administration ► Plugins ► Web services ► Mobile
      6. Create a Token for the student and teacher:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. Next, you can do a CURL REST call simulating a WS client as Student
      8. As student delete the responses you submitted (replace the wstoken with your token and the choiceid with the choice instance id).

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_choice_delete_choice_responses&choiceid=2&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed | python -m "json.tool"

      9. Check in the Moodle web interface that your responses were deleted.
      10. Now, submit again your response (two options again).
      11. Call again the WS but now only deleting one response. To do so, replace the responses in the following call with the answerid you can find in the choice_answers table.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_choice_delete_choice_responses&choiceid=2&responses%5B0%5D=3&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed | python -m "json.tool"

      12. Check in the Moodle web interface that you still see one response.
      13. Call again the WS using invalid response ids, you will get warnings as response
      14. Now, as admin, change the choice configuration and set Allow Update to off/no
      15. Call again the WS, you will get a required capability exception
      16. Now, as admin, change the choice configuration and set Allow Update to on/yes and add a passed time close date
      17. Call again the WS, you will get a new exception because the choice is closed
      18. Now, as admin, change the choice configuration and set Allow Update to off/no
      19. Now, delete the missing response but using the Teacher token, you must be able to delete the response even with the choice closed.
      Show
      Note: Version number is bumped because a new web service is added into the Mobile app service and the module. Create a course with a choice activity with multiple possible answers Set the Allow update option to true Enrol two users (student and editing teacher) in the course As the student, complete the choice selection two options Enable the Mobile service in Site administration ► Plugins ► Web services ► Mobile Create a Token for the student and teacher: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client as Student As student delete the responses you submitted (replace the wstoken with your token and the choiceid with the choice instance id). curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_choice_delete_choice_responses&choiceid=2&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed | python -m "json.tool" Check in the Moodle web interface that your responses were deleted. Now, submit again your response (two options again). Call again the WS but now only deleting one response. To do so, replace the responses in the following call with the answerid you can find in the choice_answers table. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_choice_delete_choice_responses&choiceid=2&responses%5B0%5D=3&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed | python -m "json.tool" Check in the Moodle web interface that you still see one response. Call again the WS using invalid response ids, you will get warnings as response Now, as admin, change the choice configuration and set Allow Update to off/no Call again the WS, you will get a required capability exception Now, as admin, change the choice configuration and set Allow Update to on/yes and add a passed time close date Call again the WS, you will get a new exception because the choice is closed Now, as admin, change the choice configuration and set Allow Update to off/no Now, delete the missing response but using the Teacher token, you must be able to delete the response even with the choice closed.
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-51566-master

      Description

      Web Service for deleting the responses of a give choice

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Adrian Greeve
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Dan Marsden, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                16/Nov/15