From d04626e4cd670a069d1c4417c3922b72b1c60f4a Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 11 May 2011 17:19:12 +0100 Subject: [PATCH] MDL-20636 Question engine upgrade unit tests for shortanswer, random and multichoice. --- .../db/simpletest/testupgradelibnewqe.php | 2756 +++++++++++++++++ .../db/simpletest/testupgradelibnewqe.php | 785 +++++ .../db/simpletest/testupgradelibnewqe.php | 637 ++++ .../db/simpletest/testupgradelibnewqe.php | 2 +- 4 files changed, 4179 insertions(+), 1 deletion(-) create mode 100644 question/type/multichoice/db/simpletest/testupgradelibnewqe.php create mode 100644 question/type/random/db/simpletest/testupgradelibnewqe.php create mode 100644 question/type/shortanswer/db/simpletest/testupgradelibnewqe.php diff --git a/question/type/multichoice/db/simpletest/testupgradelibnewqe.php b/question/type/multichoice/db/simpletest/testupgradelibnewqe.php new file mode 100644 index 00000000000..ff8540a4c4b --- /dev/null +++ b/question/type/multichoice/db/simpletest/testupgradelibnewqe.php @@ -0,0 +1,2756 @@ +. + +/** + * Tests of the upgrade to the new Moodle question engine for attempts at + * multichoice questions. + * + * @package qtype + * @subpackage multichoice + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + +require_once($CFG->dirroot . '/question/engine/upgrade/simpletest/helper.php'); + + +/** + * Testing the upgrade of multichoice question attempts. + * + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_test_base { + + public function test_multichoice_deferredfeedback_history960() { + $quiz = (object) array( + 'id' => '1', + 'course' => '3', + 'name' => 'Test quiz 1', + 'intro' => '', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'questionsperpage' => '0', + 'shufflequestions' => '0', + 'shuffleanswers' => '1', + 'questions' => '1,0', + 'timecreated' => '0', + 'timemodified' => '1278603396', + 'timelimit' => '0', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'sumgrades' => '1.00000', + 'grade' => '10.00000', + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '0', + 'introformat' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'reviewattempt' => '69904', + 'reviewcorrectness' => '69904', + 'reviewmarks' => '69904', + 'reviewspecificfeedback' => '69904', + 'reviewgeneralfeedback' => '69904', + 'reviewrightanswer' => '69904', + 'reviewoverallfeedback' => '4368', + ); + $attempt = (object) array( + 'id' => '2', + 'uniqueid' => '2', + 'quiz' => '2', + 'userid' => '4', + 'attempt' => '1', + 'timestart' => '1278604557', + 'timefinish' => '1278604570', + 'timemodified' => '1278604597', + 'layout' => '2,0', + 'preview' => '0', + 'sumgrades' => '0.90000', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '2', + 'category' => '2', + 'parent' => '0', + 'name' => 'Which is the amphibian', + 'questiontext' => 'Which is the amphibian?', + 'questiontextformat' => '1', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'tjh238.vledev.open.ac.uk+100708154547+JrHygi', + 'version' => 'tjh238.vledev.open.ac.uk+100708154548+a3zh8v', + 'hidden' => '0', + 'timecreated' => '1278603947', + 'timemodified' => '1278603947', + 'createdby' => '3', + 'modifiedby' => '3', + 'defaultmark' => '1.0000000', + 'penalty' => '0.3333333', + 'maxmark' => '1.00000', + 'options' => (object) array( + 'id' => '1', + 'question' => '2', + 'layout' => '0', + 'answers' => array( + 3 => (object) array( + 'question' => '2', + 'answer' => 'Cat', + 'feedback' => '', + 'fraction' => '0.0000000', + 'id' => 3, + ), + 4 => (object) array( + 'question' => '2', + 'answer' => 'Frog', + 'feedback' => '', + 'fraction' => '1.0000000', + 'id' => 4, + ), + 5 => (object) array( + 'question' => '2', + 'answer' => 'Ant', + 'feedback' => '', + 'fraction' => '0.0000000', + 'id' => 5, + ), + 6 => (object) array( + 'question' => '2', + 'answer' => 'Dog', + 'feedback' => '', + 'fraction' => '0.0000000', + 'id' => 6, + ), + ), + 'single' => '1', + 'shuffleanswers' => '1', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'none', + 'shownumcorrect' => '0', + ), + 'hints' => array ( + 1 => (object) array( + 'hint' => 'First hint', + 'questionid' => '2', + 'shownumcorrect' => NULL, + 'clearwrong' => NULL, + 'options' => NULL, + 'id' => 1, + ), + 2 => (object) array( + 'hint' => 'Second hint', + 'questionid' => '2', + 'shownumcorrect' => NULL, + 'clearwrong' => NULL, + 'options' => NULL, + 'id' => 2, + ), + ), + ); + $qsession = (object) array( + 'id' => '2', + 'attemptid' => '2', + 'questionid' => '2', + 'newest' => '6', + 'newgraded' => '6', + 'sumpenalty' => '0.3333333', + 'manualcomment' => 'Well done!', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 0 => (object) array( + 'id' => '4', + 'attempt' => '2', + 'question' => '2', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '5,4,6,3:', + 'timestamp' => '1278604557', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + ), + 1 => (object) array( + 'id' => '5', + 'attempt' => '2', + 'question' => '2', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '5,4,6,3:4', + 'timestamp' => '1278604562', + 'event' => '6', + 'grade' => '1', + 'raw_grade' => '1', + 'penalty' => '0.3333333', + ), + 2 => (object) array( + 'id' => '6', + 'attempt' => '2', + 'question' => '2', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '5,4,6,3:4', + 'timestamp' => '1278604597', + 'event' => '9', + 'grade' => '0.9', + 'raw_grade' => '0.9', + 'penalty' => '0', + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 2, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'Which is the amphibian?', + 'rightanswer' => 'Frog', + 'responsesummary' => 'Frog', + 'timemodified' => 1278604597, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1278604557, + 'userid' => 4, + 'data' => array('_order' => '5,4,6,3'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1278604562, + 'userid' => 4, + 'data' => array('-finish' => '1', 'answer' => '1'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'mangrpartial', + 'fraction' => 0.9, + 'timecreated' => 1278604597, + 'userid' => null, + 'data' => array('-comment' => 'Well done!', '-mark' => '0.9', '-maxmark' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_history0() { + $quiz = (object) array( + 'id' => '8', + 'course' => '1095', + 'name' => 'End of course quiz', + 'intro' => 'Use this self-assessment quiz to judge your overall understanding. ', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '1150107600', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71760879', + 'questionsperpage' => '0', + 'shufflequestions' => '1', + 'shuffleanswers' => '1', + 'questions' => '71,72,73,89,74,75,76,92,77,78,79,93,80,90,81,91,94,95,82,83,84,85,86,87,88,0', + 'sumgrades' => '25', + 'grade' => '25', + 'timecreated' => '0', + 'timemodified' => '1150107596', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '17', + 'uniqueid' => '17', + 'quiz' => '8', + 'userid' => '26290', + 'attempt' => '1', + 'sumgrades' => '0', + 'timestart' => '1150203042', + 'timefinish' => '0', + 'timemodified' => '1150203042', + 'layout' => '93,76,82,75,87,74,90,94,73,77,81,95,79,92,88,80,91,86,72,83,84,89,85,78,71,0', + 'preview' => '1', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '72', + 'category' => '10', + 'parent' => '0', + 'name' => 'Q02', + 'questiontext' => 'Why were standards such an important driver in the growth of systems integration?', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+060612113403+Fz0GGO', + 'version' => 'learn.open.ac.uk+060612160802+I6ctMQ', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'id' => '44', + 'question' => '72', + 'layout' => '0', + 'answers' => array( + 200 => (object) array( + 'question' => '72', + 'answer' => 'Because they enable stored data and interfaces to be standardised.', + 'fraction' => '1', + 'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.', + 'id' => 200, + ), + 201 => (object) array( + 'question' => '72', + 'answer' => 'Because they enable the members of an integration team to communicate together.', + 'fraction' => '0', + 'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.', + 'id' => 201, + ), + 202 => (object) array( + 'question' => '72', + 'answer' => 'Because they produce good quality documentation.', + 'fraction' => '0', + 'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.', + 'id' => 202, + ), + ), + 'single' => '1', + 'shuffleanswers' => '1', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '132', + 'attemptid' => '17', + 'questionid' => '72', + 'newest' => '196', + 'newgraded' => '196', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 196 => (object) array( + 'attempt' => '17', + 'question' => '72', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '200,202,201:', + 'timestamp' => '1150203042', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 196, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 72, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'Why were standards such an important driver in the growth of systems integration?', + 'rightanswer' => 'Because they enable stored data and interfaces to be standardised.', + 'responsesummary' => '', + 'timemodified' => 1150203042, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1150203042, + 'userid' => 26290, + 'data' => array('_order' => '200,202,201'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_history60() { + $quiz = (object) array( + 'id' => '13', + 'course' => '1416', + 'name' => 'Self assessment', + 'intro' => '

This quiz enables you to rate how much you have demonstrated certain skills in assignments. +

+

Each question is phrased so that you agree or disagree with a statement that describes your level of attainment, and is accompanied by a link to advice on recognising and practising the skill. +

+

The quiz is intended to form part of a dialogue on skills improvement between you and your tutor. Hence there is no "right" answer to it, and it is awarded no marks towards the course result. +

+

Any benefits to you depend on your being realistic about what you have demonstrated. Reserve the extreme ratings for when you think you have demonstrated mastery or complete incompetence! +
+

', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '1', + 'grademethod' => '4', + 'decimalpoints' => '0', + 'review' => '71760879', + 'questionsperpage' => '0', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '218,221,219,220,223,224,222,0', + 'sumgrades' => '7', + 'grade' => '0', + 'timecreated' => '0', + 'timemodified' => '1160991947', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '181', + 'uniqueid' => '181', + 'quiz' => '13', + 'userid' => '9932', + 'attempt' => '1', + 'sumgrades' => '0', + 'timestart' => '1161946984', + 'timefinish' => '1161947130', + 'timemodified' => '1161947130', + 'layout' => '218,221,219,220,223,224,222,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '218', + 'category' => '21', + 'parent' => '0', + 'name' => 'Answering the question that is asked', + 'questiontext' => '

I have demonstrated the ability to analyse and answer the question that is asked. (Click for advice on this skill)', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+060822084343+5JvlNr', + 'version' => 'learn.open.ac.uk+060822084343+CQPfhb', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'id' => '152', + 'question' => '218', + 'layout' => '0', + 'answers' => array( + 664 => (object) array( + 'question' => '218', + 'answer' => 'Agree', + 'fraction' => '0', + 'feedback' => ' ', + 'id' => 664, + ), + 665 => (object) array( + 'question' => '218', + 'answer' => 'Uncertain', + 'fraction' => '0', + 'feedback' => ' ', + 'id' => 665, + ), + 666 => (object) array( + 'question' => '218', + 'answer' => 'Disagree', + 'fraction' => '0', + 'feedback' => ' ', + 'id' => 666, + ), + 667 => (object) array( + 'question' => '218', + 'answer' => 'Strongly disagree', + 'fraction' => '0', + 'feedback' => ' ', + 'id' => 667, + ), + 668 => (object) array( + 'question' => '218', + 'answer' => 'Strongly agree', + 'fraction' => '0', + 'feedback' => ' ', + 'id' => 668, + ), + ), + 'single' => '0', + 'shuffleanswers' => '0', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '2412', + 'attemptid' => '181', + 'questionid' => '218', + 'newest' => '3891', + 'newgraded' => '3891', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 3888 => (object) array( + 'attempt' => '181', + 'question' => '218', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '664,665,666,667,668:', + 'timestamp' => '1161946984', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 3888, + ), + 3891 => (object) array( + 'attempt' => '181', + 'question' => '218', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '664,665,666,667,668:664', + 'timestamp' => '1161947130', + 'event' => '6', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 3891, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 218, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'I have demonstrated the ability to analyse and ANSWER THE QUESTION that is asked. (Click for advice on this skill)', + 'rightanswer' => '', + 'responsesummary' => 'Agree', + 'timemodified' => 1161947130, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1161946984, + 'userid' => 9932, + 'data' => array('_order' => '664,665,666,667,668'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'gradedwrong', + 'fraction' => 0, + 'timecreated' => 1161947130, + 'userid' => 9932, + 'data' => array('choice0' => 1, 'choice1' => 0, 'choice2' => 0, 'choice3' => 0, 'choice4' => 0, '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_history6220() { + $quiz = (object) array( + 'id' => '95', + 'course' => '1181', + 'name' => 'Study Guide 7 Quiz', + 'intro' => '', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '1', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71760879', + 'questionsperpage' => '2', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '2855,2856,0,2857,2858,0,2859,2860,0,2861,2862,0,2863,2864,0,2865,0', + 'sumgrades' => '59', + 'grade' => '59', + 'timecreated' => '0', + 'timemodified' => '1170427431', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '3237', + 'uniqueid' => '3237', + 'quiz' => '95', + 'userid' => '120555', + 'attempt' => '1', + 'sumgrades' => '35.4166', + 'timestart' => '1177006492', + 'timefinish' => '1177008802', + 'timemodified' => '1177008794', + 'layout' => '2855,2856,0,2857,2858,0,2859,2860,0,2861,2862,0,2863,2864,0,2865,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '2855', + 'category' => '114', + 'parent' => '0', + 'name' => 'Question 1', + 'questiontext' => '

Which of the following techniques can identify non-functional requirements?

', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+061221143845+nohATp', + 'version' => 'learn.open.ac.uk+070131102906+bviJOZ', + 'hidden' => '0', + 'generalfeedback' => 'The correct answers are b and c. + For further information about this question see Study Guide 7 SAQ 2.1(b and c) + Misuse cases were discussed in SG4', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '5', + 'options' => (object) array( + 'id' => '943', + 'question' => '2855', + 'layout' => '0', + 'answers' => array( + 8356 => (object) array( + 'question' => '2855', + 'answer' => 'Use cases.', + 'fraction' => '-0.33333', + 'feedback' => '', + 'id' => 8356, + ), + 8357 => (object) array( + 'question' => '2855', + 'answer' => 'Verb identification.', + 'fraction' => '0.5', + 'feedback' => '', + 'id' => 8357, + ), + 8358 => (object) array( + 'question' => '2855', + 'answer' => 'Misuse cases.', + 'fraction' => '0.5', + 'feedback' => '', + 'id' => 8358, + ), + 8359 => (object) array( + 'question' => '2855', + 'answer' => 'Adjective identification.', + 'fraction' => '-0.33333', + 'feedback' => '', + 'id' => 8359, + ), + 8360 => (object) array( + 'question' => '2855', + 'answer' => 'Noun identification.', + 'fraction' => '-0.33333', + 'feedback' => '', + 'id' => 8360, + ), + ), + 'single' => '0', + 'shuffleanswers' => '0', + 'correctfeedback' => 'Your answer is correct.', + 'partiallycorrectfeedback' => 'Your answer is partially correct.', + 'incorrectfeedback' => 'Your answer is incorrect.', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '30584', + 'attemptid' => '3237', + 'questionid' => '2855', + 'newest' => '72341', + 'newgraded' => '72341', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 72307 => (object) array( + 'attempt' => '3237', + 'question' => '2855', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '8356,8357,8358,8359,8360:', + 'timestamp' => '1177006492', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 72307, + ), + 72318 => (object) array( + 'attempt' => '3237', + 'question' => '2855', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '8356,8357,8358,8359,8360:8357,8359', + 'timestamp' => '1177007066', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0.83335', + 'penalty' => '0', + 'id' => 72318, + ), + 72328 => (object) array( + 'attempt' => '3237', + 'question' => '2855', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '8356,8357,8358,8359,8360:8357,8359', + 'timestamp' => '1177008016', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0.83335', + 'penalty' => '0', + 'id' => 72328, + ), + 72341 => (object) array( + 'attempt' => '3237', + 'question' => '2855', + 'originalquestion' => '0', + 'seq_number' => '3', + 'answer' => '8356,8357,8358,8359,8360:8357,8359', + 'timestamp' => '1177008016', + 'event' => '6', + 'grade' => '0.83335', + 'raw_grade' => '0.83335', + 'penalty' => '0', + 'id' => 72341, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 2855, + 'maxmark' => 5, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'Which of the following techniques can identify non-functional requirements?', + 'rightanswer' => 'Verb identification.; Misuse cases.', + 'responsesummary' => 'Verb identification.; Adjective identification.', + 'timemodified' => 1177008016, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1177006492, + 'userid' => 120555, + 'data' => array('_order' => '8356,8357,8358,8359,8360'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1177007066, + 'userid' => 120555, + 'data' => array('choice0' => 0, 'choice1' => 1, 'choice2' => 0, 'choice3' => 1, 'choice4' => 0), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1177008016, + 'userid' => 120555, + 'data' => array('choice0' => 0, 'choice1' => 1, 'choice2' => 0, 'choice3' => 1, 'choice4' => 0), + ), + 3 => (object) array( + 'sequencenumber' => 3, + 'state' => 'gradedpartial', + 'fraction' => 0.16667, + 'timecreated' => 1177008016, + 'userid' => 120555, + 'data' => array('choice0' => 0, 'choice1' => 1, 'choice2' => 0, 'choice3' => 1, 'choice4' => 0, '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_missing() { + $quiz = (object) array( + 'id' => '8', + 'course' => '1095', + 'name' => 'End of course quiz', + 'intro' => 'Use this self-assessment quiz to judge your overall understanding. ', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '1150107600', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71760879', + 'questionsperpage' => '0', + 'shufflequestions' => '1', + 'shuffleanswers' => '1', + 'questions' => '71,72,73,89,74,75,76,92,77,78,79,93,80,90,81,91,94,95,82,83,84,85,86,87,88,0', + 'sumgrades' => '25', + 'grade' => '25', + 'timecreated' => '0', + 'timemodified' => '1150107596', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '17', + 'uniqueid' => '17', + 'quiz' => '8', + 'userid' => '26290', + 'attempt' => '1', + 'sumgrades' => '0', + 'timestart' => '1150203042', + 'timefinish' => '0', + 'timemodified' => '1150203042', + 'layout' => '93,76,82,75,87,74,90,94,73,77,81,95,79,92,88,80,91,86,72,83,84,89,85,78,71,0', + 'preview' => '1', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '72', + 'category' => '10', + 'parent' => '0', + 'name' => 'Q02', + 'questiontext' => 'Why were standards such an important driver in the growth of systems integration?', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+060612113403+Fz0GGO', + 'version' => 'learn.open.ac.uk+060612160802+I6ctMQ', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'id' => '44', + 'question' => '72', + 'layout' => '0', + 'answers' => array( + 200 => (object) array( + 'question' => '72', + 'answer' => 'Because they enable stored data and interfaces to be standardised.', + 'fraction' => '1', + 'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.', + 'id' => 200, + ), + 201 => (object) array( + 'question' => '72', + 'answer' => 'Because they enable the members of an integration team to communicate together.', + 'fraction' => '0', + 'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.', + 'id' => 201, + ), + 202 => (object) array( + 'question' => '72', + 'answer' => 'Because they produce good quality documentation.', + 'fraction' => '0', + 'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.', + 'id' => 202, + ), + ), + 'single' => '1', + 'shuffleanswers' => '1', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + + $qa = $this->updater->supply_missing_question_attempt($quiz, $attempt, $question); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 72, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'Why were standards such an important driver in the growth of systems integration?', + 'rightanswer' => 'Because they enable stored data and interfaces to be standardised.', + 'responsesummary' => '', + 'timemodified' => 1150203042, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1150203042, + 'userid' => 26290, + 'data' => array('_order' => '200,201,202'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + +public function test_multichoice_deferredfeedback_qsession140() { + $quiz = (object) array( + 'id' => '58', + 'course' => '3420', + 'name' => 'Practice Quiz', + 'intro' => '', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'optionflags' => '0', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '3', + 'decimalpoints' => '2', + 'review' => '71760879', + 'questionsperpage' => '2', + 'shufflequestions' => '0', + 'shuffleanswers' => '1', + 'questions' => '178,179,0,180,181,0,182,183,0,184,185,0,189,187,0', + 'sumgrades' => '10', + 'grade' => '10', + 'timecreated' => '0', + 'timemodified' => '1200043605', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + 'preferredbehaviour' => 'deferredfeedback', + ); + $attempt = (object) array( + 'id' => '38', + 'uniqueid' => '38', + 'quiz' => '58', + 'userid' => '51335', + 'attempt' => '1', + 'sumgrades' => '5', + 'timestart' => '1198254245', + 'timefinish' => '1198254438', + 'timemodified' => '1198254352', + 'layout' => '178,179,180,181,182,183,184,185,189,187,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '179', + 'category' => '51', + 'parent' => '0', + 'name' => 'Question 2', + 'questiontext' => '

Where will the 19th International Biology Olympiad be held?

', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'openlearn.open.ac.uk+071210172238+HpCRWO', + 'version' => 'openlearn.open.ac.uk+071211115640+SZulvf', + 'hidden' => '0', + 'generalfeedback' => '

', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'id' => '71', + 'question' => '179', + 'layout' => '0', + 'answers' => array( + 372 => (object) array( + 'question' => '179', + 'answer' => 'Mumbai, India', + 'fraction' => '1', + 'feedback' => '', + 'id' => 372, + ), + 373 => (object) array( + 'question' => '179', + 'answer' => 'Rome, Italy', + 'fraction' => '-1', + 'feedback' => '', + 'id' => 373, + ), + 374 => (object) array( + 'question' => '179', + 'answer' => 'Oslo, Norway', + 'fraction' => '-1', + 'feedback' => '', + 'id' => 374, + ), + 375 => (object) array( + 'question' => '179', + 'answer' => 'Tokyo, Japan', + 'fraction' => '-1', + 'feedback' => '', + 'id' => 375, + ), + ), + 'single' => '1', + 'shuffleanswers' => '1', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '140', + 'attemptid' => '38', + 'questionid' => '179', + 'newest' => '273', + 'newgraded' => '273', + 'sumpenalty' => '0.2', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 243 => (object) array( + 'attempt' => '38', + 'question' => '179', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '375,372,374,373:', + 'timestamp' => '1198254245', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 243, + ), + 254 => (object) array( + 'attempt' => '38', + 'question' => '179', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '375,372,374,373:375', + 'timestamp' => '1198254261', + 'event' => '3', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0.1', + 'id' => 254, + ), + 273 => (object) array( + 'attempt' => '38', + 'question' => '179', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '375,372,374,373:375', + 'timestamp' => '1198254261', + 'event' => '6', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0.1', + 'id' => 273, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 179, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'Where will the 19th International Biology Olympiad be held?', + 'rightanswer' => 'Mumbai, India', + 'responsesummary' => 'Tokyo, Japan', + 'timemodified' => 1198254261, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1198254245, + 'userid' => 51335, + 'data' => array('_order' => '375,372,374,373'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'gradedwrong', + 'fraction' => 0, + 'timecreated' => 1198254261, + 'userid' => 51335, + 'data' => array('answer' => '0', '-finish' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_qsession2018195() { + $quiz = (object) array( + 'id' => '1832', + 'course' => '4912', + 'name' => 'Unit 12 IL & ICT review quiz', + 'intro' => '

This quiz has been developed to help you review your skills development in information literacy and ICT and to gather feedback on the use of the skills activities within K315 and within the Social Work degree Practice Learning courses.

+

We would welcome your input (allow 10-15 minutes). The data you provide will be anonymised and used for research purposes only. This project is administered under the OU’s general data protection policy guidelines, which can be seen here: http://www3.open.ac.uk/our-student-policies/pdf/dataprotection.pdf

', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'optionflags' => '0', + 'penaltyscheme' => '1', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71565312', + 'questionsperpage' => '2', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '26132,26128,0,26143,26140,0,26144,26141,0,26145,26142,0,26126,26127,0,26134,26135,0,26131,26133,0,26130,26129,0,26136,26137,0,26139,26138,0', + 'sumgrades' => '0', + 'grade' => '0', + 'timecreated' => '0', + 'timemodified' => '1232636874', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + 'preferredbehaviour' => 'deferredfeedback', + ); + $attempt = (object) array( + 'id' => '174744', + 'uniqueid' => '174745', + 'quiz' => '1832', + 'userid' => '181806', + 'attempt' => '1', + 'sumgrades' => '0', + 'timestart' => '1249488674', + 'timefinish' => '1250702880', + 'timemodified' => '1249488674', + 'layout' => '26132,26128,0,26143,26140,0,26144,26141,0,26145,26142,0,26126,26127,0,26134,26135,0,26131,26133,0,26130,26129,0,26136,26137,0,26139,26138,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '26132', + 'category' => '2506', + 'parent' => '0', + 'name' => '01 most useful', + 'questiontext' => 'Which was the most useful K315 information literacy or ICT activity?', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+080529101041+d4XuNI', + 'version' => 'learn.open.ac.uk+100725192556+KIetVC', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1212055841', + 'timemodified' => '1280085956', + 'createdby' => '28856', + 'modifiedby' => '25299', + 'unlimited' => '0', + 'maxmark' => '0', + 'options' => (object) array( + 'id' => '11628', + 'question' => '26132', + 'layout' => '0', + 'answers' => array( + 77406 => (object) array( + 'question' => '26132', + 'answer' => 'Introduction to & evaluation of MyStuff (Course Introduction)', + 'fraction' => '0', + 'feedback' => '', + 'id' => 77406, + ), + 77407 => (object) array( + 'question' => '26132', + 'answer' => 'Values Exchange case studies', + 'fraction' => '1', + 'feedback' => '', + 'id' => 77407, + ), + 77408 => (object) array( + 'question' => '26132', + 'answer' => 'Secure accommodation orders (Unit 2, Activity 3.3)', + 'fraction' => '0', + 'feedback' => '', + 'id' => 77408, + ), + 77409 => (object) array( + 'question' => '26132', + 'answer' => 'Advanced search tools (Unit 3, Activity 1.3)', + 'fraction' => '0', + 'feedback' => '', + 'id' => 77409, + ), + 77410 => (object) array( + 'question' => '26132', + 'answer' => 'Different types of information (Unit 7, Activity 1.2)', + 'fraction' => '0', + 'feedback' => '', + 'id' => 77410, + ), + 77411 => (object) array( + 'question' => '26132', + 'answer' => 'Informing your practice with empirical evidence (Unit 8, Activity 3.1)', + 'fraction' => '0', + 'feedback' => '', + 'id' => 77411, + ), + 77412 => (object) array( + 'question' => '26132', + 'answer' => 'Reviewing and saving your work (Unit 12, Activity 2.2)', + 'fraction' => '0', + 'feedback' => '', + 'id' => 77412, + ), + ), + 'single' => '1', + 'shuffleanswers' => '0', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '2018195', + 'attemptid' => '174745', + 'questionid' => '26132', + 'newest' => '5162301', + 'newgraded' => '5162301', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 5107187 => (object) array( + 'attempt' => '174745', + 'question' => '26132', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '77406,77407,77408,77409,77410,77411,77412:', + 'timestamp' => '1249488674', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 5107187, + ), + 5107188 => (object) array( + 'attempt' => '174745', + 'question' => '26132', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '', + 'timestamp' => '1249488674', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 5107188, + ), + 5107190 => (object) array( + 'attempt' => '174745', + 'question' => '26132', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '77406,77407,77408,77409,77410,77411,77412:77407', + 'timestamp' => '1249488763', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 5107190, + ), + 5162301 => (object) array( + 'attempt' => '174745', + 'question' => '26132', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '77406,77407,77408,77409,77410,77411,77412:77407', + 'timestamp' => '1249488763', + 'event' => '6', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 5162301, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 26132, + 'maxmark' => 0, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'Which was the most useful K315 information literacy or ICT activity?', + 'rightanswer' => 'Values Exchange case studies', + 'responsesummary' => 'Values Exchange case studies', + 'timemodified' => 1249488763, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1249488674, + 'userid' => 181806, + 'data' => array('_order' => '77406,77407,77408,77409,77410,77411,77412'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1249488763, + 'userid' => 181806, + 'data' => array('answer' => '1'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'finished', + 'fraction' => null, + 'timecreated' => 1249488763, + 'userid' => 181806, + 'data' => array('answer' => '1', '-finish' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_qsession2653368() { + $quiz = (object) array( + 'id' => '3273', + 'course' => '5862', + 'name' => 'Assessing information sources', + 'intro' => 'Assessing information sources - literature review table', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'optionflags' => '0', + 'penaltyscheme' => '1', + 'attempts' => '0', + 'attemptonlast' => '1', + 'grademethod' => '4', + 'decimalpoints' => '2', + 'review' => '71727591', + 'questionsperpage' => '0', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '60135,60136,60137,0', + 'sumgrades' => '3', + 'grade' => '10', + 'timecreated' => '0', + 'timemodified' => '1223992271', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + 'preferredbehaviour' => 'deferredfeedback', + ); + $attempt = (object) array( + 'id' => '229025', + 'uniqueid' => '229026', + 'quiz' => '3273', + 'userid' => '597153', + 'attempt' => '4', + 'sumgrades' => '0.999999', + 'timestart' => '1258492857', + 'timefinish' => '1258492862', + 'timemodified' => '1258492857', + 'layout' => '60135,60136,60137,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '60137', + 'category' => '6026', + 'parent' => '0', + 'name' => 'Assessing information sources - No. 3', + 'questiontext' => 'For source 3, the \'Loose Change\' video, select the statements to indicate \'yes\':', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+080811153454+BMEq1t', + 'version' => 'learn.open.ac.uk+081010072800+oSu1g3', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1218468894', + 'timemodified' => '1223623680', + 'createdby' => '26409', + 'modifiedby' => '351133', + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'id' => '23896', + 'question' => '60137', + 'layout' => '0', + 'answers' => array( + 181821 => (object) array( + 'question' => '60137', + 'answer' => 'Would you regard this source as objective?', + 'fraction' => '0.142857', + 'feedback' => '', + 'id' => 181821, + ), + 181822 => (object) array( + 'question' => '60137', + 'answer' => 'Does the source provide references?', + 'fraction' => '0.142857', + 'feedback' => '', + 'id' => 181822, + ), + 181823 => (object) array( + 'question' => '60137', + 'answer' => 'Are all viewpoints considered?', + 'fraction' => '0.142857', + 'feedback' => '', + 'id' => 181823, + ), + 181824 => (object) array( + 'question' => '60137', + 'answer' => 'Are quotations placed in their full context?', + 'fraction' => '0.142857', + 'feedback' => '', + 'id' => 181824, + ), + 181825 => (object) array( + 'question' => '60137', + 'answer' => 'Does the source include conclusions based on evidence?', + 'fraction' => '0.142857', + 'feedback' => '', + 'id' => 181825, + ), + 181826 => (object) array( + 'question' => '60137', + 'answer' => 'Would you trust this source?', + 'fraction' => '0.142857', + 'feedback' => '', + 'id' => 181826, + ), + 181827 => (object) array( + 'question' => '60137', + 'answer' => 'Has it been peer-reviewed?', + 'fraction' => '0.142857', + 'feedback' => '', + 'id' => 181827, + ), + ), + 'single' => '0', + 'shuffleanswers' => '0', + 'correctfeedback' => 'This is a very polemical source which clearly has a standpoint. Whether or not you would use this material would be largely dependent on your reseach question. If you did use it, you would need to be clear that you would require academic sources that would support the claims being made.
', + 'partiallycorrectfeedback' => 'This is a very polemical source which clearly has a standpoint. Whether or not you would use this material would be largely dependent on your reseach question. If you did use it, you would need to be clear that you would require academic sources that would support the claims being made.

', + 'incorrectfeedback' => 'This is a very polemical source which clearly has a standpoint. Whether or not you would use this material would be largely dependent on your reseach question. If you did use it, you would need to be clear that you would require academic sources that would support the claims being made.

', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '2653368', + 'attemptid' => '229026', + 'questionid' => '60137', + 'newest' => '6676055', + 'newgraded' => '6676055', + 'sumpenalty' => '0.1', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 6676031 => (object) array( + 'attempt' => '229026', + 'question' => '60137', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '181821,181822,181823,181824,181825,181826,181827:181821,181822,181823,181824,181825,181826', + 'timestamp' => '1258492857', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0.857142', + 'penalty' => '0', + 'id' => 6676031, + ), + 6676034 => (object) array( + 'attempt' => '229026', + 'question' => '60137', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '181821,181822,181823,181824,181825,181826,181827:', + 'timestamp' => '1258492857', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0.1', + 'id' => 6676034, + ), + 6676055 => (object) array( + 'attempt' => '229026', + 'question' => '60137', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '181821,181822,181823,181824,181825,181826,181827:', + 'timestamp' => '1258492857', + 'event' => '6', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0.1', + 'id' => 6676055, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 60137, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => "For source 3, the 'Loose Change' video, select the statements to indicate 'yes':", + 'rightanswer' => 'Would you regard this source as objective?; Does the source provide references?; Are all viewpoints considered?; Are quotations placed in their full context?; Does the source include conclusions based on evidence?; Would you trust this source?; Has it been peer-reviewed?', + 'responsesummary' => 'Would you regard this source as objective?; Does the source provide references?; Are all viewpoints considered?; Are quotations placed in their full context?; Does the source include conclusions based on evidence?; Would you trust this source?', + 'timemodified' => 1258492857, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1258492857, + 'userid' => 597153, + 'data' => array('_order' => '181821,181822,181823,181824,181825,181826,181827'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'gradedwrong', + 'fraction' => 0, + 'timecreated' => 1258492857, + 'userid' => 597153, + 'data' => array('choice0' => 0, 'choice1' => 0, 'choice2' => 0, 'choice3' => 0, 'choice4' => 0, 'choice5' => 0, 'choice6' => 0, '-finish' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_qsession3131() { + $quiz = (object) array( + 'id' => '10', + 'course' => '608', + 'name' => 'TMA 01, Part 1 (Activity 12)', + 'intro' => '

Activity 12 is a multiple-choice assessment quiz. It is Part 1 of TMA 01 and contributes 20 per cent of the marks for the TMA. It invites you to check your understandings of the topics with which you engaged in Activities 6–11.

+ +

Activity 12 is distinctive in that you are welcome to try as much as you want at any one time and to try as often as you wish. However, you have to get full marks on it in order to proceed to the second part of TMA 01, Activity 15.

+ +

There are 30 questions, which can be attempted in any order. When you are ready to attempt a question, choose your answer and then \'Submit\'. You will get feedback. If you need to try again, follow the same process. When you are satisfied with your answer to one question, go on to another. Remember to choose \'Submit\' for each answer that you want to be saved.

+ +

You do not have to do the questions all at one sitting: at any time you can choose \'Save without submitting\'. This saves the current state of all questions so you can come back later to do some more.

+ +

When you are satisfied with your answers to all 30 questions, choose \'Submit all and finish\'. This marks all questions, closes the current quiz attempt and gives the PCAP team formal notification that you have successfully completed this part of the TMA. Should you inadvertently choose this option you will need to start from scratch when you next attempt the task.

', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'optionflags' => '0', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '2', + 'decimalpoints' => '2', + 'review' => '71760879', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '1', + 'questions' => '161,0,160,0,162,0,163,0,164,0,165,0,166,0,190,0,191,0,192,0,193,0,194,0,195,0,196,0,197,0,198,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,0,179,0,180,0,181,0', + 'sumgrades' => '30', + 'grade' => '10', + 'timecreated' => '0', + 'timemodified' => '1266247621', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + 'preferredbehaviour' => 'deferredfeedback', + ); + $attempt = (object) array( + 'id' => '302', + 'uniqueid' => '302', + 'quiz' => '10', + 'userid' => '63173', + 'attempt' => '1', + 'sumgrades' => '30', + 'timestart' => '1163428543', + 'timefinish' => '1166546613', + 'timemodified' => '1166546472', + 'layout' => '161,0,160,0,162,0,163,0,164,0,165,0,166,0,190,0,191,0,192,0,193,0,194,0,195,0,196,0,197,0,198,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,0,179,0,180,0,181,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '163', + 'category' => '15', + 'parent' => '0', + 'name' => 'Question 04', + 'questiontext' => 'Can we have a \'realist\' or objective social science?', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+060614160624+gkAYii', + 'version' => 'learn.open.ac.uk+060614160624+LYm8Rl', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'id' => '117', + 'question' => '163', + 'layout' => '0', + 'answers' => array( + 456 => (object) array( + 'question' => '163', + 'answer' => 'No', + 'fraction' => '0', + 'feedback' => 'This is a common position but it does overlook areas in which it is possible to observe, tally and describe in pretty objective (low-inference) ways. Much social geography is of this sort.', + 'id' => 456, + ), + 457 => (object) array( + 'question' => '163', + 'answer' => 'Yes', + 'fraction' => '0', + 'feedback' => 'A great deal of social science is to do with making sense of subjective phenomena. We might expect social scientists to be honest and careful but, where subjective phenomena are concerned there can be no objective truth. However, there are areas in which it is possible to observe, tally and describe in pretty objective (low-inference) ways. Much social geography is of this sort.', + 'id' => 457, + ), + 458 => (object) array( + 'question' => '163', + 'answer' => 'Sometimes', + 'fraction' => '1', + 'feedback' => 'This is a judicious response to two positions, each of which has strengths but neither of which covers the range of social science practices.', + 'id' => 458, + ), + ), + 'single' => '1', + 'shuffleanswers' => '0', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '3131', + 'attemptid' => '302', + 'questionid' => '163', + 'newest' => '14715', + 'newgraded' => '14715', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 5922 => (object) array( + 'attempt' => '302', + 'question' => '163', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '456,457,458:', + 'timestamp' => '1163428543', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 5922, + ), + 5941 => (object) array( + 'attempt' => '302', + 'question' => '163', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '456,457,458:', + 'timestamp' => '1163428576', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '1', + 'id' => 5941, + ), + 5942 => (object) array( + 'attempt' => '302', + 'question' => '163', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '456,457,458:', + 'timestamp' => '1163428577', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '1', + 'id' => 5942, + ), + 14713 => (object) array( + 'attempt' => '302', + 'question' => '163', + 'originalquestion' => '0', + 'seq_number' => '3', + 'answer' => '456,457,458:456', + 'timestamp' => '1165355190', + 'event' => '3', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '1', + 'id' => 14713, + ), + 14715 => (object) array( + 'attempt' => '302', + 'question' => '163', + 'originalquestion' => '0', + 'seq_number' => '4', + 'answer' => '456,457,458:458', + 'timestamp' => '1165355352', + 'event' => '3', + 'grade' => '1', + 'raw_grade' => '1', + 'penalty' => '1', + 'id' => 14715, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 163, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'Can we have a \'realist\' or objective social science?', + 'rightanswer' => 'Sometimes', + 'responsesummary' => 'Sometimes', + 'timemodified' => 1165355352, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1163428543, + 'userid' => 63173, + 'data' => array('_order' => '456,457,458'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1163428576, + 'userid' => 63173, + 'data' => array(), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1163428577, + 'userid' => 63173, + 'data' => array(), + ), + 3 => (object) array( + 'sequencenumber' => 3, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1165355352, + 'userid' => 63173, + 'data' => array('answer' => '2', '-finish' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_qsession4307870 () { + $quiz = (object) array( + 'id' => '4070', + 'course' => '5139', + 'name' => 'Reading practice: Session 16', + 'intro' => '', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'optionflags' => '0', + 'penaltyscheme' => '1', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '0', + 'review' => '71727591', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '1', + 'questions' => '89002,0,89040,0,89042,0,89043,0,89044,0,89045,0,89046,0,89047,0', + 'sumgrades' => '8', + 'grade' => '8', + 'timecreated' => '0', + 'timemodified' => '1265136533', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + 'showscores' => '1', + 'preferredbehaviour' => 'deferredfeedback', + ); + $attempt = (object) array( + 'id' => '428769', + 'uniqueid' => '428770', + 'quiz' => '4070', + 'userid' => '605575', + 'attempt' => '3', + 'sumgrades' => '7', + 'timestart' => '1275088684', + 'timefinish' => '1275089588', + 'timemodified' => '1275089451', + 'layout' => '89002,0,89040,0,89042,0,89043,0,89044,0,89045,0,89046,0,89047,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '89040', + 'category' => '6016', + 'parent' => '0', + 'name' => 'R2S16', + 'questiontext' => '

Read the text below and then answer the question based on the information given.

我大哥没有我二哥高,我比我二哥高。

Who is the tallest?

', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.33', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+100204101142+Bygd63', + 'version' => 'learn.open.ac.uk+100204101142+exBG6F', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1265278302', + 'timemodified' => '1265278302', + 'createdby' => '532546', + 'modifiedby' => '532546', + 'unlimited' => '0', + 'maxmark' => '1', + 'options' => (object) array( + 'id' => '33730', + 'question' => '89040', + 'layout' => '0', + 'answers' => array( + 300601 => (object) array( + 'question' => '89040', + 'answer' => '我。', + 'fraction' => '1', + 'feedback' => '', + 'id' => 300601, + ), + 300602 => (object) array( + 'question' => '89040', + 'answer' => '我大哥。', + 'fraction' => '0', + 'feedback' => '', + 'id' => 300602, + ), + 300603 => (object) array( + 'question' => '89040', + 'answer' => '我二哥。', + 'fraction' => '0', + 'feedback' => '', + 'id' => 300603, + ), + ), + 'single' => '1', + 'shuffleanswers' => '1', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'none', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '4307870', + 'attemptid' => '428770', + 'questionid' => '89040', + 'newest' => '11002905', + 'newgraded' => '11002905', + 'sumpenalty' => '0.33', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 11002780 => (object) array( + 'attempt' => '428770', + 'question' => '89040', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '300603,300602,300601:', + 'timestamp' => '1275088684', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 11002780, + ), + 11002813 => (object) array( + 'attempt' => '428770', + 'question' => '89040', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '300601', + 'timestamp' => '1275089101', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '1', + 'penalty' => '0.33', + 'id' => 11002813, + ), + 11002905 => (object) array( + 'attempt' => '428770', + 'question' => '89040', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '300603,300602,300601:300601', + 'timestamp' => '1275089101', + 'event' => '6', + 'grade' => '1', + 'raw_grade' => '1', + 'penalty' => '0.33', + 'id' => 11002905, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 89040, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => "Read the text below and then answer the question based on the information given.\n\n我大哥没有我二哥高,我比我二哥高。\n\nWho is the tallest?", + 'rightanswer' => '我。', + 'responsesummary' => '我。', + 'timemodified' => 1275089101, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1275088684, + 'userid' => 605575, + 'data' => array('_order' => '300603,300602,300601'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1275089101, + 'userid' => 605575, + 'data' => array('answer' => '2'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1275089101, + 'userid' => 605575, + 'data' => array('answer' => '2', '-finish' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_qsession49446() { + $quiz = (object) array( + 'id' => '203', + 'course' => '2359', + 'name' => 'Quiz 1', + 'intro' => '', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '1', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71760879', + 'questionsperpage' => '2', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '3859,3860,0,3861,3862,0,3863,3864,0,3865,3866,0,3867,3868,0', + 'sumgrades' => '50', + 'grade' => '50', + 'timecreated' => '0', + 'timemodified' => '1176461532', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '4338', + 'uniqueid' => '4338', + 'quiz' => '203', + 'userid' => '30631', + 'attempt' => '2', + 'sumgrades' => '30', + 'timestart' => '1179303963', + 'timefinish' => '1179303960', + 'timemodified' => '1179303420', + 'layout' => '3859,3860,0,3861,3862,0,3863,3864,0,3865,3866,0,3867,3868,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '3863', + 'category' => '187', + 'parent' => '0', + 'name' => 'Question 5', + 'questiontext' => 'What is SOAP?', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+070404142540+CpseAv', + 'version' => 'learn.open.ac.uk+070405112519+qNb2kt', + 'hidden' => '0', + 'generalfeedback' => '

', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '5', + 'options' => (object) array( + 'id' => '1439', + 'question' => '3863', + 'layout' => '0', + 'answers' => array( + 11686 => (object) array( + 'question' => '3863', + 'answer' => 'It is a technology used for sending bulk data through the internet.', + 'fraction' => '0', + 'feedback' => 'Your answer is incorrect.
The correct answer is b. ', + 'id' => 11686, + ), + 11687 => (object) array( + 'question' => '3863', + 'answer' => 'It is the transport mechanism used with web services.', + 'fraction' => '1', + 'feedback' => 'Your answer is correct ', + 'id' => 11687, + ), + 11688 => (object) array( + 'question' => '3863', + 'answer' => 'It is a distributed object technology', + 'fraction' => '0', + 'feedback' => 'Your answer is incorrect.
The correct answer is b. ', + 'id' => 11688, + ), + ), + 'single' => '1', + 'shuffleanswers' => '0', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + 'answernumbering' => 'abc', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '49446', + 'attemptid' => '4338', + 'questionid' => '3863', + 'newest' => '112195', + 'newgraded' => '112195', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 112159 => (object) array( + 'attempt' => '4338', + 'question' => '3863', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '11686,11687,11688:', + 'timestamp' => '1179303963', + 'event' => '8', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 112159, + ), + 112164 => (object) array( + 'attempt' => '4338', + 'question' => '3863', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '11686,11687,11688:', + 'timestamp' => '1179303963', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 112164, + ), + 112176 => (object) array( + 'attempt' => '4338', + 'question' => '3863', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '11686,11687,11688:11687', + 'timestamp' => '1179303218', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '5', + 'penalty' => '0', + 'id' => 112176, + ), + 112195 => (object) array( + 'attempt' => '4338', + 'question' => '3863', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '11686,11687,11688:11687', + 'timestamp' => '1179303218', + 'event' => '6', + 'grade' => '5', + 'raw_grade' => '5', + 'penalty' => '0', + 'id' => 112195, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 3863, + 'maxmark' => 5, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'What is SOAP?', + 'rightanswer' => 'It is the transport mechanism used with web services.', + 'responsesummary' => 'It is the transport mechanism used with web services.', + 'timemodified' => 1179303963, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1179303963, + 'userid' => 30631, + 'data' => array('_order' => '11686,11687,11688'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1179303218, + 'userid' => 30631, + 'data' => array('answer' => 1), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1179303218, + 'userid' => 30631, + 'data' => array('answer' => 1, '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_qsession591() { + $quiz = (object) array( + 'id' => '22', + 'course' => '272', + 'name' => 'ICT self-assessment quiz', + 'intro' => '

Work through the ICT skills self-assessment quiz in order to assess your ability to use ICT for study on the Youth Justice Programme. Doing this will also help you to plan a short programme of learning.

+

Use the questions to rate your ability in each area as either:

+ +

Once you have done that, and seen the feedback associated with your answers, you will need to think about prioritising the skills that need development. You will also need to allocate some time in order to develop the skills you need to concentrate on. Within the feedback for each question are some subject-related links which you may find useful.

', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '4', + 'decimalpoints' => '0', + 'review' => '71760879', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '242,0,243,0,244,0,245,0,246,0,247,0', + 'sumgrades' => '0', + 'grade' => '0', + 'timecreated' => '0', + 'timemodified' => '1174581121', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '95', + 'uniqueid' => '94', + 'quiz' => '22', + 'userid' => '9721', + 'attempt' => '1', + 'timestart' => '1177777016', + 'timefinish' => '1177777128', + 'timemodified' => '1177777101', + 'layout' => '242,0,243,0,244,0,245,0,246,0,247,0', + 'preview' => '0', + 'sumgrades' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '247', + 'category' => '12', + 'parent' => '0', + 'name' => 'Regular access to a computer', + 'questiontext' => '[CUT]', + 'questiontextformat' => '1', + 'defaultmark' => '0', + 'penalty' => '0', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+070321164105+qIeJ9g', + 'hidden' => '0', + 'version' => 'learn.open.ac.uk+070427170153+plBFqV', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '0', + 'options' => (object) array( + 'id' => '180', + 'question' => '247', + 'layout' => '0', + 'answers' => array( + 666 => (object) array( + 'question' => '247', + 'answer' => 'Well developed', + 'feedback' => 'It\'s good that you don\'t feel as though you will have problems accessing a computer in order to study within the Youth Justice Programme. However, you may find the OU Library\'s information page on Using public access computers in libraries and other venues of interest.', + 'fraction' => '1', + 'id' => 666, + ), + 667 => (object) array( + 'question' => '247', + 'answer' => 'Not sure', + 'feedback' => 'We recommend that you visit the OU Library\'s information page on Using public access computers in libraries and other venues.', + 'fraction' => '1', + 'id' => 667, + ), + 668 => (object) array( + 'question' => '247', + 'answer' => 'Needs development', + 'feedback' => 'We recommend that you visit the OU Library\'s information page on Using public access computers in libraries and other venues.', + 'fraction' => '1', + 'id' => 668, + ), + ), + 'single' => '1', + 'shuffleanswers' => '0', + 'answernumbering' => 'abc', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '591', + 'attemptid' => '94', + 'questionid' => '247', + 'newest' => '1220', + 'newgraded' => '1220', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 1208 => (object) array( + 'attempt' => '94', + 'question' => '247', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '666,667,668:', + 'timestamp' => '1177777016', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 1208, + ), + 1219 => (object) array( + 'attempt' => '94', + 'question' => '247', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '666,667,668:666', + 'timestamp' => '1177777116', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 1219, + ), + 1220 => (object) array( + 'attempt' => '94', + 'question' => '247', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '666,667,668:666', + 'timestamp' => '1177777116', + 'event' => '6', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 1220, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 247, + 'maxmark' => 0, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => '[CUT]', + 'rightanswer' => 'Well developed', + 'responsesummary' => 'Well developed', + 'timemodified' => 1177777116, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1177777016, + 'userid' => 9721, + 'data' => array('_order' => '666,667,668'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1177777116, + 'userid' => 9721, + 'data' => array('answer' => 0), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'finished', + 'fraction' => null, + 'timecreated' => 1177777116, + 'userid' => 9721, + 'data' => array('answer' => 0, '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_multichoice_deferredfeedback_qsession594() { + $quiz = (object) array( + 'id' => '22', + 'course' => '272', + 'name' => 'ICT self-assessment quiz', + 'intro' => '

Work through the ICT skills self-assessment quiz in order to assess your ability to use ICT for study on the Youth Justice Programme. Doing this will also help you to plan a short programme of learning.

+

Use the questions to rate your ability in each area as either:

+ +

Once you have done that, and seen the feedback associated with your answers, you will need to think about prioritising the skills that need development. You will also need to allocate some time in order to develop the skills you need to concentrate on. Within the feedback for each question are some subject-related links which you may find useful.

', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '4', + 'decimalpoints' => '0', + 'review' => '71760879', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '242,0,243,0,244,0,245,0,246,0,247,0', + 'sumgrades' => '0', + 'grade' => '0', + 'timecreated' => '0', + 'timemodified' => '1174581121', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '95', + 'uniqueid' => '94', + 'quiz' => '22', + 'userid' => '9721', + 'attempt' => '1', + 'timestart' => '1177777016', + 'timefinish' => '1177777128', + 'timemodified' => '1177777101', + 'layout' => '242,0,243,0,244,0,245,0,246,0,247,0', + 'preview' => '0', + 'sumgrades' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '242', + 'category' => '12', + 'parent' => '0', + 'name' => 'Using the internet', + 'questiontext' => '

Using the internet

+

Many study resources are available online, and you will also be expected to find things out yourself using the web.

+

How would you rate your skills in using browsers and managing documents you find on the internet?

', + 'questiontextformat' => '1', + 'defaultmark' => '0', + 'penalty' => '0', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+070321161800+WlAJ5D', + 'hidden' => '0', + 'version' => 'learn.open.ac.uk+070329133200+dO4WQO', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '0', + 'options' => (object) array( + 'id' => '175', + 'question' => '242', + 'layout' => '0', + 'answers' => array( + 651 => (object) array( + 'question' => '242', + 'answer' => 'Well developed', + 'feedback' => 'You obviously feel confident about using the internet in order to manage your documentation and find information on the World Wide Web. However, you may still find the OU\'s Web Guide site of interest.', + 'fraction' => '1', + 'id' => 651, + ), + 652 => (object) array( + 'question' => '242', + 'answer' => 'Not sure', + 'feedback' => 'We recommend that you visit the OU\'s Web Guide site and work through some of the tips and advice about using the web effectively.', + 'fraction' => '1', + 'id' => 652, + ), + 653 => (object) array( + 'question' => '242', + 'answer' => 'Needs development', + 'feedback' => 'We recommend that you visit the OU\'s Web Guide site and work through some of the tips and advice about using the web effectively.', + 'fraction' => '1', + 'id' => 653, + ), + ), + 'single' => '1', + 'shuffleanswers' => '0', + 'answernumbering' => 'abc', + 'correctfeedback' => '', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => '', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '594', + 'attemptid' => '94', + 'questionid' => '242', + 'newest' => '1223', + 'newgraded' => '1223', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 1211 => (object) array( + 'attempt' => '94', + 'question' => '242', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '651,652,653:', + 'timestamp' => '1177777016', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 1211, + ), + 1214 => (object) array( + 'attempt' => '94', + 'question' => '242', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '651,652,653:651', + 'timestamp' => '1177777040', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 1214, + ), + 1223 => (object) array( + 'attempt' => '94', + 'question' => '242', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => '651,652,653:651', + 'timestamp' => '1177777040', + 'event' => '6', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 1223, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 242, + 'maxmark' => 0, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => "USING THE INTERNET \n\nMany study resources are available online, and you will also be expected to find things out yourself using the web. \n\n_How would you rate your skills in using browsers and managing documents you find on the internet? _", + 'rightanswer' => 'Well developed', + 'responsesummary' => 'Well developed', + 'timemodified' => 1177777040, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1177777016, + 'userid' => 9721, + 'data' => array('_order' => '651,652,653'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1177777040, + 'userid' => 9721, + 'data' => array('answer' => '0'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'finished', + 'fraction' => null, + 'timecreated' => 1177777040, + 'userid' => 9721, + 'data' => array('answer' => '0', '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } +} diff --git a/question/type/random/db/simpletest/testupgradelibnewqe.php b/question/type/random/db/simpletest/testupgradelibnewqe.php new file mode 100644 index 00000000000..d46dc64e773 --- /dev/null +++ b/question/type/random/db/simpletest/testupgradelibnewqe.php @@ -0,0 +1,785 @@ +. + +/** + * Tests of the upgrade to the new Moodle question engine for attempts at + * random questions. + * + * @package qtype + * @subpackage random + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + +require_once($CFG->dirroot . '/question/engine/upgrade/simpletest/helper.php'); + + +/** + * Testing the upgrade of random question attempts. + * + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class qtype_random_attempt_upgrader_test extends question_attempt_upgrader_test_base { + + public function test_random_deferredfeedback_history620() { + $quiz = (object) array( + 'id' => '2177', + 'course' => '5174', + 'name' => 'iCMA 41', + 'intro' => '

Welcome. This is the first K101 Interactive Computer Marked Assignment (iCMA).

+

After the open date, begin by clicking Start attempt and a pop-up box will appear. Click OK and this will take you to the questions.

+

', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '1236556800', + 'timeclose' => '1238713140', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '1', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '0', + 'review' => '67268673', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '28698,0,34245,0,34248,0,35005,0,35009,0,35013,0', + 'sumgrades' => '5', + 'grade' => '100', + 'timecreated' => '0', + 'timemodified' => '1236269160', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '125687', + 'uniqueid' => '125688', + 'quiz' => '2177', + 'userid' => '509191', + 'attempt' => '1', + 'sumgrades' => '5', + 'timestart' => '1236590532', + 'timefinish' => '1238184306', + 'timemodified' => '1238182560', + 'layout' => '28698,0,34245,0,34248,0,35005,0,35009,0,35013,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '34248', + 'category' => '3762', + 'parent' => '34248', + 'name' => 'Random Question (Q2)', + 'questiontext' => '1', + 'questiontextformat' => '0', + 'defaultmark' => '1', + 'penalty' => '0', + 'qtype' => 'random', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+090218115858+6H1FBE', + 'version' => 'learn.open.ac.uk+090218115858+REDwJ6', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1234958338', + 'timemodified' => '1234958338', + 'createdby' => '219095', + 'modifiedby' => '219095', + 'unlimited' => '0', + 'maxmark' => '1', + ); + $qsession = (object) array( + 'id' => '1512603', + 'attemptid' => '125688', + 'questionid' => '34248', + 'newest' => '4010008', + 'newgraded' => '4010008', + 'sumpenalty' => '0.1', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 3820084 => (object) array( + 'attempt' => '125688', + 'question' => '34248', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => 'random34999-103135,103136,103137:', + 'timestamp' => '1236590532', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 3820084, + ), + 4009916 => (object) array( + 'attempt' => '125688', + 'question' => '34248', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => 'random34999-103135,103136,103137:103137', + 'timestamp' => '1238182723', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '1', + 'penalty' => '0.1', + 'id' => 4009916, + ), + 4010008 => (object) array( + 'attempt' => '125688', + 'question' => '34248', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => 'random34999-103135,103136,103137:103137', + 'timestamp' => '1238182723', + 'event' => '6', + 'grade' => '1', + 'raw_grade' => '1', + 'penalty' => '0.1', + 'id' => 4010008, + ), + ); + $realquestion = (object) array( + 'id' => '34999', + 'category' => '3762', + 'parent' => '0', + 'name' => 'K101 iCMA41 Qs 2-v2', + 'questiontext' => '

(Notice in the panel at the left that the question you have just done is now greyed out. Remember that you can revisit any questions by clicking on the numbered boxes. Click Q1 now to try this out and then click Q2 to return here.)

+

Table 1 showing Number of households receiving home care (England)

+

(Link to resizable Table 1)

+

Which was the first year when more than a quarter of a million households received care from independent agencies?

', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.1', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+090227173002+mbdE0X', + 'version' => 'learn.open.ac.uk+090304190917+xAB5Nf', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1235755802', + 'timemodified' => '1236193757', + 'createdby' => '25299', + 'modifiedby' => '25299', + 'unlimited' => '0', + 'options' => (object) array( + 'id' => '15211', + 'question' => '34999', + 'layout' => '0', + 'answers' => array( + 103135 => (object) array( + 'question' => '34999', + 'answer' => '2001', + 'fraction' => '0', + 'feedback' => '', + 'id' => 103135, + ), + 103136 => (object) array( + 'question' => '34999', + 'answer' => '2003', + 'fraction' => '0', + 'feedback' => '', + 'id' => 103136, + ), + 103137 => (object) array( + 'question' => '34999', + 'answer' => '2005', + 'fraction' => '1', + 'feedback' => '', + 'id' => 103137, + ), + ), + 'single' => '1', + 'shuffleanswers' => '1', + 'correctfeedback' => 'Your answer is correct. Well done.', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => 'Your answer is incorrect. The correct answer is: 2005.', + 'answernumbering' => 'abc', + ), + ); + $this->loader->put_question_in_cache($realquestion); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 34999, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => "(Notice in the panel at the left that the question you have just done is now greyed out. Remember that you can REVISIT ANY QUESTIONS by clicking on the NUMBERED BOXES. Click Q1 now to try this out and then click Q2 to return here.) \n\n[Table 1 showing Number of households receiving home care (England)] \n\n() \n\nWhich was the first year when more than a quarter of a million households received care from independent agencies?", + 'rightanswer' => '2005', + 'responsesummary' => '2005', + 'timemodified' => 1238182723, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1236590532, + 'userid' => 509191, + 'data' => array('_order' => '103135,103136,103137'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1238182723, + 'userid' => 509191, + 'data' => array('answer' => 2), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1238182723, + 'userid' => 509191, + 'data' => array('answer' => 2, '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_random_deferredfeedback_qsession4225582() { + $quiz = (object) array( + 'id' => '4410', + 'course' => '5444', + 'name' => 'Block 3, Session 5 Quiz', + 'intro' => 'Pour chacune des questions suivantes vous avez trois réponses possibles. Cochez la bonne. (Cliquez sur « Check » pour vérifier votre réponse.)', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '0', + 'timeclose' => '0', + 'optionflags' => '0', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71727591', + 'questionsperpage' => '3', + 'shufflequestions' => '1', + 'shuffleanswers' => '1', + 'questions' => '101983,101984,101985,0,101986,101987,101988,0,101989,101990,101991,0,101992,101993,101994,0,101995,101996,101997,0', + 'sumgrades' => '15', + 'grade' => '10', + 'timecreated' => '0', + 'timemodified' => '1269429396', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + 'preferredbehaviour' => 'deferredfeedback', + ); + $attempt = (object) array( + 'id' => '418702', + 'uniqueid' => '418703', + 'quiz' => '4410', + 'userid' => '62892', + 'attempt' => '2', + 'sumgrades' => '9', + 'timestart' => '1274178725', + 'timefinish' => '1274179255', + 'timemodified' => '1274178763', + 'layout' => '101989,101985,101994,0,101988,101986,101992,0,101997,101990,101991,0,101984,101995,101987,0,101983,101993,101996,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '101984', + 'category' => '9148', + 'parent' => '101984', + 'name' => 'Random Question (Block 3, Session 5 Quiz)', + 'questiontext' => '1', + 'questiontextformat' => '0', + 'image' => '', + 'defaultmark' => '1', + 'penalty' => '0', + 'qtype' => 'random', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+100416133531+H1yive', + 'version' => 'learn.open.ac.uk+100416133531+KrpbHq', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1271424931', + 'timemodified' => '1271424931', + 'createdby' => '220574', + 'modifiedby' => '220574', + 'unlimited' => '0', + 'maxmark' => '1', + ); + $qsession = (object) array( + 'id' => '4225582', + 'attemptid' => '418703', + 'questionid' => '101984', + 'newest' => '10786541', + 'newgraded' => '10786541', + 'sumpenalty' => '0.33', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 10786382 => (object) array( + 'attempt' => '418703', + 'question' => '101984', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => 'random98355-341067,341066,341068:', + 'timestamp' => '1274178725', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 10786382, + ), + 10786398 => (object) array( + 'attempt' => '418703', + 'question' => '101984', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => 'random98355-341067,341066,341068:341061', + 'timestamp' => '1274178725', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0.33', + 'id' => 10786398, + ), + 10786515 => (object) array( + 'attempt' => '418703', + 'question' => '101984', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => 'random98355-341067,341066,341068:341067', + 'timestamp' => '1274179164', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '1', + 'penalty' => '0.33', + 'id' => 10786515, + ), + 10786541 => (object) array( + 'attempt' => '418703', + 'question' => '101984', + 'originalquestion' => '0', + 'seq_number' => '3', + 'answer' => 'random98355-341067,341066,341068:341067', + 'timestamp' => '1274179164', + 'event' => '6', + 'grade' => '1', + 'raw_grade' => '1', + 'penalty' => '0.33', + 'id' => 10786541, + ), + ); + $realquestion = (object) array( + 'id' => '98355', + 'category' => '9148', + 'parent' => '0', + 'name' => '20', + 'questiontext' => 'En France, le covoiturage est une pratique qui a été au départ préconisé par « les écolos et les verts », mais depuis, elle :', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.33', + 'qtype' => 'multichoice', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+100324131532+CExeWh', + 'version' => 'learn.open.ac.uk+100326162411+qEo2Bg', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1269436532', + 'timemodified' => '1269620651', + 'createdby' => '220574', + 'modifiedby' => '220574', + 'unlimited' => '0', + 'options' => (object) array( + 'id' => '37042', + 'question' => '98355', + 'layout' => '0', + 'answers' => array( + 341066 => (object) array( + 'question' => '98355', + 'answer' => 'a été soutenue par les partis de droite.', + 'fraction' => '0', + 'feedback' => '', + 'id' => 341066, + ), + 341067 => (object) array( + 'question' => '98355', + 'answer' => 'n’est plus uniquement un positionnement écologiste.', + 'fraction' => '1', + 'feedback' => '', + 'id' => 341067, + ), + 341068 => (object) array( + 'question' => '98355', + 'answer' => 'est une idée de gauche, du centre, de droite, d’extrême gauche ou d’extrême droite.', + 'fraction' => '0', + 'feedback' => '', + 'id' => 341068, + ), + ), + 'single' => '1', + 'shuffleanswers' => '1', + 'correctfeedback' => 'Vrai.', + 'partiallycorrectfeedback' => '', + 'incorrectfeedback' => 'Faux.', + 'answernumbering' => 'abc', + ), + 'hints' => false, + 'maxmark' => '1', + ); + $this->loader->put_question_in_cache($realquestion); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 98355, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'En France, le covoiturage est une pratique qui a été au départ préconisé par « les écolos et les verts », mais depuis, elle :', + 'rightanswer' => 'n’est plus uniquement un positionnement écologiste.', + 'responsesummary' => 'n’est plus uniquement un positionnement écologiste.', + 'timemodified' => 1274179164, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1274178725, + 'userid' => 62892, + 'data' => array('_order' => '341067,341066,341068'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1274178725, + 'userid' => 62892, + 'data' => array('answer' => '-1'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1274179164, + 'userid' => 62892, + 'data' => array('answer' => '0'), + ), + 3 => (object) array( + 'sequencenumber' => 3, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1274179164, + 'userid' => 62892, + 'data' => array('answer' => '0', '-finish' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_random_deferredfeedback_qsession3481928() { + $quiz = (object) array( + 'id' => '2624', + 'course' => '5233', + 'name' => 'iCMA 42', + 'intro' => '', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '1267056000', + 'timeclose' => '1271890740', + 'optionflags' => '0', + 'attempts' => '1', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '67268673', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '1', + 'questions' => '68646,0,81245,0,81246,0,81247,0,81248,0,81249,0,81250,0,82795,0,82797,0,82798,0,82799,0,82800,0,82801,0,82802,0,82803,0,82804,0,82805,0,82806,0,82807,0', + 'sumgrades' => '18', + 'grade' => '18', + 'timecreated' => '0', + 'timemodified' => '1271852647', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + 'preferredbehaviour' => 'deferredfeedback', + ); + $attempt = (object) array( + 'id' => '331814', + 'uniqueid' => '331815', + 'quiz' => '2624', + 'userid' => '239341', + 'attempt' => '1', + 'sumgrades' => '9.13333', + 'timestart' => '1267605659', + 'timefinish' => '1270202969', + 'timemodified' => '1269508052', + 'layout' => '68646,0,81245,0,81246,0,81247,0,81248,0,81249,0,81250,0,82795,0,82797,0,82798,0,82799,0,82800,0,82801,0,82802,0,82803,0,82804,0,82805,0,82806,0,82807,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '81247', + 'category' => '6882', + 'parent' => '81247', + 'name' => 'Random Question (42.02.03.GraphConvert)', + 'questiontext' => '1', + 'questiontextformat' => '0', + 'image' => '', + 'defaultmark' => '1', + 'penalty' => '0', + 'qtype' => 'random', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+091215084951+AYsG5O', + 'version' => 'learn.open.ac.uk+091215084951+VSqp4u', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '1260866991', + 'timemodified' => '1260866991', + 'createdby' => '27595', + 'modifiedby' => '27595', + 'unlimited' => '0', + 'maxmark' => '1', + ); + $qsession = (object) array( + 'id' => '3481928', + 'attemptid' => '331815', + 'questionid' => '81247', + 'newest' => '9646306', + 'newgraded' => '9646306', + 'sumpenalty' => '0.333333', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 8809801 => (object) array( + 'attempt' => '331815', + 'question' => '81247', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => 'random83248-', + 'timestamp' => '1267605659', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 8809801, + ), + 9081885 => (object) array( + 'attempt' => '331815', + 'question' => '81247', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => '64', + 'timestamp' => '1268384692', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '1', + 'penalty' => '0.333333', + 'id' => 9081885, + ), + 9107452 => (object) array( + 'attempt' => '331815', + 'question' => '81247', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => 'random83248-64', + 'timestamp' => '1268471437', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '1', + 'penalty' => '0.333333', + 'id' => 9107452, + ), + 9646306 => (object) array( + 'attempt' => '331815', + 'question' => '81247', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => 'random83248-64', + 'timestamp' => '1268471437', + 'event' => '6', + 'grade' => '1', + 'raw_grade' => '1', + 'penalty' => '0.333333', + 'id' => 9646306, + ), + ); + $realquestion = (object) array( + 'id' => '83248', + 'category' => '6882', + 'parent' => '0', + 'name' => '42.02.03.GraphConvert.E', + 'questiontext' => '

The figure below shows a graph for converting between miles and kilometres.

 The graph has a horizontal axis, labelled miles, with a scale marked from 0 to 50 in steps of 5, and a vertical axis, labelled kilometres, with a scale from 0 to 80 in steps of 10. The straight line of the graph starts at the origin and slopes up to the right, and appears to pass through the point corresponding to 25 miles and 40 kilometres, and through the point corresponding to 50 miles and 80 kilometres.

By taking a reading from the graph, estimate how many kilometres are equivalent to 40 miles.

Round your answer to the nearest kilometre and type it in the box below.

(Your answer should be a single number, without units.)

', + 'questiontextformat' => '0', + 'defaultmark' => '3', + 'penalty' => '0.333333', + 'qtype' => 'numerical', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+100108135957+SZhkKF', + 'version' => 'learn.open.ac.uk+100108135957+ej40PM', + 'hidden' => '0', + 'generalfeedback' => '

Conversion graph for miles and kilometres.

 The figure is the same as in the question, with some two additional lines drawn. So, the graph has a horizontal axis, labelled miles, with a scale marked from 0 to 50 in steps of 5, and a vertical axis, labelled kilometres, with a scale from 0 to 80 in steps of 10. The straight line of the graph starts at the origin and slopes up to the right, and appears to pass through the point corresponding to 25 miles and 40 kilometres, and through the point corresponding to 50 miles and 80 kilometres. The first additional line is vertical line drawn upwards from the horizontal axis from the point corresponding to 40 miles to the point where it meets the sloping line of the graph. From that point a horizontal line is drawn to meet the vertical axis at the point corresponding to 64 kilometres approximately.

So 40 miles is approximately 64 km.

See Unit 2, Subsection 2.3.

', + 'generalfeedbackformat' => '1', + 'timecreated' => '1262959197', + 'timemodified' => '0', + 'createdby' => '123783', + 'modifiedby' => NULL, + 'unlimited' => '0', + 'options' => (object) array( + 'answers' => array( + 278332 => (object) array( + 'question' => '83248', + 'answer' => '64', + 'fraction' => '1', + 'feedback' => 'Your answer is correct.', + 'tolerance' => '1', + 'id' => 278332, + ), + 278333 => (object) array( + 'question' => '83248', + 'answer' => '64', + 'fraction' => '0', + 'feedback' => 'Your answer is incorrect. It is close, but not quite accurate enough.', + 'tolerance' => '5', + 'id' => 278333, + ), + 278334 => (object) array( + 'question' => '83248', + 'answer' => '25', + 'fraction' => '0', + 'feedback' => 'Your answer is incorrect. Remember you are converting from miles to kilometres.', + 'tolerance' => '5', + 'id' => 278334, + ), + 278335 => (object) array( + 'question' => '83248', + 'answer' => '*', + 'fraction' => '0', + 'feedback' => 'Your answer is incorrect.', + 'tolerance' => '0', + 'id' => 278335, + ), + ), + 'units' => array( + 0 => (object) array( + 'question' => '83248', + 'multiplier' => 1, + 'unit' => 'km', + 'id' => 2030, + ), + 1 => (object) array( + 'question' => '83248', + 'multiplier' => 1, + 'unit' => 'kilometres', + 'id' => 2031, + ), + ), + ), + 'hints' => array( + 44315 => (object) array( + 'questionid' => '83248', + 'hint' => 'See Unit 2, Subsection 2.3.', + 'rest' => NULL, + 'id' => 44315, + ), + 44316 => (object) array( + 'questionid' => '83248', + 'hint' => '

Find the measurement on the horizontal axis, draw a line vertically up to meet the conversion line and read off the corresponding value on the vertical axis.

See Unit 2, Subsection 2.3.

', + 'rest' => NULL, + 'id' => 44316, + ), + ), + 'maxmark' => '1', + ); + $this->loader->put_question_in_cache($realquestion); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 83248, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => "The figure below shows a graph for converting between miles and kilometres. \n\n[ The graph has a horizontal axis, labelled miles, with a scale marked from 0 to 50 in steps of 5, and a vertical axis, labelled kilometres, with a scale from 0 to 80 in steps of 10. The straight line of the graph starts at the origin and slopes up to the right, and appears to pass through the point corresponding to 25 miles and 40 kilometres, and through the point corresponding to 50 miles and 80 kilometres. ] \n\nBy taking a reading from the graph, estimate how many kilometres are equivalent to 40 miles. \n\nRound your answer to the nearest kilometre and type it in the box below. \n\n(Your answer should be a single number, without units.)", + 'rightanswer' => '64', + 'responsesummary' => '64', + 'timemodified' => 1268471437, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1267605659, + 'userid' => 239341, + 'data' => array('_separators' => '.$,'), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1268471437, + 'userid' => 239341, + 'data' => array('answer' => '64'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1268471437, + 'userid' => 239341, + 'data' => array('answer' => '64', '-finish' => '1'), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } +} diff --git a/question/type/shortanswer/db/simpletest/testupgradelibnewqe.php b/question/type/shortanswer/db/simpletest/testupgradelibnewqe.php new file mode 100644 index 00000000000..07805b3382d --- /dev/null +++ b/question/type/shortanswer/db/simpletest/testupgradelibnewqe.php @@ -0,0 +1,637 @@ +. + +/** + * Tests of the upgrade to the new Moodle question engine for attempts at + * truefalse questions. + * + * @package qtype + * @subpackage shortanswer + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + +require_once($CFG->dirroot . '/question/engine/upgrade/simpletest/helper.php'); + + +/** + * Testing the upgrade of shortanswer question attempts. + * + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class qtype_shortanswer_attempt_upgrader_test extends question_attempt_upgrader_test_base { + + public function test_shortanswer_deferredfeedback_history620() { + $quiz = (object) array( + 'id' => '221', + 'course' => '187', + 'name' => 'Practice CTMA04', + 'intro' => 'This is the Practice CTMA04. Your mark for this CTMA does not contribute to your continuous assessment mark for B680.

This CTMA covers material primarily in Books 10 and 11, however some of the questions may return to material you covered in Books 0 to 9. There are 100 questions in total.

It is a function of this testing software that it cannot provide for every possible spelling error that you make. The onus is therefore on you, the student, to ensure that your spelling is correct. ', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '1178492400', + 'timeclose' => '1193875200', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71727591', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '4184,0,4185,0,4154,0,4186,0,4187,0,4188,0,4189,0,4190,0,4162,0,4191,0,4192,0,4193,0,4254,0,4195,0,4196,0,4163,0,4197,0,4198,0,4199,0,4164,0,4200,0,4165,0,4201,0,4202,0,4166,0,4203,0,4204,0,4205,0,4167,0,4155,0,4168,0,4206,0,4207,0,4208,0,4209,0,4210,0,4211,0,4212,0,4213,0,4214,0,4156,0,4215,0,4216,0,4217,0,4169,0,4170,0,4157,0,4218,0,4219,0,4220,0,4171,0,4221,0,4172,0,4222,0,4223,0,4224,0,4225,0,4226,0,4227,0,4228,0,4173,0,4229,0,4230,0,4231,0,4232,0,4174,0,4233,0,4234,0,4235,0,4236,0,4237,0,4238,0,4239,0,4240,0,4241,0,4242,0,4158,0,4243,0,4244,0,4245,0,4246,0,4159,0,4175,0,4247,0,4176,0,4248,0,4177,0,4160,0,4249,0,4178,0,4250,0,4161,0,4251,0,4179,0,4252,0,4180,0,4181,0,4182,0,4253,0,4183,0', + 'sumgrades' => '100', + 'grade' => '100', + 'timecreated' => '0', + 'timemodified' => '1195232889', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '4025', + 'uniqueid' => '4025', + 'quiz' => '221', + 'userid' => '55568', + 'attempt' => '1', + 'sumgrades' => '30', + 'timestart' => '1178549306', + 'timefinish' => '1178641326', + 'timemodified' => '1178549306', + 'layout' => '4184,0,4185,0,4154,0,4186,0,4187,0,4188,0,4189,0,4190,0,4162,0,4191,0,4192,0,4193,0,4254,0,4195,0,4196,0,4163,0,4197,0,4198,0,4199,0,4164,0,4200,0,4165,0,4201,0,4202,0,4166,0,4203,0,4204,0,4205,0,4167,0,4155,0,4168,0,4206,0,4207,0,4208,0,4209,0,4210,0,4211,0,4212,0,4213,0,4214,0,4156,0,4215,0,4216,0,4217,0,4169,0,4170,0,4157,0,4218,0,4219,0,4220,0,4171,0,4221,0,4172,0,4222,0,4223,0,4224,0,4225,0,4226,0,4227,0,4228,0,4173,0,4229,0,4230,0,4231,0,4232,0,4174,0,4233,0,4234,0,4235,0,4236,0,4237,0,4238,0,4239,0,4240,0,4241,0,4242,0,4158,0,4243,0,4244,0,4245,0,4246,0,4159,0,4175,0,4247,0,4176,0,4248,0,4177,0,4160,0,4249,0,4178,0,4250,0,4161,0,4251,0,4179,0,4252,0,4180,0,4181,0,4182,0,4253,0,4183,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '4239', + 'category' => '204', + 'parent' => '0', + 'name' => '4hdP73 Book 11 Section 2.1 ignore unavoidable costs when analysing data', + 'questiontext' => 'Complete the following sentence. +

In general, the procedures for analysing cost data for decision making are:

+

Ignore all sunk costs, ignore all ______ costs, use remaining costs for decision making purposes.

', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '1', + 'qtype' => 'shortanswer', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+070417143728+6z2qbB', + 'version' => 'learn.open.ac.uk+070417143728+BJ8YOd', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'answers' => array( + 12944 => (object) array( + 'question' => '4239', + 'answer' => 'unavoidable*', + 'fraction' => '1', + 'feedback' => 'Yes, the correct answer is unavoidable costs. Well done!

Book 11 Section 2.1', + 'id' => 12944, + ), + 12945 => (object) array( + 'question' => '4239', + 'answer' => 'irrelevant*', + 'fraction' => '1', + 'feedback' => 'Yes, the correct answer is unavoidable (or \'irrelevant\') costs. Well done!

Book 11 Section 2.1', + 'id' => 12945, + ), + 12946 => (object) array( + 'question' => '4239', + 'answer' => 'comitte*', + 'fraction' => '1', + 'feedback' => 'Yes, the correct answer is unavoidable costs. Well done!

Book 11 Section 2.1', + 'id' => 12946, + ), + 12947 => (object) array( + 'question' => '4239', + 'answer' => 'commite*', + 'fraction' => '1', + 'feedback' => 'Yes, the correct answer is unavoidable costs. Well done!

Book 11 Section 2.1', + 'id' => 12947, + ), + 12948 => (object) array( + 'question' => '4239', + 'answer' => '*', + 'fraction' => '0', + 'feedback' => 'The correct answer is unavoidable costs.

Book 11 Section 2.1', + 'id' => 12948, + ), + ), + 'usecase' => '0', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '39422', + 'attemptid' => '4025', + 'questionid' => '4239', + 'newest' => '94517', + 'newgraded' => '94517', + 'sumpenalty' => '1', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 92129 => (object) array( + 'attempt' => '4025', + 'question' => '4239', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '', + 'timestamp' => '1178549306', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 92129, + ), + 94433 => (object) array( + 'attempt' => '4025', + 'question' => '4239', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => 'irrelevant', + 'timestamp' => '1178639607', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '1', + 'penalty' => '1', + 'id' => 94433, + ), + 94517 => (object) array( + 'attempt' => '4025', + 'question' => '4239', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => 'irrelevant', + 'timestamp' => '1178639607', + 'event' => '6', + 'grade' => '1', + 'raw_grade' => '1', + 'penalty' => '1', + 'id' => 94517, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 4239, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => "Complete the following sentence. \n\nIn general, the procedures for analysing cost data for decision making are: \n\nIgnore all sunk costs, ignore all ______ costs, use remaining costs for decision making purposes.", + 'rightanswer' => 'unavoidable*', + 'responsesummary' => 'irrelevant', + 'timemodified' => 1178639607, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1178549306, + 'userid' => 55568, + 'data' => array(), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1178639607, + 'userid' => 55568, + 'data' => array('answer' => 'irrelevant'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'gradedright', + 'fraction' => 1, + 'timecreated' => 1178639607, + 'userid' => 55568, + 'data' => array('answer' => 'irrelevant', '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_shortanswer_deferredfeedback_history60() { + $quiz = (object) array( + 'id' => '789', + 'course' => '3500', + 'name' => 'Modes of integration quiz', + 'intro' => '

Use this quiz to test your knowledge of when you have completed Modes of Integration.

+

This quiz is for your information only, the results will not be used as part of the work based activity.

', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '1147960800', + 'timeclose' => '1233414000', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71760879', + 'questionsperpage' => '0', + 'shufflequestions' => '1', + 'shuffleanswers' => '1', + 'questions' => '10218,10216,10219,10220,10217,0', + 'sumgrades' => '5', + 'grade' => '5', + 'timecreated' => '0', + 'timemodified' => '1191939532', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '17778', + 'uniqueid' => '17778', + 'quiz' => '789', + 'userid' => '111471', + 'attempt' => '1', + 'sumgrades' => '4.6', + 'timestart' => '1161205933', + 'timefinish' => '1161206024', + 'timemodified' => '1161206024', + 'layout' => '10219,10220,10216,10217,10218,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '10216', + 'category' => '528', + 'parent' => '0', + 'name' => 'Q2', + 'questiontext' => 'In information-oriented integration what is the document which describes all the data structures in a potential integrated system and their relationships, for example, the fact that one database contained on a server will consist of a subset of another database contained in another server?', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '0.1', + 'qtype' => 'shortanswer', + 'length' => '1', + 'stamp' => 'vledemo.open.ac.uk+060512111049+aApRic', + 'version' => 'vledemo.open.ac.uk+060719152101+aydsEU', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'answers' => array( + 31846 => (object) array( + 'question' => '10216', + 'answer' => '*Enterprise data model*', + 'fraction' => '1', + 'feedback' => 'It is the \'Enterprise data model\'.', + 'id' => 31846, + ), + 31847 => (object) array( + 'question' => '10216', + 'answer' => '*Enterprise*', + 'fraction' => '0.8', + 'feedback' => 'It is the \'Enterprise data model\'.', + 'id' => 31847, + ), + 31848 => (object) array( + 'question' => '10216', + 'answer' => '*', + 'fraction' => '0', + 'feedback' => 'It is the \'Enterprise data model\'.', + 'id' => 31848, + ), + ), + 'usecase' => '0', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '283784', + 'attemptid' => '17778', + 'questionid' => '10216', + 'newest' => '677550', + 'newgraded' => '677550', + 'sumpenalty' => '0', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 677543 => (object) array( + 'attempt' => '17778', + 'question' => '10216', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '', + 'timestamp' => '1161205933', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 677543, + ), + 677550 => (object) array( + 'attempt' => '17778', + 'question' => '10216', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => 'enterprise data dictionary', + 'timestamp' => '1161206024', + 'event' => '6', + 'grade' => '0.8', + 'raw_grade' => '0.8', + 'penalty' => '0.1', + 'id' => 677550, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 10216, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => 'In information-oriented integration what is the document which describes all the data structures in a potential integrated system and their relationships, for example, the fact that one database contained on a server will consist of a subset of another database contained in another server?', + 'rightanswer' => '*Enterprise data model*', + 'responsesummary' => 'enterprise data dictionary', + 'timemodified' => 1161206024, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1161205933, + 'userid' => 111471, + 'data' => array(), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'gradedpartial', + 'fraction' => 0.8, + 'timecreated' => 1161206024, + 'userid' => 111471, + 'data' => array('answer' => 'enterprise data dictionary', '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } + + public function test_shortanswer_deferredfeedback_history3220() { + $quiz = (object) array( + 'id' => '221', + 'course' => '187', + 'name' => 'Practice CTMA04', + 'intro' => 'This is the Practice CTMA04. Your mark for this CTMA does not contribute to your continuous assessment mark for B680.

This CTMA covers material primarily in Books 10 and 11, however some of the questions may return to material you covered in Books 0 to 9. There are 100 questions in total.

It is a function of this testing software that it cannot provide for every possible spelling error that you make. The onus is therefore on you, the student, to ensure that your spelling is correct. ', + 'introformat' => FORMAT_HTML, + 'questiondecimalpoints' => '-1', + 'showuserpicture' => '1', + 'showblocks' => '1', + 'timeopen' => '1178492400', + 'timeclose' => '1193875200', + 'preferredbehaviour' => 'deferredfeedback', + 'attempts' => '0', + 'attemptonlast' => '0', + 'grademethod' => '1', + 'decimalpoints' => '2', + 'review' => '71727591', + 'questionsperpage' => '1', + 'shufflequestions' => '0', + 'shuffleanswers' => '0', + 'questions' => '4184,0,4185,0,4154,0,4186,0,4187,0,4188,0,4189,0,4190,0,4162,0,4191,0,4192,0,4193,0,4254,0,4195,0,4196,0,4163,0,4197,0,4198,0,4199,0,4164,0,4200,0,4165,0,4201,0,4202,0,4166,0,4203,0,4204,0,4205,0,4167,0,4155,0,4168,0,4206,0,4207,0,4208,0,4209,0,4210,0,4211,0,4212,0,4213,0,4214,0,4156,0,4215,0,4216,0,4217,0,4169,0,4170,0,4157,0,4218,0,4219,0,4220,0,4171,0,4221,0,4172,0,4222,0,4223,0,4224,0,4225,0,4226,0,4227,0,4228,0,4173,0,4229,0,4230,0,4231,0,4232,0,4174,0,4233,0,4234,0,4235,0,4236,0,4237,0,4238,0,4239,0,4240,0,4241,0,4242,0,4158,0,4243,0,4244,0,4245,0,4246,0,4159,0,4175,0,4247,0,4176,0,4248,0,4177,0,4160,0,4249,0,4178,0,4250,0,4161,0,4251,0,4179,0,4252,0,4180,0,4181,0,4182,0,4253,0,4183,0', + 'sumgrades' => '100', + 'grade' => '100', + 'timecreated' => '0', + 'timemodified' => '1195232889', + 'password' => '', + 'subnet' => '', + 'popup' => '0', + 'delay1' => '0', + 'delay2' => '0', + 'timelimit' => '0', + ); + $attempt = (object) array( + 'id' => '4058', + 'uniqueid' => '4058', + 'quiz' => '221', + 'userid' => '83485', + 'attempt' => '1', + 'sumgrades' => '19', + 'timestart' => '1178636138', + 'timefinish' => '1178874880', + 'timemodified' => '1178636138', + 'layout' => '4184,0,4185,0,4154,0,4186,0,4187,0,4188,0,4189,0,4190,0,4162,0,4191,0,4192,0,4193,0,4254,0,4195,0,4196,0,4163,0,4197,0,4198,0,4199,0,4164,0,4200,0,4165,0,4201,0,4202,0,4166,0,4203,0,4204,0,4205,0,4167,0,4155,0,4168,0,4206,0,4207,0,4208,0,4209,0,4210,0,4211,0,4212,0,4213,0,4214,0,4156,0,4215,0,4216,0,4217,0,4169,0,4170,0,4157,0,4218,0,4219,0,4220,0,4171,0,4221,0,4172,0,4222,0,4223,0,4224,0,4225,0,4226,0,4227,0,4228,0,4173,0,4229,0,4230,0,4231,0,4232,0,4174,0,4233,0,4234,0,4235,0,4236,0,4237,0,4238,0,4239,0,4240,0,4241,0,4242,0,4158,0,4243,0,4244,0,4245,0,4246,0,4159,0,4175,0,4247,0,4176,0,4248,0,4177,0,4160,0,4249,0,4178,0,4250,0,4161,0,4251,0,4179,0,4252,0,4180,0,4181,0,4182,0,4253,0,4183,0', + 'preview' => '0', + 'needsupgradetonewqe' => '1', + ); + $question = (object) array( + 'id' => '4184', + 'category' => '204', + 'parent' => '0', + 'name' => '4abP1 Book 11 Section 3.1 capit invest appraisal defn', + 'questiontext' => 'Complete the following sentence by providing an appropriate word for the indicated gap. +

Capital investment appraisal involves both quantitative and ______ issues.

', + 'questiontextformat' => '1', + 'defaultmark' => '1', + 'penalty' => '1', + 'qtype' => 'shortanswer', + 'length' => '1', + 'stamp' => 'learn.open.ac.uk+070417143727+tO4yGs', + 'version' => 'learn.open.ac.uk+070417143727+fieanX', + 'hidden' => '0', + 'generalfeedback' => '', + 'generalfeedbackformat' => '1', + 'timecreated' => '0', + 'timemodified' => '0', + 'createdby' => NULL, + 'modifiedby' => NULL, + 'unlimited' => NULL, + 'maxmark' => '1', + 'options' => (object) array( + 'answers' => array( + 12768 => (object) array( + 'question' => '4184', + 'answer' => 'qualitative*', + 'fraction' => '1', + 'feedback' => 'Yes, the correct answer is qualitative issues. Well done!

Book 11 Section 3.1', + 'id' => 12768, + ), + 12769 => (object) array( + 'question' => '4184', + 'answer' => 'qual*tat*ve*', + 'fraction' => '1', + 'feedback' => 'Yes, the correct answer is qualitative issues. Well done! (but watch your spelling!)

Book 11 Section 3.1', + 'id' => 12769, + ), + 12770 => (object) array( + 'question' => '4184', + 'answer' => '*', + 'fraction' => '0', + 'feedback' => 'The correct answer is qualitative issues.

Book 11 Section 3.1', + 'id' => 12770, + ), + ), + 'usecase' => '0', + ), + 'hints' => false, + ); + $qsession = (object) array( + 'id' => '40854', + 'attemptid' => '4058', + 'questionid' => '4184', + 'newest' => '100733', + 'newgraded' => '100733', + 'sumpenalty' => '1', + 'manualcomment' => '', + 'manualcommentformat' => '1', + 'flagged' => '1', + ); + $qstates = array( + 94330 => (object) array( + 'attempt' => '4058', + 'question' => '4184', + 'originalquestion' => '0', + 'seq_number' => '0', + 'answer' => '', + 'timestamp' => '1178636138', + 'event' => '0', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '0', + 'id' => 94330, + ), + 94415 => (object) array( + 'attempt' => '4058', + 'question' => '4184', + 'originalquestion' => '0', + 'seq_number' => '1', + 'answer' => 'qualitative', + 'timestamp' => '1178636171', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '1', + 'penalty' => '1', + 'id' => 94415, + ), + 100142 => (object) array( + 'attempt' => '4058', + 'question' => '4184', + 'originalquestion' => '0', + 'seq_number' => '2', + 'answer' => 'subjective', + 'timestamp' => '1178825180', + 'event' => '2', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '1', + 'id' => 100142, + ), + 100733 => (object) array( + 'attempt' => '4058', + 'question' => '4184', + 'originalquestion' => '0', + 'seq_number' => '3', + 'answer' => 'subjective', + 'timestamp' => '1178825180', + 'event' => '3', + 'grade' => '0', + 'raw_grade' => '0', + 'penalty' => '1', + 'id' => 100733, + ), + ); + + $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); + + $expectedqa = (object) array( + 'behaviour' => 'deferredfeedback', + 'questionid' => 4184, + 'maxmark' => 1, + 'minfraction' => 0, + 'flagged' => 0, + 'questionsummary' => "Complete the following sentence by providing an appropriate word for the indicated gap. \n\nCapital investment appraisal involves both quantitative and ______ issues.", + 'rightanswer' => 'qualitative*', + 'responsesummary' => 'subjective', + 'timemodified' => 1178825180, + 'steps' => array( + 0 => (object) array( + 'sequencenumber' => 0, + 'state' => 'todo', + 'fraction' => null, + 'timecreated' => 1178636138, + 'userid' => 83485, + 'data' => array(), + ), + 1 => (object) array( + 'sequencenumber' => 1, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1178636171, + 'userid' => 83485, + 'data' => array('answer' => 'qualitative'), + ), + 2 => (object) array( + 'sequencenumber' => 2, + 'state' => 'complete', + 'fraction' => null, + 'timecreated' => 1178825180, + 'userid' => 83485, + 'data' => array('answer' => 'subjective'), + ), + 3 => (object) array( + 'sequencenumber' => 3, + 'state' => 'gradedwrong', + 'fraction' => 0, + 'timecreated' => 1178825180, + 'userid' => 83485, + 'data' => array('answer' => 'subjective', '-finish' => 1), + ), + ), + ); + + $this->assertEqual($expectedqa, $qa); + } +} diff --git a/question/type/truefalse/db/simpletest/testupgradelibnewqe.php b/question/type/truefalse/db/simpletest/testupgradelibnewqe.php index 8a54a760908..6b64bbcd483 100644 --- a/question/type/truefalse/db/simpletest/testupgradelibnewqe.php +++ b/question/type/truefalse/db/simpletest/testupgradelibnewqe.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/simpletest/helper.php'); /** - * Subclass of question_engine_attempt_upgrader to help with testing. + * Testing the upgrade of truefalse question attempts. * * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later