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

Quiz graphs broken in PHP 5.4

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.2.5, 2.3.2
    • 2.2.4, 2.3.1, 2.4
    • Quiz
    • MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE
    • Hide

      [If a tester with php 5.4 can be found, this would be best, but regression testing on <5.4 is also sufficient]

      1. For a quiz with attempts, go to Results -> Grades in the navigation.

      2. Verify that the graph at the bottom of the page appears.

      Show
      [If a tester with php 5.4 can be found, this would be best, but regression testing on <5.4 is also sufficient] 1. For a quiz with attempts, go to Results -> Grades in the navigation. 2. Verify that the graph at the bottom of the page appears.

      Matthew Davidson reported in MDL-34164:

      After some testing, the problem seems to be with the line in reportlib.php, function quiz_report_grade_bands():

      unset($data[$bands]);

      There is definitely a PHP 5.4 issue here. I have made a small script to show this issue. I'll submit it to PHP to get this fixed. It has something to do with how $bands or $foo in this case is cast. It starts as a string, then becomes a double, but something is wrong with it because if you cast the variable as anything the unset() statement will work as intended. Event casting it as a double works:

      $test = array("5"=>"bar");
      $foo = "10.0000"; // gettype($foo) = "string"
      $foo /= 2; //Makes $foo = 5 but still gettype($foo) = "double"
      echo gettype($foo);
      unset($test[$foo]);

      However, if Moodle would like to be proactive in this, it could be fixed on your end by casting the variable $bands like so...

      unset($data[(int) $bands]);

            timhunt Tim Hunt
            timhunt Tim Hunt
            Dan Poltawski Dan Poltawski
            David Monllaó David Monllaó
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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