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

grade_report array_key_exists() in grade_category

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • None
    • 4.2.5, 4.3.2
    • Gradebook
    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-80535-404
    • MDL-80535-405
    • MDL-80535-main
    • Hide
      1. Login as admin.
      2. Create a course.
      3. Go to the course Gradebook setup page.
      4. Create a new category called cat80535.
      5. Create another category called subcat80535, setting the parent category to cat80535.
      6. Confirm subcat80535 is shown in the Gradebook setup page correctly.
      7. Go to the Grader report page. Confirm subcat80535 is shown correctly.
      8. Upload the attached script test80535.php to the root directory of your site, and run it (eg. go to http://localhost/m/test80535.php). Check that it says "Updated record" - if it shows anything else then there is an issue.
      9. Go the Gradebook setup page again.
      10. Confirm subcat80535 no longer shows.
      11. Go to the Grader report page. Confirm subcat80535 no longer shows.
      Show
      Login as admin. Create a course. Go to the course Gradebook setup page. Create a new category called cat80535 . Create another category called subcat80535 , setting the parent category to cat80535 . Confirm subcat80535 is shown in the Gradebook setup page correctly. Go to the Grader report page. Confirm subcat80535 is shown correctly. Upload the attached script test80535.php to the root directory of your site, and run it (eg. go to http://localhost/m/test80535.php ). Check that it says "Updated record" - if it shows anything else then there is an issue. Go the Gradebook setup page again. Confirm subcat80535 no longer shows. Go to the Grader report page. Confirm subcat80535 no longer shows.
    • Hide

      Code verified against automated checks.

      Checked MDL-80535 using repository: https://github.com/kevpercy/moodle.git

      More information about this report

      Built on: Thu Jan 23 09:08:26 AM UTC 2025

      Show
      Code verified against automated checks. Checked MDL-80535 using repository: https://github.com/kevpercy/moodle.git MOODLE_404_STABLE (0 errors / 0 warnings) [branch: MDL-80535-404 | CI Job ] MOODLE_405_STABLE (0 errors / 0 warnings) [branch: MDL-80535-405 | CI Job ] main (0 errors / 0 warnings) [branch: MDL-80535-main | CI Job ] More information about this report Built on: Thu Jan 23 09:08:26 AM UTC 2025
    • 3
    • Team Alpha - Planning I2-2024

      Exception - array_key_exists(): Argument #2 ($array) must be of type array, null given
       
      More information about this error
       
      Debug info:
      Error code: generalexceptionmessage×Dismiss this notification
      Stack trace:
      line 2187 of /lib/grade/grade_category.php: TypeError thrown
      line 2042 of /lib/grade/grade_category.php: call to grade_category->get_children()
      line 2339 of /grade/lib.php: call to grade_category::fetch_course_tree()
      line 148 of /grade/report/grader/lib.php: call to grade_tree->__construct()
      line 118 of /grade/report/grader/index.php: call to grade_report_grader->__construct() 

      updating:

      while (array_key_exists($sortorder, $cats[$cat->parent]->children))
      {
          //debugging("$sortorder exists in cat loop");
          $sortorder++;
          $cats[$cat->parent]->children[$sortorder] = &$cats[$catid];
      }

      to:

      if (!is_null($cats[$cat->parent])) {
          while (array_key_exists($sortorder, $cats[$cat->parent]->children)) {
              //debugging("$sortorder exists in cat loop");
              $sortorder++;
              $cats[$cat->parent]->children[$sortorder] = &$cats[$catid];
          }
      } 

      adds a sanity check to ensure the non-existing children are not calculated. 

            kevin.percy@moodle.com Kevin Percy
            dustinbrisebois Dustin Brisebois
            Andrew Gosali Andrew Gosali
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 1 hour
                2d 1h

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