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

New WebService core_badges_get_user_badge

    XMLWordPrintable

Details

    • Improvement
    • Status: Waiting for peer review
    • Minor
    • Resolution: Unresolved
    • DEV backlog
    • None
    • Badges
    • MDL-74570-400
    • 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&wstoken=$wstoken&hash=$uniquehash' --compressed

      1. Confirm that:
        • You receive your badge
        • If you paste the badgeurl appending ?token=your token, in a browser tab you see the badge image or remove the 'webservice/' from the URL
      2. Now, try to access with an invalid hash, you should get a warning telling: "Cannot verify this awarded badge. This badge may have been revoked."
      3. Now, configure a new badge with endorsement, related badges, and alignment. This information should appear in the return.
      4. Remove the user 'moodle/badges:viewotherbadges' capability, and you should get less information about the badge 
      5. 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, 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&wstoken=$wstoken&hash=$uniquehash' --compressed Confirm that: You receive your badge If you paste the badgeurl appending ?token=your token, in a browser tab you see the badge image or remove the 'webservice/' from the URL Now, try to access with an invalid hash, you should get a warning telling: "Cannot verify this awarded badge. This badge may have been revoked." Now, configure a new badge with endorsement, related badges, and alignment. This information should appear in the return. Remove the user 'moodle/badges:viewotherbadges' capability, and you should get less information about the badge  Last, disable the global setting enablebadges and 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

        Activity

          People

            rodrigo.mady@moodle.com Rodrigo Mady
            jleyva Juan Leyva
            Ilya Tregubov Ilya Tregubov
            Yuliya Bozhko, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Laurent David, Sabina Abellan, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 week, 3 days, 1 hour, 30 minutes
                1w 3d 1h 30m