From: Jun Pataleta Date: Wed, 18 Apr 2018 01:46:57 +0000 (+0800) Subject: Merge branch 'MDL-61950-master' of git://github.com/ryanwyllie/moodle X-Git-Tag: v3.5.0-beta~106 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=3a37a5e9342b13cfd5bcccd0f694eb20a1459f35;hp=6979cf56e21dbe3db96fe0a7cd4e217e6cf8e45d Merge branch 'MDL-61950-master' of git://github.com/ryanwyllie/moodle --- diff --git a/question/classes/statistics/questions/calculator.php b/question/classes/statistics/questions/calculator.php index 66249122a3b..3d76679f0cd 100644 --- a/question/classes/statistics/questions/calculator.php +++ b/question/classes/statistics/questions/calculator.php @@ -181,16 +181,15 @@ class calculator { // Finish computing the averages, and put the sub-question data into the // corresponding questions. - - // This cannot be a foreach loop because we need to have both - // $question and $nextquestion available, but apart from that it is - // foreach ($this->questions as $qid => $question). $slots = $this->stats->get_all_slots(); - $this->progress->start_progress('', count($slots), 1); - foreach ($slots as $slot) { + $totalnumberofslots = count($slots); + $maxindex = $totalnumberofslots - 1; + $this->progress->start_progress('', $totalnumberofslots, 1); + foreach ($slots as $index => $slot) { $this->stats->for_slot($slot)->sort_variants(); $this->progress->increment_progress(); - $nextslot = current($slots); + $nextslotindex = $index + 1; + $nextslot = ($nextslotindex > $maxindex) ? false : $slots[$nextslotindex]; $this->initial_question_walker($this->stats->for_slot($slot));