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

New Web Service core_rating_add_rating

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.2
    • Component/s: Ratings, Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a glossary with the rating options enabled (choose for example, aggregate rates and a numeric scale with a maximum of 100)
      2. Now as admin create a couple of entries
      3. Add the mod/glossary:rate capability to the student role
      4. Enrol a couple of students in the course
      5. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      6. Create a Token for the student users:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, instanceid with the glossary cmid, itemid is a entry id and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'contextlevel=module&instanceid=293&component=mod_glossary&ratingarea=entry&itemid=16&scaleid=100&rateduserid=2&aggregation=5&rating=50&wsfunction=core_rating_add_rating&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      8. Go to the web interface (as admin) and check that the rating was updated successfully, you can see in the glossary entry the correct rating (50)
      9. Now, using the other student token run the same curl command but replacing the rating to 100
      10. As an admin check again the entry (reload) and verify that now the aggregate rating is 75 (100+50/2) and you can see the list of ratings for the element
      11. You can create a token for the admin and try to rate your own entry, you will get an error (you cannot rate your own items)
      Show
      Create a glossary with the rating options enabled (choose for example, aggregate rates and a numeric scale with a maximum of 100) Now as admin create a couple of entries Add the mod/glossary:rate capability to the student role Enrol a couple of students in the course As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student users: 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, instanceid with the glossary cmid, itemid is a entry id and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'contextlevel=module&instanceid=293&component=mod_glossary&ratingarea=entry&itemid=16&scaleid=100&rateduserid=2&aggregation=5&rating=50&wsfunction=core_rating_add_rating&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Go to the web interface (as admin) and check that the rating was updated successfully, you can see in the glossary entry the correct rating (50) Now, using the other student token run the same curl command but replacing the rating to 100 As an admin check again the entry (reload) and verify that now the aggregate rating is 75 (100+50/2) and you can see the list of ratings for the element You can create a token for the admin and try to rate your own entry, you will get an error (you cannot rate your own items)
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-55786-master

      Description

      New Web Service for adding rates to a Moodle item (like a forum post)

      The code should be very close to the current AJAX interface for rating (we should move it to a locallib or something like that)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  5/Dec/16