Skip to content

Commit

Permalink
Merge branch 'MDL-34589_23' of git://github.com/timhunt/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_23_STABLE
  • Loading branch information
danpoltawski committed Jul 30, 2012
2 parents db8e600 + 59b983a commit 1ab970d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mod/quiz/report/overview/overviewgraph.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,7 +89,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; $bandwidth = $quiz->grade / $bands;
$bandlabels = array(); $bandlabels = array();
for ($i = 1; $i <= $bands; $i++) { for ($i = 1; $i <= $bands; $i++) {
Expand Down
7 changes: 6 additions & 1 deletion mod/quiz/report/reportlib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ function quiz_report_qm_filter_select($quiz, $quizattemptsalias = 'quiza') {
*/ */
function quiz_report_grade_bands($bandwidth, $bands, $quizid, $userids = array()) { function quiz_report_grade_bands($bandwidth, $bands, $quizid, $userids = array()) {
global $DB; 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) { if ($userids) {
list($usql, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'u'); list($usql, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'u');
Expand Down Expand Up @@ -220,7 +225,7 @@ function quiz_report_grade_bands($bandwidth, $bands, $quizid, $userids = array()
$data = $DB->get_records_sql_menu($sql, $params); $data = $DB->get_records_sql_menu($sql, $params);


// We need to create array elements with values 0 at indexes where there is no element. // We need to create array elements with values 0 at indexes where there is no element.
$data = $data + array_fill(0, $bands+1, 0); $data = $data + array_fill(0, $bands + 1, 0);
ksort($data); ksort($data);


// Place the maximum (prefect grade) into the last band i.e. make last // Place the maximum (prefect grade) into the last band i.e. make last
Expand Down

0 comments on commit 1ab970d

Please sign in to comment.