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

New Web Service core_badges_get_user_badges

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.3
    • Fix Version/s: 3.1
    • Component/s: Badges
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Enable badges and course badges in advanced features
      3. Create a site level badge, award this badge to one student user
      4. In a course, create a course badge, award this badge to the same student user (must be enrolled in the course)
      5. Create a Token for the student user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_user_badges&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e

      7. Confirm that:
        • You receive a list with your badges
        • If you paste the badgeurl appending ?token=your token, in a browser tab you see the badge image
      8. Now, append the following parameters in the curl request: page=0&perpage=1 and check that you only receive one badge
      9. Now, remove those last parameters and append courseid=x , where x is the course where is the course badge, check that you receive only that badge
      10. Remove the courseid parameter, and add a search parameter (search by the name of the badge)
      11. Now, create a token for a editing teacher enrolled in the course where is the badge
      12. Use the original CURL request appending: userid=X (the student user id)
      13. Check that you can see the user badges, but for the SITE badge you don't see the complete badge information
      14. Last, disable the global setting enablebadges and check that the Web Service return an exception
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Enable badges and course badges in advanced features Create a site level badge, award this badge to one student user In a course, create a course badge, award this badge to the same student user (must be enrolled in the course) Create a Token for the student user: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_user_badges&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e Confirm that: You receive a list with your badges If you paste the badgeurl appending ?token=your token, in a browser tab you see the badge image Now, append the following parameters in the curl request: page=0&perpage=1 and check that you only receive one badge Now, remove those last parameters and append courseid=x , where x is the course where is the course badge, check that you receive only that badge Remove the courseid parameter, and add a search parameter (search by the name of the badge) Now, create a token for a editing teacher enrolled in the course where is the badge Use the original CURL request appending: userid=X (the student user id) Check that you can see the user badges, but for the SITE badge you don't see the complete badge information Last, disable the global setting enablebadges and check that the Web Service return an exception
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-53462-master

      Description

      This Web Service will be used for returning the list of badges awarded to a given user

        Attachments

          Activity

            People

            Assignee:
            jleyva Juan Leyva
            Reporter:
            jleyva Juan Leyva
            Peer reviewer:
            cameron1729
            Integrator:
            Andrew Nicols
            Tester:
            Frédéric Massart
            Participants:
            Component watchers:
            Yuliya Bozhko, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              23/May/16