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

New Web Service mod_forum_can_add_discussion

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1
    • 3.0
    • Forum, Web Services
    • MOODLE_30_STABLE
    • MOODLE_31_STABLE
    • MDL-52165-master
    • Hide
      1. Create a course with visible groups enabled (do not force groups)
      2. Create 3 different forums in that course
      3. Forum 1: Without groups
      4. Forum 2: With visible groups enabled
      5. Forum 3: With separate groups enabled
      6. Create two groups in the course
      7. Enrol two users as student in the course
      8. Add the users to different groups
      9. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      10. Create tokens for the two users:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      11. Next, you can do a CURL REST call simulating a WS client with one of the users.
        • You need to replace the wstoken, formumid (the forum instance value of the forum not using groups) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=18&wsfunction=mod_forum_can_add_discussion&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      12. Check that in the response you see status = True (that means that you can create discussions)
      13. Now, execute the following request (replace again your url tokens etc..). Replace the groupid value “4” with the user group id (retrieve id from the database or web interface)

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=18&wsfunction=mod_forum_can_add_discussion&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&groupid=4' | python -m "json.tool"

      14. Verify that in the response you see status = True
      15. Run the same request but with groupid=-1, verify that in the response you see status = true
      16. Run the same curl request but using the forumid of the forum using visible groups (and using a valid groupid again)
        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=19&wsfunction=mod_forum_can_add_discussion&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&groupid=4' | python -m "json.tool"
      17. Verify that in the response you see status = True
      18. Run the same command but replacing the user token and the groupid of the other user
      19. Verify that in the response you see status = True
      20. Now, try to use and invalid groupid. You should receive a status = false
      21. Repeat the last steps but for the forum with separate groups
      22. Now, enroll a teacher in the course and create a WS token for that user.
      23. Check if you can create a discussion in the default news forum in the course:

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=17&wsfunction=mod_forum_can_add_discussion&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' | python -m "json.tool"

      24. Check that the teacher has the capability "site:accessallgroups" enabled and run the query for a normal forumid using groups adding the groupid=-1 parameter to the query. Verify that you get a status=true
      25. Run the same request but using a student token, you should get an status = false
      Show
      Create a course with visible groups enabled (do not force groups) Create 3 different forums in that course Forum 1: Without groups Forum 2: With visible groups enabled Forum 3: With separate groups enabled Create two groups in the course Enrol two users as student in the course Add the users to different groups As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create tokens for the two users: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with one of the users. You need to replace the wstoken, formumid (the forum instance value of the forum not using groups) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=18&wsfunction=mod_forum_can_add_discussion&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Check that in the response you see status = True (that means that you can create discussions) Now, execute the following request (replace again your url tokens etc..). Replace the groupid value “4” with the user group id (retrieve id from the database or web interface) curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=18&wsfunction=mod_forum_can_add_discussion&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&groupid=4' | python -m "json.tool" Verify that in the response you see status = True Run the same request but with groupid=-1, verify that in the response you see status = true Run the same curl request but using the forumid of the forum using visible groups (and using a valid groupid again) curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=19&wsfunction=mod_forum_can_add_discussion&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&groupid=4' | python -m "json.tool" Verify that in the response you see status = True Run the same command but replacing the user token and the groupid of the other user Verify that in the response you see status = True Now, try to use and invalid groupid. You should receive a status = false Repeat the last steps but for the forum with separate groups Now, enroll a teacher in the course and create a WS token for that user. Check if you can create a discussion in the default news forum in the course: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=17&wsfunction=mod_forum_can_add_discussion&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' | python -m "json.tool" Check that the teacher has the capability "site:accessallgroups" enabled and run the query for a normal forumid using groups adding the groupid=-1 parameter to the query. Verify that you get a status=true Run the same request but using a student token, you should get an status = false

      Check if the user can add discussions in the given forum (and optionally group).

            jleyva Juan Leyva
            jleyva Juan Leyva
            Dani Palou Dani Palou
            Dan Poltawski Dan Poltawski
            Mark Nelson Mark Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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