/** * Then loop through all questions for the first time. * * Perform some computations on the per-question statistics calculations after * we have been through all the step data. * * @param calculated $stats question stats to update. */ protected function initial_question_walker($stats) { $stats->markaverage = $stats->totalmarks / $stats->s; if ($stats->maxmark != 0) { $stats->facility = $stats->markaverage / $stats->maxmark; } else { $stats->facility = null; } $stats->othermarkaverage = $stats->totalothermarks / $stats->s; $stats->summarksaverage = $stats->totalsummarks / $stats->s; sort($stats->markarray, SORT_NUMERIC); sort($stats->othermarksarray, SORT_NUMERIC); // Here we have collected enough data to make the decision about which questions have variants whose stats we also want to // calculate. We delete the initialised structures where they are not needed. if (!$stats->get_variants() || !$stats->break_down_by_variant()) { $stats->clear_variants(); } foreach ($stats->get_variants() as $variant) { $this->initial_question_walker($stats->variantstats[$variant]); } }