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

External functions that return badges should include the course name

XMLWordPrintable

    • MOODLE_405_STABLE
    • MOODLE_500_STABLE
    • MDL-83026-main
    • Hide
      1. In a course, create a course badge, award this badge to a student user (must be enrolled in the course)
      2. Create a Token for the student:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Call the the external function "core_badges_get_user_badges" using CURL.
        • Replace the wstoken and the URL of your Moodle instance

          curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_user_badges&wstoken=$wstoken'

      4. Confirm that the response includes "coursefullname" with the full name of the course of the badge.
        • Also, annotate the "id" and "uniquehash" of the badge.
      5. Call the the external function "core_badges_get_user_badge_by_hash" using CURL.
        • Replace the wstoken, hash (the uniquehash badge 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'

      6. Confirm that the response includes "coursefullname" with the full name of the course of the badge.
      7. Call the the external function "core_badges_get_badge" using CURL.
        • Replace the wstoken, id (the id badge value) and the URL of your Moodle instance

          curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_badge&wstoken=$wstoken&id=$id'

      8. Confirm that the response includes "coursefullname" with the full name of the course of the badge.
      Show
      In a course, create a course badge, award this badge to a student user (must be enrolled in the course) Create a Token for the student: Click on Site administration ► Plugins ► Web services ► Manage tokens Call the the external function "core_badges_get_user_badges" using CURL. Replace the wstoken and the URL of your Moodle instance curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_user_badges&wstoken=$wstoken' Confirm that the response includes "coursefullname" with the full name of the course of the badge. Also, annotate the "id" and "uniquehash" of the badge. Call the the external function "core_badges_get_user_badge_by_hash" using CURL. Replace the wstoken, hash (the uniquehash badge 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' Confirm that the response includes "coursefullname" with the full name of the course of the badge. Call the the external function "core_badges_get_badge" using CURL. Replace the wstoken, id (the id badge value) and the URL of your Moodle instance curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_badges_get_badge&wstoken=$wstoken&id=$id' Confirm that the response includes "coursefullname" with the full name of the course of the badge.
    • Hide

      Code verified against automated checks.

      Checked MDL-83026 using repository: https://github.com/albertgasset/moodle.git

      More information about this report

      Built on: Fri Feb 14 09:46:32 AM UTC 2025

      Show
      Code verified against automated checks. Checked MDL-83026 using repository: https://github.com/albertgasset/moodle.git main (0 errors / 0 warnings) [branch: MDL-83026-main | CI Job ] More information about this report Built on: Fri Feb 14 09:46:32 AM UTC 2025
    • Show
      Launching automatic jobs for branch MDL-83026 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/18128/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/61935/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/61936/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/61937/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/61938/ App tests (stable app version) Built on: Fri Jan 31 12:30:18 PM UTC 2025

      The external functions that return information about badges do not include the name of the course as part of the result. Two of the functions return the ID of the course, but this is not enough because the user might not have permission to fetch the name of the course using other external functions.

      These are the affected functions:

      • core_badges_get_badge
      • core_badges_get_user_badges
      • core_badges_get_user_badge_by_hash

       

            albert.gasset@moodle.com Albert Gasset
            albert.gasset@moodle.com Albert Gasset
            Juan Leyva Juan Leyva
            Ferran Recio Ferran Recio
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 2 hours, 59 minutes
                1d 2h 59m

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