|
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_numerical_attempt_upgrader_test extends question_attempt_upgrader_test_base { 00040 00041 public function test_numerical_deferredfeedback_history620() { 00042 $quiz = (object) array( 00043 'id' => '221', 00044 'course' => '187', 00045 'name' => 'Practice CTMA04', 00046 '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. ', 00047 'introformat' => FORMAT_HTML, 00048 'questiondecimalpoints' => '-1', 00049 'showuserpicture' => '1', 00050 'showblocks' => '1', 00051 'timeopen' => '1178492400', 00052 'timeclose' => '1193875200', 00053 'preferredbehaviour' => 'deferredfeedback', 00054 'attempts' => '0', 00055 'attemptonlast' => '0', 00056 'grademethod' => '1', 00057 'decimalpoints' => '2', 00058 'review' => '71727591', 00059 'questionsperpage' => '1', 00060 'shufflequestions' => '0', 00061 'shuffleanswers' => '0', 00062 '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', 00063 'sumgrades' => '100', 00064 'grade' => '100', 00065 'timecreated' => '0', 00066 'timemodified' => '1195232889', 00067 'password' => '', 00068 'subnet' => '', 00069 'popup' => '0', 00070 'delay1' => '0', 00071 'delay2' => '0', 00072 'timelimit' => '0', 00073 ); 00074 $attempt = (object) array( 00075 'id' => '4034', 00076 'uniqueid' => '4034', 00077 'quiz' => '221', 00078 'userid' => '405', 00079 'attempt' => '1', 00080 'sumgrades' => '59', 00081 'timestart' => '1178564323', 00082 'timefinish' => '1178575685', 00083 'timemodified' => '1178571037', 00084 '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', 00085 'preview' => '0', 00086 'needsupgradetonewqe' => '1', 00087 ); 00088 $question = (object) array( 00089 'id' => '4165', 00090 'category' => '204', 00091 'parent' => '0', 00092 'name' => '4ccP22 Book 11 Electronic Activity 6.3 Screen F2 NPV calcn(7)', 00093 'questiontext' => 'Calculate your answer to the nearest WHOLE £ and enter it in the blank space provided. 00094 <p>[Note: Please <b><i>DO NOT</i></b> enter commas, spaces or £ signs within the number you enter.] </p> 00095 <p>The cash flows of a project are set out below: </p> 00096 <p> 00097 <table width="500" border="1"><tbody> 00098 <tr> 00099 <th valign="top" width="50%" halign="CENTER">year 00100 </th> 00101 <th valign="top" width="50%">£ 00102 </th> 00103 </tr> 00104 <tr> 00105 <td>Year 0 00106 </td> 00107 <td>(28,000) 00108 </td> 00109 </tr> 00110 <tr> 00111 <td>Year 1 00112 </td> 00113 <td>18,000 00114 </td> 00115 </tr> 00116 <tr> 00117 <td>Year 2 00118 </td> 00119 <td>16,000 00120 </td> 00121 </tr></tbody> 00122 </table></p> 00123 <p>Using the Table in Book 11, what is the project\'s net present value using a discount rate of 10%? </p> 00124 <p>If it is negative, put a minus sign before the number you enter. </p> 00125 <p>£ </p>', 00126 'questiontextformat' => '1', 00127 'defaultmark' => '1', 00128 'penalty' => '1', 00129 'qtype' => 'numerical', 00130 'length' => '1', 00131 'stamp' => 'learn.open.ac.uk+070417143727+5hOqJ8', 00132 'version' => 'learn.open.ac.uk+070417154843+o0iHPi', 00133 'hidden' => '0', 00134 'generalfeedback' => '', 00135 'generalfeedbackformat' => '1', 00136 'timecreated' => '0', 00137 'timemodified' => '0', 00138 'createdby' => null, 00139 'modifiedby' => null, 00140 'unlimited' => null, 00141 'maxmark' => '1', 00142 'options' => (object) array( 00143 'answers' => array( 00144 12729 => (object) array( 00145 'question' => '4165', 00146 'answer' => '1586', 00147 'fraction' => '1', 00148 'feedback' => 'Yes, the correct answer is £1,586. Well done! 00149 <p>Note to the answer:<br />£(18,000 x 0.9091) + (£16,000 x 0.8264) - £28,000 = £1,586.2 (the factors are found in the Table 1 of the Appendix to Book 11) </p> 00150 <p>Book 11 Electronic Activity 6.3 Screen F2 </p>', 00151 'tolerance' => '0', 00152 'id' => 12729, 00153 ), 00154 12730 => (object) array( 00155 'question' => '4165', 00156 'answer' => '*', 00157 'fraction' => '0', 00158 'feedback' => 'The correct answer is £1,586. 00159 <p>Note to the answer:<br />£(18,000 x 0.9091) + (£16,000 x 0.8264) - £28,000 = £1,586.2 (the factors are found in the Table 1 of the Appendix to Book 11) </p> 00160 <p>Book 11 Electronic Activity 6.3 Screen F2 </p>', 00161 'tolerance' => '0', 00162 'id' => 12730, 00163 ), 00164 ), 00165 'units' => array( 00166 ), 00167 ), 00168 'hints' => false, 00169 ); 00170 $qsession = (object) array( 00171 'id' => '39882', 00172 'attemptid' => '4034', 00173 'questionid' => '4165', 00174 'newest' => '92971', 00175 'newgraded' => '92971', 00176 'sumpenalty' => '1', 00177 'manualcomment' => '', 00178 'manualcommentformat' => '1', 00179 'flagged' => '1', 00180 ); 00181 $qstates = array( 00182 92694 => (object) array( 00183 'attempt' => '4034', 00184 'question' => '4165', 00185 'originalquestion' => '0', 00186 'seq_number' => '0', 00187 'answer' => '', 00188 'timestamp' => '1178564323', 00189 'event' => '0', 00190 'grade' => '0', 00191 'raw_grade' => '0', 00192 'penalty' => '0', 00193 'id' => 92694, 00194 ), 00195 92764 => (object) array( 00196 'attempt' => '4034', 00197 'question' => '4165', 00198 'originalquestion' => '0', 00199 'seq_number' => '1', 00200 'answer' => '17520', 00201 'timestamp' => '1178567143', 00202 'event' => '2', 00203 'grade' => '0', 00204 'raw_grade' => '0', 00205 'penalty' => '1', 00206 'id' => 92764, 00207 ), 00208 92971 => (object) array( 00209 'attempt' => '4034', 00210 'question' => '4165', 00211 'originalquestion' => '0', 00212 'seq_number' => '2', 00213 'answer' => '17520', 00214 'timestamp' => '1178567143', 00215 'event' => '6', 00216 'grade' => '0', 00217 'raw_grade' => '0', 00218 'penalty' => '1', 00219 'id' => 92971, 00220 ), 00221 ); 00222 00223 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 00224 00225 $expectedqa = (object) array( 00226 'behaviour' => 'deferredfeedback', 00227 'questionid' => 4165, 00228 'variant' => 1, 00229 'maxmark' => 1, 00230 'minfraction' => 0, 00231 'flagged' => 0, 00232 'questionsummary' => "Calculate your answer to the nearest WHOLE £ and enter it in the blank space provided. \n\n[Note: Please _DO NOT_ enter commas, spaces or £ signs within the number you enter.] \n\nThe cash flows of a project are set out below: \n\n \t\tYear 0 \n \t\t(28,000) \n\n \t\tYear 1 \n \t\t18,000 \n\n \t\tYear 2 \n \t\t16,000 \n\nUsing the Table in Book 11, what is the project's net present value using a discount rate of 10%? \n\nIf it is negative, put a minus sign before the number you enter. \n\n£", 00233 'rightanswer' => '1586', 00234 'responsesummary' => '17520', 00235 'timemodified' => 1178567143, 00236 'steps' => array( 00237 0 => (object) array( 00238 'sequencenumber' => 0, 00239 'state' => 'todo', 00240 'fraction' => null, 00241 'timecreated' => 1178564323, 00242 'userid' => 405, 00243 'data' => array('_separators' => '.$,'), 00244 ), 00245 1 => (object) array( 00246 'sequencenumber' => 1, 00247 'state' => 'complete', 00248 'fraction' => null, 00249 'timecreated' => 1178567143, 00250 'userid' => 405, 00251 'data' => array('answer' => 17520), 00252 ), 00253 2 => (object) array( 00254 'sequencenumber' => 2, 00255 'state' => 'gradedwrong', 00256 'fraction' => 0, 00257 'timecreated' => 1178567143, 00258 'userid' => 405, 00259 'data' => array('answer' => 17520, '-finish' => 1), 00260 ), 00261 ), 00262 ); 00263 00264 $this->compare_qas($expectedqa, $qa); 00265 } 00266 00267 public function test_numerical_deferredfeedback_required_units() { 00268 $quiz = (object) array( 00269 'id' => '2', 00270 'course' => '2', 00271 'name' => 'Numerical quiz', 00272 'intro' => '', 00273 'introformat' => '1', 00274 'timeopen' => '0', 00275 'timeclose' => '0', 00276 'attempts' => '0', 00277 'attemptonlast' => '0', 00278 'grademethod' => '1', 00279 'decimalpoints' => '2', 00280 'questiondecimalpoints' => '-1', 00281 'review' => '4459503', 00282 'questionsperpage' => '1', 00283 'shufflequestions' => '0', 00284 'shuffleanswers' => '1', 00285 'questions' => '6,12,13,15,14,0', 00286 'sumgrades' => '5.00000', 00287 'grade' => '10.00000', 00288 'timecreated' => '0', 00289 'timemodified' => '1305273177', 00290 'timelimit' => '0', 00291 'password' => '', 00292 'subnet' => '', 00293 'popup' => '0', 00294 'delay1' => '0', 00295 'delay2' => '0', 00296 'showuserpicture' => '0', 00297 'showblocks' => '0', 00298 'preferredbehaviour' => 'deferredfeedback', 00299 ); 00300 $attempt = (object) array( 00301 'id' => '6', 00302 'uniqueid' => '6', 00303 'quiz' => '2', 00304 'userid' => '2', 00305 'attempt' => '1', 00306 'sumgrades' => '4.00000', 00307 'timestart' => '1305273566', 00308 'timefinish' => '1305273600', 00309 'timemodified' => '1305273600', 00310 'layout' => '6,12,13,15,14,0', 00311 'preview' => '1', 00312 'needsupgradetonewqe' => 1, 00313 ); 00314 $question = (object) array( 00315 'id' => '15', 00316 'category' => '2', 00317 'parent' => '0', 00318 'name' => 'Required units', 00319 'questiontext' => '<p>What is twice 1.5 m?</p>', 00320 'questiontextformat' => '1', 00321 'generalfeedback' => '', 00322 'generalfeedbackformat' => '1', 00323 'penalty' => '0.1000000', 00324 'qtype' => 'numerical', 00325 'length' => '1', 00326 'stamp' => 'tjh238.vledev2.open.ac.uk+110513075857+rrvakr', 00327 'version' => 'tjh238.vledev2.open.ac.uk+110513075857+PH0loi', 00328 'hidden' => '0', 00329 'timecreated' => '1305273537', 00330 'timemodified' => '1305273537', 00331 'createdby' => '2', 00332 'modifiedby' => '2', 00333 'maxmark' => '1.0000000', 00334 'options' => (object) array( 00335 'answers' => array( 00336 22 => (object) array( 00337 'id' => '22', 00338 'question' => '15', 00339 'answer' => '3', 00340 'answerformat' => '0', 00341 'fraction' => '1.0000000', 00342 'feedback' => '', 00343 'feedbackformat' => '1', 00344 'tolerance' => '', 00345 ), 00346 ), 00347 'units' => array( 00348 0 => (object) array( 00349 'id' => '7', 00350 'question' => '15', 00351 'multiplier' => 1, 00352 'unit' => 'm', 00353 ), 00354 1 => (object) array( 00355 'id' => '8', 00356 'question' => '15', 00357 'multiplier' => 100, 00358 'unit' => 'cm', 00359 ), 00360 ), 00361 'unitgradingtype' => '2', 00362 'unitpenalty' => '0.5000000', 00363 'showunits' => '0', 00364 'unitsleft' => '0', 00365 'instructions' => '<p>Write an answer like 3 m.</p>', 00366 'instructionsformat' => '1', 00367 ), 00368 'defaultmark' => '1.0000000', 00369 ); 00370 $qsession = (object) array( 00371 'id' => '49', 00372 'attemptid' => '6', 00373 'questionid' => '15', 00374 'newest' => '139', 00375 'newgraded' => '139', 00376 'sumpenalty' => '0.1000000', 00377 'manualcomment' => '', 00378 'manualcommentformat' => '1', 00379 'flagged' => '0', 00380 ); 00381 $qstates = array( 00382 129 => (object) array( 00383 'id' => '129', 00384 'attempt' => '6', 00385 'question' => '15', 00386 'seq_number' => '0', 00387 'answer' => '|||||', 00388 'timestamp' => '1305273566', 00389 'event' => '0', 00390 'grade' => '0.0000000', 00391 'raw_grade' => '0.0000000', 00392 'penalty' => '0.0000000', 00393 ), 00394 134 => (object) array( 00395 'id' => '134', 00396 'attempt' => '6', 00397 'question' => '15', 00398 'seq_number' => '1', 00399 'answer' => '3|||||m', 00400 'timestamp' => '1305273595', 00401 'event' => '2', 00402 'grade' => '0.0000000', 00403 'raw_grade' => '1.0000000', 00404 'penalty' => '0.1000000', 00405 ), 00406 139 => (object) array( 00407 'id' => '139', 00408 'attempt' => '6', 00409 'question' => '15', 00410 'seq_number' => '2', 00411 'answer' => '3|||||m', 00412 'timestamp' => '1305273595', 00413 'event' => '6', 00414 'grade' => '1.0000000', 00415 'raw_grade' => '1.0000000', 00416 'penalty' => '0.1000000', 00417 ), 00418 ); 00419 00420 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 00421 00422 $expectedqa = (object) array( 00423 'behaviour' => 'deferredfeedback', 00424 'questionid' => 15, 00425 'variant' => 1, 00426 'maxmark' => 1.0000000, 00427 'minfraction' => 0, 00428 'flagged' => 0, 00429 'questionsummary' => 'What is twice 1.5 m?', 00430 'rightanswer' => '3 m', 00431 'responsesummary' => '3 m', 00432 'timemodified' => 1305273595, 00433 'steps' => array( 00434 0 => (object) array( 00435 'sequencenumber' => 0, 00436 'state' => 'todo', 00437 'fraction' => null, 00438 'timecreated' => 1305273566, 00439 'userid' => 2, 00440 'data' => array('_separators' => '.$,'), 00441 ), 00442 1 => (object) array( 00443 'sequencenumber' => 1, 00444 'state' => 'complete', 00445 'fraction' => null, 00446 'timecreated' => 1305273595, 00447 'userid' => 2, 00448 'data' => array('answer' => '3 m'), 00449 ), 00450 2 => (object) array( 00451 'sequencenumber' => 2, 00452 'state' => 'gradedright', 00453 'fraction' => 1, 00454 'timecreated' => 1305273595, 00455 'userid' => 2, 00456 'data' => array('answer' => '3 m', '-finish' => '1'), 00457 ), 00458 ), 00459 ); 00460 00461 $this->compare_qas($expectedqa, $qa); 00462 } 00463 }