1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-23 09:23:09 +02:00

MDL-45373 quiz response analysis : count all tries at question

don't filter repeated tries.
This commit is contained in:
James Pratt 2014-05-06 12:26:02 +07:00
parent 0401143193
commit 96a0b9aaaa
4 changed files with 17 additions and 82 deletions
mod/quiz/report/statistics/tests/fixtures
question/behaviour
behaviourbase.php
interactivecountback

@ -1,18 +1,18 @@
slot,randq,variant,subpart,modelresponse,actualresponse,count1,count2,count3,count4,count5,totalcount
1,shortanswer,1,1,frog,,0,0,0,0,0,0
1,shortanswer,1,1,toad,toad,1,0,1,0,0,2
1,shortanswer,1,1,toad,toad,2,1,1,0,0,4
1,shortanswer,1,1,*,butterfly,1,0,0,0,0,1
1,shortanswer,1,1,*,dog,1,1,0,0,0,2
1,shortanswer,1,1,*,chicken,0,0,1,0,0,1
1,shortanswer,1,1,*,Tod,1,0,0,0,0,1
1,shortanswer,1,1,*,Tony,0,1,0,0,0,1
1,shortanswer,1,1,*,Sharon,0,0,1,0,0,1
1,shortanswer,1,1,*,snake,0,1,0,0,0,1
1,shortanswer,1,1,*,snake,1,1,0,0,0,2
1,shortanswer,1,1,*,snakes,0,0,1,0,0,1
1,shortanswer,1,1,*,Snakes,0,0,0,1,0,1
1,shortanswer,1,1,*,SnakeS,0,0,0,0,1,1
1,shortanswer,1,1,*,goat,1,0,0,0,0,1
1,shortanswer,1,1,*,"Mexican burrowing caecilian",0,0,1,0,0,1
1,shortanswer,1,1,*,"Mexican burrowing caecilian",0,1,1,0,0,2
1,shortanswer,1,1,*,newt,0,0,0,1,0,1
1,shortanswer,1,1,*,human,0,0,0,0,1,1
1,shortanswer,1,1,*,eggs,1,0,0,0,0,1
@ -32,9 +32,9 @@ slot,randq,variant,subpart,modelresponse,actualresponse,count1,count2,count3,cou
2,,1,1,[Did not match any answer],9,0,0,0,1,0,1
2,,1,1,[No response],,0,0,0,0,0,0
2,,2,1,{a} + {b} (±0.01 Relative),8.5,1,0,0,0,1,2
2,,2,1,"[Did not match any answer]",19.4,0,1,0,0,0,1
2,,2,1,"[Did not match any answer]",19.4,1,1,0,0,0,2
2,,2,1,[Did not match any answer],4.5,1,0,0,0,0,1
2,,2,1,"[Did not match any answer]",8,0,0,0,1,0,1
2,,2,1,"[Did not match any answer]",8,1,1,1,1,0,4
2,,2,1,[No response],,0,0,0,0,0,0
2,,3,1,{a} + {b} (±0.01 Relative),3.3,0,1,0,0,0,1
2,,3,1,[Did not match any answer],19.4,1,0,0,0,0,1
@ -56,16 +56,16 @@ slot,randq,variant,subpart,modelresponse,actualresponse,count1,count2,count3,cou
2,,10,1,"[Did not match any answer]",11,0,0,0,1,0,1
2,,10,1,"[Did not match any answer]",12,0,0,0,0,1,1
2,,10,1,"[No response]",,0,0,0,0,0,0
3,,1,1,"frog: amphibian",amphibian,8,0,1,0,0,9
3,,1,1,"frog: amphibian",amphibian,8,2,3,3,0,16
3,,1,1,frog: mammal,mammal,0,0,0,1,1,2
3,,1,1,frog: insect,insect,4,3,0,0,0,7
3,,1,1,"frog: insect",insect,4,4,2,1,0,11
3,,1,1,[No response],,0,0,0,0,0,0
3,,1,2,"cat: amphibian",amphibian,8,0,1,1,0,10
3,,1,2,"cat: amphibian",amphibian,8,1,2,1,1,13
3,,1,2,cat: mammal,mammal,0,1,1,2,0,4
3,,1,2,"cat: insect",insect,4,1,1,1,0,7
3,,1,2,"cat: insect",insect,4,4,2,2,0,12
3,,1,2,[No response],,0,0,0,0,0,0
3,,1,3,"newt: amphibian",amphibian,6,2,1,0,0,9
3,,1,3,"newt: mammal",mammal,3,0,0,1,0,5
3,,1,3,"newt: amphibian",amphibian,6,4,4,3,1,18
3,,1,3,"newt: mammal",mammal,3,0,1,2,0,6
3,,1,3,newt: insect,insect,3,2,0,0,0,5
3,,1,3,[No response],,0,0,0,0,0,0
4,,1,1,False,,3,0,0,0,0,3

1 slot randq variant subpart modelresponse actualresponse count1 count2 count3 count4 count5 totalcount
2 1 shortanswer 1 1 frog 0 0 0 0 0 0
3 1 shortanswer 1 1 toad toad 1 2 0 1 1 0 0 2 4
4 1 shortanswer 1 1 * butterfly 1 0 0 0 0 1
5 1 shortanswer 1 1 * dog 1 1 0 0 0 2
6 1 shortanswer 1 1 * chicken 0 0 1 0 0 1
7 1 shortanswer 1 1 * Tod 1 0 0 0 0 1
8 1 shortanswer 1 1 * Tony 0 1 0 0 0 1
9 1 shortanswer 1 1 * Sharon 0 0 1 0 0 1
10 1 shortanswer 1 1 * snake 0 1 1 0 0 0 1 2
11 1 shortanswer 1 1 * snakes 0 0 1 0 0 1
12 1 shortanswer 1 1 * Snakes 0 0 0 1 0 1
13 1 shortanswer 1 1 * SnakeS 0 0 0 0 1 1
14 1 shortanswer 1 1 * goat 1 0 0 0 0 1
15 1 shortanswer 1 1 * Mexican burrowing caecilian 0 0 1 1 0 0 1 2
16 1 shortanswer 1 1 * newt 0 0 0 1 0 1
17 1 shortanswer 1 1 * human 0 0 0 0 1 1
18 1 shortanswer 1 1 * eggs 1 0 0 0 0 1
32 2 1 1 [Did not match any answer] 9 0 0 0 1 0 1
33 2 1 1 [No response] 0 0 0 0 0 0
34 2 2 1 {a} + {b} (±0.01 Relative) 8.5 1 0 0 0 1 2
35 2 2 1 [Did not match any answer] 19.4 0 1 1 0 0 0 1 2
36 2 2 1 [Did not match any answer] 4.5 1 0 0 0 0 1
37 2 2 1 [Did not match any answer] 8 0 1 0 1 0 1 1 0 1 4
38 2 2 1 [No response] 0 0 0 0 0 0
39 2 3 1 {a} + {b} (±0.01 Relative) 3.3 0 1 0 0 0 1
40 2 3 1 [Did not match any answer] 19.4 1 0 0 0 0 1
56 2 10 1 [Did not match any answer] 11 0 0 0 1 0 1
57 2 10 1 [Did not match any answer] 12 0 0 0 0 1 1
58 2 10 1 [No response] 0 0 0 0 0 0
59 3 1 1 frog: amphibian amphibian 8 0 2 1 3 0 3 0 9 16
60 3 1 1 frog: mammal mammal 0 0 0 1 1 2
61 3 1 1 frog: insect insect 4 3 4 0 2 0 1 0 7 11
62 3 1 1 [No response] 0 0 0 0 0 0
63 3 1 2 cat: amphibian amphibian 8 0 1 1 2 1 0 1 10 13
64 3 1 2 cat: mammal mammal 0 1 1 2 0 4
65 3 1 2 cat: insect insect 4 1 4 1 2 1 2 0 7 12
66 3 1 2 [No response] 0 0 0 0 0 0
67 3 1 3 newt: amphibian amphibian 6 2 4 1 4 0 3 0 1 9 18
68 3 1 3 newt: mammal mammal 3 0 0 1 1 2 0 5 6
69 3 1 3 newt: insect insect 3 2 0 0 0 5
70 3 1 3 [No response] 0 0 0 0 0 0
71 4 1 1 False 3 0 0 0 0 3

@ -1,9 +1,9 @@
slot,subpart,modelresponse,actualresponse,totalcount,count1,count2,count3,count4,count5
1,1,frog: insect,insect,3,3,0,0,0,0
1,1,"frog: mammal",mammal,1,0,0,1,0,0
1,1,"frog: insect",insect,12,3,3,2,2,2
1,1,"frog: mammal",mammal,4,0,0,1,1,2
1,1,"frog: amphibian",amphibian,1,0,0,0,0,1
1,2,"cat: insect",insect,3,2,1,0,0,0
1,2,"cat: insect",insect,13,2,3,3,3,2
1,2,cat: amphibian,amphibian,1,1,0,0,0,0
1,2,cat: mammal,mammal,2,0,0,0,0,2
1,3,newt: insect,insect,3,3,0,0,0,0
1,2,cat: mammal,mammal,3,0,0,0,0,3
1,3,newt: insect,insect,15,3,3,3,3,3
1,3,newt: amphibian,amphibian,2,0,0,0,0,2

1 slot subpart modelresponse actualresponse totalcount count1 count2 count3 count4 count5
2 1 1 frog: insect insect 3 12 3 0 3 0 2 0 2 0 2
3 1 1 frog: mammal mammal 1 4 0 0 1 0 1 0 2
4 1 1 frog: amphibian amphibian 1 0 0 0 0 1
5 1 2 cat: insect insect 3 13 2 1 3 0 3 0 3 0 2
6 1 2 cat: amphibian amphibian 1 1 0 0 0 0
7 1 2 cat: mammal mammal 2 3 0 0 0 0 2 3
8 1 3 newt: insect insect 3 15 3 0 3 0 3 0 3 0 3
9 1 3 newt: amphibian amphibian 2 0 0 0 0 2

@ -304,49 +304,11 @@ abstract class question_behaviour {
foreach ($stepswithsubmit as $submittedresponseno => $step) {
$classifiedresponses[$submittedresponseno] = $this->question->classify_response($step->get_qt_data());
}
return $this->remove_repeated_submitted_responses($classifiedresponses);
return $classifiedresponses;
}
}
}
/**
* Filter classified responses for multiple tries to remove identical responses that are not significant.
*
* In base class we compare last response to preceding responses and remove all identical responses until a different one is
* found then for that different response compare to preceding and remove all identical until ...
*
* @param array[] $classifiedresponses first index is submitted response no and second is sub-part id. Value is of type
* question_classified_response. Return value from self::classify_response for ALL_TRIES.
* @return array[] return non repeated responses.
*/
protected function remove_repeated_submitted_responses($classifiedresponses) {
$submittedresponsenos = array_keys($classifiedresponses);
$submittedresponsenos = array_reverse($submittedresponsenos);
$lastsubmittedresponseno = array_shift($submittedresponsenos);
$nooflastnewresponse = $lastsubmittedresponseno;
while (count($submittedresponsenos)) {
$precedingresponseno = array_shift($submittedresponsenos);
$responsesrepeated = true;
if (count($classifiedresponses[$precedingresponseno]) !== count($classifiedresponses[$nooflastnewresponse])) {
$responsesrepeated = false;
} else {
foreach (array_keys($classifiedresponses[$precedingresponseno]) as $subpartid) {
if ($classifiedresponses[$precedingresponseno][$subpartid] !=
$classifiedresponses[$nooflastnewresponse][$subpartid]) {
$responsesrepeated = false;
break;
}
}
}
if ($responsesrepeated) {
unset($classifiedresponses[$precedingresponseno]);
} else {
$nooflastnewresponse = $precedingresponseno;
}
}
return $classifiedresponses;
}
/**
* Generate a brief textual description of the current state of the question,
* normally displayed under the question number.

@ -90,31 +90,4 @@ class qbehaviour_interactivecountback extends qbehaviour_interactive {
return $this->question->compute_final_grade($responses, $totaltries);
}
/**
* Filter classified responses for multiple tries to remove identical responses that are not significant.
*
* For this behaviour the significant repeated response part are the first of any repeated responses, for any part of the
* question. These are the responses that are graded.
*
* @param array[] $classifiedresponses first index is submitted response no and second is sub-part id. Value is of type
* question_classified_response. Return value from self::classify_response for ALL_TRIES.
* @return array[] return non repeated responses.
*/
protected function remove_repeated_submitted_responses($classifiedresponses) {
$subpartids = array_keys($classifiedresponses[1]);
foreach ($subpartids as $subpartid) {
$lastdifferentresponsepart = 1;
$tryno = 2;
while (isset($classifiedresponses[$tryno])) {
if ($classifiedresponses[$tryno][$subpartid] != $classifiedresponses[$lastdifferentresponsepart][$subpartid]) {
$lastdifferentresponsepart = $tryno;
} else {
unset($classifiedresponses[$tryno][$subpartid]);
}
$tryno++;
}
}
return $classifiedresponses;
}
}