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

New Web Service mod_forum_add_discussion_post

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.9
    • 3.0
    • Forum, Web Services
    • MOODLE_29_STABLE
    • MOODLE_30_STABLE
    • MDL-50995-master
    • Hide
      1. Create a course with visible groups enabled (do not force groups)
      2. Enrol two users as student in the course
      3. Add the users to different groups
      4. Create 3 different forums in that course
      5. Forum 1: Without groups (Create a discussion with one of the students)
      6. Forum 2: With visible groups enabled (Create one discussion with each student)
      7. Forum 3: With separate groups enabled (Create one discussion with each student)
      8. Create two groups in the course
      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, postid (the first post in the discussion (created in step 5, we need the post id not the discussion id)) and the URL of your moodle instance

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

      12. Check that the post was created in the Moodle web interface
      13. Check in the activity logs that there are new entries with origin WS: Post created and Some content has been posted.
      14. Repeat the curl call but using the other user token
      15. verify that the message is also created
      16. Run the same curl request but using the postid of the forum using visible groups (use the token of the user that created the post)
      17. Verify the post is created
      18. Run the same command but replacing the user token with the other user token
      19. You should receive a nopostforum error since you are trying to post in a discussion that belongs to a different group
      20. Run the same command but replacing the postid with the id of a post created by the same user that the one the token belongs to
      21. Verify the post is created
      22. Repeat the 6 last steps with the separate groups forum
      23. Now as teacher or admin create a new discussion in the news forum
      24. Run the curl request with a student token replacing the postid with the postid for the new announcement created:
      25. You should get an exception: nopostforum
      Show
      Create a course with visible groups enabled (do not force groups) Enrol two users as student in the course Add the users to different groups Create 3 different forums in that course Forum 1: Without groups (Create a discussion with one of the students) Forum 2: With visible groups enabled (Create one discussion with each student) Forum 3: With separate groups enabled (Create one discussion with each student) Create two groups in the course 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, postid (the first post in the discussion (created in step 5, we need the post id not the discussion id)) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'postid=53&wsfunction=mod_forum_add_discussion_post&subject=Hi&message=hello&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Check that the post was created in the Moodle web interface Check in the activity logs that there are new entries with origin WS: Post created and Some content has been posted. Repeat the curl call but using the other user token verify that the message is also created Run the same curl request but using the postid of the forum using visible groups (use the token of the user that created the post) Verify the post is created Run the same command but replacing the user token with the other user token You should receive a nopostforum error since you are trying to post in a discussion that belongs to a different group Run the same command but replacing the postid with the id of a post created by the same user that the one the token belongs to Verify the post is created Repeat the 6 last steps with the separate groups forum Now as teacher or admin create a new discussion in the news forum Run the curl request with a student token replacing the postid with the postid for the new announcement created: You should get an exception: nopostforum

    Description

      This function will be used for creating new posts into an existing discussion.

      Parameters:
      postid (post to reply, the initial discussion or any post within the discussion), subject, message, options

      Response:
      Same response that get_forum_posts but only including the post created

      Initially, we won't support attachments or another advanced features.

      We will used a generic parameter "options" for parameters like groups or future functionality like the ones mentioned above. This will make very easy to maintain the function without further API changes

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              jleyva Juan Leyva
              Frédéric Massart Frédéric Massart
              Andrew Lyons Andrew Lyons
              Simey Lameze Simey Lameze
              Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                16/Nov/15