Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.4.1, 3.6
-
MOODLE_34_STABLE, MOODLE_36_STABLE
-
MOODLE_36_STABLE
-
MDL-60425-master -
Hide
- Login as admin
- Enable blogs in Site administration > Advanced features
- Go to Site administration > Appearance > Blog and enable “Enable blog associations” and set Blog visibility to “The world can read entries set to be world accessible”
- Go to Site administration > Security > Site policies and ensure that “Force users to log in” is not checked
- Go to the Admin profile (click on his name at the top of the right) > Profile > Blog entries and then Add a new entry
- Add a new Blog entry including images in the Blog entry body and attachments. Ensure that “Publish to” is set to Anyone in the world
- In a different browser (or incognito tab) where you are not logged to the site open the page YOUR_SITE_URL/blog/index.php and check that you see the entry you created (including the images and attachments)
- Open the console and execute the following curl request replacing localhost/m/stable_master with your site URL
curl 'http://localhost/m/stable_master/lib/ajax/service.php' --data-binary '[{"index":0,"methodname":"core_blog_get_entries","args":{}}]' | python -m "json.tool"
- Confirm that:
- You receive a JSON structure and that in total entries you see 1,
- In data->entries->attachmentfiles you see the files you attached,
- In data->entries->summaryfiles you see the images you included in the post body
- The subject and summary match the text you entered when you created the post
- Now, as admin create a new entry (follow step 5) but this time setting “Publish to” to “Anyone on this site”
- In a different browser (or incognito tab) where you are not logged to the site open the page YOUR_SITE_URL/blog/index.php and check that you don’t see the new entry created (because you are not logged to the site)
- In the console, execute again the CURL request and check that you steel see only 1 entry (the first entry you created, not the last one)
- Login to the site using a normal user account (not admin) go to YOUR_SITE_URL/blog/index.ph and check that you see the two posts you created so far
- As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
- Create a Token in the mobile app service for the user used two steps above (the one not admin you check that you see all the posts in blog/index.php)
- Click on Site administration ► Plugins ► Web services ► Manage tokens
- Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours.
curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_blog_get_entries&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' | python -m "json.tool"
- Confirm that:
- You receive a JSON structure with the two entries
- Now, append the following &page=0&perpage=1 just after the wstoken, execute the curl request in the console
- Confirm that:
- You see the latest entry you created
- Replace page=0 with page=1, execute the curl request in the console
- Confirm that:
- You see the first entry you created
- Login as admin. Go to Site administration > Appearance > Blog and enable “Enable blog associations” and set Blog visibility to “all site users can see all blog entries”
- Open the console and execute the following request
curl 'http://localhost/m/stable_master/lib/ajax/service.php' --data-binary '[{"index":0,"methodname":"core_blog_get_entries","args":{}}]' | python -m "json.tool"
- Confirm that:
- You get an exception and the field exception.>errorcode is set to requireloginerror
- In a different browser (or incognito tab) where you are not logged to the site open the page YOUR_SITE_URL/blog/index.php and check that you are redirected to the log in page
- Open the console an execute this curl request, replacing wstoken with the token for the user you created and the site url with yours.
curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_blog_get_entries&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' | python -m "json.tool"
- Confirm that you only see your latest entry (the first entry is not displayed anymore)
- Now, login as the user you created the token for creating a new entry (follow step 5) setting “Publish to” to “Anyone on this site”
- Execute the previous curl request and check that you receive two entries, including the one you just created.
- Now, append the following to the curl request: &filters[0][name]=userid&filters[0][value]=ADMIN_USER_ID (replacing ADMIN_USER_ID) with the id of the admin user
- In the console execute the curl request and check that you receive just one entry (the entry created by the admin user)
- Now, from the curl output annotate some where the entries->id
- Replace the user with other id belonging to a user who didn’t create entries
- Execute the curl request and check that you don’t receive anything
- In the curl request replace the &filters[0][name] “userid” value with “entryid” and the filters[0][value] with the entries->id you annotated
# Execute the curl console and check that you retrieve successfully one entry whose entries->id matches the one annotated - Login as admin, Go to a course in the site -> Turn editing on and add the block “BLOG MENU”
- Once the block is created click on the “Add an entry about this course” link and create a new blog entry
- In the curl request replace the &filters[0][name] “entryid” value with “courseid” and the filters[0][value] with the courseid where you created the blog
- Execute the curl request and check that you receive just the entry you created for that course
- Replace the courseid with other id belonging to a course where the block is not enabled
- Execute the curl request and check that you don’t receive anything
ShowLogin as admin Enable blogs in Site administration > Advanced features Go to Site administration > Appearance > Blog and enable “Enable blog associations” and set Blog visibility to “The world can read entries set to be world accessible” Go to Site administration > Security > Site policies and ensure that “Force users to log in” is not checked Go to the Admin profile (click on his name at the top of the right) > Profile > Blog entries and then Add a new entry Add a new Blog entry including images in the Blog entry body and attachments. Ensure that “Publish to” is set to Anyone in the world In a different browser (or incognito tab) where you are not logged to the site open the page YOUR_SITE_URL/blog/index.php and check that you see the entry you created (including the images and attachments) Open the console and execute the following curl request replacing localhost/m/stable_master with your site URL curl 'http://localhost/m/stable_master/lib/ajax/service.php' --data-binary ' [{"index":0,"methodname":"core_blog_get_entries","args":{}}] ' | python -m "json.tool" Confirm that: You receive a JSON structure and that in total entries you see 1, In data->entries->attachmentfiles you see the files you attached, In data->entries->summaryfiles you see the images you included in the post body The subject and summary match the text you entered when you created the post Now, as admin create a new entry (follow step 5) but this time setting “Publish to” to “Anyone on this site” In a different browser (or incognito tab) where you are not logged to the site open the page YOUR_SITE_URL/blog/index.php and check that you don’t see the new entry created (because you are not logged to the site) In the console, execute again the CURL request and check that you steel see only 1 entry (the first entry you created, not the last one) Login to the site using a normal user account (not admin) go to YOUR_SITE_URL/blog/index.ph and check that you see the two posts you created so far As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the user used two steps above (the one not admin you check that you see all the posts in blog/index.php) Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_blog_get_entries&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' | python -m "json.tool" Confirm that: You receive a JSON structure with the two entries Now, append the following &page=0&perpage=1 just after the wstoken, execute the curl request in the console Confirm that: You see the latest entry you created Replace page=0 with page=1, execute the curl request in the console Confirm that: You see the first entry you created Login as admin. Go to Site administration > Appearance > Blog and enable “Enable blog associations” and set Blog visibility to “all site users can see all blog entries” Open the console and execute the following request curl 'http://localhost/m/stable_master/lib/ajax/service.php' --data-binary ' [{"index":0,"methodname":"core_blog_get_entries","args":{}}] ' | python -m "json.tool" Confirm that: You get an exception and the field exception.>errorcode is set to requireloginerror In a different browser (or incognito tab) where you are not logged to the site open the page YOUR_SITE_URL/blog/index.php and check that you are redirected to the log in page Open the console an execute this curl request, replacing wstoken with the token for the user you created and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_blog_get_entries&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' | python -m "json.tool" Confirm that you only see your latest entry (the first entry is not displayed anymore) Now, login as the user you created the token for creating a new entry (follow step 5) setting “Publish to” to “Anyone on this site” Execute the previous curl request and check that you receive two entries, including the one you just created. Now, append the following to the curl request: &filters [0] [name] =userid&filters [0] [value] =ADMIN_USER_ID (replacing ADMIN_USER_ID) with the id of the admin user In the console execute the curl request and check that you receive just one entry (the entry created by the admin user) Now, from the curl output annotate some where the entries->id Replace the user with other id belonging to a user who didn’t create entries Execute the curl request and check that you don’t receive anything In the curl request replace the &filters [0] [name] “userid” value with “entryid” and the filters [0] [value] with the entries->id you annotated # Execute the curl console and check that you retrieve successfully one entry whose entries->id matches the one annotated Login as admin, Go to a course in the site -> Turn editing on and add the block “BLOG MENU” Once the block is created click on the “Add an entry about this course” link and create a new blog entry In the curl request replace the &filters [0] [name] “entryid” value with “courseid” and the filters [0] [value] with the courseid where you created the blog Execute the curl request and check that you receive just the entry you created for that course Replace the courseid with other id belonging to a course where the block is not enabled Execute the curl request and check that you don’t receive anything
Description
New Web Service for retrieving blog entries
Attachments
Issue Links
- blocks
-
MOBILE-2386 Support blog entries to view
-
- Closed
-
-
MDL-61245 New Web Service core_blog_view_entries
-
- Closed
-
- will help resolve
-
MDL-41804 core_blog_get_xxx
-
- Closed
-