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

Delete responses webservice is deleting all responses for teachers

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a course and inside the course a choice activity that allows changing response to the user ("Allow choice to be updated" option).
      3. Add one student and one teacher to the course
      4. Acces to the choice as the student and answer the choice. Do the same with the teacher
      5. Create a Token in the mobile app service for the teacher user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Now, via the Moodle Mobile app access to the choice as the teacher.
      7. Delete your response via the "Remove my choice" button.
      8. Check only your responses have been deleted. The student response should be still there.
      9. Next, you can do a CURL REST call simulating a WS client with the user.

        curl '[YOUR_MOODLE_URL]/webservice/rest/server.php?moodlewsrestformat=json' --data 'choiceid=[CHOICE_ID]&responses[0]=[RESPONSE_ID]&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_choice_delete_choice_responses&wstoken=[WS_TOKEN]' | python -m json.tool

        • You need to replace the following parameters:
          1. "wstoken" with the teacher's WS token,
          2. "choiceid" with the choice instance id (from "choice" table)
          3. "responses[0]" with the ID of the student response (you can get if from the "choice_answers" table in the DB)
          4. the URL of your Moodle instance
      10. Now check in the app or on the site that the student response was deleted.
      11. If you execute the previous curl request but passing a "responses[0]" value that does not exist in the DB or that belongs to a different choice, you will get an exception "No permission to delete this response"
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a course and inside the course a choice activity that allows changing response to the user ("Allow choice to be updated" option). Add one student and one teacher to the course Acces to the choice as the student and answer the choice. Do the same with the teacher Create a Token in the mobile app service for the teacher user: Click on Site administration ► Plugins ► Web services ► Manage tokens Now, via the Moodle Mobile app access to the choice as the teacher. Delete your response via the "Remove my choice" button. Check only your responses have been deleted. The student response should be still there. Next, you can do a CURL REST call simulating a WS client with the user. curl ' [YOUR_MOODLE_URL] /webservice/rest/server.php?moodlewsrestformat=json' --data 'choiceid= [CHOICE_ID] &responses [0] = [RESPONSE_ID] &moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_choice_delete_choice_responses&wstoken= [WS_TOKEN] ' | python -m json.tool You need to replace the following parameters: " wstoken " with the teacher's WS token, " choiceid " with the choice instance id (from " choice " table) " responses [0] " with the ID of the student response (you can get if from the " choice_answers " table in the DB) the URL of your Moodle instance Now check in the app or on the site that the student response was deleted. If you execute the previous curl request but passing a " responses [0] " value that does not exist in the DB or that belongs to a different choice, you will get an exception "No permission to delete this response"
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-60882-master

      Description

      When using mod_choice_delete_responses WS for a teacher, if it doesn't send any specific response to delete it should delete all the user responses but it delete every user responses.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/May/18

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 30 minutes
                1h 30m