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

Related system badges causing badge rendering issue

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MDL-74784-311
    • MDL-74784-400
    • MDL-74784-master
    • Hide

      Setup

      1. Login as admin.
      2. Create 1 system badge (badge1):
        1. In the criteria, add a new ''Manual issue by role' criteria and select that it can be awarded by a manager.
      3. Create 1 more system badge (badge2):
        1. In the criteria, add a new ''Manual issue by role' criteria and select that it can be awarded by a manager.
        2. In the "Related badges", select the previous badge.
        3. Enable access to it.
      4. Follow the "Recipients" section of badge2 and award it to a student.

      Testing instructions

      1. Login as student s1.
      2. Go to the user profile.
      3. Follow the badge link in the "Badges" section.
      4. Click the "More details" link
      5. Check no error appears and ** badge1 is displayed in the "Related badges".
      6. Copy the URL and logout.
      7. Access to the badge URL you copied.
      8. Check no error appears and ** badge1 is displayed in the "Related badges".
      9. Login as a guest.
      10. Access again to the badge URL you copied.
      11. Check no error appears and ** badge1 is displayed in the "Related badges".
      Show
      Setup Login as admin. Create 1 system badge (badge1): In the criteria, add a new ''Manual issue by role' criteria and select that it can be awarded by a manager. Create 1 more system badge (badge2): In the criteria, add a new ''Manual issue by role' criteria and select that it can be awarded by a manager. In the "Related badges", select the previous badge. Enable access to it. Follow the "Recipients" section of badge2 and award it to a student. Testing instructions Login as student s1. Go to the user profile. Follow the badge link in the "Badges" section. Click the "More details" link Check no error appears and ** badge1 is displayed in the "Related badges". Copy the URL and logout. Access to the badge URL you copied. Check no error appears and ** badge1 is displayed in the "Related badges". Login as a guest. Access again to the badge URL you copied. Check no error appears and ** badge1 is displayed in the "Related badges".
    • Moppies Kanban, Old Moppies Kanban Board

    Description

      We have a system badge with the some other system badges that were marked as related.

      After updating from an earlier version of 3.11 there appears to be some changes to badges/classes/output/issued_badge.php 

      When trying to view the issued badges for system badges with related badges the system would output an error with the debug message below:

      Default exception handler: Coding error detected, it must be fixed by a programmer: Context does not belong to any course. Debug: 
      Error code: codingerror
      * line 5758 of /lib/accesslib.php: coding_exception thrown
      * line 1856 of /lib/accesslib.php: call to context->get_course_context()
      * line 210 of /badges/classes/output/issued_badge.php: call to is_guest()
      * line 326 of /badges/renderer.php: call to core_badges\output\issued_badge->export_for_template()
      * line 466 of /lib/outputrenderers.php: call to core_badges_renderer->render_issued_badge()
      * line 70 of /badges/badge.php: call to plugin_renderer_base->render()

      The trace seems to indicate the issue to the is_guest call on line 210 of issued_badge.php which uses a $context variable set earlier in the file. This is part of the code block under // Field: Related badges.{}

      As a test, I removed the call to the is_guest function on 210 and the badge page rendered properly. This is the only code block in the issued_badge.php that seems to calls this function or use the context.

      Attachments

        1. 11_MDL-74784_311.png
          11_MDL-74784_311.png
          135 kB
        2. 11_MDL-74784_400.png
          11_MDL-74784_400.png
          127 kB
        3. 11_MDL-74784_master.png
          11_MDL-74784_master.png
          125 kB
        4. 5_MDL-74784_311.png
          5_MDL-74784_311.png
          151 kB
        5. 5_MDL-74784_400.png
          5_MDL-74784_400.png
          131 kB
        6. 5_MDL-74784_master.png
          5_MDL-74784_master.png
          130 kB
        7. 8_MDL-74784_311.png
          8_MDL-74784_311.png
          128 kB
        8. 8_MDL-74784_400.png
          8_MDL-74784_400.png
          124 kB
        9. 8_MDL-74784_master.png
          8_MDL-74784_master.png
          123 kB

        Activity

          People

            sarjona Sara Arjona (@sarjona)
            mganderson Martin Anderson
            Carlos Escobedo Carlos Escobedo
            Amaia Anabitarte Amaia Anabitarte
            John Edward Pedregosa John Edward Pedregosa
            Yuliya Bozhko, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Laurent David, Sabina Abellan, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              22/Aug/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours
                5h