Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.6, 3.8
-
MOODLE_36_STABLE, MOODLE_38_STABLE
-
MOODLE_38_STABLE
-
MDL-64254-master -
Hide
Test for regressions in the web site
- Create or use a course with one user enrolled as teacher (t1) and a couple of users enrolled as students (s1 and s2)
- Create a forum in that course. Configure it so discussion subscriptions are optional.
- As admin, ensure that the maxeditingtime for posts global setting (Site security settings) is set to 30 minutes
- Now, log in as teacher t1 and create a new discussion in that forum (using the advance mode) marking as selected the "Pinned" option and also the "Discussion subscription one"
- Confirm that:
- After saving the message is "pinned" in the main discussions view and it says that you are subscribed.
- Access to the forum discussion and edit the post, this time uncheck the "Pinned" and "Discussion subscription option"
- Confirm that:
- After saving the message, in the main discussion view, you don't see any more the post "Pinned" and the message that says that you are subscribed
- Now, as s1, access to the forum
- Reply to the discussion created by t1 using the "Advance mode" changing the Subject and writting some text in the Message field
- Confirm that:
- The post with the reply is created properly
- Now, still as s1 click "Edit" at the bottom of the post you just created
- Edit the post changing the "Subject" and the "Message" and uncheck the "Discussion subscription option"
- Save the changes and confirm that:
- The post was updated correctly and it displays the new subject and message
- Edit again the message this time adding attachments and some images in the message text
- Save the changes and confirm that:
- The post was updated correctly and you can see the image in the text and the attachments
- As admin, now change the "maxeditingtime" global setting (in Site security settings) and set it to 1 minute
- Wait for a minute and log-in as s1 again
- Check that within the forum discussion, you don't see the "edit" option anymore in the s1 created posts
Test for web services
- As 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 admin, ensure that the maxeditingtime for posts global setting (Site security settings) is set to 30 minutes
- Now, log in as teacher t1 and create a new discussion in the forum used in the previout set of tests.
- Open the console an execute this new curl request, replacing wstoken with the t1 token, the postid with the first post id of the discussion created a couple of steps ago. (You can get the post id just from the "Edit" link)
curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_get_discussion_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=53' | python -m "json.tool"
- Confirm you receive the complete post information. Including a "capabilities->edit" field set to true
- Now, log-in as s1 in the web site and reply to the discussion. Do not include any attachment or images in the message body
- Open the console an execute this new curl request, replacing wstoken with the s1 token, the postid with the one you just created and the site url with yours.
curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_prepare_draft_area_for_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=54&area=attachment' | python -m "json.tool"
- Confirm that as part of the response you receive a "draftitemid". Please, copy this value somewhere (you'll need it later)
- Now, copy in your computer home or document folder an existing pdf document (any), renaming it to "document.pdf"
- Open the console an execute this new curl request, replacing token with the s1 token, the itemid parameter with the draftitemid value your copied before and the path of your "document.pdf" document with your local path
curl -i -F name=document.pdf -F filedata=@/Users/juanleyvadelgado/Documents/document.pdf "http://localhost/m/stable_master/webservice/upload.php?token=3af67232a7596ceb658df4db329e5ad6&itemid=421435137"
- Confirm you receive as response a JSON structure with some data including the file name
- Open the console an execute this new curl request, replacing wstoken with the s1 token, the postid with the one you used in the previous request, and the value of the "options[4][value]" parameter with the "draftitemid" you used in the previous request the site url with yours.
curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_update_discussion_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=53&subject=SubjectTestUpdated&message=MessageTestUpdated&messageformat=1&options[0][name]=inlineattachmentsid&options[0][value]=-1&options[1][name]=attachmentsid&options[1][value]=-1' | python -m "json.tool"
- Confirm that you receive a response with status set to true
- Log-in into the web site as s1, open the updated post and check that now in the subject you see "SubjectTestUpdated", in the message body you see "MessageTestUpdated" and you see the document.pdf as an attachment
ShowTest for regressions in the web site Create or use a course with one user enrolled as teacher (t1) and a couple of users enrolled as students (s1 and s2) Create a forum in that course. Configure it so discussion subscriptions are optional. As admin, ensure that the maxeditingtime for posts global setting (Site security settings) is set to 30 minutes Now, log in as teacher t1 and create a new discussion in that forum (using the advance mode) marking as selected the "Pinned" option and also the "Discussion subscription one" Confirm that: After saving the message is "pinned" in the main discussions view and it says that you are subscribed. Access to the forum discussion and edit the post, this time uncheck the "Pinned" and "Discussion subscription option" Confirm that: After saving the message, in the main discussion view, you don't see any more the post "Pinned" and the message that says that you are subscribed Now, as s1, access to the forum Reply to the discussion created by t1 using the "Advance mode" changing the Subject and writting some text in the Message field Confirm that: The post with the reply is created properly Now, still as s1 click "Edit" at the bottom of the post you just created Edit the post changing the "Subject" and the "Message" and uncheck the "Discussion subscription option" Save the changes and confirm that: The post was updated correctly and it displays the new subject and message Edit again the message this time adding attachments and some images in the message text Save the changes and confirm that: The post was updated correctly and you can see the image in the text and the attachments As admin, now change the "maxeditingtime" global setting (in Site security settings) and set it to 1 minute Wait for a minute and log-in as s1 again Check that within the forum discussion, you don't see the "edit" option anymore in the s1 created posts Test for web services As 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 admin, ensure that the maxeditingtime for posts global setting (Site security settings) is set to 30 minutes Now, log in as teacher t1 and create a new discussion in the forum used in the previout set of tests. Open the console an execute this new curl request, replacing wstoken with the t1 token, the postid with the first post id of the discussion created a couple of steps ago. (You can get the post id just from the "Edit" link) curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_get_discussion_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=53' | python -m "json.tool" Confirm you receive the complete post information. Including a "capabilities->edit" field set to true Now, log-in as s1 in the web site and reply to the discussion. Do not include any attachment or images in the message body Open the console an execute this new curl request, replacing wstoken with the s1 token, the postid with the one you just created and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_prepare_draft_area_for_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=54&area=attachment' | python -m "json.tool" Confirm that as part of the response you receive a "draftitemid". Please, copy this value somewhere (you'll need it later) Now, copy in your computer home or document folder an existing pdf document (any), renaming it to "document.pdf" Open the console an execute this new curl request, replacing token with the s1 token, the itemid parameter with the draftitemid value your copied before and the path of your "document.pdf" document with your local path curl -i -F name=document.pdf -F filedata=@/Users/juanleyvadelgado/Documents/document.pdf "http://localhost/m/stable_master/webservice/upload.php?token=3af67232a7596ceb658df4db329e5ad6&itemid=421435137" Confirm you receive as response a JSON structure with some data including the file name Open the console an execute this new curl request, replacing wstoken with the s1 token, the postid with the one you used in the previous request, and the value of the "options [4] [value] " parameter with the "draftitemid" you used in the previous request the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_forum_update_discussion_post&wstoken=3af67232a7596ceb658df4db329e5ad6&postid=53&subject=SubjectTestUpdated&message=MessageTestUpdated&messageformat=1&options [0] [name] =inlineattachmentsid&options [0] [value] =-1&options [1] [name] =attachmentsid&options [1] [value] =-1' | python -m "json.tool" Confirm that you receive a response with status set to true Log-in into the web site as s1, open the updated post and check that now in the subject you see "SubjectTestUpdated", in the message body you see "MessageTestUpdated" and you see the document.pdf as an attachment
Description
Create a new set of functions for being able to update discussion posts.
It will require some additional helper WS function to set/prepare the draft attachment and editors.
Web services to be created are:
mod_forum_get_discussion_post - To obtain particular information about a post and specifically if the user is able to update ir or not
mod_forum_prepare_draft_area_for_post - To prepare the draft areas for a post that it is going to be updated including the files to be kept in the draft area when editing a post
mod_forum_update_discussion_post - To update a post
Attachments
- Screenshot 1.png
- 566 kB
- Gladys Basiana
- Screenshot 2.png
- 288 kB
- Gladys Basiana
Issue Links
- blocks
-
MOBILE-3070 Clicking on a forum notification can take too long
-
- Closed
-
-
MOBILE-2267 Allow user to edit forum posts
-
- Closed
-
-
MOBILE-3157 Delete forum posts
-
- Closed
-