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

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

XMLWordPrintable

    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MDL-57962-master
    • 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 ".

      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.

            dpalou Dani Palou
            dpalou Dani Palou
            cameron1729 cameron1729
            Dan Poltawski Dan Poltawski
            Andrew Lyons Andrew Lyons
            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.