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

New WebServices for retrieve and filter/search by tag

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.2
    • Fix Version/s: 3.7
    • Component/s: Tags
    • Testing Instructions:
      Hide
      Test first that we can retrieve tags from different activities
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a new course in the site, and enrol one user as teacher
      3. Add the following resources and activities:
        • Forum: Create a standard forum, create a new discussion and a post in that discussion including “tags”, for example: dogs, cats, birds, mice
        • Book: Create new book and at least with one chapter, including tags (try to use similar tags always).
        • Database: Create a new database entry including tags (please note that you can use an existing template for the database but you must edit it to include tags)
        • Glossary: Create a new glossary activity including entries
        • Wiki: Create a new wiki page, including tags as well.
      4. Create a Token in the mobile app service for the teacher you used when creating the activities
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Now, execute the following curl requests, replacing the WSToken with the teacher one and the site URL, in the curl response you must check that you receive in a field called “tags” all the tags items you used in the activity indicated. It is very important to annotate somewhere the tags used in each activity so you can match the WebService responses later.
      6. Forum: You will have to change the discussionid parameter to match the forum discussion id

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'discussionid=5&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_forum_get_forum_discussion_posts&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool"

      7. Book: you will have to change the courseid to match the course id and the 103 value indicating instead the book module course module id

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=3&options%5B0%5D%5Bname%5D=includestealthmodules&options%5B0%5D%5Bvalue%5D=1&options%5B1%5D%5Bname%5D=cmid&options%5B1%5D%5Bvalue%5D=103&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed

      8. Database: you will have to change the databaseid and use the database activity instance id.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'databaseid=1&returncontents=1&page=0&perpage=25&groupid=0&sort=0&order=DESC&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_data_get_entries&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed

      9. Glossary: you will have to change the id to use the glossary activity instance id.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'id=1&letter=ALL&from=0&limit=25&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_glossary_get_entries_by_letter&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed

      10. Wiki: you will have to change the wikiid with the wiki activity instance id

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wikiid=1&groupid=0&userid=0&options%5Bsortby%5D=title&options%5Bsortdirection%5D=ASC&options%5Bincludecontent%5D=0&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_wiki_get_subwiki_pages&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed

      Now, check that via WebServices we can retrieve the different tag information:
      1. Execute the following curl request replacing the word "literature" with one of the tags used in the previous activities:

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_tag_get_tagindex_per_area&wstoken=3af67232a7596ceb658df4db329e5ad6&tagindex[tag]=literature' | python -m "json.tool"

      2. Check that in the curl response, there are several "component" fields, each one indicating a module where the tag was used.
      3. Now, execute the following curl request:

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_tag_get_tag_cloud&wstoken=3af67232a7596ceb658df4db329e5ad6' | python -m "json.tool"

      4. And check that you see listed all the tags you used for the different activities and that the "count" field for each tag matches the number of times the tag was used.
      Show
      Test first that we can retrieve tags from different activities As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a new course in the site, and enrol one user as teacher Add the following resources and activities: Forum: Create a standard forum, create a new discussion and a post in that discussion including “tags”, for example: dogs, cats, birds, mice Book: Create new book and at least with one chapter, including tags (try to use similar tags always). Database: Create a new database entry including tags (please note that you can use an existing template for the database but you must edit it to include tags) Glossary: Create a new glossary activity including entries Wiki: Create a new wiki page, including tags as well. Create a Token in the mobile app service for the teacher you used when creating the activities Click on Site administration ► Plugins ► Web services ► Manage tokens Now, execute the following curl requests, replacing the WSToken with the teacher one and the site URL, in the curl response you must check that you receive in a field called “tags” all the tags items you used in the activity indicated. It is very important to annotate somewhere the tags used in each activity so you can match the WebService responses later. Forum: You will have to change the discussionid parameter to match the forum discussion id curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'discussionid=5&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_forum_get_forum_discussion_posts&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool" Book: you will have to change the courseid to match the course id and the 103 value indicating instead the book module course module id curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=3&options%5B0%5D%5Bname%5D=includestealthmodules&options%5B0%5D%5Bvalue%5D=1&options%5B1%5D%5Bname%5D=cmid&options%5B1%5D%5Bvalue%5D=103&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed Database: you will have to change the databaseid and use the database activity instance id. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'databaseid=1&returncontents=1&page=0&perpage=25&groupid=0&sort=0&order=DESC&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_data_get_entries&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed Glossary: you will have to change the id to use the glossary activity instance id. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'id=1&letter=ALL&from=0&limit=25&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_glossary_get_entries_by_letter&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed Wiki: you will have to change the wikiid with the wiki activity instance id curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wikiid=1&groupid=0&userid=0&options%5Bsortby%5D=title&options%5Bsortdirection%5D=ASC&options%5Bincludecontent%5D=0&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_wiki_get_subwiki_pages&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed Now, check that via WebServices we can retrieve the different tag information: Execute the following curl request replacing the word "literature" with one of the tags used in the previous activities: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_tag_get_tagindex_per_area&wstoken=3af67232a7596ceb658df4db329e5ad6&tagindex [tag] =literature' | python -m "json.tool" Check that in the curl response, there are several "component" fields, each one indicating a module where the tag was used. Now, execute the following curl request: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_tag_get_tag_cloud&wstoken=3af67232a7596ceb658df4db329e5ad6' | python -m "json.tool" And check that you see listed all the tags you used for the different activities and that the "count" field for each tag matches the number of times the tag was used.
    • Affected Branches:
      MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-64656-master

      Description

      We need WebServices for returning tags associated with an element.

      We may follow a similar approach to rating (use the existing WebServices that retrieve elements to return there the tags information)

        Attachments

        1. Screenshot_1.png
          Screenshot_1.png
          350 kB
        2. Screenshot_2.png
          Screenshot_2.png
          388 kB
        3. Screenshot_3.png
          Screenshot_3.png
          506 kB

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  20/May/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 51 minutes
                  3h 51m