Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34589 quiz report graphs: PHP5.4 issue with unset($array[$float]).

Thanks to Matthew Davidson for diagnosing the problem.
  • Loading branch information...
commit d87c8d7ffd27892d3873d266e570057fd43fe750 1 parent dd9274c
Tim Hunt timhunt authored
4 mod/quiz/report/overview/overviewgraph.php
View
@@ -90,7 +90,9 @@
}
}
-$bands = ceil($bands);
+// See MDL-34589. Using doubles as array keys causes problems in PHP 5.4,
+// hence the explicit cast to int.
+$bands = (int) ceil($bands);
$bandwidth = $quiz->grade / $bands;
$bandlabels = array();
for ($i = 1; $i <= $bands; $i++) {
9 mod/quiz/report/reportlib.php
View
@@ -190,6 +190,11 @@ function quiz_report_qm_filter_select($quiz, $quizattemptsalias = 'quiza') {
*/
function quiz_report_grade_bands($bandwidth, $bands, $quizid, $userids = array()) {
global $DB;
+ if (!is_int($bands)) {
+ debugging('$bands passed to quiz_report_grade_bands must be an integer. (' .
+ gettype($bands) . ' passed.)', DEBUG_DEVELOPER);
+ $bands = (int) $bands;
+ }
if ($userids) {
list($usql, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'u');
@@ -218,8 +223,8 @@ function quiz_report_grade_bands($bandwidth, $bands, $quizid, $userids = array()
$data = $DB->get_records_sql_menu($sql, $params);
- //need to create array elements with values 0 at indexes where there is no element
- $data = $data + array_fill(0, $bands+1, 0);
+ // We need to create array elements with values 0 at indexes where there is no element.
+ $data = $data + array_fill(0, $bands + 1, 0);
ksort($data);
//place the maximum (prefect grade) into the last band i.e. make last
Please sign in to comment.
Something went wrong with that request. Please try again.