/** * Output the table that lists all the questions in the quiz with their statistics. * * @param \core_question\statistics\questions\all_calculated_for_qubaid_condition $questionstats the stats for all questions in * the quiz including subqs and * variants. */ protected function output_quiz_structure_analysis_table($questionstats) { $tooutput = array(); $limitvariants = !$this->table->is_downloading(); foreach ($questionstats->get_all_slots() as $slot) { // Output the data for these question statistics. $tooutput = array_merge($tooutput, $questionstats->structure_analysis_for_one_slot($slot, $limitvariants)); } $this->table->format_and_add_array_of_rows($tooutput); }
/** * Check that the stat is as expected within a reasonable tolerance. * * @param float|string|bool $expected expected value of stat. * @param \core_question\statistics\questions\all_calculated_for_qubaid_condition $questionstats * @param int $slot * @param string $subqname if empty string then not an item stat. * @param int|string $variant if empty string then not a variantstat. * @param string $statname */ protected function assert_stat_equals($expected, $questionstats, $slot, $subqname, $variant, $statname) { if ($variant === '' && $subqname === '') { $actual = $questionstats->for_slot($slot)->{$statname}; } else { if ($subqname !== '') { $actual = $questionstats->for_subq($this->randqids[$slot][$subqname])->{$statname}; } else { $actual = $questionstats->for_slot($slot, $variant)->{$statname}; } } $message = "{$statname} for slot {$slot}"; if ($expected === '**NULL**') { $this->assertEquals(null, $actual, $message); } else { if (is_bool($expected)) { $this->assertEquals($expected, $actual, $message); } else { if (is_numeric($expected)) { switch ($statname) { case 'covariance': case 'discriminationindex': case 'discriminativeefficiency': case 'effectiveweight': $precision = 1.0E-5; break; default: $precision = 1.0E-6; } $delta = abs($expected) * $precision; $this->assertEquals((double) $expected, $actual, $message, $delta); } else { $this->assertEquals($expected, $actual, $message); } } } }