Course Tag API: Custom role
Introduction
This involves calling the API web service using the token provided by the administrator and configuring the service parameters accordingly for the courses to be tagged.
Adding tags to courses
By whichever means you wish, you just need to send a web service request to the moodle Course Tag API tool. The relevant web service protocol also needs to be enabled on your Moodle site. In this user guide, we have been using the REST protocol as part of the described configuration process.
To call the REST web service, you need to include the following parameters:
- wsfunction = tool_coursetagger_create_coursetags (it must be this exact value)
- wstoken = the user token
- coursetype (optional) = {id|shortname|idnumber} // Defaults to shortname for identifying courses.
- courselist = course1,course2,course3 // The courses as a comma separated list, identified as specified by the coursetype param.
- taglist = tag1,tag2,tag3 // The tags to be added to all the specified courses, as a comma separated list.
- removeprev (optional) (if set to ‘removeprev’, will remove all existing course tags from the specified courses first).
Example REST URL
An example REST URL for the Course Tag API tool:
- https://<siteurl>/webservice/rest/server.php?wsfunction=tool_coursetagger_create_coursetags&wstoken=xxx&coursetype=&courselist=Lesson,yoga 103,LETS Cite&taglist=art,culture,history,blah&removeprev=
Web service call tips
- The coursetype value can optionally be set to idnumber or id, it defaults to shortname if not set.
- Leave removeprev as blank if you want to retain old tags and have them in addition to the new list, or set to “removeprev=removeprev” to remove all previously assigned tags, existing at the time of the web service call, from the specified courses.