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

Return rating information in database, forum and glossary Web Services

XMLWordPrintable

    • MOODLE_32_STABLE, MOODLE_34_STABLE
    • MOODLE_34_STABLE
    • MDL-57407-master
    • Hide
      1. Log in as admin
      2. Give the student role the capability to rate posts
        1. site administration > users > permissions > define roles
        2. under the manage roles tab edit the "student" role
        3. click allow for the mod/forum:rate capability
      3. Create a forum in a course with rating enabled (using Average of ratings) using an existing scale in the site (or create a new one)
      4. Enrol 4 users in the course (3 students: s.1..s3 and one teacher t1)
      5. As t1 create a new discussion
      6. As s1 post in the discussion
      7. As s2 and s3 rate the post created by s1
      8. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      9. Create a Token in the mobile app service for the student s1 and teacher t1:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      10. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken with the student s1, the discussionid with the main discussion id where the post is rated and the URL of your moodle instance

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

      11. Now check that in the response apart from the posts you see a field named ratinginfo. The field canviewall should be set to false
      12. The ratings[0] -> aggregatelabel reflects the current aggregation of the ratings so it must display the same value that is displayed in the web interface when the user see the posts ratings. The ratings[0] -> count value must be 2 (because the post received two ratings)
      13. And the field ratinginfo->scales should include information about the scale used for rating (including all the possible values)
      14. You can optionally test ratings in the glossary and database modules but in this case, you will need to use the teacher t1 wstoken (because by default students can't see the ratings). You will need to add ratings as the teacher as well. Please, note also that if you don't use a scale and you rate based on points you won't see anything in the ratinginfo->scale field.
      Show
      Log in as admin Give the student role the capability to rate posts site administration > users > permissions > define roles under the manage roles tab edit the "student" role click allow for the mod/forum:rate capability Create a forum in a course with rating enabled (using Average of ratings) using an existing scale in the site (or create a new one) Enrol 4 users in the course (3 students: s.1..s3 and one teacher t1) As t1 create a new discussion As s1 post in the discussion As s2 and s3 rate the post created by s1 As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the student s1 and teacher t1: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the wstoken with the student s1, the discussionid with the main discussion id where the post is rated and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'discussionid=53&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_forum_get_forum_discussion_posts&wstoken=12a2a65aeea2a177055e233f9e303218' --compressed | python -m "json.tool" Now check that in the response apart from the posts you see a field named ratinginfo. The field canviewall should be set to false The ratings [0] -> aggregatelabel reflects the current aggregation of the ratings so it must display the same value that is displayed in the web interface when the user see the posts ratings. The ratings [0] -> count value must be 2 (because the post received two ratings) And the field ratinginfo->scales should include information about the scale used for rating (including all the possible values) You can optionally test ratings in the glossary and database modules but in this case, you will need to use the teacher t1 wstoken (because by default students can't see the ratings). You will need to add ratings as the teacher as well. Please, note also that if you don't use a scale and you rate based on points you won't see anything in the ratinginfo->scale field.

      Right now we are not displaying the ratings in the Mobile app for:

      • forum posts
      • glossary entries
      • database records

      The main reason is because the Web Services returning those elements are not processing the ratings.

      We should create a external structure definition and an API function in the rating lib to be able to return the rating information, including:

      • The current rating of the element
      • The required information for using the Web Service for rating elements
      • Whether the user can rate or not

            jleyva Juan Leyva
            jleyva Juan Leyva
            Damyon Wiese Damyon Wiese
            David Monllaó David Monllaó
            Ryan Wyllie Ryan Wyllie
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.