From 58794ac9487f8a0559057c976116d74d7b672b8c Mon Sep 17 00:00:00 2001 From: James Pratt Date: Wed, 19 Mar 2014 18:22:35 +0700 Subject: [PATCH] MDL-44690 core_questions : download of question steps data as csv file --- .../responses/tests/fixtures/steps00.csv | 2 +- .../statistics/tests/fixtures/steps00.csv | 52 +++--- .../statistics/tests/fixtures/steps01.csv | 162 +++++++++--------- .../statistics/tests/fixtures/steps02.csv | 64 +++---- .../stats_from_steps_walkthrough_test.php | 3 +- question/type/match/question.php | 22 ++- question/type/multianswer/question.php | 14 ++ question/type/multichoice/question.php | 48 +++++- question/type/questionbase.php | 35 +++- question/type/upgrade.txt | 12 +- 10 files changed, 253 insertions(+), 161 deletions(-) diff --git a/mod/quiz/report/responses/tests/fixtures/steps00.csv b/mod/quiz/report/responses/tests/fixtures/steps00.csv index f48149aa45f..31d8fa7b3f3 100644 --- a/mod/quiz/report/responses/tests/fixtures/steps00.csv +++ b/mod/quiz/report/responses/tests/fixtures/steps00.csv @@ -1,4 +1,4 @@ -quizattempt,firstname,lastname,randqs.1,responses.1.answer,responses.1.-submit,responses.1.-tryagain,variants.2,responses.2.answer,responses.2.-submit,responses.2.-tryagain,responses.3.0,responses.3.1,responses.3.2,responses.3.-submit,responses.3.-tryagain,responses.4.answer,responses.4.-submit,responses.4.-tryagain,finished +quizattempt,firstname,lastname,randqs.1,responses.1.answer,responses.1.-submit,responses.1.-tryagain,variants.2,responses.2.answer,responses.2.-submit,responses.2.-tryagain,responses.3.frog,responses.3.cat,responses.3.newt,responses.3.-submit,responses.3.-tryagain,responses.4.answer,responses.4.-submit,responses.4.-tryagain,finished 1,John,Jones,shortanswer,toad,1,0,4,19.4,0,0,mammal,mammal,amphibian,0,0,1,0,0,0 1,John,Jones,shortanswer,toad,0,1,4,19.4,0,0,mammal,mammal,amphibian,0,0,1,0,0,0 1,John,Jones,shortanswer,frog,1,0,4,19.4,0,0,mammal,mammal,amphibian,0,0,1,0,0,0 diff --git a/mod/quiz/report/statistics/tests/fixtures/steps00.csv b/mod/quiz/report/statistics/tests/fixtures/steps00.csv index aeb0070abfb..9daf91205f5 100644 --- a/mod/quiz/report/statistics/tests/fixtures/steps00.csv +++ b/mod/quiz/report/statistics/tests/fixtures/steps00.csv @@ -1,26 +1,26 @@ -quizattempt,firstname,lastname,randqs.1,responses.1.answer,variants.2,responses.2.answer,responses.3.0,responses.3.1,responses.3.2,responses.4.answer,responses.5.0,responses.5.1,responses.5.2,responses.5.3,responses.6.answer,responses.7.1.answer,responses.7.2.answer -1,John,Jones,numerical,3.14,1,9.9,amphibian,mammal,amphibian,1,1,0,1,0,1,Owl,2 -2,John,Smith,shortanswer,frog,1,9.9,amphibian,mammal,amphibian,1,0,1,1,0,0,Dog,0 -3,John,Vicars,numerical,3.14,6,9.4,amphibian,mammal,amphibian,1,0,0,1,1,1,Owl,2 -4,John,Pacino,shortanswer,butterfly,6,-0.1,amphibian,mammal,amphibian,1,1,0,1,0,3,Dog,0 -5,John,Deniro,numerical,3.14,4,0,amphibian,mammal,amphibian,0,0,1,0,1,0,Dog,2 -6,John,Banks,numerical,3.14,1,9.9,amphibian,mammal,amphibian,1,1,0,0,1,1,Owl,1 -7,John,Asimov,numerical,3.142,7,9.1,amphibian,mammal,amphibian,1,0,0,1,1,0,Owl,1 -8,John,Chomsky,numerical,3.14,4,19.4,amphibian,mammal,amphibian,0,0,0,1,1,0,Owl,1 -9,John,Yamaguchi,shortanswer,frog,1,-0.7,amphibian,mammal,amphibian,1,1,0,1,0,0,Owl,2 -10,John,Robbins,numerical,3.1,5,14.2,amphibian,mammal,amphibian,0,0,1,1,0,0,Owl,0 -11,Joe,Jones,shortanswer,toad,6,-0.2,amphibian,mammal,amphibian,1,1,1,0,0,0,Owl,0 -12,Joe,Smith,shortanswer,frog,8,5.7,amphibian,mammal,amphibian,0,0,0,1,1,0,Owl,2 -13,Joe,Vicars,numerical,3.14,8,-0.2,amphibian,mammal,amphibian,1,1,0,0,1,0,wfz9p,2 -14,Joe,Pacino,shortanswer,frog,1,-0.2,amphibian,mammal,amphibian,1,1,0,1,0,1,Owl,0 -15,Joe,Deniro,numerical,3.1,7,-0.9,amphibian,mammal,amphibian,1,0,1,0,1,0,Owl,2 -16,Joe,Banks,shortanswer,frog,10,-0.7,amphibian,mammal,amphibian,0,1,0,0,1,0,Owl,2 -17,Joe,Asimov,shortanswer,toad,4,-0.4,amphibian,mammal,amphibian,1,0,1,1,0,2,Owl,2 -18,Joe,Chomsky,shortanswer,frog,6,-1,amphibian,mammal,amphibian,1,0,1,0,1,0,Pussy-cat,2 -19,Joe,Yamaguchi,numerical,3.14,8,-0.5,amphibian,mammal,amphibian,1,1,1,0,0,1,Owl,0 -20,Joe,Robbins,shortanswer,butterfly,4,19.4,amphibian,mammal,amphibian,0,0,1,1,0,0,"Wiggly worm",0 -21,Roberto,Jones,shortanswer,frog,8,5.7,amphibian,amphibian,mammal,1,0,1,1,0,2,RjUpn,2 -22,Roberto,Smith,shortanswer,frog,5,14.2,amphibian,mammal,amphibian,0,1,0,0,1,1,Dog,2 -23,Roberto,Vicars,shortanswer,frog,5,14.2,amphibian,mammal,amphibian,1,0,1,0,1,0,"Wiggly worm",2 -24,Roberto,Pacino,numerical,3.1,1,-1,amphibian,mammal,amphibian,0,1,1,0,0,0,Owl,2 -25,Roberto,Deniro,numerical,3.1,8,-0.1,amphibian,mammal,amphibian,1,1,0,1,0,0,Owl,2 +quizattempt,firstname,lastname,randqs.1,responses.1.answer,variants.2,responses.2.answer,responses.3.cat,responses.3.frog,responses.3.newt,responses.4.answer,responses.5.Four,responses.5.One,responses.5.Three,responses.5.Two,responses.6.answer,responses.7.1.answer,responses.7.2.answer +1,John,Jones,numerical,3.14,1,9.9,mammal,amphibian,amphibian,1,,1,1,,Two,Owl,Pussy-cat +2,John,Smith,shortanswer,frog,1,9.9,mammal,amphibian,amphibian,1,,,1,1,One,Dog,Bow-wow +3,John,Vicars,numerical,3.14,6,9.4,mammal,amphibian,amphibian,1,1,,1,,Two,Owl,Pussy-cat +4,John,Pacino,shortanswer,butterfly,6,-0.1,mammal,amphibian,amphibian,1,,1,1,,Four,Dog,Bow-wow +5,John,Deniro,numerical,3.14,4,0,mammal,amphibian,amphibian,0,1,,,1,One,Dog,Pussy-cat +6,John,Banks,numerical,3.14,1,9.9,mammal,amphibian,amphibian,1,1,1,,,Two,Owl,"Wiggly worm" +7,John,Asimov,numerical,3.142,7,9.1,mammal,amphibian,amphibian,1,1,,1,,One,Owl,"Wiggly worm" +8,John,Chomsky,numerical,3.14,4,19.4,mammal,amphibian,amphibian,0,1,,1,,One,Owl,"Wiggly worm" +9,John,Yamaguchi,shortanswer,frog,1,-0.7,mammal,amphibian,amphibian,1,,1,1,,One,Owl,Pussy-cat +10,John,Robbins,numerical,3.1,5,14.2,mammal,amphibian,amphibian,0,,,1,1,One,Owl,Bow-wow +11,Joe,Jones,shortanswer,toad,6,-0.2,mammal,amphibian,amphibian,1,,1,,1,One,Owl,Bow-wow +12,Joe,Smith,shortanswer,frog,8,5.7,mammal,amphibian,amphibian,0,1,,1,,One,Owl,Pussy-cat +13,Joe,Vicars,numerical,3.14,8,-0.2,mammal,amphibian,amphibian,1,1,1,,,One,wfz9p,Pussy-cat +14,Joe,Pacino,shortanswer,frog,1,-0.2,mammal,amphibian,amphibian,1,,1,1,,Two,Owl,Bow-wow +15,Joe,Deniro,numerical,3.1,7,-0.9,mammal,amphibian,amphibian,1,1,,,1,One,Owl,Pussy-cat +16,Joe,Banks,shortanswer,frog,10,-0.7,mammal,amphibian,amphibian,0,1,1,,,One,Owl,Pussy-cat +17,Joe,Asimov,shortanswer,toad,4,-0.4,mammal,amphibian,amphibian,1,,,1,1,Three,Owl,Pussy-cat +18,Joe,Chomsky,shortanswer,frog,6,-1,mammal,amphibian,amphibian,1,1,,,1,One,Pussy-cat,Pussy-cat +19,Joe,Yamaguchi,numerical,3.14,8,-0.5,mammal,amphibian,amphibian,1,,1,,1,Two,Owl,Bow-wow +20,Joe,Robbins,shortanswer,butterfly,4,19.4,mammal,amphibian,amphibian,0,,,1,1,One,"Wiggly worm",Bow-wow +21,Roberto,Jones,shortanswer,frog,8,5.7,amphibian,amphibian,mammal,1,,,1,1,Three,RjUpn,Pussy-cat +22,Roberto,Smith,shortanswer,frog,5,14.2,mammal,amphibian,amphibian,0,1,1,,,Two,Dog,Pussy-cat +23,Roberto,Vicars,shortanswer,frog,5,14.2,mammal,amphibian,amphibian,1,1,,,1,One,"Wiggly worm",Pussy-cat +24,Roberto,Pacino,numerical,3.1,1,-1,mammal,amphibian,amphibian,0,,1,,1,One,Owl,Pussy-cat +25,Roberto,Deniro,numerical,3.1,8,-0.1,mammal,amphibian,amphibian,1,,1,1,,One,Owl,Pussy-cat diff --git a/mod/quiz/report/statistics/tests/fixtures/steps01.csv b/mod/quiz/report/statistics/tests/fixtures/steps01.csv index 952a5376f22..e9a0d858179 100644 --- a/mod/quiz/report/statistics/tests/fixtures/steps01.csv +++ b/mod/quiz/report/statistics/tests/fixtures/steps01.csv @@ -1,83 +1,79 @@ -quizattempt,firstname,lastname,finished,randqs.1,responses.1.-submit,responses.1.-tryagain,responses.1.answer,responses.2.-submit,responses.2.-tryagain,responses.2.answer,variants.2,responses.3.-submit,responses.3.-tryagain,responses.3.0,responses.3.1,responses.3.2,responses.4.-submit,responses.4.answer -1,John,Jones,0,shortanswer,1,0,butterfly,0,0,19.4,4,0,0,,amphibian,,0,1 -1,John,Jones,0,shortanswer,0,1,butterfly,0,0,19.4,4,1,0,insect,insect,insect,0,1 -1,John,Jones,0,shortanswer,1,0,dog,0,0,19.4,4,0,1,insect,insect,insect,0,1 -1,John,Jones,0,shortanswer,0,1,dog,0,0,19.4,4,1,0,insect,insect,amphibian,0,1 -1,John,Jones,0,shortanswer,1,0,chicken,0,0,19.4,4,0,1,insect,insect,amphibian,0,1 -1,John,Jones,0,shortanswer,0,0,chicken,0,0,19.4,4,1,0,insect,mammal,amphibian,0,1 -1,John,Jones,0,shortanswer,0,0,chicken,0,0,19.4,4,0,1,insect,mammal,amphibian,0,1 -1,John,Jones,0,shortanswer,0,0,chicken,0,0,19.4,4,1,0,insect,amphibian,amphibian,0,1 -1,John,Jones,0,shortanswer,0,0,chicken,0,0,19.4,4,0,1,insect,amphibian,amphibian,0,1 -1,John,Jones,1,shortanswer,0,0,chicken,0,0,19.4,4,1,0,mammal,amphibian,amphibian,0,1 -2,Han,Solo,0,shortanswer,1,0,Tod,1,0,19.4,2,1,0,amphibian,amphibian,amphibian,1,0 -2,Han,Solo,0,shortanswer,0,1,Tod,0,1,19.4,2,0,1,amphibian,amphibian,amphibian,0,0 -2,Han,Solo,0,shortanswer,1,0,Tony,0,0,19.4,2,1,0,insect,mammal,insect,0,0 -2,Han,Solo,0,shortanswer,0,1,Tony,0,0,19.4,2,0,1,insect,mammal,insect,0,0 -2,Han,Solo,0,shortanswer,1,0,Sharon,0,0,19.4,2,1,0,amphibian,insect,mammal,0,0 -2,Han,Solo,0,shortanswer,0,0,Sharon,0,0,19.4,2,0,1,amphibian,insect,mammal,0,0 -2,Han,Solo,0,shortanswer,0,0,Sharon,0,0,19.4,2,1,0,amphibian,insect,mammal,0,0 -2,Han,Solo,1,shortanswer,0,0,Sharon,0,0,19.4,2,0,0,amphibian,insect,mammal,0,0 -3,Yoda,Wise He Is,0,shortanswer,1,0,snake,1,0,7,9,1,0,amphibian,insect,amphibian,0,1 -3,Yoda,Wise He Is,0,shortanswer,0,1,snake,0,0,7,9,0,1,amphibian,insect,amphibian,0,1 -3,Yoda,Wise He Is,0,shortanswer,1,0,snake,0,0,7,9,1,0,amphibian,insect,amphibian,0,1 -3,Yoda,Wise He Is,0,shortanswer,0,1,snake,0,0,7,9,0,1,amphibian,insect,amphibian,0,1 -3,Yoda,Wise He Is,0,shortanswer,1,0,snakes,0,0,7,9,1,0,amphibian,insect,amphibian,0,1 -3,Yoda,Wise He Is,0,shortanswer,0,1,snakes,0,0,7,9,0,1,amphibian,insect,amphibian,0,1 -3,Yoda,Wise He Is,0,shortanswer,1,0,Snakes,0,0,7,9,1,0,amphibian,mammal,amphibian,0,1 -3,Yoda,Wise He Is,0,shortanswer,0,1,Snakes,0,0,7,9,0,0,amphibian,mammal,amphibian,0,1 -3,Yoda,Wise He Is,1,shortanswer,1,0,SnakeS,0,0,7,9,0,0,amphibian,mammal,amphibian,0,1 -4,Herbert,Garrison,0,shortanswer,0,0,dog,0,0,9.4,6,1,0,amphibian,amphibian,amphibian,0,1 -4,Herbert,Garrison,0,shortanswer,0,0,dog,0,0,9.4,6,0,1,amphibian,amphibian,amphibian,0,1 -4,Herbert,Garrison,0,shortanswer,0,0,dog,0,0,9.4,6,1,0,insect,insect,insect,0,1 -4,Herbert,Garrison,0,shortanswer,0,0,dog,0,0,9.4,6,0,1,insect,insect,insect,0,1 -4,Herbert,Garrison,0,shortanswer,0,0,dog,0,0,9.4,6,1,0,insect,amphibian,amphibian,0,1 -4,Herbert,Garrison,0,shortanswer,0,0,dog,0,0,9.4,6,0,1,insect,amphibian,amphibian,0,1 -4,Herbert,Garrison,1,shortanswer,0,0,dog,0,0,9.4,6,1,0,mammal,insect,mammal,0,1 -5,Agent,Smith,0,numerical,1,0,3.1,1,0,x+y,2,0,0,amphibian,amphibian,mammal,0,1 -5,Agent,Smith,0,numerical,0,0,3.1,1,0,4.5,2,0,0,amphibian,amphibian,mammal,0,1 -5,Agent,Smith,1,numerical,0,0,3.1,0,0,4.5,2,0,0,amphibian,amphibian,mammal,0,1 -6,Agent,Smith,0,numerical,0,0,3.142,0,0,19.4,3,0,0,amphibian,insect,mammal,1,0 -6,Agent,Smith,0,numerical,1,0,3.14,1,0,19.4,3,1,0,amphibian,insect,mammal,0,0 -6,Agent,Smith,0,numerical,0,0,3.14,0,1,19.4,3,0,1,amphibian,insect,mammal,0,0 -6,Agent,Smith,1,numerical,0,0,3.14,1,0,3.3,3,1,0,insect,insect,amphibian,0,0 -7,Agent,Smith,0,numerical,1,0,3.14,1,0,19.3,4,0,0,insect,amphibian,insect,0,1 -7,Agent,Smith,1,numerical,0,0,3.14,0,0,19.3,4,0,0,insect,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,1,0,goat,1,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,0,1,goat,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,1,0,Mexican burrowing caecilian,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,0,1,Mexican burrowing caecilian,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,1,0,Mexican burrowing caecilian,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,0,1,Mexican burrowing caecilian,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,1,0,newt,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,0,shortanswer,0,1,newt,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -9,Bebe,Stevens,1,shortanswer,1,0,human,0,0,8.5,2,0,0,amphibian,amphibian,insect,0,1 -10,Luke,Skywalker,0,numerical,1,0,2,1,0,555,10,1,0,amphibian,amphibian,amphibian,1,0 -10,Luke,Skywalker,0,numerical,0,1,2,0,1,555,10,0,1,amphibian,amphibian,amphibian,0,0 -10,Luke,Skywalker,0,numerical,1,0,20,1,0,44,10,1,0,amphibian,amphibian,amphibian,0,0 -10,Luke,Skywalker,0,numerical,0,1,20,0,1,44,10,0,1,amphibian,amphibian,amphibian,0,0 -10,Luke,Skywalker,0,numerical,1,0,34,1,0,22,10,1,0,amphibian,amphibian,amphibian,0,0 -10,Luke,Skywalker,0,numerical,0,0,34,0,1,22,10,0,1,amphibian,amphibian,amphibian,0,0 -10,Luke,Skywalker,0,numerical,0,0,34,1,0,11,10,1,0,amphibian,mammal,amphibian,0,0 -10,Luke,Skywalker,0,numerical,0,0,34,0,1,11,10,0,0,amphibian,mammal,amphibian,0,0 -10,Luke,Skywalker,1,numerical,0,0,34,1,0,12,10,0,0,amphibian,mammal,amphibian,0,0 -11,Luke,Skywalker,0,shortanswer,1,0,toad,1,0,23,1,1,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,0,shortanswer,0,0,toad,0,1,23,1,0,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,0,shortanswer,0,0,toad,1,0,22,1,0,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,0,shortanswer,0,0,toad,0,1,22,1,0,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,0,shortanswer,0,0,toad,1,0,21,1,0,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,0,shortanswer,0,0,toad,0,1,21,1,0,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,0,shortanswer,0,0,toad,1,0,9,1,0,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,0,shortanswer,0,0,toad,0,1,9,1,0,0,insect,amphibian,amphibian,0,1 -11,Luke,Skywalker,1,shortanswer,0,0,toad,1,0,9.9,1,0,0,insect,amphibian,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,1,0,toad,1,0,8,2,1,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,0,1,toad,0,1,8,2,0,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,1,0,toad,1,0,8,2,0,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,0,1,toad,0,1,8,2,0,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,1,0,toad,1,0,8,2,0,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,0,0,toad,0,1,8,2,0,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,0,0,toad,1,0,8,2,0,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,0,shortanswer,0,0,toad,0,1,8,2,0,0,insect,insect,amphibian,0,1 -12,Luke,Skywalker,1,shortanswer,0,0,toad,1,0,8.5,2,0,0,insect,insect,amphibian,0,1 -13,Leia,The Princess,0,shortanswer,0,0,eggs,0,0,19.4,4,1,0,amphibian,amphibian,,1,1 -13,Leia,The Princess,0,shortanswer,0,0,eggs,0,0,19.4,4,1,0,amphibian,amphibian,mammal,0,1 -13,Leia,The Princess,1,shortanswer,0,0,eggs,0,0,19.4,4,0,0,amphibian,amphibian,mammal,0,1 +quizattempt,firstname,lastname,randqs.1,responses.1.-submit,responses.1.-tryagain,responses.1.answer,variants.2,responses.2.-submit,responses.2.-tryagain,responses.2.answer,responses.3.-submit,responses.3.-tryagain,responses.3.cat,responses.3.frog,responses.3.newt,responses.4.-submit,responses.4.answer,finished +1,John,Jones,shortanswer,1,,butterfly,4,,,19.4,,,amphibian,,,,1,0 +1,,,,,1,butterfly,,,,19.4,1,,insect,insect,insect,,1,0 +1,,,,1,,dog,,,,19.4,,1,insect,insect,insect,,1,0 +1,,,,,1,dog,,,,19.4,1,,insect,insect,amphibian,,1,0 +1,,,,1,,chicken,,,,19.4,,1,insect,insect,amphibian,,1,0 +1,,,,,,chicken,,,,19.4,1,,mammal,insect,amphibian,,1,0 +1,,,,,,chicken,,,,19.4,,1,mammal,insect,amphibian,,1,0 +1,,,,,,chicken,,,,19.4,1,,amphibian,insect,amphibian,,1,0 +1,,,,,,chicken,,,,19.4,,1,amphibian,insect,amphibian,,1,0 +1,,,,,,chicken,,,,19.4,1,,amphibian,mammal,amphibian,,1,1 +2,Han,Solo,shortanswer,1,,Tod,2,1,,19.4,1,,amphibian,amphibian,amphibian,1,0,0 +2,,,,,1,Tod,,,1,19.4,,1,amphibian,amphibian,amphibian,,0,0 +2,,,,1,,Tony,,,,19.4,1,,mammal,insect,insect,,0,0 +2,,,,,1,Tony,,,,19.4,,1,mammal,insect,insect,,0,0 +2,,,,1,,Sharon,,,,19.4,1,,insect,amphibian,mammal,,0,0 +2,,,,,,Sharon,,,,19.4,,1,insect,amphibian,mammal,,0,0 +2,,,,,,Sharon,,,,19.4,1,,insect,amphibian,mammal,,0,1 +3,Yoda,"Wise He Is",shortanswer,1,,snake,9,1,,7,1,,insect,amphibian,amphibian,,1,0 +3,,,,,1,snake,,,,7,,1,insect,amphibian,amphibian,,1,0 +3,,,,1,,snake,,,,7,1,,insect,amphibian,amphibian,,1,0 +3,,,,,1,snake,,,,7,,1,insect,amphibian,amphibian,,1,0 +3,,,,1,,snakes,,,,7,1,,insect,amphibian,amphibian,,1,0 +3,,,,,1,snakes,,,,7,,1,insect,amphibian,amphibian,,1,0 +3,,,,1,,Snakes,,,,7,1,,mammal,amphibian,amphibian,,1,0 +3,,,,,1,Snakes,,,,7,,,mammal,amphibian,amphibian,,1,0 +3,,,,1,,SnakeS,,,,7,,,mammal,amphibian,amphibian,,1,1 +4,Herbert,Garrison,shortanswer,,,dog,6,,,9.4,1,,amphibian,amphibian,amphibian,,1,0 +4,,,,,,dog,,,,9.4,,1,amphibian,amphibian,amphibian,,1,0 +4,,,,,,dog,,,,9.4,1,,insect,insect,insect,,1,0 +4,,,,,,dog,,,,9.4,,1,insect,insect,insect,,1,0 +4,,,,,,dog,,,,9.4,1,,amphibian,insect,amphibian,,1,0 +4,,,,,,dog,,,,9.4,,1,amphibian,insect,amphibian,,1,0 +4,,,,,,dog,,,,9.4,1,,insect,mammal,mammal,,1,1 +5,Agent,Smith,numerical,1,,3.1,2,1,,x+y,,,amphibian,amphibian,mammal,,1,0 +5,,,,,,3.1,,1,,4.5,,,amphibian,amphibian,mammal,,1,1 +6,Agent,Smith,numerical,,,3.142,3,,,19.4,,,insect,amphibian,mammal,1,0,0 +6,,,,1,,3.14,,1,,19.4,1,,insect,amphibian,mammal,,0,0 +6,,,,,,3.14,,,1,19.4,,1,insect,amphibian,mammal,,0,0 +6,,,,,,3.14,,1,,3.3,1,,insect,insect,amphibian,,0,1 +7,Agent,Smith,numerical,1,,3.14,4,1,,19.3,,,amphibian,insect,insect,,1,1 +8,Bebe,Stevens,shortanswer,1,,goat,2,1,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,,1,goat,,,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,1,,"Mexican burrowing caecilian",,,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,,1,"Mexican burrowing caecilian",,,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,1,,"Mexican burrowing caecilian",,,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,,1,"Mexican burrowing caecilian",,,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,1,,newt,,,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,,1,newt,,,,8.5,,,amphibian,amphibian,insect,,1,0 +8,,,,1,,human,,,,8.5,,,amphibian,amphibian,insect,,1,1 +9,Luke,Skywalker,numerical,1,,2,10,1,,555,1,,amphibian,amphibian,amphibian,1,0,0 +9,,,,,1,2,,,1,555,,1,amphibian,amphibian,amphibian,,0,0 +9,,,,1,,20,,1,,44,1,,amphibian,amphibian,amphibian,,0,0 +9,,,,,1,20,,,1,44,,1,amphibian,amphibian,amphibian,,0,0 +9,,,,1,,34,,1,,22,1,,amphibian,amphibian,amphibian,,0,0 +9,,,,,,34,,,1,22,,1,amphibian,amphibian,amphibian,,0,0 +9,,,,,,34,,1,,11,1,,mammal,amphibian,amphibian,,0,0 +9,,,,,,34,,,1,11,,,mammal,amphibian,amphibian,,0,0 +9,,,,,,34,,1,,12,,,mammal,amphibian,amphibian,,0,1 +10,Luke,Skywalker,shortanswer,1,,toad,1,1,,23,1,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,,1,23,,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,1,,22,,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,,1,22,,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,1,,21,,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,,1,21,,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,1,,9,,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,,1,9,,,amphibian,insect,amphibian,,1,0 +10,,,,,,toad,,1,,9.9,,,amphibian,insect,amphibian,,1,1 +11,Luke,Skywalker,shortanswer,1,,toad,2,1,,8,1,,insect,insect,amphibian,,1,0 +11,,,,,1,toad,,,1,8,,,insect,insect,amphibian,,1,0 +11,,,,1,,toad,,1,,8,,,insect,insect,amphibian,,1,0 +11,,,,,1,toad,,,1,8,,,insect,insect,amphibian,,1,0 +11,,,,1,,toad,,1,,8,,,insect,insect,amphibian,,1,0 +11,,,,,,toad,,,1,8,,,insect,insect,amphibian,,1,0 +11,,,,,,toad,,1,,8,,,insect,insect,amphibian,,1,0 +11,,,,,,toad,,,1,8,,,insect,insect,amphibian,,1,0 +11,,,,,,toad,,1,,8.5,,,insect,insect,amphibian,,1,1 +12,Leia,"The Princess",shortanswer,,,eggs,4,,,19.4,1,,amphibian,amphibian,,1,1,0 +12,,,,,,eggs,,,,19.4,1,,amphibian,amphibian,mammal,,1,1 diff --git a/mod/quiz/report/statistics/tests/fixtures/steps02.csv b/mod/quiz/report/statistics/tests/fixtures/steps02.csv index 9857c793cb7..18f8ca05884 100644 --- a/mod/quiz/report/statistics/tests/fixtures/steps02.csv +++ b/mod/quiz/report/statistics/tests/fixtures/steps02.csv @@ -1,32 +1,32 @@ -quizattempt,firstname,lastname,responses.1.0,responses.1.1,responses.1.2,responses.1.-submit,responses.1.-tryagain,finished -1,John,Jones,insect,insect,insect,1,0,0 -1,John,Jones,insect,insect,insect,0,1,0 -1,John,Jones,insect,insect,insect,1,0,0 -1,John,Jones,insect,insect,insect,0,1,0 -1,John,Jones,insect,insect,insect,1,0,0 -1,John,Jones,insect,insect,insect,0,1,0 -1,John,Jones,insect,insect,insect,1,0,0 -1,John,Jones,insect,insect,insect,0,1,0 -1,John,Jones,insect,insect,insect,1,0,1 -2,Mark,Jones,insect,amphibian,insect,1,0,0 -2,Mark,Jones,insect,amphibian,insect,0,1,0 -2,Mark,Jones,insect,insect,insect,1,0,0 -2,Mark,Jones,insect,insect,insect,0,1,0 -2,Mark,Jones,mammal,insect,insect,1,0,0 -2,Mark,Jones,mammal,insect,insect,0,1,0 -2,Mark,Jones,mammal,insect,insect,1,0,0 -2,Mark,Jones,mammal,insect,insect,0,1,0 -2,Mark,Jones,mammal,mammal,insect,1,0,0 -2,Mark,Jones,mammal,mammal,insect,0,1,0 -2,Mark,Jones,mammal,mammal,amphibian,1,0,1 -3,Michael,Jackson,insect,insect,insect,1,0,0 -3,Michael,Jackson,insect,insect,insect,0,1,0 -3,Michael,Jackson,insect,insect,insect,1,0,0 -3,Michael,Jackson,insect,insect,insect,0,1,0 -3,Michael,Jackson,insect,insect,insect,1,0,0 -3,Michael,Jackson,insect,insect,insect,0,1,0 -3,Michael,Jackson,insect,insect,insect,1,0,0 -3,Michael,Jackson,insect,insect,insect,0,1,0 -3,Michael,Jackson,insect,insect,insect,1,0,0 -3,Michael,Jackson,insect,insect,insect,0,1,0 -3,Michael,Jackson,amphibian,mammal,amphibian,1,0,1 +quizattempt,firstname,lastname,responses.1.-submit,responses.1.-tryagain,responses.1.cat,responses.1.frog,responses.1.newt,finished +1,John,Jones,1,,insect,insect,insect,0 +1,,,,1,insect,insect,insect,0 +1,,,1,,insect,insect,insect,0 +1,,,,1,insect,insect,insect,0 +1,,,1,,insect,insect,insect,0 +1,,,,1,insect,insect,insect,0 +1,,,1,,insect,insect,insect,0 +1,,,,1,insect,insect,insect,0 +1,,,1,,insect,insect,insect,1 +2,Mark,Jones,1,,amphibian,insect,insect,0 +2,,,,1,amphibian,insect,insect,0 +2,,,1,,insect,insect,insect,0 +2,,,,1,insect,insect,insect,0 +2,,,1,,insect,mammal,insect,0 +2,,,,1,insect,mammal,insect,0 +2,,,1,,insect,mammal,insect,0 +2,,,,1,insect,mammal,insect,0 +2,,,1,,mammal,mammal,insect,0 +2,,,,1,mammal,mammal,insect,0 +2,,,1,,mammal,mammal,amphibian,1 +3,Michael,Jackson,1,,insect,insect,insect,0 +3,,,,1,insect,insect,insect,0 +3,,,1,,insect,insect,insect,0 +3,,,,1,insect,insect,insect,0 +3,,,1,,insect,insect,insect,0 +3,,,,1,insect,insect,insect,0 +3,,,1,,insect,insect,insect,0 +3,,,,1,insect,insect,insect,0 +3,,,1,,insect,insect,insect,0 +3,,,,1,insect,insect,insect,0 +3,,,1,,mammal,amphibian,amphibian,1 diff --git a/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php b/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php index 80fdd316945..eaa597f7357 100644 --- a/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php +++ b/mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php @@ -208,8 +208,7 @@ class quiz_report_statistics_from_steps_testcase extends mod_quiz_attempt_walkth $actualresponsecounts = $responseclassanalysis->data_for_question_response_table('', ''); foreach ($actualresponsecounts as $actualresponsecount) { - if ($actualresponsecount->response == $expected['actualresponse'] || - count($actualresponsecounts) == 1) { + if ($actualresponsecount->response == $expected['actualresponse'] || count($actualresponsecounts) == 1) { $i = 1; $partofanalysis = " slot {$expected['slot']}, rand q '{$expected['randq']}', variant {$expected['variant']}, ". "for expected model response {$expected['modelresponse']}, ". diff --git a/question/type/match/question.php b/question/type/match/question.php index 41835ca4522..b5edea247bd 100644 --- a/question/type/match/question.php +++ b/question/type/match/question.php @@ -190,11 +190,12 @@ class qtype_match_question extends question_graded_automatically_with_countback public function prepare_simulated_post_data($simulatedresponse) { $postdata = array(); - $stemids = array_keys($this->stems); + $stemtostemids = array_flip(clean_param_array($this->stems, PARAM_NOTAGS)); $choicetochoiceno = array_flip($this->choices); $choicenotochoiceselectvalue = array_flip($this->choiceorder); - foreach ($simulatedresponse as $stemno => $choice) { - $stemid = $stemids[$stemno]; + foreach ($simulatedresponse as $stem => $choice) { + $choice = clean_param($choice, PARAM_NOTAGS); + $stemid = $stemtostemids[$stem]; $shuffledstemno = array_search($stemid, $this->stemorder); if (empty($choice)) { $choiceselectvalue = 0; @@ -208,6 +209,21 @@ class qtype_match_question extends question_graded_automatically_with_countback return $postdata; } + public function get_student_response_values_for_simulation($postdata) { + $simulatedresponse = array(); + foreach ($this->stemorder as $shuffledstemno => $stemid) { + if (!empty($postdata[$this->field($shuffledstemno)])) { + $choiceselectvalue = $postdata[$this->field($shuffledstemno)]; + $choiceno = $this->choiceorder[$choiceselectvalue]; + $choice = clean_param($this->choices[$choiceno], PARAM_NOTAGS); + $stem = clean_param($this->stems[$stemid], PARAM_NOTAGS); + $simulatedresponse[$stem] = $choice; + } + } + ksort($simulatedresponse); + return $simulatedresponse; + } + public function get_right_choice_for($stemid) { foreach ($this->choiceorder as $choicekey => $choiceid) { if ($this->right[$stemid] == $choiceid) { diff --git a/question/type/multianswer/question.php b/question/type/multianswer/question.php index 6e5e3c4e472..1d0d817ec1b 100644 --- a/question/type/multianswer/question.php +++ b/question/type/multianswer/question.php @@ -161,6 +161,20 @@ class qtype_multianswer_question extends question_graded_automatically_with_coun return $postdata; } + public function get_student_response_values_for_simulation($postdata) { + $simulatedresponse = array(); + foreach ($this->subquestions as $i => $subq) { + $substep = $this->get_substep(null, $i); + $subqpostdata = $substep->filter_array($postdata); + $subqsimulatedresponse = $subq->get_student_response_values_for_simulation($subqpostdata); + foreach ($subqsimulatedresponse as $subresponsekey => $responsevalue) { + $simulatedresponse[$i.'.'.$subresponsekey] = $responsevalue; + } + } + ksort($simulatedresponse); + return $simulatedresponse; + } + public function is_complete_response(array $response) { foreach ($this->subquestions as $i => $subq) { $substep = $this->get_substep(null, $i); diff --git a/question/type/multichoice/question.php b/question/type/multichoice/question.php index 5746474e5f2..553fcd35096 100644 --- a/question/type/multichoice/question.php +++ b/question/type/multichoice/question.php @@ -194,11 +194,26 @@ class qtype_multichoice_single_question extends qtype_multichoice_base { return array(); } - public function prepare_simulated_post_data($simulatedresponse) { - $ansnumbertoanswerid = array_keys($this->answers); - $ansid = $ansnumbertoanswerid[$simulatedresponse['answer']]; - return array('answer' => array_search($ansid, $this->order)); + $ansid = 0; + foreach ($this->answers as $answer) { + if ($answer->answer == $simulatedresponse['answer']) { + $ansid = $answer->id; + } + } + if ($ansid) { + return array('answer' => array_search($ansid, $this->order)); + } else { + return array(); + } + } + + public function get_student_response_values_for_simulation($postdata) { + if (!isset($postdata['answer'])) { + return array(); + } else { + return array('answer' => $this->answers[$this->order[$postdata['answer']]]->answer); + } } public function is_same_response(array $prevresponse, array $newresponse) { @@ -344,15 +359,30 @@ class qtype_multichoice_multi_question extends qtype_multichoice_base { public function prepare_simulated_post_data($simulatedresponse) { $postdata = array(); - $ansidtochoiceno = array_flip($this->order); - ksort($ansidtochoiceno, SORT_NUMERIC); - $ansnotochoiceno = array_values($ansidtochoiceno); - foreach ($simulatedresponse as $ansno => $checked) { - $postdata[$this->field($ansnotochoiceno[$ansno])] = $checked; + foreach ($simulatedresponse as $ans => $checked) { + if ($checked) { + foreach ($this->answers as $ansid => $answer) { + if ($answer->answer == $ans) { + $fieldno = array_search($ansid, $this->order); + $postdata[$this->field($fieldno)] = '1'; + } + } + } } return $postdata; } + public function get_student_response_values_for_simulation($postdata) { + $simulatedresponse = array(); + foreach ($this->order as $fieldno => $ansid) { + if (isset($postdata[$this->field($fieldno)])) { + $simulatedresponse[$this->answers[$ansid]->answer] = 1; + } + } + ksort($simulatedresponse); + return $simulatedresponse; + } + public function is_same_response(array $prevresponse, array $newresponse) { foreach ($this->order as $key => $notused) { $fieldname = $this->field($key); diff --git a/question/type/questionbase.php b/question/type/questionbase.php index 042afb5a86a..8c5ecfaf2a6 100644 --- a/question/type/questionbase.php +++ b/question/type/questionbase.php @@ -301,12 +301,23 @@ abstract class question_definition { /** - * Passed an array of data representing a student response this function transforms the array to a response array as would be - * returned from the html form for this question instance. + * Takes an array of values representing a student response represented in a way that is understandable by a human and + * transforms that to the response as the POST values returned from the HTML form that takes the student response during a + * student attempt. Primarily this is used when reading csv values from a file of student responses in order to be able to + * simulate the student interaction with a quiz. * - * In most cases the array will just be returned as is. Some question types will need to transform the keys of the array in + * In most cases the array will just be returned as is. Some question types will need to transform the keys of the array, * as the meaning of the keys in the html form is deliberately obfuscated so that someone looking at the html does not get an - * advantage. + * advantage. The values that represent the response might also be changed in order to more meaningful to a human. + * + * See the examples of question types that have overridden this in core and also see the csv files of simulated student + * responses used in unit tests in : + * - mod/quiz/tests/fixtures/stepsXX.csv + * - mod/quiz/report/responses/tests/fixtures/steps00.csv + * - mod/quiz/report/statistics/tests/fixtures/stepsXX.csv + * + * Also see {@link https://github.com/jamiepratt/moodle-quiz_simulate}, a quiz report plug in for uploading and downloading + * student responses as csv files. * * @param array $simulatedresponse an array of data representing a student response * @return array a response array as would be returned from the html form (but without prefixes) @@ -315,6 +326,22 @@ abstract class question_definition { return $simulatedresponse; } + /** + * Does the opposite of {@link prepare_simulated_post_data}. + * + * This takes a student response (the POST values returned from the HTML form that takes the student response during a + * student attempt) it then represents it in a way that is understandable by a human. + * + * Primarily this is used when creating a file of csv from real student responses in order later to be able to + * simulate the same student interaction with a quiz later. + * + * @param string[] $realresponse the response array as was returned from the form during a student attempt (without prefixes). + * @return string[] an array of data representing a student response. + */ + public function get_student_response_values_for_simulation($realresponse) { + return $realresponse; + } + /** * Apply {@link format_text()} to some content with appropriate settings for * this question. diff --git a/question/type/upgrade.txt b/question/type/upgrade.txt index 08de8c6ee6d..2cd5513fcbb 100644 --- a/question/type/upgrade.txt +++ b/question/type/upgrade.txt @@ -7,7 +7,17 @@ This files describes API changes for question type plugins. response analysis and question stats by variant. But for some question types there might be an almost infinite quantity of variants for the question, in this case you can suppress break down by variant by returning false from this method. See for example the non-core question type varnumeric or the slightly more complex stack question type. - + + We have added a pair of methods to the question_definition class 'prepare_simulated_post_data' and + 'get_student_response_values_for_simulation'. You may want to override these methods in question.php in your question type plug + -in. These methods are used to convert data from a csv file of simulated step data into the simulated post data that is fed + to the question engine. These csv files can be used for unit testing or manual testing the use of your question type within the + quiz module. You can use the simulate quiz report for manual testing and also to easily generate csv test files. You can + run a number of students through a test and then download a csv file representing their interaction with the quiz. For most + question types the default of just passing csv data as post data, directly from the csv file will probably work fine. But for + certain question types where the meaning of the post data is deliberately obfuscated it might be necessary to convert from a + human friendly format in the csv file to response data expected by the question type using 'prepare_simulated_post_data' and + to convert back from a question type response array to values for download in a csv file using + 'get_student_response_values_for_simulation'. === 2.6 === + The changes in MDL-32750 were reverted in favour of the new pdw toggle toolbars plugin for TinyMCE. The get_non_collapsible_editor_options method has been deprecated.