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

mod_forum_add_discussion doesn't allow posting to groupid -1 (All Participants)

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a course with groups enabled (do not force groups).
      2. Create a forum in that course with groups enabled (visible or separate, as you prefer).
      3. Create two groups in the course.
      4. Enrol two users in the course: a student and a teacher.
      5. Add the student to one of the groups.
      6. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      7. Create tokens for the two users:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      8. Next, you can do a CURL REST call simulating a WS client with one of the users. First, test that the teacher can post to "All participants".
        • You need to replace the wstoken (use the teacher token), forumid (the forum instance value) and the URL of your moodle instance.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=1&wsfunction=mod_forum_add_discussion&subject=Hi&message=hello&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&groupid=-1' | python -m "json.tool"

      9. Check that the discussion was created in the Moodle web interface. Check that you can see it both as the student and the teacher.
      10. Now perform the same request but using the student's token. Check that it returns an error "cannotcreatediscussion".
      Show
      Create a course with groups enabled (do not force groups). Create a forum in that course with groups enabled (visible or separate, as you prefer). Create two groups in the course. Enrol two users in the course: a student and a teacher. Add the student to one of the 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. First, test that the teacher can post to "All participants". You need to replace the wstoken (use the teacher token), forumid (the forum instance value) and the URL of your moodle instance. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'forumid=1&wsfunction=mod_forum_add_discussion&subject=Hi&message=hello&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&groupid=-1' | python -m "json.tool" Check that the discussion was created in the Moodle web interface. Check that you can see it both as the student and the teacher. Now perform the same request but using the student's token. Check that it returns an error " cannotcreatediscussion ".
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-57962-master

      Description

      If a teacher creates a discussion in Moodle web to "All participants", it is saved with groupid -1. This means that the discussion can be seen in "All participants" and also in each of the groups.

      If the WebService mod_forum_add_discussion is called with groupid=-1, it converts this value to 0. This means that the discussion can only be seen in "All participants", not in each group.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dpalou Dani Palou
                Reporter:
                dpalou Dani Palou
                Peer reviewer:
                cameron1729
                Integrator:
                Dan Poltawski
                Tester:
                Andrew Nicols
                Participants:
                Component watchers:
                Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze, Juan Leyva, Jake Dallimore, Jun Pataleta, Ryan Wyllie
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/Mar/17