Skip to content

Commit

Permalink
MDL-44980 quiz statistics report : break down by variants failing
Browse files Browse the repository at this point in the history
when there has only been one variant seen.
  • Loading branch information
jamiepratt committed Apr 7, 2014
1 parent 1a727e1 commit bec7719
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
2 changes: 2 additions & 0 deletions mod/quiz/report/statistics/tests/fixtures/questions03.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
slot,type,which,cat,mark
1,calculatedsimple,sumwithvariants,maincat,1
1 change: 1 addition & 0 deletions mod/quiz/report/statistics/tests/fixtures/quizzes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ testnumber,preferredbehaviour
00,deferredfeedback
01,interactive
02,interactive
03,deferredfeedback
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
slot,variant,modelresponse,actualresponse,totalcount
1,4,"{a} + {b} (±0.01 Relative)",19.4,1
2 changes: 2 additions & 0 deletions mod/quiz/report/statistics/tests/fixtures/steps03.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quizattempt,firstname,lastname,responses.1.answer,variants.1
1,John,Jones,19.4,4
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,6 @@ public function get_all_slots() {
return array_keys($this->questionstats);
}

/**
* Array of variants of one randomly selected question that have appeared in the attempt data.
*
* @param int $questionid The id for the sub question.
* @return int[] The variant nos.
*/
public function get_variants_for_subq($questionid) {
if (count($this->subquestionstats[$questionid]->variantstats) > 1) {
return array_keys($this->subquestionstats[$questionid]->variantstats);
} else {
return false;
}
}

/**
* Get position stats instance for a slot and optional variant no.
*
Expand Down Expand Up @@ -351,7 +337,7 @@ protected function all_subq_variants_for_one_slot($slot) {
$toreturn = array();
$displayorder = 1;
foreach ($this->for_slot($slot)->get_sub_question_ids() as $subqid) {
if ($variants = $this->get_variants_for_subq($subqid)) {
if ($variants = $this->for_subq($subqid)->get_variants()) {
foreach ($variants as $variant) {
$toreturn[] = $this->make_new_subq_stat_for($displayorder, $slot, $subqid, $variant);
}
Expand Down Expand Up @@ -406,7 +392,7 @@ protected function all_subq_and_variant_stats_for_slot($slot, $limited) {
$displaynumber = 1;
foreach ($this->for_slot($slot)->get_sub_question_ids() as $subqid) {
$toreturn[] = $this->make_new_subq_stat_for($displaynumber, $slot, $subqid);
if ($variants = $this->get_variants_for_subq($subqid)) {
if ($variants = $this->for_subq($subqid)->get_variants()) {
foreach ($variants as $variant) {
$toreturn[] = $this->make_new_subq_stat_for($displaynumber, $slot, $subqid, $variant);
}
Expand Down
4 changes: 2 additions & 2 deletions question/classes/statistics/questions/calculated.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function cache($qubaids) {
}
$DB->insert_record('question_statistics', $toinsert, false);

if (count($this->variantstats) > 1) {
if ($this->get_variants()) {
foreach ($this->variantstats as $variantstat) {
$variantstat->cache($qubaids);
}
Expand Down Expand Up @@ -276,7 +276,7 @@ public function get_sub_question_ids() {
*/
public function get_variants() {
$variants = array_keys($this->variantstats);
if (count($variants) > 1) {
if (count($variants) > 1 || reset($variants) != 1) {
return $variants;
} else {
return array();
Expand Down
2 changes: 1 addition & 1 deletion question/classes/statistics/questions/calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function calculate($qubaids) {
$this->stats->for_subq($qid)->question = $subquestion;
$this->stats->for_subq($qid)->randomguessscore = $this->get_random_guess_score($subquestion);

if ($variants = $this->stats->get_variants_for_subq($qid)) {
if ($variants = $this->stats->for_subq($qid)->get_variants()) {
foreach ($variants as $variant) {
$this->stats->for_subq($qid, $variant)->question = $subquestion;
$this->stats->for_subq($qid, $variant)->randomguessscore = $this->get_random_guess_score($subquestion);
Expand Down

0 comments on commit bec7719

Please sign in to comment.