|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00028 defined('MOODLE_INTERNAL') || die(); 00029 00030 require_once($CFG->dirroot . '/question/engine/upgrade/simpletest/helper.php'); 00031 00032 00039 class qtype_random_attempt_upgrader_test extends question_attempt_upgrader_test_base { 00040 00041 public function test_random_deferredfeedback_history620() { 00042 $quiz = (object) array( 00043 'id' => '2177', 00044 'course' => '5174', 00045 'name' => 'iCMA 41', 00046 'intro' => '<p>Welcome. This is the first K101 Interactive Computer Marked Assignment (iCMA).</p> 00047 <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> 00048 <p> </p>', 00049 'introformat' => FORMAT_HTML, 00050 'questiondecimalpoints' => '-1', 00051 'showuserpicture' => '1', 00052 'showblocks' => '1', 00053 'timeopen' => '1236556800', 00054 'timeclose' => '1238713140', 00055 'preferredbehaviour' => 'deferredfeedback', 00056 'attempts' => '1', 00057 'attemptonlast' => '0', 00058 'grademethod' => '1', 00059 'decimalpoints' => '0', 00060 'review' => '67268673', 00061 'questionsperpage' => '1', 00062 'shufflequestions' => '0', 00063 'shuffleanswers' => '0', 00064 'questions' => '28698,0,34245,0,34248,0,35005,0,35009,0,35013,0', 00065 'sumgrades' => '5', 00066 'grade' => '100', 00067 'timecreated' => '0', 00068 'timemodified' => '1236269160', 00069 'password' => '', 00070 'subnet' => '', 00071 'popup' => '0', 00072 'delay1' => '0', 00073 'delay2' => '0', 00074 'timelimit' => '0', 00075 ); 00076 $attempt = (object) array( 00077 'id' => '125687', 00078 'uniqueid' => '125688', 00079 'quiz' => '2177', 00080 'userid' => '509191', 00081 'attempt' => '1', 00082 'sumgrades' => '5', 00083 'timestart' => '1236590532', 00084 'timefinish' => '1238184306', 00085 'timemodified' => '1238182560', 00086 'layout' => '28698,0,34245,0,34248,0,35005,0,35009,0,35013,0', 00087 'preview' => '0', 00088 'needsupgradetonewqe' => '1', 00089 ); 00090 $question = (object) array( 00091 'id' => '34248', 00092 'category' => '3762', 00093 'parent' => '34248', 00094 'name' => 'Random Question (Q2)', 00095 'questiontext' => '1', 00096 'questiontextformat' => '0', 00097 'defaultmark' => '1', 00098 'penalty' => '0', 00099 'qtype' => 'random', 00100 'length' => '1', 00101 'stamp' => 'learn.open.ac.uk+090218115858+6H1FBE', 00102 'version' => 'learn.open.ac.uk+090218115858+REDwJ6', 00103 'hidden' => '0', 00104 'generalfeedback' => '', 00105 'generalfeedbackformat' => '1', 00106 'timecreated' => '1234958338', 00107 'timemodified' => '1234958338', 00108 'createdby' => '219095', 00109 'modifiedby' => '219095', 00110 'unlimited' => '0', 00111 'maxmark' => '1', 00112 ); 00113 $qsession = (object) array( 00114 'id' => '1512603', 00115 'attemptid' => '125688', 00116 'questionid' => '34248', 00117 'newest' => '4010008', 00118 'newgraded' => '4010008', 00119 'sumpenalty' => '0.1', 00120 'manualcomment' => '', 00121 'manualcommentformat' => '1', 00122 'flagged' => '1', 00123 ); 00124 $qstates = array( 00125 3820084 => (object) array( 00126 'attempt' => '125688', 00127 'question' => '34248', 00128 'originalquestion' => '0', 00129 'seq_number' => '0', 00130 'answer' => 'random34999-103135,103136,103137:', 00131 'timestamp' => '1236590532', 00132 'event' => '0', 00133 'grade' => '0', 00134 'raw_grade' => '0', 00135 'penalty' => '0', 00136 'id' => 3820084, 00137 ), 00138 4009916 => (object) array( 00139 'attempt' => '125688', 00140 'question' => '34248', 00141 'originalquestion' => '0', 00142 'seq_number' => '1', 00143 'answer' => 'random34999-103135,103136,103137:103137', 00144 'timestamp' => '1238182723', 00145 'event' => '2', 00146 'grade' => '0', 00147 'raw_grade' => '1', 00148 'penalty' => '0.1', 00149 'id' => 4009916, 00150 ), 00151 4010008 => (object) array( 00152 'attempt' => '125688', 00153 'question' => '34248', 00154 'originalquestion' => '0', 00155 'seq_number' => '2', 00156 'answer' => 'random34999-103135,103136,103137:103137', 00157 'timestamp' => '1238182723', 00158 'event' => '6', 00159 'grade' => '1', 00160 'raw_grade' => '1', 00161 'penalty' => '0.1', 00162 'id' => 4010008, 00163 ), 00164 ); 00165 $realquestion = (object) array( 00166 'id' => '34999', 00167 'category' => '3762', 00168 'parent' => '0', 00169 'name' => 'K101 iCMA41 Qs 2-v2', 00170 '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> 00171 <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> 00172 <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> 00173 <p>Which was the first year when more than a quarter of a million households received care from independent agencies?</p>', 00174 'questiontextformat' => '1', 00175 'defaultmark' => '1', 00176 'penalty' => '0.1', 00177 'qtype' => 'multichoice', 00178 'length' => '1', 00179 'stamp' => 'learn.open.ac.uk+090227173002+mbdE0X', 00180 'version' => 'learn.open.ac.uk+090304190917+xAB5Nf', 00181 'hidden' => '0', 00182 'generalfeedback' => '', 00183 'generalfeedbackformat' => '1', 00184 'timecreated' => '1235755802', 00185 'timemodified' => '1236193757', 00186 'createdby' => '25299', 00187 'modifiedby' => '25299', 00188 'unlimited' => '0', 00189 'options' => (object) array( 00190 'id' => '15211', 00191 'question' => '34999', 00192 'layout' => '0', 00193 'answers' => array( 00194 103135 => (object) array( 00195 'question' => '34999', 00196 'answer' => '2001', 00197 'fraction' => '0', 00198 'feedback' => '', 00199 'id' => 103135, 00200 ), 00201 103136 => (object) array( 00202 'question' => '34999', 00203 'answer' => '2003', 00204 'fraction' => '0', 00205 'feedback' => '', 00206 'id' => 103136, 00207 ), 00208 103137 => (object) array( 00209 'question' => '34999', 00210 'answer' => '2005', 00211 'fraction' => '1', 00212 'feedback' => '', 00213 'id' => 103137, 00214 ), 00215 ), 00216 'single' => '1', 00217 'shuffleanswers' => '1', 00218 'correctfeedback' => 'Your answer is correct. Well done.', 00219 'partiallycorrectfeedback' => '', 00220 'incorrectfeedback' => 'Your answer is incorrect. The correct answer is: 2005.', 00221 'answernumbering' => 'abc', 00222 ), 00223 ); 00224 $this->loader->put_question_in_cache($realquestion); 00225 00226 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 00227 00228 $expectedqa = (object) array( 00229 'behaviour' => 'deferredfeedback', 00230 'questionid' => 34999, 00231 'variant' => 1, 00232 'maxmark' => 1, 00233 'minfraction' => 0, 00234 'flagged' => 0, 00235 '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?", 00236 'rightanswer' => '2005', 00237 'responsesummary' => '2005', 00238 'timemodified' => 1238182723, 00239 'steps' => array( 00240 0 => (object) array( 00241 'sequencenumber' => 0, 00242 'state' => 'todo', 00243 'fraction' => null, 00244 'timecreated' => 1236590532, 00245 'userid' => 509191, 00246 'data' => array('_order' => '103135,103136,103137'), 00247 ), 00248 1 => (object) array( 00249 'sequencenumber' => 1, 00250 'state' => 'complete', 00251 'fraction' => null, 00252 'timecreated' => 1238182723, 00253 'userid' => 509191, 00254 'data' => array('answer' => 2), 00255 ), 00256 2 => (object) array( 00257 'sequencenumber' => 2, 00258 'state' => 'gradedright', 00259 'fraction' => 1, 00260 'timecreated' => 1238182723, 00261 'userid' => 509191, 00262 'data' => array('answer' => 2, '-finish' => 1), 00263 ), 00264 ), 00265 ); 00266 00267 $this->compare_qas($expectedqa, $qa); 00268 } 00269 00270 public function test_random_deferredfeedback_qsession4225582() { 00271 $quiz = (object) array( 00272 'id' => '4410', 00273 'course' => '5444', 00274 'name' => 'Block 3, Session 5 Quiz', 00275 'intro' => 'Pour chacune des questions suivantes vous avez trois réponses possibles. Cochez la bonne. (Cliquez sur « Check » pour vérifier votre réponse.)', 00276 'introformat' => FORMAT_HTML, 00277 'questiondecimalpoints' => '-1', 00278 'showuserpicture' => '1', 00279 'showblocks' => '1', 00280 'timeopen' => '0', 00281 'timeclose' => '0', 00282 'optionflags' => '0', 00283 'attempts' => '0', 00284 'attemptonlast' => '0', 00285 'grademethod' => '1', 00286 'decimalpoints' => '2', 00287 'review' => '71727591', 00288 'questionsperpage' => '3', 00289 'shufflequestions' => '1', 00290 'shuffleanswers' => '1', 00291 'questions' => '101983,101984,101985,0,101986,101987,101988,0,101989,101990,101991,0,101992,101993,101994,0,101995,101996,101997,0', 00292 'sumgrades' => '15', 00293 'grade' => '10', 00294 'timecreated' => '0', 00295 'timemodified' => '1269429396', 00296 'password' => '', 00297 'subnet' => '', 00298 'popup' => '0', 00299 'delay1' => '0', 00300 'delay2' => '0', 00301 'timelimit' => '0', 00302 'preferredbehaviour' => 'deferredfeedback', 00303 ); 00304 $attempt = (object) array( 00305 'id' => '418702', 00306 'uniqueid' => '418703', 00307 'quiz' => '4410', 00308 'userid' => '62892', 00309 'attempt' => '2', 00310 'sumgrades' => '9', 00311 'timestart' => '1274178725', 00312 'timefinish' => '1274179255', 00313 'timemodified' => '1274178763', 00314 'layout' => '101989,101985,101994,0,101988,101986,101992,0,101997,101990,101991,0,101984,101995,101987,0,101983,101993,101996,0', 00315 'preview' => '0', 00316 'needsupgradetonewqe' => '1', 00317 ); 00318 $question = (object) array( 00319 'id' => '101984', 00320 'category' => '9148', 00321 'parent' => '101984', 00322 'name' => 'Random Question (Block 3, Session 5 Quiz)', 00323 'questiontext' => '1', 00324 'questiontextformat' => '0', 00325 'image' => '', 00326 'defaultmark' => '1', 00327 'penalty' => '0', 00328 'qtype' => 'random', 00329 'length' => '1', 00330 'stamp' => 'learn.open.ac.uk+100416133531+H1yive', 00331 'version' => 'learn.open.ac.uk+100416133531+KrpbHq', 00332 'hidden' => '0', 00333 'generalfeedback' => '', 00334 'generalfeedbackformat' => '1', 00335 'timecreated' => '1271424931', 00336 'timemodified' => '1271424931', 00337 'createdby' => '220574', 00338 'modifiedby' => '220574', 00339 'unlimited' => '0', 00340 'maxmark' => '1', 00341 ); 00342 $qsession = (object) array( 00343 'id' => '4225582', 00344 'attemptid' => '418703', 00345 'questionid' => '101984', 00346 'newest' => '10786541', 00347 'newgraded' => '10786541', 00348 'sumpenalty' => '0.33', 00349 'manualcomment' => '', 00350 'manualcommentformat' => '1', 00351 'flagged' => '1', 00352 ); 00353 $qstates = array( 00354 10786382 => (object) array( 00355 'attempt' => '418703', 00356 'question' => '101984', 00357 'originalquestion' => '0', 00358 'seq_number' => '0', 00359 'answer' => 'random98355-341067,341066,341068:', 00360 'timestamp' => '1274178725', 00361 'event' => '0', 00362 'grade' => '0', 00363 'raw_grade' => '0', 00364 'penalty' => '0', 00365 'id' => 10786382, 00366 ), 00367 10786398 => (object) array( 00368 'attempt' => '418703', 00369 'question' => '101984', 00370 'originalquestion' => '0', 00371 'seq_number' => '1', 00372 'answer' => 'random98355-341067,341066,341068:341061', 00373 'timestamp' => '1274178725', 00374 'event' => '2', 00375 'grade' => '0', 00376 'raw_grade' => '0', 00377 'penalty' => '0.33', 00378 'id' => 10786398, 00379 ), 00380 10786515 => (object) array( 00381 'attempt' => '418703', 00382 'question' => '101984', 00383 'originalquestion' => '0', 00384 'seq_number' => '2', 00385 'answer' => 'random98355-341067,341066,341068:341067', 00386 'timestamp' => '1274179164', 00387 'event' => '2', 00388 'grade' => '0', 00389 'raw_grade' => '1', 00390 'penalty' => '0.33', 00391 'id' => 10786515, 00392 ), 00393 10786541 => (object) array( 00394 'attempt' => '418703', 00395 'question' => '101984', 00396 'originalquestion' => '0', 00397 'seq_number' => '3', 00398 'answer' => 'random98355-341067,341066,341068:341067', 00399 'timestamp' => '1274179164', 00400 'event' => '6', 00401 'grade' => '1', 00402 'raw_grade' => '1', 00403 'penalty' => '0.33', 00404 'id' => 10786541, 00405 ), 00406 ); 00407 $realquestion = (object) array( 00408 'id' => '98355', 00409 'category' => '9148', 00410 'parent' => '0', 00411 'name' => '20', 00412 '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 :', 00413 'questiontextformat' => '1', 00414 'defaultmark' => '1', 00415 'penalty' => '0.33', 00416 'qtype' => 'multichoice', 00417 'length' => '1', 00418 'stamp' => 'learn.open.ac.uk+100324131532+CExeWh', 00419 'version' => 'learn.open.ac.uk+100326162411+qEo2Bg', 00420 'hidden' => '0', 00421 'generalfeedback' => '', 00422 'generalfeedbackformat' => '1', 00423 'timecreated' => '1269436532', 00424 'timemodified' => '1269620651', 00425 'createdby' => '220574', 00426 'modifiedby' => '220574', 00427 'unlimited' => '0', 00428 'options' => (object) array( 00429 'id' => '37042', 00430 'question' => '98355', 00431 'layout' => '0', 00432 'answers' => array( 00433 341066 => (object) array( 00434 'question' => '98355', 00435 'answer' => 'a été soutenue par les partis de droite.', 00436 'fraction' => '0', 00437 'feedback' => '', 00438 'id' => 341066, 00439 ), 00440 341067 => (object) array( 00441 'question' => '98355', 00442 'answer' => 'n’est plus uniquement un positionnement écologiste.', 00443 'fraction' => '1', 00444 'feedback' => '', 00445 'id' => 341067, 00446 ), 00447 341068 => (object) array( 00448 'question' => '98355', 00449 'answer' => 'est une idée de gauche, du centre, de droite, d’extrême gauche ou d’extrême droite.', 00450 'fraction' => '0', 00451 'feedback' => '', 00452 'id' => 341068, 00453 ), 00454 ), 00455 'single' => '1', 00456 'shuffleanswers' => '1', 00457 'correctfeedback' => 'Vrai.', 00458 'partiallycorrectfeedback' => '', 00459 'incorrectfeedback' => 'Faux.', 00460 'answernumbering' => 'abc', 00461 ), 00462 'hints' => false, 00463 'maxmark' => '1', 00464 ); 00465 $this->loader->put_question_in_cache($realquestion); 00466 00467 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 00468 00469 $expectedqa = (object) array( 00470 'behaviour' => 'deferredfeedback', 00471 'questionid' => 98355, 00472 'variant' => 1, 00473 'maxmark' => 1, 00474 'minfraction' => 0, 00475 'flagged' => 0, 00476 '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 :', 00477 'rightanswer' => 'n’est plus uniquement un positionnement écologiste.', 00478 'responsesummary' => 'n’est plus uniquement un positionnement écologiste.', 00479 'timemodified' => 1274179164, 00480 'steps' => array( 00481 0 => (object) array( 00482 'sequencenumber' => 0, 00483 'state' => 'todo', 00484 'fraction' => null, 00485 'timecreated' => 1274178725, 00486 'userid' => 62892, 00487 'data' => array('_order' => '341067,341066,341068'), 00488 ), 00489 1 => (object) array( 00490 'sequencenumber' => 1, 00491 'state' => 'complete', 00492 'fraction' => null, 00493 'timecreated' => 1274178725, 00494 'userid' => 62892, 00495 'data' => array('answer' => '-1'), 00496 ), 00497 2 => (object) array( 00498 'sequencenumber' => 2, 00499 'state' => 'complete', 00500 'fraction' => null, 00501 'timecreated' => 1274179164, 00502 'userid' => 62892, 00503 'data' => array('answer' => '0'), 00504 ), 00505 3 => (object) array( 00506 'sequencenumber' => 3, 00507 'state' => 'gradedright', 00508 'fraction' => 1, 00509 'timecreated' => 1274179164, 00510 'userid' => 62892, 00511 'data' => array('answer' => '0', '-finish' => '1'), 00512 ), 00513 ), 00514 ); 00515 00516 $this->compare_qas($expectedqa, $qa); 00517 } 00518 00519 public function test_random_deferredfeedback_qsession3481928() { 00520 $quiz = (object) array( 00521 'id' => '2624', 00522 'course' => '5233', 00523 'name' => 'iCMA 42', 00524 'intro' => '', 00525 'introformat' => FORMAT_HTML, 00526 'questiondecimalpoints' => '-1', 00527 'showuserpicture' => '1', 00528 'showblocks' => '1', 00529 'timeopen' => '1267056000', 00530 'timeclose' => '1271890740', 00531 'optionflags' => '0', 00532 'attempts' => '1', 00533 'attemptonlast' => '0', 00534 'grademethod' => '1', 00535 'decimalpoints' => '2', 00536 'review' => '67268673', 00537 'questionsperpage' => '1', 00538 'shufflequestions' => '0', 00539 'shuffleanswers' => '1', 00540 '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', 00541 'sumgrades' => '18', 00542 'grade' => '18', 00543 'timecreated' => '0', 00544 'timemodified' => '1271852647', 00545 'password' => '', 00546 'subnet' => '', 00547 'popup' => '0', 00548 'delay1' => '0', 00549 'delay2' => '0', 00550 'timelimit' => '0', 00551 'preferredbehaviour' => 'deferredfeedback', 00552 ); 00553 $attempt = (object) array( 00554 'id' => '331814', 00555 'uniqueid' => '331815', 00556 'quiz' => '2624', 00557 'userid' => '239341', 00558 'attempt' => '1', 00559 'sumgrades' => '9.13333', 00560 'timestart' => '1267605659', 00561 'timefinish' => '1270202969', 00562 'timemodified' => '1269508052', 00563 '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', 00564 'preview' => '0', 00565 'needsupgradetonewqe' => '1', 00566 ); 00567 $question = (object) array( 00568 'id' => '81247', 00569 'category' => '6882', 00570 'parent' => '81247', 00571 'name' => 'Random Question (42.02.03.GraphConvert)', 00572 'questiontext' => '1', 00573 'questiontextformat' => '0', 00574 'image' => '', 00575 'defaultmark' => '1', 00576 'penalty' => '0', 00577 'qtype' => 'random', 00578 'length' => '1', 00579 'stamp' => 'learn.open.ac.uk+091215084951+AYsG5O', 00580 'version' => 'learn.open.ac.uk+091215084951+VSqp4u', 00581 'hidden' => '0', 00582 'generalfeedback' => '', 00583 'generalfeedbackformat' => '1', 00584 'timecreated' => '1260866991', 00585 'timemodified' => '1260866991', 00586 'createdby' => '27595', 00587 'modifiedby' => '27595', 00588 'unlimited' => '0', 00589 'maxmark' => '1', 00590 ); 00591 $qsession = (object) array( 00592 'id' => '3481928', 00593 'attemptid' => '331815', 00594 'questionid' => '81247', 00595 'newest' => '9646306', 00596 'newgraded' => '9646306', 00597 'sumpenalty' => '0.333333', 00598 'manualcomment' => '', 00599 'manualcommentformat' => '1', 00600 'flagged' => '1', 00601 ); 00602 $qstates = array( 00603 8809801 => (object) array( 00604 'attempt' => '331815', 00605 'question' => '81247', 00606 'originalquestion' => '0', 00607 'seq_number' => '0', 00608 'answer' => 'random83248-', 00609 'timestamp' => '1267605659', 00610 'event' => '0', 00611 'grade' => '0', 00612 'raw_grade' => '0', 00613 'penalty' => '0', 00614 'id' => 8809801, 00615 ), 00616 9081885 => (object) array( 00617 'attempt' => '331815', 00618 'question' => '81247', 00619 'originalquestion' => '0', 00620 'seq_number' => '1', 00621 'answer' => '64', 00622 'timestamp' => '1268384692', 00623 'event' => '2', 00624 'grade' => '0', 00625 'raw_grade' => '1', 00626 'penalty' => '0.333333', 00627 'id' => 9081885, 00628 ), 00629 9107452 => (object) array( 00630 'attempt' => '331815', 00631 'question' => '81247', 00632 'originalquestion' => '0', 00633 'seq_number' => '1', 00634 'answer' => 'random83248-64', 00635 'timestamp' => '1268471437', 00636 'event' => '2', 00637 'grade' => '0', 00638 'raw_grade' => '1', 00639 'penalty' => '0.333333', 00640 'id' => 9107452, 00641 ), 00642 9646306 => (object) array( 00643 'attempt' => '331815', 00644 'question' => '81247', 00645 'originalquestion' => '0', 00646 'seq_number' => '2', 00647 'answer' => 'random83248-64', 00648 'timestamp' => '1268471437', 00649 'event' => '6', 00650 'grade' => '1', 00651 'raw_grade' => '1', 00652 'penalty' => '0.333333', 00653 'id' => 9646306, 00654 ), 00655 ); 00656 $realquestion = (object) array( 00657 'id' => '83248', 00658 'category' => '6882', 00659 'parent' => '0', 00660 'name' => '42.02.03.GraphConvert.E', 00661 '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>', 00662 'questiontextformat' => '0', 00663 'defaultmark' => '3', 00664 'penalty' => '0.333333', 00665 'qtype' => 'numerical', 00666 'length' => '1', 00667 'stamp' => 'learn.open.ac.uk+100108135957+SZhkKF', 00668 'version' => 'learn.open.ac.uk+100108135957+ej40PM', 00669 'hidden' => '0', 00670 '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>', 00671 'generalfeedbackformat' => '1', 00672 'timecreated' => '1262959197', 00673 'timemodified' => '0', 00674 'createdby' => '123783', 00675 'modifiedby' => null, 00676 'unlimited' => '0', 00677 'options' => (object) array( 00678 'answers' => array( 00679 278332 => (object) array( 00680 'question' => '83248', 00681 'answer' => '64', 00682 'fraction' => '1', 00683 'feedback' => 'Your answer is correct.', 00684 'tolerance' => '1', 00685 'id' => 278332, 00686 ), 00687 278333 => (object) array( 00688 'question' => '83248', 00689 'answer' => '64', 00690 'fraction' => '0', 00691 'feedback' => 'Your answer is incorrect. It is close, but not quite accurate enough.', 00692 'tolerance' => '5', 00693 'id' => 278333, 00694 ), 00695 278334 => (object) array( 00696 'question' => '83248', 00697 'answer' => '25', 00698 'fraction' => '0', 00699 'feedback' => 'Your answer is incorrect. Remember you are converting from miles to kilometres.', 00700 'tolerance' => '5', 00701 'id' => 278334, 00702 ), 00703 278335 => (object) array( 00704 'question' => '83248', 00705 'answer' => '*', 00706 'fraction' => '0', 00707 'feedback' => 'Your answer is incorrect.', 00708 'tolerance' => '0', 00709 'id' => 278335, 00710 ), 00711 ), 00712 'units' => array( 00713 0 => (object) array( 00714 'question' => '83248', 00715 'multiplier' => 1, 00716 'unit' => 'km', 00717 'id' => 2030, 00718 ), 00719 1 => (object) array( 00720 'question' => '83248', 00721 'multiplier' => 1, 00722 'unit' => 'kilometres', 00723 'id' => 2031, 00724 ), 00725 ), 00726 ), 00727 'hints' => array( 00728 44315 => (object) array( 00729 'questionid' => '83248', 00730 'hint' => 'See Unit 2, Subsection 2.3.', 00731 'rest' => null, 00732 'id' => 44315, 00733 ), 00734 44316 => (object) array( 00735 'questionid' => '83248', 00736 '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>', 00737 'rest' => null, 00738 'id' => 44316, 00739 ), 00740 ), 00741 'maxmark' => '1', 00742 ); 00743 $this->loader->put_question_in_cache($realquestion); 00744 00745 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 00746 00747 $expectedqa = (object) array( 00748 'behaviour' => 'deferredfeedback', 00749 'questionid' => 83248, 00750 'variant' => 1, 00751 'maxmark' => 1, 00752 'minfraction' => 0, 00753 'flagged' => 0, 00754 '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.)", 00755 'rightanswer' => '64 km', 00756 'responsesummary' => '64', 00757 'timemodified' => 1268471437, 00758 'steps' => array( 00759 0 => (object) array( 00760 'sequencenumber' => 0, 00761 'state' => 'todo', 00762 'fraction' => null, 00763 'timecreated' => 1267605659, 00764 'userid' => 239341, 00765 'data' => array('_separators' => '.$,'), 00766 ), 00767 1 => (object) array( 00768 'sequencenumber' => 1, 00769 'state' => 'complete', 00770 'fraction' => null, 00771 'timecreated' => 1268471437, 00772 'userid' => 239341, 00773 'data' => array('answer' => '64'), 00774 ), 00775 2 => (object) array( 00776 'sequencenumber' => 2, 00777 'state' => 'gradedright', 00778 'fraction' => 1, 00779 'timecreated' => 1268471437, 00780 'userid' => 239341, 00781 'data' => array('answer' => '64', '-finish' => '1'), 00782 ), 00783 ), 00784 ); 00785 00786 $this->compare_qas($expectedqa, $qa); 00787 } 00788 00789 public function test_numerical_deferredfeedback_qsession55() { 00790 $quiz = (object) array( 00791 'id' => '2', 00792 'course' => '2', 00793 'name' => 'Numerical quiz', 00794 'intro' => '', 00795 'introformat' => '1', 00796 'timeopen' => '0', 00797 'timeclose' => '0', 00798 'attempts' => '0', 00799 'attemptonlast' => '0', 00800 'grademethod' => '1', 00801 'decimalpoints' => '2', 00802 'questiondecimalpoints' => '-1', 00803 'review' => '4459503', 00804 'questionsperpage' => '1', 00805 'shufflequestions' => '0', 00806 'shuffleanswers' => '1', 00807 'questions' => '6,12,13,15,14,0', 00808 'sumgrades' => '5.00000', 00809 'grade' => '10.00000', 00810 'timecreated' => '0', 00811 'timemodified' => '1305273177', 00812 'timelimit' => '0', 00813 'password' => '', 00814 'subnet' => '', 00815 'popup' => '0', 00816 'delay1' => '0', 00817 'delay2' => '0', 00818 'showuserpicture' => '0', 00819 'showblocks' => '0', 00820 'preferredbehaviour' => 'deferredfeedback', 00821 ); 00822 $attempt = (object) array( 00823 'id' => '7', 00824 'uniqueid' => '7', 00825 'quiz' => '2', 00826 'userid' => '3', 00827 'attempt' => '1', 00828 'sumgrades' => '5.00000', 00829 'timestart' => '1305273645', 00830 'timefinish' => '1305273672', 00831 'timemodified' => '1305273672', 00832 'layout' => '6,12,13,15,14,0', 00833 'preview' => '0', 00834 'needsupgradetonewqe' => 1, 00835 ); 00836 $question = (object) array( 00837 'id' => '14', 00838 'category' => '2', 00839 'parent' => '0', 00840 'name' => 'MC units', 00841 'questiontext' => '<p>What is twice 1.5 m?</p>', 00842 'questiontextformat' => '1', 00843 'generalfeedback' => '', 00844 'generalfeedbackformat' => '1', 00845 'penalty' => '0.1000000', 00846 'qtype' => 'numerical', 00847 'length' => '1', 00848 'stamp' => 'tjh238.vledev2.open.ac.uk+110513075703+anXKfw', 00849 'version' => 'tjh238.vledev2.open.ac.uk+110513075807+HiXe4P', 00850 'hidden' => '0', 00851 'timecreated' => '1305273423', 00852 'timemodified' => '1305273487', 00853 'createdby' => '2', 00854 'modifiedby' => '2', 00855 'maxmark' => '1.0000000', 00856 'options' => (object) array( 00857 'answers' => array( 00858 21 => (object) array( 00859 'id' => '21', 00860 'question' => '14', 00861 'answer' => '3', 00862 'answerformat' => '0', 00863 'fraction' => '1.0000000', 00864 'feedback' => '', 00865 'feedbackformat' => '1', 00866 'tolerance' => '', 00867 ), 00868 ), 00869 'units' => array( 00870 0 => (object) array( 00871 'id' => '5', 00872 'question' => '14', 00873 'multiplier' => 1, 00874 'unit' => 'm', 00875 ), 00876 1 => (object) array( 00877 'id' => '6', 00878 'question' => '14', 00879 'multiplier' => 100, 00880 'unit' => 'cm', 00881 ), 00882 ), 00883 'unitgradingtype' => '2', 00884 'unitpenalty' => '0.5000000', 00885 'showunits' => '1', 00886 'unitsleft' => '0', 00887 'instructions' => '<p>Write an answer like 3 m.</p>', 00888 'instructionsformat' => '1', 00889 ), 00890 'defaultmark' => '1.0000000', 00891 ); 00892 $qsession = (object) array( 00893 'id' => '55', 00894 'attemptid' => '7', 00895 'questionid' => '14', 00896 'newest' => '155', 00897 'newgraded' => '155', 00898 'sumpenalty' => '0.1000000', 00899 'manualcomment' => '', 00900 'manualcommentformat' => '1', 00901 'flagged' => '0', 00902 ); 00903 $qstates = array( 00904 145 => (object) array( 00905 'id' => '145', 00906 'attempt' => '7', 00907 'question' => '14', 00908 'seq_number' => '0', 00909 'answer' => '|||||', 00910 'timestamp' => '1305273645', 00911 'event' => '0', 00912 'grade' => '0.0000000', 00913 'raw_grade' => '0.0000000', 00914 'penalty' => '0.0000000', 00915 ), 00916 150 => (object) array( 00917 'id' => '150', 00918 'attempt' => '7', 00919 'question' => '14', 00920 'seq_number' => '1', 00921 'answer' => '300|||||cm', 00922 'timestamp' => '1305273666', 00923 'event' => '2', 00924 'grade' => '0.0000000', 00925 'raw_grade' => '1.0000000', 00926 'penalty' => '0.1000000', 00927 ), 00928 155 => (object) array( 00929 'id' => '155', 00930 'attempt' => '7', 00931 'question' => '14', 00932 'seq_number' => '2', 00933 'answer' => '300|||||cm', 00934 'timestamp' => '1305273666', 00935 'event' => '6', 00936 'grade' => '1.0000000', 00937 'raw_grade' => '1.0000000', 00938 'penalty' => '0.1000000', 00939 ), 00940 ); 00941 00942 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 00943 00944 $expectedqa = (object) array( 00945 'behaviour' => 'deferredfeedback', 00946 'questionid' => 14, 00947 'variant' => 1, 00948 'maxmark' => 1.0000000, 00949 'minfraction' => 0, 00950 'flagged' => 0, 00951 'questionsummary' => 'What is twice 1.5 m?', 00952 'rightanswer' => '3 m', 00953 'responsesummary' => '300 cm', 00954 'timemodified' => 1305273666, 00955 'steps' => array( 00956 0 => (object) array( 00957 'sequencenumber' => 0, 00958 'state' => 'todo', 00959 'fraction' => null, 00960 'timecreated' => 1305273645, 00961 'userid' => 3, 00962 'data' => array('_separators' => '.$,'), 00963 ), 00964 1 => (object) array( 00965 'sequencenumber' => 1, 00966 'state' => 'complete', 00967 'fraction' => null, 00968 'timecreated' => 1305273666, 00969 'userid' => 3, 00970 'data' => array('answer' => '300', 'unit' => 'cm'), 00971 ), 00972 2 => (object) array( 00973 'sequencenumber' => 2, 00974 'state' => 'gradedright', 00975 'fraction' => 1, 00976 'timecreated' => 1305273666, 00977 'userid' => 3, 00978 'data' => array('answer' => '300', 'unit' => 'cm', '-finish' => 1), 00979 ), 00980 ), 00981 ); 00982 00983 $this->compare_qas($expectedqa, $qa); 00984 } 00985 }