mirror of
https://github.com/moodle/moodle.git
synced 2025-03-06 16:59:56 +01:00
MDL-20636 Question engine upgrade unit tests for shortanswer, random and multichoice.
This commit is contained in:
parent
38d42fc476
commit
d04626e4cd
2756
question/type/multichoice/db/simpletest/testupgradelibnewqe.php
Normal file
2756
question/type/multichoice/db/simpletest/testupgradelibnewqe.php
Normal file
File diff suppressed because it is too large
Load Diff
785
question/type/random/db/simpletest/testupgradelibnewqe.php
Normal file
785
question/type/random/db/simpletest/testupgradelibnewqe.php
Normal file
@ -0,0 +1,785 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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' => '<p>Welcome. This is the first K101 Interactive Computer Marked Assignment (iCMA).</p>
|
||||
<p>After the open date, begin by clicking <b>Start attempt</b> and a pop-up box will appear. Click OK and this will take you to the questions.</p>
|
||||
<p> </p>',
|
||||
'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' => '<p>(Notice in the panel at the left that the question you have just done is now greyed out. Remember that you can <b>revisit any questions</b> by clicking on the <b>numbered boxes</b>. Click Q1 now to try this out and then click Q2 to return here.)</p>
|
||||
<p><img style="margin-left: 0px; margin-right: 0px;" src="http://learn.open.ac.uk/file.php/5174/K101images/icma41/K101CMA41-Q1-v0.gif" alt="Table 1 showing Number of households receiving home care (England)" title="Table 1 showing Number of households receiving home care (England)" width="512" height="284" /></p>
|
||||
<p><b>(<a target="_blank" href="http://learn.open.ac.uk/file.php/5174/iCMA-PDFs-resizableimages/k101-iCMA41-Q2-v2-ResizableFigure.pdf" title="PDF document containing iCMA image - to enable enlargement">Link to resizable Table 1</a>) </b></p>
|
||||
<p>Which was the first year when more than a quarter of a million households received care from independent agencies?</p>',
|
||||
'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' => '<p> The figure below shows a graph for converting between miles and kilometres. </p><p><img src="http://learnacct.open.ac.uk/file.php/5233/quizImages/u2/figs/42.02.07.GraphConvert.png" alt=" 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. "></img> </p><p>By taking a reading from the graph, estimate how many kilometres are equivalent to 40 miles. </p><p>Round your answer to the nearest kilometre and type it in the box below. </p><p>(Your answer should be a single number, without units.) </p>',
|
||||
'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' => '<p> Conversion graph for miles and kilometres. </p><p><img src="http://learnacct.open.ac.uk/file.php/5233/quizImages/u2/figs/42.02.07.GraphConvert.E.png" alt=" 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."></img> </p><p>So 40 miles is approximately 64 km. </p><p>See Unit 2, Subsection 2.3. </p>',
|
||||
'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' => '<p> 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. </p><p>See Unit 2, Subsection 2.3. </p>',
|
||||
'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);
|
||||
}
|
||||
}
|
637
question/type/shortanswer/db/simpletest/testupgradelibnewqe.php
Normal file
637
question/type/shortanswer/db/simpletest/testupgradelibnewqe.php
Normal file
@ -0,0 +1,637 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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 <span style="font-style: italic">does not </span>contribute to your continuous assessment mark for B680.<br /><br />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.<br /><br />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.
|
||||
<p>In general, the procedures for analysing cost data for decision making are: </p>
|
||||
<p>Ignore all sunk costs, ignore all ______ costs, use remaining costs for decision making purposes. </p>',
|
||||
'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! <p> 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! <p> 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! <i> <p> 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! <i> <p> Book 11 Section 2.1',
|
||||
'id' => 12947,
|
||||
),
|
||||
12948 => (object) array(
|
||||
'question' => '4239',
|
||||
'answer' => '*',
|
||||
'fraction' => '0',
|
||||
'feedback' => 'The correct answer is unavoidable costs. <p> 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' => '<p><font size="2">Use this quiz to test your knowledge of when you have completed <span style="font-style: italic">Modes of Integration</span>.</font> </p>
|
||||
<p><font size="2">This quiz is for your information only, the results will not be used as part of the work based activity. </font></p>',
|
||||
'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' => '<font size="2">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?</font>',
|
||||
'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 <span style="font-style: italic">does not </span>contribute to your continuous assessment mark for B680.<br /><br />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.<br /><br />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.
|
||||
<p>Capital investment appraisal involves both quantitative and ______ issues. </p>',
|
||||
'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! <p> 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! <i>(but watch your spelling!)</i> <p> Book 11 Section 3.1',
|
||||
'id' => 12769,
|
||||
),
|
||||
12770 => (object) array(
|
||||
'question' => '4184',
|
||||
'answer' => '*',
|
||||
'fraction' => '0',
|
||||
'feedback' => 'The correct answer is qualitative issues. <p> 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);
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user