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

Delete responses webservice is deleting all responses for teachers

XMLWordPrintable

    • MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • MOODLE_33_STABLE, MOODLE_34_STABLE
    • MDL-60882-master
    • 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"

      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.

            jleyva Juan Leyva
            pferre22 Pau Ferrer
            Jun Pataleta Jun Pataleta
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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