1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace qtype_essay; 18 19 defined('MOODLE_INTERNAL') || die(); 20 21 global $CFG; 22 require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); 23 24 25 /** 26 * Testing the upgrade of essay question attempts. 27 * 28 * @package qtype_essay 29 * @copyright 2009 The Open University 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 */ 32 class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { 33 34 public function test_essay_deferredfeedback_history98220() { 35 $quiz = (object) array( 36 'id' => '4140', 37 'course' => '5012', 38 'name' => 'M887 Online Examination: 19th April 2010, 10am - 1pm', 39 'intro' => '<h2>M887 Examination Paper 19th April 2010</h2> 40 41 <h2>Postgraduate Computing<br />Web Systems Integration<br /></h2> 42 43 <h2>Begin by pressing Start Attempt (below)</h2>', 44 'introformat' => FORMAT_HTML, 45 'questiondecimalpoints' => '-1', 46 'showuserpicture' => '1', 47 'showblocks' => '1', 48 'timeopen' => '1271665800', 49 'timeclose' => '1271682000', 50 'preferredbehaviour' => 'deferredfeedback', 51 'attempts' => '1', 52 'attemptonlast' => '0', 53 'grademethod' => '1', 54 'decimalpoints' => '2', 55 'review' => '71727591', 56 'questionsperpage' => '1', 57 'shufflequestions' => '0', 58 'shuffleanswers' => '1', 59 'sumgrades' => '100', 60 'grade' => '100', 61 'timecreated' => '0', 62 'timemodified' => '1272274569', 63 'password' => '', 64 'subnet' => '', 65 'popup' => '0', 66 'delay1' => '0', 67 'delay2' => '0', 68 'timelimit' => '0', 69 ); 70 $attempt = (object) array( 71 'id' => '388325', 72 'uniqueid' => '388326', 73 'quiz' => '4140', 74 'userid' => '118065', 75 'attempt' => '1', 76 'sumgrades' => '51', 77 'timestart' => '1271667586', 78 'timefinish' => '1271678351', 79 'timemodified' => '1273069013', 80 'layout' => '90042,0,90043,0,90045,0,90052,0,90053,0,90054,0,90055,0,90056,0,90057,0,90058,0,90059,0,90046,0,90044,0,90047,0,90048,0,90049,0', 81 'preview' => '0', 82 ); 83 $question = (object) array( 84 'id' => '90056', 85 'category' => '8619', 86 'parent' => '0', 87 'name' => 'Question 6', 88 'questiontext' => '<p> 89 90 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><meta name="ProgId" content="Word.Document"></meta><meta name="Generator" content="Microsoft Word 11"></meta><meta name="Originator" content="Microsoft Word 11"></meta><link rel="File-List" href="file:///C:\\DOCUME~1\\pgt2\\LOCALS~1\\Temp\\msohtml1\\01\\clip_filelist.xml"></link><style></style>Give two examples of facilities within XML schemas that cannot be found in Document Type Definitions (DTDs).<br /><i>(2 marks)</i></p>', 91 'questiontextformat' => '1', 92 'defaultmark' => '2', 93 'penalty' => '0', 94 'qtype' => 'essay', 95 'length' => '1', 96 'stamp' => 'learn.open.ac.uk+100205101651+5eB30s', 97 'version' => 'learn.open.ac.uk+100209161823+oZCX9n', 98 'hidden' => '0', 99 'generalfeedback' => '', 100 'generalfeedbackformat' => '1', 101 'timecreated' => '1265365011', 102 'timemodified' => '1265732303', 103 'createdby' => '219095', 104 'modifiedby' => '25483', 105 'unlimited' => '0', 106 'maxmark' => '2', 107 'options' => (object) array( 108 'answers' => array( 109 303772 => (object) array( 110 'question' => '90056', 111 'answer' => '', 112 'fraction' => '0', 113 'feedback' => '', 114 'id' => 303772, 115 ), 116 ), 117 ), 118 'hints' => false, 119 ); 120 $qsession = (object) array( 121 'id' => '3962570', 122 'attemptid' => '388326', 123 'questionid' => '90056', 124 'newest' => '10517712', 125 'newgraded' => '10517712', 126 'sumpenalty' => '0', 127 'manualcomment' => '', 128 'manualcommentformat' => '1', 129 'flagged' => '1', 130 ); 131 $qstates = array( 132 10094242 => (object) array( 133 'attempt' => '388326', 134 'question' => '90056', 135 'originalquestion' => '0', 136 'seq_number' => '0', 137 'answer' => '', 138 'timestamp' => '1271667586', 139 'event' => '0', 140 'grade' => '0', 141 'raw_grade' => '0', 142 'penalty' => '0', 143 'id' => 10094242, 144 ), 145 10096161 => (object) array( 146 'attempt' => '388326', 147 'question' => '90056', 148 'originalquestion' => '0', 149 'seq_number' => '1', 150 'answer' => '<p>Variable typeing</p> 151 <p>Namespaces</p>', 152 'timestamp' => '1271670445', 153 'event' => '2', 154 'grade' => '0', 155 'raw_grade' => '0', 156 'penalty' => '0', 157 'id' => 10096161, 158 ), 159 10097144 => (object) array( 160 'attempt' => '388326', 161 'question' => '90056', 162 'originalquestion' => '0', 163 'seq_number' => '2', 164 'answer' => '<p>Variable can be typed</p> 165 <p>xml Schemas fully support Namespaces</p>', 166 'timestamp' => '1271671440', 167 'event' => '2', 168 'grade' => '0', 169 'raw_grade' => '0', 170 'penalty' => '0', 171 'id' => 10097144, 172 ), 173 10103710 => (object) array( 174 'attempt' => '388326', 175 'question' => '90056', 176 'originalquestion' => '0', 177 'seq_number' => '3', 178 'answer' => '<p>Variable can be typed</p> 179 <p>xml Schemas fully support Namespaces</p>', 180 'timestamp' => '1271671440', 181 'event' => '8', 182 'grade' => '0', 183 'raw_grade' => '0', 184 'penalty' => '0', 185 'id' => 10103710, 186 ), 187 10517712 => (object) array( 188 'attempt' => '388326', 189 'question' => '90056', 190 'originalquestion' => '0', 191 'seq_number' => '4', 192 'answer' => '<p>Variable can be typed</p> 193 <p>xml Schemas fully support Namespaces</p>', 194 'timestamp' => '1273068477', 195 'event' => '9', 196 'grade' => '2', 197 'raw_grade' => '2', 198 'penalty' => '0', 199 'id' => 10517712, 200 ), 201 ); 202 203 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 204 205 $expectedqa = (object) array( 206 'behaviour' => 'manualgraded', 207 'questionid' => 90056, 208 'variant' => 1, 209 'maxmark' => 2, 210 'minfraction' => 0, 211 'maxfraction' => 1, 212 'flagged' => 0, 213 'questionsummary' => "Give two examples of facilities within XML schemas that cannot be found in Document Type Definitions (DTDs).\n_(2 marks)_", 214 'rightanswer' => '', 215 'responsesummary' => "Variable can be typed \n\nxml Schemas fully support Namespaces", 216 'timemodified' => 1273068477, 217 'steps' => array( 218 0 => (object) array( 219 'sequencenumber' => 0, 220 'state' => 'todo', 221 'fraction' => null, 222 'timecreated' => 1271667586, 223 'userid' => 118065, 224 'data' => array(), 225 ), 226 1 => (object) array( 227 'sequencenumber' => 1, 228 'state' => 'complete', 229 'fraction' => null, 230 'timecreated' => 1271670445, 231 'userid' => 118065, 232 'data' => array('answer' => '<p>Variable typeing</p> 233 <p>Namespaces</p>', 'answerformat' => FORMAT_HTML), 234 ), 235 2 => (object) array( 236 'sequencenumber' => 2, 237 'state' => 'complete', 238 'fraction' => null, 239 'timecreated' => 1271671440, 240 'userid' => 118065, 241 'data' => array('answer' => '<p>Variable can be typed</p> 242 <p>xml Schemas fully support Namespaces</p>', 'answerformat' => FORMAT_HTML), 243 ), 244 3 => (object) array( 245 'sequencenumber' => 3, 246 'state' => 'needsgrading', 247 'fraction' => null, 248 'timecreated' => 1271671440, 249 'userid' => 118065, 250 'data' => array('answer' => '<p>Variable can be typed</p> 251 <p>xml Schemas fully support Namespaces</p>', '-finish' => 1, 'answerformat' => FORMAT_HTML), 252 ), 253 4 => (object) array( 254 'sequencenumber' => 4, 255 'state' => 'mangrright', 256 'fraction' => 1, 257 'timecreated' => 1273068477, 258 'userid' => null, 259 'data' => array('-comment' => '', '-mark' => 2, '-maxmark' => 2, 'answerformat' => FORMAT_HTML), 260 ), 261 ), 262 ); 263 264 $this->compare_qas($expectedqa, $qa); 265 } 266 267 public function test_essay_deferredfeedback_history820() { 268 $quiz = (object) array( 269 'id' => '142', 270 'course' => '187', 271 'name' => 'Questionnaire', 272 'intro' => '<p>B680 is pioneering the use of the eAssessment module in the OU VLE (Virtual Learning Environment). We believe that the module is fit for purpose but we need users\' (students and ALs) experience to confirm this. Your answers to this short questionnaire therefore are of wide importance to the OU VLE Development Programme. If you could complete this short questionnaire after attempting Practice CTMA04 <b></b>it would be greatly appreciated.</p> 273 <p>The questionnaire has 15 questions and we would like you to answer as many of these as possible. When you have completed your answers you will see a End test button, similar to the one in Practice CTMA 04, which you will need to click. This will move you to a Summary page. Please click the \'Submit all and finish\' button when you are happy to submit your final answers. <strong>Please complete the questionnaire only once.</strong> At a later stage the B680 Course Team will analyse the students\' answers to the questions. <br /></p>', 274 'introformat' => FORMAT_HTML, 275 'questiondecimalpoints' => '-1', 276 'showuserpicture' => '1', 277 'showblocks' => '1', 278 'timeopen' => '0', 279 'timeclose' => '0', 280 'preferredbehaviour' => 'deferredfeedback', 281 'attempts' => '0', 282 'attemptonlast' => '0', 283 'grademethod' => '1', 284 'decimalpoints' => '2', 285 'review' => '71727591', 286 'questionsperpage' => '1', 287 'shufflequestions' => '0', 288 'shuffleanswers' => '0', 289 'sumgrades' => '0', 290 'grade' => '0', 291 'timecreated' => '0', 292 'timemodified' => '1178202609', 293 'password' => '', 294 'subnet' => '', 295 'popup' => '0', 296 'delay1' => '0', 297 'delay2' => '0', 298 'timelimit' => '0', 299 ); 300 $attempt = (object) array( 301 'id' => '4246', 302 'uniqueid' => '4246', 303 'quiz' => '142', 304 'userid' => '96864', 305 'attempt' => '1', 306 'sumgrades' => '0', 307 'timestart' => '1179134211', 308 'timefinish' => '1179134998', 309 'timemodified' => '1179134869', 310 'layout' => '3664,3716,0,3663,3717,0,3718,3719,0,3720,0,3733,3727,0,3728,3730,0,3731,3732,0,3726,3729,0', 311 'preview' => '0', 312 ); 313 $question = (object) array( 314 'id' => '3729', 315 'category' => '163', 316 'parent' => '0', 317 'name' => 'Question 98', 318 'questiontext' => 'If you answered ‘No’ to the previous question please expand on your problem here.<br /><b></b><br />', 319 'questiontextformat' => '1', 320 'defaultmark' => '0', 321 'penalty' => '0', 322 'qtype' => 'essay', 323 'length' => '1', 324 'stamp' => 'learn.open.ac.uk+070312094434+k2HaUF', 325 'version' => 'learn.open.ac.uk+070501173219+spx2IM', 326 'hidden' => '0', 327 'generalfeedback' => '', 328 'generalfeedbackformat' => '1', 329 'timecreated' => '0', 330 'timemodified' => '0', 331 'createdby' => null, 332 'modifiedby' => null, 333 'unlimited' => null, 334 'maxmark' => '0', 335 'options' => (object) array( 336 'answers' => array( 337 11264 => (object) array( 338 'question' => '3729', 339 'answer' => '', 340 'fraction' => '0', 341 'feedback' => '', 342 'id' => 11264, 343 ), 344 ), 345 ), 346 'hints' => false, 347 ); 348 $qsession = (object) array( 349 'id' => '47133', 350 'attemptid' => '4246', 351 'questionid' => '3729', 352 'newest' => '107502', 353 'newgraded' => '107407', 354 'sumpenalty' => '0', 355 'manualcomment' => '', 356 'manualcommentformat' => '1', 357 'flagged' => '1', 358 ); 359 $qstates = array( 360 107407 => (object) array( 361 'attempt' => '4246', 362 'question' => '3729', 363 'originalquestion' => '0', 364 'seq_number' => '0', 365 'answer' => '', 366 'timestamp' => '1179134211', 367 'event' => '0', 368 'grade' => '0', 369 'raw_grade' => '0', 370 'penalty' => '0', 371 'id' => 107407, 372 ), 373 107484 => (object) array( 374 'attempt' => '4246', 375 'question' => '3729', 376 'originalquestion' => '0', 377 'seq_number' => '1', 378 'answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.', 379 'timestamp' => '1179134869', 380 'event' => '2', 381 'grade' => '0', 382 'raw_grade' => '0', 383 'penalty' => '0', 384 'id' => 107484, 385 ), 386 107502 => (object) array( 387 'attempt' => '4246', 388 'question' => '3729', 389 'originalquestion' => '0', 390 'seq_number' => '2', 391 'answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.', 392 'timestamp' => '1179134869', 393 'event' => '8', 394 'grade' => '0', 395 'raw_grade' => '0', 396 'penalty' => '0', 397 'id' => 107502, 398 ), 399 ); 400 401 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates); 402 403 $expectedqa = (object) array( 404 'behaviour' => 'manualgraded', 405 'questionid' => 3729, 406 'variant' => 1, 407 'maxmark' => 0, 408 'minfraction' => 0, 409 'maxfraction' => 1, 410 'flagged' => 0, 411 'questionsummary' => "If you answered ‘No’ to the previous question please expand on your problem here.", 412 'rightanswer' => '', 413 'responsesummary' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.', 414 'timemodified' => 1179134869, 415 'steps' => array( 416 0 => (object) array( 417 'sequencenumber' => 0, 418 'state' => 'todo', 419 'fraction' => null, 420 'timecreated' => 1179134211, 421 'userid' => 96864, 422 'data' => array(), 423 ), 424 1 => (object) array( 425 'sequencenumber' => 1, 426 'state' => 'complete', 427 'fraction' => null, 428 'timecreated' => 1179134869, 429 'userid' => 96864, 430 'data' => array('answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.', 'answerformat' => FORMAT_HTML), 431 ), 432 2 => (object) array( 433 'sequencenumber' => 2, 434 'state' => 'needsgrading', 435 'fraction' => null, 436 'timecreated' => 1179134869, 437 'userid' => 96864, 438 'data' => array('-finish' => 1, 'answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.', 'answerformat' => FORMAT_HTML), 439 ), 440 ), 441 ); 442 443 $this->compare_qas($expectedqa, $qa); 444 } 445 446 public function test_essay_deferredfeedback_missing() { 447 $quiz = (object) array( 448 'id' => '142', 449 'course' => '187', 450 'name' => 'Questionnaire', 451 'intro' => '<p>B680 is pioneering the use of the eAssessment module in the OU VLE (Virtual Learning Environment). We believe that the module is fit for purpose but we need users\' (students and ALs) experience to confirm this. Your answers to this short questionnaire therefore are of wide importance to the OU VLE Development Programme. If you could complete this short questionnaire after attempting Practice CTMA04 <b></b>it would be greatly appreciated.</p> 452 <p>The questionnaire has 15 questions and we would like you to answer as many of these as possible. When you have completed your answers you will see a End test button, similar to the one in Practice CTMA 04, which you will need to click. This will move you to a Summary page. Please click the \'Submit all and finish\' button when you are happy to submit your final answers. <strong>Please complete the questionnaire only once.</strong> At a later stage the B680 Course Team will analyse the students\' answers to the questions. <br /></p>', 453 'introformat' => FORMAT_HTML, 454 'questiondecimalpoints' => '-1', 455 'showuserpicture' => '1', 456 'showblocks' => '1', 457 'timeopen' => '0', 458 'timeclose' => '0', 459 'preferredbehaviour' => 'deferredfeedback', 460 'attempts' => '0', 461 'attemptonlast' => '0', 462 'grademethod' => '1', 463 'decimalpoints' => '2', 464 'review' => '71727591', 465 'questionsperpage' => '1', 466 'shufflequestions' => '0', 467 'shuffleanswers' => '0', 468 'sumgrades' => '0', 469 'grade' => '0', 470 'timecreated' => '0', 471 'timemodified' => '1178202609', 472 'password' => '', 473 'subnet' => '', 474 'popup' => '0', 475 'delay1' => '0', 476 'delay2' => '0', 477 'timelimit' => '0', 478 ); 479 $attempt = (object) array( 480 'id' => '4246', 481 'uniqueid' => '4246', 482 'quiz' => '142', 483 'userid' => '96864', 484 'attempt' => '1', 485 'sumgrades' => '0', 486 'timestart' => '1179134211', 487 'timefinish' => '1179134998', 488 'timemodified' => '1179134869', 489 'layout' => '3664,3716,0,3663,3717,0,3718,3719,0,3720,0,3733,3727,0,3728,3730,0,3731,3732,0,3726,3729,0', 490 'preview' => '0', 491 ); 492 $question = (object) array( 493 'id' => '3729', 494 'category' => '163', 495 'parent' => '0', 496 'name' => 'Question 98', 497 'questiontext' => 'If you answered ‘No’ to the previous question please expand on your problem here.<br /><b></b><br />', 498 'questiontextformat' => '1', 499 'defaultmark' => '0', 500 'penalty' => '0', 501 'qtype' => 'essay', 502 'length' => '1', 503 'stamp' => 'learn.open.ac.uk+070312094434+k2HaUF', 504 'version' => 'learn.open.ac.uk+070501173219+spx2IM', 505 'hidden' => '0', 506 'generalfeedback' => '', 507 'generalfeedbackformat' => '1', 508 'timecreated' => '0', 509 'timemodified' => '0', 510 'createdby' => null, 511 'modifiedby' => null, 512 'unlimited' => null, 513 'maxmark' => '0', 514 'options' => (object) array( 515 'answers' => array( 516 11264 => (object) array( 517 'question' => '3729', 518 'answer' => '', 519 'fraction' => '0', 520 'feedback' => '', 521 'id' => 11264, 522 ), 523 ), 524 ), 525 'hints' => false, 526 ); 527 528 $qa = $this->updater->supply_missing_question_attempt( $quiz, $attempt, $question); 529 530 $expectedqa = (object) array( 531 'behaviour' => 'manualgraded', 532 'questionid' => 3729, 533 'variant' => 1, 534 'maxmark' => 0, 535 'minfraction' => 0, 536 'maxfraction' => 1, 537 'flagged' => 0, 538 'questionsummary' => "If you answered ‘No’ to the previous question please expand on your problem here.", 539 'rightanswer' => '', 540 'responsesummary' => '', 541 'timemodified' => 1179134211, 542 'steps' => array( 543 0 => (object) array( 544 'sequencenumber' => 0, 545 'state' => 'todo', 546 'fraction' => null, 547 'timecreated' => 1179134211, 548 'userid' => 96864, 549 'data' => array(), 550 ), 551 ), 552 ); 553 554 $this->compare_qas($expectedqa, $qa); 555 } 556 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body