Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-43369 : quiz statistics - average across attempts

where item seen and not across all attempts for subqs.
  • Loading branch information...
commit 7cd9c85868bd9e6b5eef15c364d424286511e59e 1 parent 3dc57a1
@jamiepratt jamiepratt authored
View
13 mod/quiz/report/statistics/qstats.php
@@ -36,8 +36,6 @@ class quiz_statistics_question_stats {
public $questions;
public $subquestions = array();
- protected $s;
- protected $summarksavg;
protected $allattempts;
/** @var mixed states from which to calculate stats - iteratable. */
@@ -49,12 +47,8 @@ class quiz_statistics_question_stats {
/**
* Constructor.
* @param $questions the questions.
- * @param $s the number of attempts included in the stats.
- * @param $summarksavg the average attempt summarks.
*/
- public function __construct($questions, $s, $summarksavg) {
- $this->s = $s;
- $this->summarksavg = $summarksavg;
+ public function __construct($questions) {
foreach ($questions as $slot => $question) {
$question->_stats = $this->make_blank_question_stats();
@@ -74,6 +68,7 @@ protected function make_blank_question_stats() {
$stats->s = 0;
$stats->totalmarks = 0;
$stats->totalothermarks = 0;
+ $stats->totalsumgrades = 0;
$stats->markvariancesum = 0;
$stats->othermarkvariancesum = 0;
$stats->covariancesum = 0;
@@ -285,6 +280,7 @@ public function compute_statistics() {
protected function initial_steps_walker($step, $stats, $positionstat = true) {
$stats->s++;
$stats->totalmarks += $step->mark;
+ $stats->totalsumgrades += $step->sumgrades;
$stats->markarray[] = $step->mark;
if ($positionstat) {
@@ -313,6 +309,7 @@ protected function initial_question_walker($stats) {
}
$stats->othermarkaverage = $stats->totalothermarks / $stats->s;
+ $stats->sumgradeaverage = $stats->totalsumgrades / $stats->s;
sort($stats->markarray, SORT_NUMERIC);
sort($stats->othermarksarray, SORT_NUMERIC);
@@ -334,7 +331,7 @@ protected function secondary_steps_walker($step, $stats) {
$othermarkdifference = $step->sumgrades - $step->mark -
$stats->othermarkaverage;
}
- $overallmarkdifference = $step->sumgrades - $this->summarksavg;
+ $overallmarkdifference = $step->sumgrades - $stats->sumgradeaverage;
$sortedmarkdifference = array_shift($stats->markarray) - $stats->markaverage;
$sortedothermarkdifference = array_shift($stats->othermarksarray) -
View
3  mod/quiz/report/statistics/report.php
@@ -676,7 +676,6 @@ protected function compute_stats($quizid, $currentgroup, $nostudentsingroup,
return $this->get_emtpy_stats($questions, $firstattempts->countrecs,
$allattempts->countrecs);
}
- $summarksavg = $usingattempts->total / $usingattempts->countrecs;
$quizstats = new stdClass();
$quizstats->allattempts = $useallattempts;
@@ -750,7 +749,7 @@ protected function compute_stats($quizid, $currentgroup, $nostudentsingroup,
}
}
- $qstats = new quiz_statistics_question_stats($questions, $s, $summarksavg);
+ $qstats = new quiz_statistics_question_stats($questions);
$qstats->load_step_data($quizid, $currentgroup, $groupstudents, $useallattempts);
$qstats->compute_statistics();
View
2  mod/quiz/report/statistics/tests/statistics_test.php
@@ -68,7 +68,7 @@ public function test_qstats() {
// Data is taken from questions mostly generated by
// contrib/tools/generators/generator.php.
$questions = $this->get_records_from_csv(__DIR__.'/fixtures/mdl_question.csv');
- $this->qstats = new testable_quiz_statistics_question_stats($questions, 22, 10045.45455);
+ $this->qstats = new testable_quiz_statistics_question_stats($questions);
$this->qstats->set_step_data($steps);
$this->qstats->compute_statistics();
Please sign in to comment.
Something went wrong with that request. Please try again.