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

New web service to delete forum posts

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      Test for regressions in the web site
      1. Create or use a course with one user enrolled as a teacher (t1) and a couple of users enrolled as students (s1 and s2)
      2. Create a forum in that course
      3. As an admin, ensure that the maxeditingtime for the posts global setting (Site security settings) is set to 30 minutes
      4. Now, log in as teacher t1 and create a new discussion
      5. Delete it and check that it is properly deleted
      6. Now, create a new discussion
      7. Reply to the original discussion creating a new post
      8. Delete that post and check that it is properly deleted
      9. Reply to the original discussion again
      10. Now, log-in as the student user s1
      11. Reply to the original discussion
      12. Check that the post is created
      13. Still as s1, edit the post adding some new text
      14. Check that the post is properly updated
      15. Still as s1, delete the post you just edited
      16. Now, log-in as the student user s2
      17. Reply to the original discussion
      18. Now, log-in as the teacher again
      19. Delete the student s2 post and confirm it is properly deleted
      20. Now, log-in as student user s1
      21. Reply to the original discussion again
      22. Now, log-in as student s2
      23. Reply to the post created by s1
      24. Log-in as s1 and try to delete his last post (the one you just replied as s2)
      25. You will see an error because you can't delete a post with replies
      26. Now, as the admin, lower the maxeditingtime to 1 minute (Site administration > Security > Site security settings)
      27. Log-in as student s2
      28. Confirm you are not able to delete any s2 post (you don't see the delete option)
      29. Now, as the admin, set the maxeditingtime again to 30 minutes
      30. Log-in as student s2
      31. Confirm you are able to delete the last post created by s2. Delete it
      32. Now, obtain the postid (just from the Permlink url for example, the number after the last "p") of the last post created by s1
      33. Copy and visit the following URL as s2,: http://YOUR_MOODLE_SITE/mod/forum/post.php?delete=POSTID_COPIED_BEFORE
      34. You will see an error, as a student you can't delete another user's posts
      35. Now, as the admin, create a new Forum type "a singlesimple discussion"
      36. Get the automatically created post id from the Reply link for example
      37. Copy and visit the following URL still as the admin: http://YOUR_MOODLE_SITE/mod/forum/post.php?delete=POSTID_COPIED_BEFORE
      38. You will get an error, you can't delete the first post of a single discussion
      Test for web services
      1. Create or use a NEW course with one user enrolled as the teacher (t1) and a couple of users enrolled as students (s1 and s2)
      2. As the admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      3. Create a Token in the mobile app service for t1, s1 and s2
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Create a NEW forum in that course
      5. As the admin, ensure that the maxeditingtime for the posts global setting (Site security settings) is set to 30 minutes
      6. Now, log in as the teacher t1 and create a new discussion. Copy the id of the first post in that discussion
      7. Open the console and execute this new curl request, replacing wstoken with the t1 token, the postid with the one you just copied, and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool"

      8. Confirm you receive a status = true and that the discussion is deleted in the web site
      9. Now, again as t1, create a new discussion
      10. Reply to the original discussion creating a new post, copy the new post id
      11. Open the console and execute this new curl request, replacing wstoken with the t1 token, the postid with the one you just copied, and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool"

      12. Confirm you receive a status = true and that the post is deleted in the web site
      13. Reply to the original discussion again
      14. Now, log-in as the student user s1
      15. Reply to the original discussion and copy the new post id
      16. Open the console and execute this new curl request, replacing wstoken with the s1 token, the postid with the one you just copied, and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool"

      17. Confirm you receive a status = true and that the post is deleted in the web site
      18. Now, log-in as the student user s2
      19. Reply to the original discussion and copy the post id
      20. Open the console and execute this new curl request, replacing wstoken with the t1 token, the postid with the one you just copied, and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool"

      21. Confirm you receive a status = true and that the s2 post is deleted in the web site
      22. Now, log-in as student user s1
      23. Reply to the original discussion again
      24. Now, log-in as student s2
      25. Reply to the post created by s1, copy the original s1 post id
      26. Open the console and execute this new curl request, replacing wstoken with the s1 token, the postid with the one you just copied, and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool"

      27. You will see an error because you can't delete a post with replies
      28. Now, as the admin, lower the maxeditingtime to 1 minute
      29. Open the console and execute this new curl request, replacing wstoken with the s2 token, the postid with one of the post created by s2, and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool"

      30. Confirm receive and error, "You can't delete this post". You can't because the editing time has been reduced and one minute has expired.
      31. Now, as the admin, set the maxeditingtime again to 30 minutes
      32. Open the console an execute the last curl request
      33. Confirm you receive a status = true and that the post is deleted in the web site
      Show
      Test for regressions in the web site Create or use a course with one user enrolled as a teacher (t1) and a couple of users enrolled as students (s1 and s2) Create a forum in that course As an admin, ensure that the maxeditingtime for the posts global setting (Site security settings) is set to 30 minutes Now, log in as teacher t1 and create a new discussion Delete it and check that it is properly deleted Now, create a new discussion Reply to the original discussion creating a new post Delete that post and check that it is properly deleted Reply to the original discussion again Now, log-in as the student user s1 Reply to the original discussion Check that the post is created Still as s1, edit the post adding some new text Check that the post is properly updated Still as s1, delete the post you just edited Now, log-in as the student user s2 Reply to the original discussion Now, log-in as the teacher again Delete the student s2 post and confirm it is properly deleted Now, log-in as student user s1 Reply to the original discussion again Now, log-in as student s2 Reply to the post created by s1 Log-in as s1 and try to delete his last post (the one you just replied as s2) You will see an error because you can't delete a post with replies Now, as the admin, lower the maxeditingtime to 1 minute (Site administration > Security > Site security settings) Log-in as student s2 Confirm you are not able to delete any s2 post (you don't see the delete option) Now, as the admin, set the maxeditingtime again to 30 minutes Log-in as student s2 Confirm you are able to delete the last post created by s2. Delete it Now, obtain the postid (just from the Permlink url for example, the number after the last "p") of the last post created by s1 Copy and visit the following URL as s2,: http://YOUR_MOODLE_SITE/mod/forum/post.php?delete=POSTID_COPIED_BEFORE You will see an error, as a student you can't delete another user's posts Now, as the admin, create a new Forum type "a singlesimple discussion" Get the automatically created post id from the Reply link for example Copy and visit the following URL still as the admin: http://YOUR_MOODLE_SITE/mod/forum/post.php?delete=POSTID_COPIED_BEFORE You will get an error, you can't delete the first post of a single discussion Test for web services Create or use a NEW course with one user enrolled as the teacher (t1) and a couple of users enrolled as students (s1 and s2) As the admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for t1, s1 and s2 Click on Site administration ► Plugins ► Web services ► Manage tokens Create a NEW forum in that course As the admin, ensure that the maxeditingtime for the posts global setting (Site security settings) is set to 30 minutes Now, log in as the teacher t1 and create a new discussion. Copy the id of the first post in that discussion Open the console and execute this new curl request, replacing wstoken with the t1 token, the postid with the one you just copied, and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool" Confirm you receive a status = true and that the discussion is deleted in the web site Now, again as t1, create a new discussion Reply to the original discussion creating a new post, copy the new post id Open the console and execute this new curl request, replacing wstoken with the t1 token, the postid with the one you just copied, and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool" Confirm you receive a status = true and that the post is deleted in the web site Reply to the original discussion again Now, log-in as the student user s1 Reply to the original discussion and copy the new post id Open the console and execute this new curl request, replacing wstoken with the s1 token, the postid with the one you just copied, and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool" Confirm you receive a status = true and that the post is deleted in the web site Now, log-in as the student user s2 Reply to the original discussion and copy the post id Open the console and execute this new curl request, replacing wstoken with the t1 token, the postid with the one you just copied, and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool" Confirm you receive a status = true and that the s2 post is deleted in the web site Now, log-in as student user s1 Reply to the original discussion again Now, log-in as student s2 Reply to the post created by s1, copy the original s1 post id Open the console and execute this new curl request, replacing wstoken with the s1 token, the postid with the one you just copied, and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool" You will see an error because you can't delete a post with replies Now, as the admin, lower the maxeditingtime to 1 minute Open the console and execute this new curl request, replacing wstoken with the s2 token, the postid with one of the post created by s2, and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_delete_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=40' | python -m "json.tool" Confirm receive and error, "You can't delete this post". You can't because the editing time has been reduced and one minute has expired. Now, as the admin, set the maxeditingtime again to 30 minutes Open the console an execute the last curl request Confirm you receive a status = true and that the post is deleted in the web site
    • Affected Branches:
      MOODLE_36_STABLE, MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-65017-master

      Description

      New Web Service for deleting posts (and discussions if the post has not parent)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/19

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 days, 3 hours, 1 minute
                  4d 3h 1m