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

New WebService core_badges_get_user_badge

    XMLWordPrintable

Details

    • MOODLE_403_STABLE
    • MOODLE_403_STABLE
    • MDL-74570-master
    • 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, hash (the uniquehash instance value) and the URL of your moodle instance

          curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_user_badge_by_hash&wstoken=$wstoken&hash=$uniquehash' --compressed

      1. Confirm that:
        • You receive your badge
        • If you paste the badgeurl in a browser tab and remove the 'webservice/' from the URL, you see the badge image
      2. Now, repeat step #6 with an invalid hash
      3. Check you get a warning telling: "Cannot verify this awarded badge. This badge may have been revoked."
      4. Configure a new badge with endorsement, related badges, and alignment.
      5. Repeat step #6 (with valid hash)
      6. Check this information appears in the return.
      7. Remove the user 'moodle/badges:viewotherbadges' capability.
      8. Repeat step #6 (with valid hash)
      9. Check you get less information about the badge 
      10. Last, disable the global setting enablebadges, run the curl again
      11. 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, hash (the uniquehash instance value) and the URL of your moodle instance curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_user_badge_by_hash&wstoken=$wstoken&hash=$uniquehash' --compressed Confirm that: You receive your badge If you paste the badgeurl in a browser tab and remove the 'webservice/' from the URL, you see the badge image Now, repeat step #6 with an invalid hash Check you get a warning telling: "Cannot verify this awarded badge. This badge may have been revoked." Configure a new badge with endorsement, related badges, and alignment. Repeat step #6 (with valid hash) Check this information appears in the return. Remove the user 'moodle/badges:viewotherbadges' capability. Repeat step #6 (with valid hash) Check you get less information about the badge  Last, disable the global setting enablebadges, run the curl again Check that the Web Service return an exception

    Description

      So we can retrieve badges by their hash, this will solve issues in the app such as not being able to open a link to a badge that includes only the badge hash such as:

      https://mysite/badges/badge.php?hash=336c7c732a349be3f20d2008a3c53c84c7d0456b

      Attachments

        Issue Links

          Activity

            People

              rodrigo.mady@moodle.com Rodrigo Mady
              jleyva Juan Leyva
              Juan Leyva Juan Leyva
              Andrew Lyons Andrew Lyons
              Kim Jared Lucas Kim Jared Lucas
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 4 days, 6 hours, 24 minutes
                  1w 4d 6h 24m

                  Clockify

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