weekly release 2.3dev
[moodle.git] / question / type / multianswer / tests / upgradelibnewqe_test.php
CommitLineData
603bd001
PS
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/**
18 * Tests of the upgrade to the new Moodle question engine for attempts at
19 * multianswer questions.
20 *
21 * @package qtype
22 * @subpackage multianswer
23 * @copyright 2011 The Open University
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27
28defined('MOODLE_INTERNAL') || die();
29
30global $CFG;
31require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
32
33
34/**
35 * Testing the upgrade of multianswer question attempts.
36 *
37 * @copyright 2011 The Open University
38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 */
40class qtype_multianswer_attempt_upgrader_test extends question_attempt_upgrader_test_base {
41 public function test_multianswer_adaptivenopenalty_qsession104() {
42 $quiz = (object) array(
43 'id' => '5',
44 'course' => '2',
45 'name' => 'Multianswer quiz',
46 'intro' => '',
47 'introformat' => '1',
48 'timeopen' => '0',
49 'timeclose' => '0',
50 'attempts' => '0',
51 'attemptonlast' => '0',
52 'grademethod' => '1',
53 'decimalpoints' => '2',
54 'questiondecimalpoints' => '-1',
55 'review' => '4459503',
56 'questionsperpage' => '1',
57 'shufflequestions' => '0',
58 'shuffleanswers' => '1',
59 'questions' => '28,19,0',
60 'sumgrades' => '14.00000',
61 'grade' => '10.00000',
62 'timecreated' => '0',
63 'timemodified' => '1306424728',
64 'timelimit' => '0',
65 'password' => '',
66 'subnet' => '',
67 'popup' => '0',
68 'delay1' => '0',
69 'delay2' => '0',
70 'showuserpicture' => '0',
71 'showblocks' => '0',
72 'preferredbehaviour' => 'adaptivenopenalty',
73 );
74 $attempt = (object) array(
75 'id' => '16',
76 'uniqueid' => '16',
77 'quiz' => '5',
78 'userid' => '4',
79 'attempt' => '1',
80 'sumgrades' => '6.00000',
81 'timestart' => '1306425691',
82 'timefinish' => '1306425746',
83 'timemodified' => '1306425746',
84 'layout' => '28,19,0',
85 'preview' => '0',
86 'needsupgradetonewqe' => 1,
87 );
88 $question = (object) array(
89 'id' => '28',
90 'category' => '2',
91 'parent' => '0',
92 'name' => 'Very simple cloze',
93 'questiontext' => '<p>An answer {#1}.</p>',
94 'questiontextformat' => '1',
95 'generalfeedback' => '',
96 'generalfeedbackformat' => '1',
97 'penalty' => '0.1000000',
98 'qtype' => 'multianswer',
99 'length' => '1',
100 'stamp' => 'tjh238.vledev2.open.ac.uk+110526154631+XQLcXi',
101 'version' => 'tjh238.vledev2.open.ac.uk+110526154631+T8hPiI',
102 'hidden' => '0',
103 'timecreated' => '1306424791',
104 'timemodified' => '1306424791',
105 'createdby' => '2',
106 'modifiedby' => '2',
107 'maxmark' => '1.0000000',
108 'options' => (object) array(
109 'questions' => array(
110 1 => (object) array(
111 'id' => '29',
112 'category' => '2',
113 'parent' => '28',
114 'name' => 'Very simple cloze',
115 'questiontext' => '{1:SHORTANSWER:=frog#Yay!}',
116 'questiontextformat' => '0',
117 'generalfeedback' => '',
118 'generalfeedbackformat' => '1',
119 'defaultgrade' => '1.0000000',
120 'penalty' => '0.0000000',
121 'qtype' => 'shortanswer',
122 'length' => '1',
123 'stamp' => 'tjh238.vledev2.open.ac.uk+110526154631+j3BYTL',
124 'version' => 'tjh238.vledev2.open.ac.uk+110526154631+lxNwQv',
125 'hidden' => '0',
126 'timecreated' => '1306424791',
127 'timemodified' => '1306424791',
128 'createdby' => '2',
129 'modifiedby' => '2',
130 'options' => (object) array(
131 'answers' => array(
132 52 => (object) array(
133 'id' => '52',
134 'question' => '29',
135 'answer' => 'frog',
136 'answerformat' => '0',
137 'fraction' => '1.0000000',
138 'feedback' => 'Yay!',
139 'feedbackformat' => '1',
140 ),
141 ),
142 'usecase' => '0',
143 ),
144 'maxgrade' => '1.0000000',
145 ),
146 ),
147 ),
148 'defaultmark' => '1.0000000',
149 );
150 $qsession = (object) array(
151 'id' => '104',
152 'attemptid' => '16',
153 'questionid' => '28',
154 'newest' => '285',
155 'newgraded' => '285',
156 'sumpenalty' => '0.1000000',
157 'manualcomment' => '',
158 'manualcommentformat' => '1',
159 'flagged' => '0',
160 );
161 $qstates = array(
162 281 => (object) array(
163 'id' => '281',
164 'attempt' => '16',
165 'question' => '28',
166 'seq_number' => '0',
167 'answer' => '1-',
168 'timestamp' => '1306425691',
169 'event' => '0',
170 'grade' => '0.0000000',
171 'raw_grade' => '0.0000000',
172 'penalty' => '0.0000000',
173 ),
174 283 => (object) array(
175 'id' => '283',
176 'attempt' => '16',
177 'question' => '28',
178 'seq_number' => '1',
179 'answer' => '1-frog',
180 'timestamp' => '1306425739',
181 'event' => '2',
182 'grade' => '0.0000000',
183 'raw_grade' => '1.0000000',
184 'penalty' => '0.1000000',
185 ),
186 285 => (object) array(
187 'id' => '285',
188 'attempt' => '16',
189 'question' => '28',
190 'seq_number' => '2',
191 'answer' => '1-frog',
192 'timestamp' => '1306425739',
193 'event' => '6',
194 'grade' => '1.0000000',
195 'raw_grade' => '1.0000000',
196 'penalty' => '0.1000000',
197 ),
198 );
199
200 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
201
202 $expectedqa = (object) array(
203 'behaviour' => 'adaptivenopenalty',
204 'questionid' => 28,
205 'variant' => 1,
206 'maxmark' => 1.0000000,
207 'minfraction' => 0,
208 'flagged' => 0,
209 'questionsummary' => 'An answer _____.',
210 'rightanswer' => 'part 1: frog',
211 'responsesummary' => 'part 1: frog',
212 'timemodified' => 1306425739,
213 'steps' => array(
214 0 => (object) array(
215 'sequencenumber' => 0,
216 'state' => 'todo',
217 'fraction' => null,
218 'timecreated' => 1306425691,
219 'userid' => 4,
220 'data' => array(),
221 ),
222 1 => (object) array(
223 'sequencenumber' => 1,
224 'state' => 'complete',
225 'fraction' => null,
226 'timecreated' => 1306425739,
227 'userid' => 4,
228 'data' => array('sub1_answer' => 'frog'),
229 ),
230 2 => (object) array(
231 'sequencenumber' => 2,
232 'state' => 'gradedright',
233 'fraction' => 1.0,
234 'timecreated' => 1306425739,
235 'userid' => 4,
236 'data' => array('sub1_answer' => 'frog', '-finish' => '1',
237 '-_try' => '1', '-_rawfraction' => 1.0),
238 ),
239 ),
240 );
241
242 $this->compare_qas($expectedqa, $qa);
243 }
244
245 public function test_multianswer_adaptivenopenalty_qsession106() {
246 $quiz = (object) array(
247 'id' => '5',
248 'course' => '2',
249 'name' => 'Multianswer quiz',
250 'intro' => '',
251 'introformat' => '1',
252 'timeopen' => '0',
253 'timeclose' => '0',
254 'attempts' => '0',
255 'attemptonlast' => '0',
256 'grademethod' => '1',
257 'decimalpoints' => '2',
258 'questiondecimalpoints' => '-1',
259 'review' => '4459503',
260 'questionsperpage' => '1',
261 'shufflequestions' => '0',
262 'shuffleanswers' => '1',
263 'questions' => '28,19,0',
264 'sumgrades' => '14.00000',
265 'grade' => '10.00000',
266 'timecreated' => '0',
267 'timemodified' => '1306424728',
268 'timelimit' => '0',
269 'password' => '',
270 'subnet' => '',
271 'popup' => '0',
272 'delay1' => '0',
273 'delay2' => '0',
274 'showuserpicture' => '0',
275 'showblocks' => '0',
276 'preferredbehaviour' => 'adaptivenopenalty',
277 );
278 $attempt = (object) array(
279 'id' => '17',
280 'uniqueid' => '17',
281 'quiz' => '5',
282 'userid' => '4',
283 'attempt' => '2',
284 'sumgrades' => '0.00000',
285 'timestart' => '1306425757',
286 'timefinish' => '1306425762',
287 'timemodified' => '1306425762',
288 'layout' => '28,19,0',
289 'preview' => '0',
290 'needsupgradetonewqe' => 1,
291 );
292 $question = (object) array(
293 'id' => '28',
294 'category' => '2',
295 'parent' => '0',
296 'name' => 'Very simple cloze',
297 'questiontext' => '<p>An answer {#1}.</p>',
298 'questiontextformat' => '1',
299 'generalfeedback' => '',
300 'generalfeedbackformat' => '1',
301 'penalty' => '0.1000000',
302 'qtype' => 'multianswer',
303 'length' => '1',
304 'stamp' => 'tjh238.vledev2.open.ac.uk+110526154631+XQLcXi',
305 'version' => 'tjh238.vledev2.open.ac.uk+110526154631+T8hPiI',
306 'hidden' => '0',
307 'timecreated' => '1306424791',
308 'timemodified' => '1306424791',
309 'createdby' => '2',
310 'modifiedby' => '2',
311 'maxmark' => '1.0000000',
312 'options' => (object) array(
313 'questions' => array(
314 1 => (object) array(
315 'id' => '29',
316 'category' => '2',
317 'parent' => '28',
318 'name' => 'Very simple cloze',
319 'questiontext' => '{1:SHORTANSWER:=frog#Yay!}',
320 'questiontextformat' => '0',
321 'generalfeedback' => '',
322 'generalfeedbackformat' => '1',
323 'defaultgrade' => '1.0000000',
324 'penalty' => '0.0000000',
325 'qtype' => 'shortanswer',
326 'length' => '1',
327 'stamp' => 'tjh238.vledev2.open.ac.uk+110526154631+j3BYTL',
328 'version' => 'tjh238.vledev2.open.ac.uk+110526154631+lxNwQv',
329 'hidden' => '0',
330 'timecreated' => '1306424791',
331 'timemodified' => '1306424791',
332 'createdby' => '2',
333 'modifiedby' => '2',
334 'options' => (object) array(
335 'answers' => array(
336 52 => (object) array(
337 'id' => '52',
338 'question' => '29',
339 'answer' => 'frog',
340 'answerformat' => '0',
341 'fraction' => '1.0000000',
342 'feedback' => 'Yay!',
343 'feedbackformat' => '1',
344 ),
345 ),
346 'usecase' => '0',
347 ),
348 'maxgrade' => '1.0000000',
349 ),
350 ),
351 ),
352 'defaultmark' => '1.0000000',
353 );
354 $qsession = (object) array(
355 'id' => '106',
356 'attemptid' => '17',
357 'questionid' => '28',
358 'newest' => '289',
359 'newgraded' => '289',
360 'sumpenalty' => '0.1000000',
361 'manualcomment' => '',
362 'manualcommentformat' => '1',
363 'flagged' => '0',
364 );
365 $qstates = array(
366 287 => (object) array(
367 'id' => '287',
368 'attempt' => '17',
369 'question' => '28',
370 'seq_number' => '0',
371 'answer' => '1-',
372 'timestamp' => '1306425757',
373 'event' => '0',
374 'grade' => '0.0000000',
375 'raw_grade' => '0.0000000',
376 'penalty' => '0.0000000',
377 ),
378 289 => (object) array(
379 'id' => '289',
380 'attempt' => '17',
381 'question' => '28',
382 'seq_number' => '1',
383 'answer' => '1-',
384 'timestamp' => '1306425757',
385 'event' => '6',
386 'grade' => '0.0000000',
387 'raw_grade' => '0.0000000',
388 'penalty' => '0.1000000',
389 ),
390 );
391
392 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
393
394 $expectedqa = (object) array(
395 'behaviour' => 'adaptivenopenalty',
396 'questionid' => 28,
397 'variant' => 1,
398 'maxmark' => 1.0000000,
399 'minfraction' => 0,
400 'flagged' => 0,
401 'questionsummary' => 'An answer _____.',
402 'rightanswer' => 'part 1: frog',
403 'responsesummary' => 'part 1: ',
404 'timemodified' => 1306425757,
405 'steps' => array(
406 0 => (object) array(
407 'sequencenumber' => 0,
408 'state' => 'todo',
409 'fraction' => null,
410 'timecreated' => 1306425757,
411 'userid' => 4,
412 'data' => array(),
413 ),
414 1 => (object) array(
415 'sequencenumber' => 1,
416 'state' => 'gradedwrong',
417 'fraction' => 0.0,
418 'timecreated' => 1306425757,
419 'userid' => 4,
420 'data' => array('-finish' => '1', '-_try' => '1', '-_rawfraction' => 0.0),
421 ),
422 ),
423 );
424
425 $this->compare_qas($expectedqa, $qa);
426 }
427
428 public function test_multianswer_adaptivenopenalty_qsession108() {
429 $quiz = (object) array(
430 'id' => '5',
431 'course' => '2',
432 'name' => 'Multianswer quiz',
433 'intro' => '',
434 'introformat' => '1',
435 'timeopen' => '0',
436 'timeclose' => '0',
437 'attempts' => '0',
438 'attemptonlast' => '0',
439 'grademethod' => '1',
440 'decimalpoints' => '2',
441 'questiondecimalpoints' => '-1',
442 'review' => '4459503',
443 'questionsperpage' => '1',
444 'shufflequestions' => '0',
445 'shuffleanswers' => '1',
446 'questions' => '28,19,0',
447 'sumgrades' => '14.00000',
448 'grade' => '10.00000',
449 'timecreated' => '0',
450 'timemodified' => '1306424728',
451 'timelimit' => '0',
452 'password' => '',
453 'subnet' => '',
454 'popup' => '0',
455 'delay1' => '0',
456 'delay2' => '0',
457 'showuserpicture' => '0',
458 'showblocks' => '0',
459 'preferredbehaviour' => 'adaptivenopenalty',
460 );
461 $attempt = (object) array(
462 'id' => '18',
463 'uniqueid' => '18',
464 'quiz' => '5',
465 'userid' => '3',
466 'attempt' => '1',
467 'sumgrades' => '10.40000',
468 'timestart' => '1306425784',
469 'timefinish' => '1306425931',
470 'timemodified' => '1306425931',
471 'layout' => '28,19,0',
472 'preview' => '0',
473 'needsupgradetonewqe' => 1,
474 );
475 $question = (object) array(
476 'id' => '28',
477 'category' => '2',
478 'parent' => '0',
479 'name' => 'Very simple cloze',
480 'questiontext' => '<p>An answer {#1}.</p>',
481 'questiontextformat' => '1',
482 'generalfeedback' => '',
483 'generalfeedbackformat' => '1',
484 'penalty' => '0.1000000',
485 'qtype' => 'multianswer',
486 'length' => '1',
487 'stamp' => 'tjh238.vledev2.open.ac.uk+110526154631+XQLcXi',
488 'version' => 'tjh238.vledev2.open.ac.uk+110526154631+T8hPiI',
489 'hidden' => '0',
490 'timecreated' => '1306424791',
491 'timemodified' => '1306424791',
492 'createdby' => '2',
493 'modifiedby' => '2',
494 'maxmark' => '1.0000000',
495 'options' => (object) array(
496 'questions' => array(
497 1 => (object) array(
498 'id' => '29',
499 'category' => '2',
500 'parent' => '28',
501 'name' => 'Very simple cloze',
502 'questiontext' => '{1:SHORTANSWER:=frog#Yay!}',
503 'questiontextformat' => '0',
504 'generalfeedback' => '',
505 'generalfeedbackformat' => '1',
506 'defaultgrade' => '1.0000000',
507 'penalty' => '0.0000000',
508 'qtype' => 'shortanswer',
509 'length' => '1',
510 'stamp' => 'tjh238.vledev2.open.ac.uk+110526154631+j3BYTL',
511 'version' => 'tjh238.vledev2.open.ac.uk+110526154631+lxNwQv',
512 'hidden' => '0',
513 'timecreated' => '1306424791',
514 'timemodified' => '1306424791',
515 'createdby' => '2',
516 'modifiedby' => '2',
517 'options' => (object) array(
518 'answers' => array(
519 52 => (object) array(
520 'id' => '52',
521 'question' => '29',
522 'answer' => 'frog',
523 'answerformat' => '0',
524 'fraction' => '1.0000000',
525 'feedback' => 'Yay!',
526 'feedbackformat' => '1',
527 ),
528 ),
529 'usecase' => '0',
530 ),
531 'maxgrade' => '1.0000000',
532 ),
533 ),
534 ),
535 'defaultmark' => '1.0000000',
536 );
537 $qsession = (object) array(
538 'id' => '108',
539 'attemptid' => '18',
540 'questionid' => '28',
541 'newest' => '298',
542 'newgraded' => '298',
543 'sumpenalty' => '0.2000000',
544 'manualcomment' => '',
545 'manualcommentformat' => '1',
546 'flagged' => '0',
547 );
548 $qstates = array(
549 291 => (object) array(
550 'id' => '291',
551 'attempt' => '18',
552 'question' => '28',
553 'seq_number' => '0',
554 'answer' => '1-',
555 'timestamp' => '1306425784',
556 'event' => '0',
557 'grade' => '0.0000000',
558 'raw_grade' => '0.0000000',
559 'penalty' => '0.0000000',
560 ),
561 293 => (object) array(
562 'id' => '293',
563 'attempt' => '18',
564 'question' => '28',
565 'seq_number' => '1',
566 'answer' => '1-ds&#0044;&#0045;afg',
567 'timestamp' => '1306425801',
568 'event' => '2',
569 'grade' => '0.0000000',
570 'raw_grade' => '0.0000000',
571 'penalty' => '0.1000000',
572 ),
573 297 => (object) array(
574 'id' => '297',
575 'attempt' => '18',
576 'question' => '28',
577 'seq_number' => '2',
578 'answer' => '1-frog',
579 'timestamp' => '1306425917',
580 'event' => '3',
581 'grade' => '1.0000000',
582 'raw_grade' => '1.0000000',
583 'penalty' => '0.1000000',
584 ),
585 298 => (object) array(
586 'id' => '298',
587 'attempt' => '18',
588 'question' => '28',
589 'seq_number' => '3',
590 'answer' => '1-frog',
591 'timestamp' => '1306425917',
592 'event' => '6',
593 'grade' => '1.0000000',
594 'raw_grade' => '1.0000000',
595 'penalty' => '0.1000000',
596 ),
597 );
598
599 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
600
601 $expectedqa = (object) array(
602 'behaviour' => 'adaptivenopenalty',
603 'questionid' => 28,
604 'variant' => 1,
605 'maxmark' => 1.0000000,
606 'minfraction' => 0,
607 'flagged' => 0,
608 'questionsummary' => 'An answer _____.',
609 'rightanswer' => 'part 1: frog',
610 'responsesummary' => 'part 1: frog',
611 'timemodified' => 1306425917,
612 'steps' => array(
613 0 => (object) array(
614 'sequencenumber' => 0,
615 'state' => 'todo',
616 'fraction' => null,
617 'timecreated' => 1306425784,
618 'userid' => 3,
619 'data' => array(),
620 ),
621 1 => (object) array(
622 'sequencenumber' => 1,
623 'state' => 'complete',
624 'fraction' => null,
625 'timecreated' => 1306425801,
626 'userid' => 3,
627 'data' => array('sub1_answer' => 'ds,-afg'),
628 ),
629 2 => (object) array(
630 'sequencenumber' => 2,
631 'state' => 'complete',
632 'fraction' => 1,
633 'timecreated' => 1306425917,
634 'userid' => 3,
635 'data' => array('sub1_answer' => 'frog', '-_try' => 1,
636 '-_rawfraction' => 1.0, '-submit' => 1),
637 ),
638 3 => (object) array(
639 'sequencenumber' => 3,
640 'state' => 'gradedright',
641 'fraction' => 1,
642 'timecreated' => 1306425917,
643 'userid' => 3,
644 'data' => array('sub1_answer' => 'frog', '-_try' => 1,
645 '-_rawfraction' => 1.0, '-finish' => 1),
646 ),
647 ),
648 );
649
650 $this->compare_qas($expectedqa, $qa);
651 }
652
653 public function test_multianswer_adaptivenopenalty_qsession105() {
654 $quiz = (object) array(
655 'id' => '5',
656 'course' => '2',
657 'name' => 'Multianswer quiz',
658 'intro' => '',
659 'introformat' => '1',
660 'timeopen' => '0',
661 'timeclose' => '0',
662 'attempts' => '0',
663 'attemptonlast' => '0',
664 'grademethod' => '1',
665 'decimalpoints' => '2',
666 'questiondecimalpoints' => '-1',
667 'review' => '4459503',
668 'questionsperpage' => '1',
669 'shufflequestions' => '0',
670 'shuffleanswers' => '1',
671 'questions' => '28,19,0',
672 'sumgrades' => '14.00000',
673 'grade' => '10.00000',
674 'timecreated' => '0',
675 'timemodified' => '1306424728',
676 'timelimit' => '0',
677 'password' => '',
678 'subnet' => '',
679 'popup' => '0',
680 'delay1' => '0',
681 'delay2' => '0',
682 'showuserpicture' => '0',
683 'showblocks' => '0',
684 'preferredbehaviour' => 'adaptivenopenalty',
685 );
686 $attempt = (object) array(
687 'id' => '16',
688 'uniqueid' => '16',
689 'quiz' => '5',
690 'userid' => '4',
691 'attempt' => '1',
692 'sumgrades' => '6.00000',
693 'timestart' => '1306425691',
694 'timefinish' => '1306425746',
695 'timemodified' => '1306425746',
696 'layout' => '28,19,0',
697 'preview' => '0',
698 'needsupgradetonewqe' => 1,
699 );
700 $question = (object) array(
701 'id' => '19',
702 'category' => '2',
703 'parent' => '0',
704 'name' => 'Cloze',
705 'questiontext' => '<p>This question consists of some text with an answer embedded right here {#1}</p>
706 <p>and right after that you will have to deal with this short answer {#2}</p>
707 <p>and finally we have a floating point number {#3}.</p>
708 <p>The multichoice question can also be shown in the vertical display of the standard moodle multiple choice. {#4}</p>
709 <p>Or in an horizontal display that is included here in a table {#5}</p>
710 <p>A shortanswer question where case must match. Write moodle in upper case letters {#6}</p>
711 <p>Note that addresses like www.moodle.org and smileys :-) all work as normal:</p>
712 <p>a) How good is this? {#7}</p>
713 <p>b) What grade would you give it? {#8}</p>',
714 'questiontextformat' => '1',
715 'generalfeedback' => '',
716 'generalfeedbackformat' => '1',
717 'penalty' => '0.1000000',
718 'qtype' => 'multianswer',
719 'length' => '1',
720 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164438+iwiint',
721 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+AAjnIy',
722 'hidden' => '0',
723 'timecreated' => '1306341878',
724 'timemodified' => '1306341879',
725 'createdby' => '2',
726 'modifiedby' => '2',
727 'maxmark' => '13.0000000',
728 'options' => (object) array(
729 'questions' => array(
730 1 => (object) array(
731 'id' => '20',
732 'category' => '2',
733 'parent' => '19',
734 'name' => 'Cloze',
735 'questiontext' => '{1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}',
736 'questiontextformat' => '0',
737 'generalfeedback' => '',
738 'generalfeedbackformat' => '1',
739 'defaultgrade' => '1.0000000',
740 'penalty' => '0.0000000',
741 'qtype' => 'multichoice',
742 'length' => '1',
743 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164439+cAuJ4r',
744 'version' => 'tjh238.vledev2.open.ac.uk+110525164439+5bnnys',
745 'hidden' => '0',
746 'timecreated' => '1306341879',
747 'timemodified' => '1306341879',
748 'createdby' => '2',
749 'modifiedby' => '2',
750 'options' => (object) array(
751 'id' => '3',
752 'question' => '20',
753 'layout' => '0',
754 'answers' => array(
755 29 => (object) array(
756 'id' => '29',
757 'question' => '20',
758 'answer' => 'Wrong answer',
759 'answerformat' => '1',
760 'fraction' => '0.0000000',
761 'feedback' => 'Feedback for this wrong answer',
762 'feedbackformat' => '1',
763 ),
764 30 => (object) array(
765 'id' => '30',
766 'question' => '20',
767 'answer' => 'Another wrong answer',
768 'answerformat' => '1',
769 'fraction' => '0.0000000',
770 'feedback' => 'Feedback for the other wrong answer',
771 'feedbackformat' => '1',
772 ),
773 31 => (object) array(
774 'id' => '31',
775 'question' => '20',
776 'answer' => 'Correct answer',
777 'answerformat' => '1',
778 'fraction' => '1.0000000',
779 'feedback' => 'Feedback for correct answer',
780 'feedbackformat' => '1',
781 ),
782 32 => (object) array(
783 'id' => '32',
784 'question' => '20',
785 'answer' => 'Answer that gives half the credit',
786 'answerformat' => '1',
787 'fraction' => '0.5000000',
788 'feedback' => 'Feedback for half credit answer',
789 'feedbackformat' => '1',
790 ),
791 ),
792 'single' => '1',
793 'shuffleanswers' => '1',
794 'correctfeedback' => '',
795 'correctfeedbackformat' => '1',
796 'partiallycorrectfeedback' => '',
797 'partiallycorrectfeedbackformat' => '1',
798 'incorrectfeedback' => '',
799 'incorrectfeedbackformat' => '1',
800 'answernumbering' => '0',
801 ),
802 'maxgrade' => '1.0000000',
803 ),
804 2 => (object) array(
805 'id' => '21',
806 'category' => '2',
807 'parent' => '19',
808 'name' => 'Cloze',
809 'questiontext' => '{1:SHORTANSWER:Wrong answer#Feedback for this wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}',
810 'questiontextformat' => '0',
811 'generalfeedback' => '',
812 'generalfeedbackformat' => '1',
813 'defaultgrade' => '1.0000000',
814 'penalty' => '0.0000000',
815 'qtype' => 'shortanswer',
816 'length' => '1',
817 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164440+EN6wCk',
818 'version' => 'tjh238.vledev2.open.ac.uk+110525164440+bQzatI',
819 'hidden' => '0',
820 'timecreated' => '1306341880',
821 'timemodified' => '1306341880',
822 'createdby' => '2',
823 'modifiedby' => '2',
824 'options' => (object) array(
825 'answers' => array(
826 33 => (object) array(
827 'id' => '33',
828 'question' => '21',
829 'answer' => 'Wrong answer',
830 'answerformat' => '0',
831 'fraction' => '0.0000000',
832 'feedback' => 'Feedback for this wrong answer',
833 'feedbackformat' => '1',
834 ),
835 34 => (object) array(
836 'id' => '34',
837 'question' => '21',
838 'answer' => 'Correct answer',
839 'answerformat' => '0',
840 'fraction' => '1.0000000',
841 'feedback' => 'Feedback for correct answer',
842 'feedbackformat' => '1',
843 ),
844 35 => (object) array(
845 'id' => '35',
846 'question' => '21',
847 'answer' => 'Answer that gives half the credit',
848 'answerformat' => '0',
849 'fraction' => '0.5000000',
850 'feedback' => 'Feedback for half credit answer',
851 'feedbackformat' => '1',
852 ),
853 ),
854 'usecase' => '0',
855 ),
856 'maxgrade' => '1.0000000',
857 ),
858 3 => (object) array(
859 'id' => '22',
860 'category' => '2',
861 'parent' => '19',
862 'name' => 'Cloze',
863 'questiontext' => '{2:NUMERICAL:=23.8:0.1#Feedback for correct answer 23.8~%50%23.8:2#Feedback for half credit answer in the nearby region of the correct answer}',
864 'questiontextformat' => '0',
865 'generalfeedback' => '',
866 'generalfeedbackformat' => '1',
867 'defaultgrade' => '2.0000000',
868 'penalty' => '0.0000000',
869 'qtype' => 'numerical',
870 'length' => '1',
871 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164440+Xr29c2',
872 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+QTwsGM',
873 'hidden' => '0',
874 'timecreated' => '1306341880',
875 'timemodified' => '1306341880',
876 'createdby' => '2',
877 'modifiedby' => '2',
878 'options' => (object) array(
879 'answers' => array(
880 36 => (object) array(
881 'id' => '36',
882 'question' => '22',
883 'answer' => '23.8',
884 'answerformat' => '0',
885 'fraction' => '1.0000000',
886 'feedback' => 'Feedback for correct answer 23.8',
887 'feedbackformat' => '1',
888 'tolerance' => '0.1',
889 ),
890 37 => (object) array(
891 'id' => '37',
892 'question' => '22',
893 'answer' => '23.8',
894 'answerformat' => '0',
895 'fraction' => '0.5000000',
896 'feedback' => 'Feedback for half credit answer in the nearby region of the correct answer',
897 'feedbackformat' => '1',
898 'tolerance' => '2',
899 ),
900 ),
901 'units' => array(
902 ),
903 'unitgradingtype' => '0',
904 'unitpenalty' => '1.0000000',
905 'showunits' => '3',
906 'unitsleft' => '0',
907 'instructions' => '',
908 'instructionsformat' => '1',
909 ),
910 'maxgrade' => '2.0000000',
911 ),
912 4 => (object) array(
913 'id' => '23',
914 'category' => '2',
915 'parent' => '19',
916 'name' => 'Cloze',
917 'questiontext' => '{2:MCV:1. Wrong answer#Feedback for this wrong answer~2. Another wrong answer#Feedback for the other wrong answer~=3. Correct answer#Feedback for correct answer~%50%4. Answer that gives half the credit#Feedback for half credit answer}',
918 'questiontextformat' => '0',
919 'generalfeedback' => '',
920 'generalfeedbackformat' => '1',
921 'defaultgrade' => '2.0000000',
922 'penalty' => '0.0000000',
923 'qtype' => 'multichoice',
924 'length' => '1',
925 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+7R55HA',
926 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+uCMoQc',
927 'hidden' => '0',
928 'timecreated' => '1306341881',
929 'timemodified' => '1306341881',
930 'createdby' => '2',
931 'modifiedby' => '2',
932 'options' => (object) array(
933 'id' => '4',
934 'question' => '23',
935 'layout' => '1',
936 'answers' => array(
937 38 => (object) array(
938 'id' => '38',
939 'question' => '23',
940 'answer' => '1. Wrong answer',
941 'answerformat' => '1',
942 'fraction' => '0.0000000',
943 'feedback' => 'Feedback for this wrong answer',
944 'feedbackformat' => '1',
945 ),
946 39 => (object) array(
947 'id' => '39',
948 'question' => '23',
949 'answer' => '2. Another wrong answer',
950 'answerformat' => '1',
951 'fraction' => '0.0000000',
952 'feedback' => 'Feedback for the other wrong answer',
953 'feedbackformat' => '1',
954 ),
955 40 => (object) array(
956 'id' => '40',
957 'question' => '23',
958 'answer' => '3. Correct answer',
959 'answerformat' => '1',
960 'fraction' => '1.0000000',
961 'feedback' => 'Feedback for correct answer',
962 'feedbackformat' => '1',
963 ),
964 41 => (object) array(
965 'id' => '41',
966 'question' => '23',
967 'answer' => '4. Answer that gives half the credit',
968 'answerformat' => '1',
969 'fraction' => '0.5000000',
970 'feedback' => 'Feedback for half credit answer',
971 'feedbackformat' => '1',
972 ),
973 ),
974 'single' => '1',
975 'shuffleanswers' => '1',
976 'correctfeedback' => '',
977 'correctfeedbackformat' => '1',
978 'partiallycorrectfeedback' => '',
979 'partiallycorrectfeedbackformat' => '1',
980 'incorrectfeedback' => '',
981 'incorrectfeedbackformat' => '1',
982 'answernumbering' => '0',
983 ),
984 'maxgrade' => '2.0000000',
985 ),
986 5 => (object) array(
987 'id' => '24',
988 'category' => '2',
989 'parent' => '19',
990 'name' => 'Cloze',
991 'questiontext' => '{2:MCH:a. Wrong answer#Feedback for this wrong answer~b. Another wrong answer#Feedback for the other wrong answer~=c. Correct answer#Feedback for correct answer~%50%d. Answer that gives half the credit#Feedback for half credit answer}',
992 'questiontextformat' => '0',
993 'generalfeedback' => '',
994 'generalfeedbackformat' => '1',
995 'defaultgrade' => '2.0000000',
996 'penalty' => '0.0000000',
997 'qtype' => 'multichoice',
998 'length' => '1',
999 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+QGvRpd',
1000 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+03GsSs',
1001 'hidden' => '0',
1002 'timecreated' => '1306341881',
1003 'timemodified' => '1306341881',
1004 'createdby' => '2',
1005 'modifiedby' => '2',
1006 'options' => (object) array(
1007 'id' => '5',
1008 'question' => '24',
1009 'layout' => '2',
1010 'answers' => array(
1011 42 => (object) array(
1012 'id' => '42',
1013 'question' => '24',
1014 'answer' => 'a. Wrong answer',
1015 'answerformat' => '1',
1016 'fraction' => '0.0000000',
1017 'feedback' => 'Feedback for this wrong answer',
1018 'feedbackformat' => '1',
1019 ),
1020 43 => (object) array(
1021 'id' => '43',
1022 'question' => '24',
1023 'answer' => 'b. Another wrong answer',
1024 'answerformat' => '1',
1025 'fraction' => '0.0000000',
1026 'feedback' => 'Feedback for the other wrong answer',
1027 'feedbackformat' => '1',
1028 ),
1029 44 => (object) array(
1030 'id' => '44',
1031 'question' => '24',
1032 'answer' => 'c. Correct answer',
1033 'answerformat' => '1',
1034 'fraction' => '1.0000000',
1035 'feedback' => 'Feedback for correct answer',
1036 'feedbackformat' => '1',
1037 ),
1038 45 => (object) array(
1039 'id' => '45',
1040 'question' => '24',
1041 'answer' => 'd. Answer that gives half the credit',
1042 'answerformat' => '1',
1043 'fraction' => '0.5000000',
1044 'feedback' => 'Feedback for half credit answer',
1045 'feedbackformat' => '1',
1046 ),
1047 ),
1048 'single' => '1',
1049 'shuffleanswers' => '1',
1050 'correctfeedback' => '',
1051 'correctfeedbackformat' => '1',
1052 'partiallycorrectfeedback' => '',
1053 'partiallycorrectfeedbackformat' => '1',
1054 'incorrectfeedback' => '',
1055 'incorrectfeedbackformat' => '1',
1056 'answernumbering' => '0',
1057 ),
1058 'maxgrade' => '2.0000000',
1059 ),
1060 6 => (object) array(
1061 'id' => '25',
1062 'category' => '2',
1063 'parent' => '19',
1064 'name' => 'Cloze',
1065 'questiontext' => '{1:SHORTANSWER_C:moodle#Feedback for moodle in lower case ~=MOODLE#Feedback for MOODLE in upper case ~%50%Moodle#Feedback for only first letter in upper case}',
1066 'questiontextformat' => '0',
1067 'generalfeedback' => '',
1068 'generalfeedbackformat' => '1',
1069 'defaultgrade' => '1.0000000',
1070 'penalty' => '0.0000000',
1071 'qtype' => 'shortanswer',
1072 'length' => '1',
1073 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+n9ETJC',
1074 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+Bvqo6c',
1075 'hidden' => '0',
1076 'timecreated' => '1306341881',
1077 'timemodified' => '1306341881',
1078 'createdby' => '2',
1079 'modifiedby' => '2',
1080 'options' => (object) array(
1081 'answers' => array(
1082 46 => (object) array(
1083 'id' => '46',
1084 'question' => '25',
1085 'answer' => 'moodle',
1086 'answerformat' => '0',
1087 'fraction' => '0.0000000',
1088 'feedback' => 'Feedback for moodle in lower case',
1089 'feedbackformat' => '1',
1090 ),
1091 47 => (object) array(
1092 'id' => '47',
1093 'question' => '25',
1094 'answer' => 'MOODLE',
1095 'answerformat' => '0',
1096 'fraction' => '1.0000000',
1097 'feedback' => 'Feedback for MOODLE in upper case',
1098 'feedbackformat' => '1',
1099 ),
1100 48 => (object) array(
1101 'id' => '48',
1102 'question' => '25',
1103 'answer' => 'Moodle',
1104 'answerformat' => '0',
1105 'fraction' => '0.5000000',
1106 'feedback' => 'Feedback for only first letter in upper case',
1107 'feedbackformat' => '1',
1108 ),
1109 ),
1110 'usecase' => '1',
1111 ),
1112 'maxgrade' => '1.0000000',
1113 ),
1114 7 => (object) array(
1115 'id' => '26',
1116 'category' => '2',
1117 'parent' => '19',
1118 'name' => 'Cloze',
1119 'questiontext' => '{:MULTICHOICE:=Yes#Correct~No#We have a different opinion}',
1120 'questiontextformat' => '0',
1121 'generalfeedback' => '',
1122 'generalfeedbackformat' => '1',
1123 'defaultgrade' => '1.0000000',
1124 'penalty' => '0.0000000',
1125 'qtype' => 'multichoice',
1126 'length' => '1',
1127 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+0YjnZ7',
1128 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+1giLRX',
1129 'hidden' => '0',
1130 'timecreated' => '1306341881',
1131 'timemodified' => '1306341881',
1132 'createdby' => '2',
1133 'modifiedby' => '2',
1134 'options' => (object) array(
1135 'id' => '6',
1136 'question' => '26',
1137 'layout' => '0',
1138 'answers' => array(
1139 49 => (object) array(
1140 'id' => '49',
1141 'question' => '26',
1142 'answer' => 'Yes',
1143 'answerformat' => '1',
1144 'fraction' => '1.0000000',
1145 'feedback' => 'Correct',
1146 'feedbackformat' => '1',
1147 ),
1148 50 => (object) array(
1149 'id' => '50',
1150 'question' => '26',
1151 'answer' => 'No',
1152 'answerformat' => '1',
1153 'fraction' => '0.0000000',
1154 'feedback' => 'We have a different opinion',
1155 'feedbackformat' => '1',
1156 ),
1157 ),
1158 'single' => '1',
1159 'shuffleanswers' => '1',
1160 'correctfeedback' => '',
1161 'correctfeedbackformat' => '1',
1162 'partiallycorrectfeedback' => '',
1163 'partiallycorrectfeedbackformat' => '1',
1164 'incorrectfeedback' => '',
1165 'incorrectfeedbackformat' => '1',
1166 'answernumbering' => '0',
1167 ),
1168 'maxgrade' => '1.0000000',
1169 ),
1170 8 => (object) array(
1171 'id' => '27',
1172 'category' => '2',
1173 'parent' => '19',
1174 'name' => 'Cloze',
1175 'questiontext' => '{3:NUMERICAL:=3:2}',
1176 'questiontextformat' => '0',
1177 'generalfeedback' => '',
1178 'generalfeedbackformat' => '1',
1179 'defaultgrade' => '3.0000000',
1180 'penalty' => '0.0000000',
1181 'qtype' => 'numerical',
1182 'length' => '1',
1183 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+glbCBN',
1184 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+xWusxR',
1185 'hidden' => '0',
1186 'timecreated' => '1306341881',
1187 'timemodified' => '1306341881',
1188 'createdby' => '2',
1189 'modifiedby' => '2',
1190 'options' => (object) array(
1191 'answers' => array(
1192 51 => (object) array(
1193 'id' => '51',
1194 'question' => '27',
1195 'answer' => '3',
1196 'answerformat' => '0',
1197 'fraction' => '1.0000000',
1198 'feedback' => '',
1199 'feedbackformat' => '1',
1200 'tolerance' => '2',
1201 ),
1202 ),
1203 'units' => array(
1204 ),
1205 'unitgradingtype' => '0',
1206 'unitpenalty' => '1.0000000',
1207 'showunits' => '3',
1208 'unitsleft' => '0',
1209 'instructions' => '',
1210 'instructionsformat' => '1',
1211 ),
1212 'maxgrade' => '3.0000000',
1213 ),
1214 ),
1215 ),
1216 'defaultmark' => '13.0000000',
1217 );
1218 $qsession = (object) array(
1219 'id' => '105',
1220 'attemptid' => '16',
1221 'questionid' => '19',
1222 'newest' => '286',
1223 'newgraded' => '286',
1224 'sumpenalty' => '2.6000000',
1225 'manualcomment' => '',
1226 'manualcommentformat' => '1',
1227 'flagged' => '0',
1228 );
1229 $qstates = array(
1230 282 => (object) array(
1231 'id' => '282',
1232 'attempt' => '16',
1233 'question' => '19',
1234 'seq_number' => '0',
1235 'answer' => '1-,2-,3-,4-,5-,6-,7-,8-',
1236 'timestamp' => '1306425691',
1237 'event' => '0',
1238 'grade' => '0.0000000',
1239 'raw_grade' => '0.0000000',
1240 'penalty' => '0.0000000',
1241 ),
1242 284 => (object) array(
1243 'id' => '284',
1244 'attempt' => '16',
1245 'question' => '19',
1246 'seq_number' => '1',
1247 'answer' => '1-31,2-dsf,3-sadf,4-39,5-44,6-MOODLE,7-49,8-100%',
1248 'timestamp' => '1306425739',
1249 'event' => '3',
1250 'grade' => '5.0000000',
1251 'raw_grade' => '5.0000000',
1252 'penalty' => '1.3000000',
1253 ),
1254 286 => (object) array(
1255 'id' => '286',
1256 'attempt' => '16',
1257 'question' => '19',
1258 'seq_number' => '2',
1259 'answer' => '1-31,2-dsf,3-sadf,4-39,5-44,6-MOODLE,7-49,8-100%',
1260 'timestamp' => '1306425739',
1261 'event' => '6',
1262 'grade' => '5.0000000',
1263 'raw_grade' => '5.0000000',
1264 'penalty' => '1.3000000',
1265 ),
1266 );
1267
1268 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
1269
1270 $expectedqa = (object) array(
1271 'behaviour' => 'adaptivenopenalty',
1272 'questionid' => 19,
1273 'variant' => 1,
1274 'maxmark' => 13.0000000,
1275 'minfraction' => 0,
1276 'flagged' => 0,
1277 'questionsummary' => 'This question consists of some text with an answer embedded right here {Wrong answer; Another wrong answer; Correct answer; Answer that gives half the credit}
1278
1279and right after that you will have to deal with this short answer _____
1280
1281and finally we have a floating point number _____.
1282
1283The multichoice question can also be shown in the vertical display of the standard moodle multiple choice. {1. Wrong answer; 2. Another wrong answer; 3. Correct answer; 4. Answer that gives half the credit}
1284
1285Or in an horizontal display that is included here in a table {a. Wrong answer; b. Another wrong answer; c. Correct answer; d. Answer that gives half the credit}
1286
1287A shortanswer question where case must match. Write moodle in upper case letters _____
1288
1289Note that addresses like www.moodle.org and smileys :-) all work as normal:
1290
1291a) How good is this? {Yes; No}
1292
1293b) What grade would you give it? _____',
1294 'rightanswer' => 'part 1: Correct answer; part 2: Correct answer; part 3: 23.8; part 4: 3. Correct answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 3',
1295 'responsesummary' => 'part 1: Correct answer; part 2: dsf; part 3: sadf; part 4: 2. Another wrong answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 100%',
1296 'timemodified' => 1306425739,
1297 'steps' => array(
1298 0 => (object) array(
1299 'data' => array('_sub1_order' => '29,30,31,32',
1300 '_sub3_separators' => '.$,', '_sub4_order' => '38,39,40,41',
1301 '_sub5_order' => '42,43,44,45', '_sub7_order' => '49,50',
1302 '_sub8_separators' => '.$,'),
1303 'fraction' => null,
1304 'timecreated' => 1306425691,
1305 'userid' => 4,
1306 'state' => 'todo',
1307 'sequencenumber' => 0,
1308 ),
1309 1 => (object) array(
1310 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'dsf',
1311 'sub3_answer' => 'sadf', 'sub4_answer' => '1',
1312 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE',
1313 'sub7_answer' => 'sadf', 'sub8_answer' => '100%', '-_try' => '1',
1314 '-_rawfraction' => '0.38461538461538466', '-submit' => '1'),
1315 'fraction' => 0.38461538461538466,
1316 'timecreated' => 1306425739,
1317 'userid' => 4,
1318 'state' => 'todo',
1319 'sequencenumber' => 1,
1320 ),
1321 2 => (object) array(
1322 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'dsf',
1323 'sub3_answer' => 'sadf', 'sub4_answer' => '1',
1324 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE',
1325 'sub7_answer' => 'sadf', 'sub8_answer' => '100%', '-finish' => '1',
1326 '-_try' => '1', '-_rawfraction' => '0.38461538461538466'),
1327 'fraction' => 0.38461538461538466,
1328 'timecreated' => 1306425739,
1329 'userid' => 4,
1330 'state' => 'gradedpartial',
1331 'sequencenumber' => 2,
1332 ),
1333 ),
1334 );
1335
1336//TODO: this comparison is failing badly, looks like it was not so picky before, somebody needs to fix the expecation --skodak
1337return;
1338 $this->compare_qas($expectedqa, $qa);
1339 }
1340
1341 public function test_multianswer_adaptivenopenalty_qsession107() {
1342 $quiz = (object) array(
1343 'id' => '5',
1344 'course' => '2',
1345 'name' => 'Multianswer quiz',
1346 'intro' => '',
1347 'introformat' => '1',
1348 'timeopen' => '0',
1349 'timeclose' => '0',
1350 'attempts' => '0',
1351 'attemptonlast' => '0',
1352 'grademethod' => '1',
1353 'decimalpoints' => '2',
1354 'questiondecimalpoints' => '-1',
1355 'review' => '4459503',
1356 'questionsperpage' => '1',
1357 'shufflequestions' => '0',
1358 'shuffleanswers' => '1',
1359 'questions' => '28,19,0',
1360 'sumgrades' => '14.00000',
1361 'grade' => '10.00000',
1362 'timecreated' => '0',
1363 'timemodified' => '1306424728',
1364 'timelimit' => '0',
1365 'password' => '',
1366 'subnet' => '',
1367 'popup' => '0',
1368 'delay1' => '0',
1369 'delay2' => '0',
1370 'showuserpicture' => '0',
1371 'showblocks' => '0',
1372 'preferredbehaviour' => 'adaptivenopenalty',
1373 );
1374 $attempt = (object) array(
1375 'id' => '17',
1376 'uniqueid' => '17',
1377 'quiz' => '5',
1378 'userid' => '4',
1379 'attempt' => '2',
1380 'sumgrades' => '0.00000',
1381 'timestart' => '1306425757',
1382 'timefinish' => '1306425762',
1383 'timemodified' => '1306425762',
1384 'layout' => '28,19,0',
1385 'preview' => '0',
1386 'needsupgradetonewqe' => 1,
1387 );
1388 $question = (object) array(
1389 'id' => '19',
1390 'category' => '2',
1391 'parent' => '0',
1392 'name' => 'Cloze',
1393 'questiontext' => '<p>This question consists of some text with an answer embedded right here {#1}</p>
1394 <p>and right after that you will have to deal with this short answer {#2}</p>
1395 <p>and finally we have a floating point number {#3}.</p>
1396 <p>The multichoice question can also be shown in the vertical display of the standard moodle multiple choice. {#4}</p>
1397 <p>Or in an horizontal display that is included here in a table {#5}</p>
1398 <p>A shortanswer question where case must match. Write moodle in upper case letters {#6}</p>
1399 <p>Note that addresses like www.moodle.org and smileys :-) all work as normal:</p>
1400 <p>a) How good is this? {#7}</p>
1401 <p>b) What grade would you give it? {#8}</p>',
1402 'questiontextformat' => '1',
1403 'generalfeedback' => '',
1404 'generalfeedbackformat' => '1',
1405 'penalty' => '0.1000000',
1406 'qtype' => 'multianswer',
1407 'length' => '1',
1408 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164438+iwiint',
1409 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+AAjnIy',
1410 'hidden' => '0',
1411 'timecreated' => '1306341878',
1412 'timemodified' => '1306341879',
1413 'createdby' => '2',
1414 'modifiedby' => '2',
1415 'maxmark' => '13.0000000',
1416 'options' => (object) array(
1417 'questions' => array(
1418 1 => (object) array(
1419 'id' => '20',
1420 'category' => '2',
1421 'parent' => '19',
1422 'name' => 'Cloze',
1423 'questiontext' => '{1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}',
1424 'questiontextformat' => '0',
1425 'generalfeedback' => '',
1426 'generalfeedbackformat' => '1',
1427 'defaultgrade' => '1.0000000',
1428 'penalty' => '0.0000000',
1429 'qtype' => 'multichoice',
1430 'length' => '1',
1431 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164439+cAuJ4r',
1432 'version' => 'tjh238.vledev2.open.ac.uk+110525164439+5bnnys',
1433 'hidden' => '0',
1434 'timecreated' => '1306341879',
1435 'timemodified' => '1306341879',
1436 'createdby' => '2',
1437 'modifiedby' => '2',
1438 'options' => (object) array(
1439 'id' => '3',
1440 'question' => '20',
1441 'layout' => '0',
1442 'answers' => array(
1443 29 => (object) array(
1444 'id' => '29',
1445 'question' => '20',
1446 'answer' => 'Wrong answer',
1447 'answerformat' => '1',
1448 'fraction' => '0.0000000',
1449 'feedback' => 'Feedback for this wrong answer',
1450 'feedbackformat' => '1',
1451 ),
1452 30 => (object) array(
1453 'id' => '30',
1454 'question' => '20',
1455 'answer' => 'Another wrong answer',
1456 'answerformat' => '1',
1457 'fraction' => '0.0000000',
1458 'feedback' => 'Feedback for the other wrong answer',
1459 'feedbackformat' => '1',
1460 ),
1461 31 => (object) array(
1462 'id' => '31',
1463 'question' => '20',
1464 'answer' => 'Correct answer',
1465 'answerformat' => '1',
1466 'fraction' => '1.0000000',
1467 'feedback' => 'Feedback for correct answer',
1468 'feedbackformat' => '1',
1469 ),
1470 32 => (object) array(
1471 'id' => '32',
1472 'question' => '20',
1473 'answer' => 'Answer that gives half the credit',
1474 'answerformat' => '1',
1475 'fraction' => '0.5000000',
1476 'feedback' => 'Feedback for half credit answer',
1477 'feedbackformat' => '1',
1478 ),
1479 ),
1480 'single' => '1',
1481 'shuffleanswers' => '1',
1482 'correctfeedback' => '',
1483 'correctfeedbackformat' => '1',
1484 'partiallycorrectfeedback' => '',
1485 'partiallycorrectfeedbackformat' => '1',
1486 'incorrectfeedback' => '',
1487 'incorrectfeedbackformat' => '1',
1488 'answernumbering' => '0',
1489 ),
1490 'maxgrade' => '1.0000000',
1491 ),
1492 2 => (object) array(
1493 'id' => '21',
1494 'category' => '2',
1495 'parent' => '19',
1496 'name' => 'Cloze',
1497 'questiontext' => '{1:SHORTANSWER:Wrong answer#Feedback for this wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}',
1498 'questiontextformat' => '0',
1499 'generalfeedback' => '',
1500 'generalfeedbackformat' => '1',
1501 'defaultgrade' => '1.0000000',
1502 'penalty' => '0.0000000',
1503 'qtype' => 'shortanswer',
1504 'length' => '1',
1505 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164440+EN6wCk',
1506 'version' => 'tjh238.vledev2.open.ac.uk+110525164440+bQzatI',
1507 'hidden' => '0',
1508 'timecreated' => '1306341880',
1509 'timemodified' => '1306341880',
1510 'createdby' => '2',
1511 'modifiedby' => '2',
1512 'options' => (object) array(
1513 'answers' => array(
1514 33 => (object) array(
1515 'id' => '33',
1516 'question' => '21',
1517 'answer' => 'Wrong answer',
1518 'answerformat' => '0',
1519 'fraction' => '0.0000000',
1520 'feedback' => 'Feedback for this wrong answer',
1521 'feedbackformat' => '1',
1522 ),
1523 34 => (object) array(
1524 'id' => '34',
1525 'question' => '21',
1526 'answer' => 'Correct answer',
1527 'answerformat' => '0',
1528 'fraction' => '1.0000000',
1529 'feedback' => 'Feedback for correct answer',
1530 'feedbackformat' => '1',
1531 ),
1532 35 => (object) array(
1533 'id' => '35',
1534 'question' => '21',
1535 'answer' => 'Answer that gives half the credit',
1536 'answerformat' => '0',
1537 'fraction' => '0.5000000',
1538 'feedback' => 'Feedback for half credit answer',
1539 'feedbackformat' => '1',
1540 ),
1541 ),
1542 'usecase' => '0',
1543 ),
1544 'maxgrade' => '1.0000000',
1545 ),
1546 3 => (object) array(
1547 'id' => '22',
1548 'category' => '2',
1549 'parent' => '19',
1550 'name' => 'Cloze',
1551 'questiontext' => '{2:NUMERICAL:=23.8:0.1#Feedback for correct answer 23.8~%50%23.8:2#Feedback for half credit answer in the nearby region of the correct answer}',
1552 'questiontextformat' => '0',
1553 'generalfeedback' => '',
1554 'generalfeedbackformat' => '1',
1555 'defaultgrade' => '2.0000000',
1556 'penalty' => '0.0000000',
1557 'qtype' => 'numerical',
1558 'length' => '1',
1559 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164440+Xr29c2',
1560 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+QTwsGM',
1561 'hidden' => '0',
1562 'timecreated' => '1306341880',
1563 'timemodified' => '1306341880',
1564 'createdby' => '2',
1565 'modifiedby' => '2',
1566 'options' => (object) array(
1567 'answers' => array(
1568 36 => (object) array(
1569 'id' => '36',
1570 'question' => '22',
1571 'answer' => '23.8',
1572 'answerformat' => '0',
1573 'fraction' => '1.0000000',
1574 'feedback' => 'Feedback for correct answer 23.8',
1575 'feedbackformat' => '1',
1576 'tolerance' => '0.1',
1577 ),
1578 37 => (object) array(
1579 'id' => '37',
1580 'question' => '22',
1581 'answer' => '23.8',
1582 'answerformat' => '0',
1583 'fraction' => '0.5000000',
1584 'feedback' => 'Feedback for half credit answer in the nearby region of the correct answer',
1585 'feedbackformat' => '1',
1586 'tolerance' => '2',
1587 ),
1588 ),
1589 'units' => array(
1590 ),
1591 'unitgradingtype' => '0',
1592 'unitpenalty' => '1.0000000',
1593 'showunits' => '3',
1594 'unitsleft' => '0',
1595 'instructions' => '',
1596 'instructionsformat' => '1',
1597 ),
1598 'maxgrade' => '2.0000000',
1599 ),
1600 4 => (object) array(
1601 'id' => '23',
1602 'category' => '2',
1603 'parent' => '19',
1604 'name' => 'Cloze',
1605 'questiontext' => '{2:MCV:1. Wrong answer#Feedback for this wrong answer~2. Another wrong answer#Feedback for the other wrong answer~=3. Correct answer#Feedback for correct answer~%50%4. Answer that gives half the credit#Feedback for half credit answer}',
1606 'questiontextformat' => '0',
1607 'generalfeedback' => '',
1608 'generalfeedbackformat' => '1',
1609 'defaultgrade' => '2.0000000',
1610 'penalty' => '0.0000000',
1611 'qtype' => 'multichoice',
1612 'length' => '1',
1613 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+7R55HA',
1614 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+uCMoQc',
1615 'hidden' => '0',
1616 'timecreated' => '1306341881',
1617 'timemodified' => '1306341881',
1618 'createdby' => '2',
1619 'modifiedby' => '2',
1620 'options' => (object) array(
1621 'id' => '4',
1622 'question' => '23',
1623 'layout' => '1',
1624 'answers' => array(
1625 38 => (object) array(
1626 'id' => '38',
1627 'question' => '23',
1628 'answer' => '1. Wrong answer',
1629 'answerformat' => '1',
1630 'fraction' => '0.0000000',
1631 'feedback' => 'Feedback for this wrong answer',
1632 'feedbackformat' => '1',
1633 ),
1634 39 => (object) array(
1635 'id' => '39',
1636 'question' => '23',
1637 'answer' => '2. Another wrong answer',
1638 'answerformat' => '1',
1639 'fraction' => '0.0000000',
1640 'feedback' => 'Feedback for the other wrong answer',
1641 'feedbackformat' => '1',
1642 ),
1643 40 => (object) array(
1644 'id' => '40',
1645 'question' => '23',
1646 'answer' => '3. Correct answer',
1647 'answerformat' => '1',
1648 'fraction' => '1.0000000',
1649 'feedback' => 'Feedback for correct answer',
1650 'feedbackformat' => '1',
1651 ),
1652 41 => (object) array(
1653 'id' => '41',
1654 'question' => '23',
1655 'answer' => '4. Answer that gives half the credit',
1656 'answerformat' => '1',
1657 'fraction' => '0.5000000',
1658 'feedback' => 'Feedback for half credit answer',
1659 'feedbackformat' => '1',
1660 ),
1661 ),
1662 'single' => '1',
1663 'shuffleanswers' => '1',
1664 'correctfeedback' => '',
1665 'correctfeedbackformat' => '1',
1666 'partiallycorrectfeedback' => '',
1667 'partiallycorrectfeedbackformat' => '1',
1668 'incorrectfeedback' => '',
1669 'incorrectfeedbackformat' => '1',
1670 'answernumbering' => '0',
1671 ),
1672 'maxgrade' => '2.0000000',
1673 ),
1674 5 => (object) array(
1675 'id' => '24',
1676 'category' => '2',
1677 'parent' => '19',
1678 'name' => 'Cloze',
1679 'questiontext' => '{2:MCH:a. Wrong answer#Feedback for this wrong answer~b. Another wrong answer#Feedback for the other wrong answer~=c. Correct answer#Feedback for correct answer~%50%d. Answer that gives half the credit#Feedback for half credit answer}',
1680 'questiontextformat' => '0',
1681 'generalfeedback' => '',
1682 'generalfeedbackformat' => '1',
1683 'defaultgrade' => '2.0000000',
1684 'penalty' => '0.0000000',
1685 'qtype' => 'multichoice',
1686 'length' => '1',
1687 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+QGvRpd',
1688 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+03GsSs',
1689 'hidden' => '0',
1690 'timecreated' => '1306341881',
1691 'timemodified' => '1306341881',
1692 'createdby' => '2',
1693 'modifiedby' => '2',
1694 'options' => (object) array(
1695 'id' => '5',
1696 'question' => '24',
1697 'layout' => '2',
1698 'answers' => array(
1699 42 => (object) array(
1700 'id' => '42',
1701 'question' => '24',
1702 'answer' => 'a. Wrong answer',
1703 'answerformat' => '1',
1704 'fraction' => '0.0000000',
1705 'feedback' => 'Feedback for this wrong answer',
1706 'feedbackformat' => '1',
1707 ),
1708 43 => (object) array(
1709 'id' => '43',
1710 'question' => '24',
1711 'answer' => 'b. Another wrong answer',
1712 'answerformat' => '1',
1713 'fraction' => '0.0000000',
1714 'feedback' => 'Feedback for the other wrong answer',
1715 'feedbackformat' => '1',
1716 ),
1717 44 => (object) array(
1718 'id' => '44',
1719 'question' => '24',
1720 'answer' => 'c. Correct answer',
1721 'answerformat' => '1',
1722 'fraction' => '1.0000000',
1723 'feedback' => 'Feedback for correct answer',
1724 'feedbackformat' => '1',
1725 ),
1726 45 => (object) array(
1727 'id' => '45',
1728 'question' => '24',
1729 'answer' => 'd. Answer that gives half the credit',
1730 'answerformat' => '1',
1731 'fraction' => '0.5000000',
1732 'feedback' => 'Feedback for half credit answer',
1733 'feedbackformat' => '1',
1734 ),
1735 ),
1736 'single' => '1',
1737 'shuffleanswers' => '1',
1738 'correctfeedback' => '',
1739 'correctfeedbackformat' => '1',
1740 'partiallycorrectfeedback' => '',
1741 'partiallycorrectfeedbackformat' => '1',
1742 'incorrectfeedback' => '',
1743 'incorrectfeedbackformat' => '1',
1744 'answernumbering' => '0',
1745 ),
1746 'maxgrade' => '2.0000000',
1747 ),
1748 6 => (object) array(
1749 'id' => '25',
1750 'category' => '2',
1751 'parent' => '19',
1752 'name' => 'Cloze',
1753 'questiontext' => '{1:SHORTANSWER_C:moodle#Feedback for moodle in lower case ~=MOODLE#Feedback for MOODLE in upper case ~%50%Moodle#Feedback for only first letter in upper case}',
1754 'questiontextformat' => '0',
1755 'generalfeedback' => '',
1756 'generalfeedbackformat' => '1',
1757 'defaultgrade' => '1.0000000',
1758 'penalty' => '0.0000000',
1759 'qtype' => 'shortanswer',
1760 'length' => '1',
1761 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+n9ETJC',
1762 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+Bvqo6c',
1763 'hidden' => '0',
1764 'timecreated' => '1306341881',
1765 'timemodified' => '1306341881',
1766 'createdby' => '2',
1767 'modifiedby' => '2',
1768 'options' => (object) array(
1769 'answers' => array(
1770 46 => (object) array(
1771 'id' => '46',
1772 'question' => '25',
1773 'answer' => 'moodle',
1774 'answerformat' => '0',
1775 'fraction' => '0.0000000',
1776 'feedback' => 'Feedback for moodle in lower case',
1777 'feedbackformat' => '1',
1778 ),
1779 47 => (object) array(
1780 'id' => '47',
1781 'question' => '25',
1782 'answer' => 'MOODLE',
1783 'answerformat' => '0',
1784 'fraction' => '1.0000000',
1785 'feedback' => 'Feedback for MOODLE in upper case',
1786 'feedbackformat' => '1',
1787 ),
1788 48 => (object) array(
1789 'id' => '48',
1790 'question' => '25',
1791 'answer' => 'Moodle',
1792 'answerformat' => '0',
1793 'fraction' => '0.5000000',
1794 'feedback' => 'Feedback for only first letter in upper case',
1795 'feedbackformat' => '1',
1796 ),
1797 ),
1798 'usecase' => '1',
1799 ),
1800 'maxgrade' => '1.0000000',
1801 ),
1802 7 => (object) array(
1803 'id' => '26',
1804 'category' => '2',
1805 'parent' => '19',
1806 'name' => 'Cloze',
1807 'questiontext' => '{:MULTICHOICE:=Yes#Correct~No#We have a different opinion}',
1808 'questiontextformat' => '0',
1809 'generalfeedback' => '',
1810 'generalfeedbackformat' => '1',
1811 'defaultgrade' => '1.0000000',
1812 'penalty' => '0.0000000',
1813 'qtype' => 'multichoice',
1814 'length' => '1',
1815 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+0YjnZ7',
1816 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+1giLRX',
1817 'hidden' => '0',
1818 'timecreated' => '1306341881',
1819 'timemodified' => '1306341881',
1820 'createdby' => '2',
1821 'modifiedby' => '2',
1822 'options' => (object) array(
1823 'id' => '6',
1824 'question' => '26',
1825 'layout' => '0',
1826 'answers' => array(
1827 49 => (object) array(
1828 'id' => '49',
1829 'question' => '26',
1830 'answer' => 'Yes',
1831 'answerformat' => '1',
1832 'fraction' => '1.0000000',
1833 'feedback' => 'Correct',
1834 'feedbackformat' => '1',
1835 ),
1836 50 => (object) array(
1837 'id' => '50',
1838 'question' => '26',
1839 'answer' => 'No',
1840 'answerformat' => '1',
1841 'fraction' => '0.0000000',
1842 'feedback' => 'We have a different opinion',
1843 'feedbackformat' => '1',
1844 ),
1845 ),
1846 'single' => '1',
1847 'shuffleanswers' => '1',
1848 'correctfeedback' => '',
1849 'correctfeedbackformat' => '1',
1850 'partiallycorrectfeedback' => '',
1851 'partiallycorrectfeedbackformat' => '1',
1852 'incorrectfeedback' => '',
1853 'incorrectfeedbackformat' => '1',
1854 'answernumbering' => '0',
1855 ),
1856 'maxgrade' => '1.0000000',
1857 ),
1858 8 => (object) array(
1859 'id' => '27',
1860 'category' => '2',
1861 'parent' => '19',
1862 'name' => 'Cloze',
1863 'questiontext' => '{3:NUMERICAL:=3:2}',
1864 'questiontextformat' => '0',
1865 'generalfeedback' => '',
1866 'generalfeedbackformat' => '1',
1867 'defaultgrade' => '3.0000000',
1868 'penalty' => '0.0000000',
1869 'qtype' => 'numerical',
1870 'length' => '1',
1871 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+glbCBN',
1872 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+xWusxR',
1873 'hidden' => '0',
1874 'timecreated' => '1306341881',
1875 'timemodified' => '1306341881',
1876 'createdby' => '2',
1877 'modifiedby' => '2',
1878 'options' => (object) array(
1879 'answers' => array(
1880 51 => (object) array(
1881 'id' => '51',
1882 'question' => '27',
1883 'answer' => '3',
1884 'answerformat' => '0',
1885 'fraction' => '1.0000000',
1886 'feedback' => '',
1887 'feedbackformat' => '1',
1888 'tolerance' => '2',
1889 ),
1890 ),
1891 'units' => array(
1892 ),
1893 'unitgradingtype' => '0',
1894 'unitpenalty' => '1.0000000',
1895 'showunits' => '3',
1896 'unitsleft' => '0',
1897 'instructions' => '',
1898 'instructionsformat' => '1',
1899 ),
1900 'maxgrade' => '3.0000000',
1901 ),
1902 ),
1903 ),
1904 'defaultmark' => '13.0000000',
1905 );
1906 $qsession = (object) array(
1907 'id' => '107',
1908 'attemptid' => '17',
1909 'questionid' => '19',
1910 'newest' => '290',
1911 'newgraded' => '290',
1912 'sumpenalty' => '1.3000000',
1913 'manualcomment' => '',
1914 'manualcommentformat' => '1',
1915 'flagged' => '0',
1916 );
1917 $qstates = array(
1918 288 => (object) array(
1919 'id' => '288',
1920 'attempt' => '17',
1921 'question' => '19',
1922 'seq_number' => '0',
1923 'answer' => '1-,2-,3-,4-,5-,6-,7-,8-',
1924 'timestamp' => '1306425757',
1925 'event' => '0',
1926 'grade' => '0.0000000',
1927 'raw_grade' => '0.0000000',
1928 'penalty' => '0.0000000',
1929 ),
1930 290 => (object) array(
1931 'id' => '290',
1932 'attempt' => '17',
1933 'question' => '19',
1934 'seq_number' => '1',
1935 'answer' => '1-,2-,3-,4-,5-,6-,7-,8-',
1936 'timestamp' => '1306425757',
1937 'event' => '6',
1938 'grade' => '0.0000000',
1939 'raw_grade' => '0.0000000',
1940 'penalty' => '1.3000000',
1941 ),
1942 );
1943
1944 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
1945
1946 $expectedqa = (object) array(
1947 'behaviour' => 'adaptivenopenalty',
1948 'questionid' => 19,
1949 'variant' => 1,
1950 'maxmark' => 13.0000000,
1951 'minfraction' => 0,
1952 'flagged' => 0,
1953 'questionsummary' => 'This question consists of some text with an answer embedded right here {Wrong answer; Another wrong answer; Correct answer; Answer that gives half the credit}
1954
1955and right after that you will have to deal with this short answer _____
1956
1957and finally we have a floating point number _____.
1958
1959The multichoice question can also be shown in the vertical display of the standard moodle multiple choice. {1. Wrong answer; 2. Another wrong answer; 3. Correct answer; 4. Answer that gives half the credit}
1960
1961Or in an horizontal display that is included here in a table {a. Wrong answer; b. Another wrong answer; c. Correct answer; d. Answer that gives half the credit}
1962
1963A shortanswer question where case must match. Write moodle in upper case letters _____
1964
1965Note that addresses like www.moodle.org and smileys :-) all work as normal:
1966
1967a) How good is this? {Yes; No}
1968
1969b) What grade would you give it? _____',
1970 'rightanswer' => 'part 1: Correct answer; part 2: Correct answer; part 3: 23.8; part 4: 3. Correct answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 3',
1971 'responsesummary' => 'part 1: ; part 2: ; part 3: ; part 4: ; part 5: ; part 6: ; part 7: ; part 8: ',
1972 'timemodified' => 1306425757,
1973 'steps' => array(
1974 0 => (object) array(
1975 'sequencenumber' => 0,
1976 'state' => 'todo',
1977 'fraction' => null,
1978 'timecreated' => 1306425757,
1979 'userid' => 4,
1980 'data' => array('_sub1_order' => '29,30,31,32',
1981 '_sub3_separators' => '.$,', '_sub4_order' => '38,39,40,41',
1982 '_sub5_order' => '42,43,44,45', '_sub7_order' => '49,50',
1983 '_sub8_separators' => '.$,'),
1984 ),
1985 1 => (object) array(
1986 'sequencenumber' => 1,
1987 'state' => 'gradedwrong',
1988 'fraction' => 0.0,
1989 'timecreated' => 1306425757,
1990 'userid' => 4,
1991 'data' => array('-finish' => '1', '-_try' => '1', '-_rawfraction' => 0.0),
1992 ),
1993 ),
1994 );
1995
1996 $this->compare_qas($expectedqa, $qa);
1997 }
1998
1999 public function test_multianswer_adaptivenopenalty_qsession109() {
2000 $quiz = (object) array(
2001 'id' => '5',
2002 'course' => '2',
2003 'name' => 'Multianswer quiz',
2004 'intro' => '',
2005 'introformat' => '1',
2006 'timeopen' => '0',
2007 'timeclose' => '0',
2008 'attempts' => '0',
2009 'attemptonlast' => '0',
2010 'grademethod' => '1',
2011 'decimalpoints' => '2',
2012 'questiondecimalpoints' => '-1',
2013 'review' => '4459503',
2014 'questionsperpage' => '1',
2015 'shufflequestions' => '0',
2016 'shuffleanswers' => '1',
2017 'questions' => '28,19,0',
2018 'sumgrades' => '14.00000',
2019 'grade' => '10.00000',
2020 'timecreated' => '0',
2021 'timemodified' => '1306424728',
2022 'timelimit' => '0',
2023 'password' => '',
2024 'subnet' => '',
2025 'popup' => '0',
2026 'delay1' => '0',
2027 'delay2' => '0',
2028 'showuserpicture' => '0',
2029 'showblocks' => '0',
2030 'preferredbehaviour' => 'adaptivenopenalty',
2031 );
2032 $attempt = (object) array(
2033 'id' => '18',
2034 'uniqueid' => '18',
2035 'quiz' => '5',
2036 'userid' => '3',
2037 'attempt' => '1',
2038 'sumgrades' => '10.40000',
2039 'timestart' => '1306425784',
2040 'timefinish' => '1306425931',
2041 'timemodified' => '1306425931',
2042 'layout' => '28,19,0',
2043 'preview' => '0',
2044 'needsupgradetonewqe' => 1,
2045 );
2046 $question = (object) array(
2047 'id' => '19',
2048 'category' => '2',
2049 'parent' => '0',
2050 'name' => 'Cloze',
2051 'questiontext' => '<p>This question consists of some text with an answer embedded right here {#1}</p>
2052 <p>and right after that you will have to deal with this short answer {#2}</p>
2053 <p>and finally we have a floating point number {#3}.</p>
2054 <p>The multichoice question can also be shown in the vertical display of the standard moodle multiple choice. {#4}</p>
2055 <p>Or in an horizontal display that is included here in a table {#5}</p>
2056 <p>A shortanswer question where case must match. Write moodle in upper case letters {#6}</p>
2057 <p>Note that addresses like www.moodle.org and smileys :-) all work as normal:</p>
2058 <p>a) How good is this? {#7}</p>
2059 <p>b) What grade would you give it? {#8}</p>',
2060 'questiontextformat' => '1',
2061 'generalfeedback' => '',
2062 'generalfeedbackformat' => '1',
2063 'penalty' => '0.1000000',
2064 'qtype' => 'multianswer',
2065 'length' => '1',
2066 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164438+iwiint',
2067 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+AAjnIy',
2068 'hidden' => '0',
2069 'timecreated' => '1306341878',
2070 'timemodified' => '1306341879',
2071 'createdby' => '2',
2072 'modifiedby' => '2',
2073 'maxmark' => '13.0000000',
2074 'options' => (object) array(
2075 'questions' => array(
2076 1 => (object) array(
2077 'id' => '20',
2078 'category' => '2',
2079 'parent' => '19',
2080 'name' => 'Cloze',
2081 'questiontext' => '{1:MULTICHOICE:Wrong answer#Feedback for this wrong answer~Another wrong answer#Feedback for the other wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}',
2082 'questiontextformat' => '0',
2083 'generalfeedback' => '',
2084 'generalfeedbackformat' => '1',
2085 'defaultgrade' => '1.0000000',
2086 'penalty' => '0.0000000',
2087 'qtype' => 'multichoice',
2088 'length' => '1',
2089 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164439+cAuJ4r',
2090 'version' => 'tjh238.vledev2.open.ac.uk+110525164439+5bnnys',
2091 'hidden' => '0',
2092 'timecreated' => '1306341879',
2093 'timemodified' => '1306341879',
2094 'createdby' => '2',
2095 'modifiedby' => '2',
2096 'options' => (object) array(
2097 'id' => '3',
2098 'question' => '20',
2099 'layout' => '0',
2100 'answers' => array(
2101 29 => (object) array(
2102 'id' => '29',
2103 'question' => '20',
2104 'answer' => 'Wrong answer',
2105 'answerformat' => '1',
2106 'fraction' => '0.0000000',
2107 'feedback' => 'Feedback for this wrong answer',
2108 'feedbackformat' => '1',
2109 ),
2110 30 => (object) array(
2111 'id' => '30',
2112 'question' => '20',
2113 'answer' => 'Another wrong answer',
2114 'answerformat' => '1',
2115 'fraction' => '0.0000000',
2116 'feedback' => 'Feedback for the other wrong answer',
2117 'feedbackformat' => '1',
2118 ),
2119 31 => (object) array(
2120 'id' => '31',
2121 'question' => '20',
2122 'answer' => 'Correct answer',
2123 'answerformat' => '1',
2124 'fraction' => '1.0000000',
2125 'feedback' => 'Feedback for correct answer',
2126 'feedbackformat' => '1',
2127 ),
2128 32 => (object) array(
2129 'id' => '32',
2130 'question' => '20',
2131 'answer' => 'Answer that gives half the credit',
2132 'answerformat' => '1',
2133 'fraction' => '0.5000000',
2134 'feedback' => 'Feedback for half credit answer',
2135 'feedbackformat' => '1',
2136 ),
2137 ),
2138 'single' => '1',
2139 'shuffleanswers' => '1',
2140 'correctfeedback' => '',
2141 'correctfeedbackformat' => '1',
2142 'partiallycorrectfeedback' => '',
2143 'partiallycorrectfeedbackformat' => '1',
2144 'incorrectfeedback' => '',
2145 'incorrectfeedbackformat' => '1',
2146 'answernumbering' => '0',
2147 ),
2148 'maxgrade' => '1.0000000',
2149 ),
2150 2 => (object) array(
2151 'id' => '21',
2152 'category' => '2',
2153 'parent' => '19',
2154 'name' => 'Cloze',
2155 'questiontext' => '{1:SHORTANSWER:Wrong answer#Feedback for this wrong answer~=Correct answer#Feedback for correct answer~%50%Answer that gives half the credit#Feedback for half credit answer}',
2156 'questiontextformat' => '0',
2157 'generalfeedback' => '',
2158 'generalfeedbackformat' => '1',
2159 'defaultgrade' => '1.0000000',
2160 'penalty' => '0.0000000',
2161 'qtype' => 'shortanswer',
2162 'length' => '1',
2163 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164440+EN6wCk',
2164 'version' => 'tjh238.vledev2.open.ac.uk+110525164440+bQzatI',
2165 'hidden' => '0',
2166 'timecreated' => '1306341880',
2167 'timemodified' => '1306341880',
2168 'createdby' => '2',
2169 'modifiedby' => '2',
2170 'options' => (object) array(
2171 'answers' => array(
2172 33 => (object) array(
2173 'id' => '33',
2174 'question' => '21',
2175 'answer' => 'Wrong answer',
2176 'answerformat' => '0',
2177 'fraction' => '0.0000000',
2178 'feedback' => 'Feedback for this wrong answer',
2179 'feedbackformat' => '1',
2180 ),
2181 34 => (object) array(
2182 'id' => '34',
2183 'question' => '21',
2184 'answer' => 'Correct answer',
2185 'answerformat' => '0',
2186 'fraction' => '1.0000000',
2187 'feedback' => 'Feedback for correct answer',
2188 'feedbackformat' => '1',
2189 ),
2190 35 => (object) array(
2191 'id' => '35',
2192 'question' => '21',
2193 'answer' => 'Answer that gives half the credit',
2194 'answerformat' => '0',
2195 'fraction' => '0.5000000',
2196 'feedback' => 'Feedback for half credit answer',
2197 'feedbackformat' => '1',
2198 ),
2199 ),
2200 'usecase' => '0',
2201 ),
2202 'maxgrade' => '1.0000000',
2203 ),
2204 3 => (object) array(
2205 'id' => '22',
2206 'category' => '2',
2207 'parent' => '19',
2208 'name' => 'Cloze',
2209 'questiontext' => '{2:NUMERICAL:=23.8:0.1#Feedback for correct answer 23.8~%50%23.8:2#Feedback for half credit answer in the nearby region of the correct answer}',
2210 'questiontextformat' => '0',
2211 'generalfeedback' => '',
2212 'generalfeedbackformat' => '1',
2213 'defaultgrade' => '2.0000000',
2214 'penalty' => '0.0000000',
2215 'qtype' => 'numerical',
2216 'length' => '1',
2217 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164440+Xr29c2',
2218 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+QTwsGM',
2219 'hidden' => '0',
2220 'timecreated' => '1306341880',
2221 'timemodified' => '1306341880',
2222 'createdby' => '2',
2223 'modifiedby' => '2',
2224 'options' => (object) array(
2225 'answers' => array(
2226 36 => (object) array(
2227 'id' => '36',
2228 'question' => '22',
2229 'answer' => '23.8',
2230 'answerformat' => '0',
2231 'fraction' => '1.0000000',
2232 'feedback' => 'Feedback for correct answer 23.8',
2233 'feedbackformat' => '1',
2234 'tolerance' => '0.1',
2235 ),
2236 37 => (object) array(
2237 'id' => '37',
2238 'question' => '22',
2239 'answer' => '23.8',
2240 'answerformat' => '0',
2241 'fraction' => '0.5000000',
2242 'feedback' => 'Feedback for half credit answer in the nearby region of the correct answer',
2243 'feedbackformat' => '1',
2244 'tolerance' => '2',
2245 ),
2246 ),
2247 'units' => array(
2248 ),
2249 'unitgradingtype' => '0',
2250 'unitpenalty' => '1.0000000',
2251 'showunits' => '3',
2252 'unitsleft' => '0',
2253 'instructions' => '',
2254 'instructionsformat' => '1',
2255 ),
2256 'maxgrade' => '2.0000000',
2257 ),
2258 4 => (object) array(
2259 'id' => '23',
2260 'category' => '2',
2261 'parent' => '19',
2262 'name' => 'Cloze',
2263 'questiontext' => '{2:MCV:1. Wrong answer#Feedback for this wrong answer~2. Another wrong answer#Feedback for the other wrong answer~=3. Correct answer#Feedback for correct answer~%50%4. Answer that gives half the credit#Feedback for half credit answer}',
2264 'questiontextformat' => '0',
2265 'generalfeedback' => '',
2266 'generalfeedbackformat' => '1',
2267 'defaultgrade' => '2.0000000',
2268 'penalty' => '0.0000000',
2269 'qtype' => 'multichoice',
2270 'length' => '1',
2271 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+7R55HA',
2272 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+uCMoQc',
2273 'hidden' => '0',
2274 'timecreated' => '1306341881',
2275 'timemodified' => '1306341881',
2276 'createdby' => '2',
2277 'modifiedby' => '2',
2278 'options' => (object) array(
2279 'id' => '4',
2280 'question' => '23',
2281 'layout' => '1',
2282 'answers' => array(
2283 38 => (object) array(
2284 'id' => '38',
2285 'question' => '23',
2286 'answer' => '1. Wrong answer',
2287 'answerformat' => '1',
2288 'fraction' => '0.0000000',
2289 'feedback' => 'Feedback for this wrong answer',
2290 'feedbackformat' => '1',
2291 ),
2292 39 => (object) array(
2293 'id' => '39',
2294 'question' => '23',
2295 'answer' => '2. Another wrong answer',
2296 'answerformat' => '1',
2297 'fraction' => '0.0000000',
2298 'feedback' => 'Feedback for the other wrong answer',
2299 'feedbackformat' => '1',
2300 ),
2301 40 => (object) array(
2302 'id' => '40',
2303 'question' => '23',
2304 'answer' => '3. Correct answer',
2305 'answerformat' => '1',
2306 'fraction' => '1.0000000',
2307 'feedback' => 'Feedback for correct answer',
2308 'feedbackformat' => '1',
2309 ),
2310 41 => (object) array(
2311 'id' => '41',
2312 'question' => '23',
2313 'answer' => '4. Answer that gives half the credit',
2314 'answerformat' => '1',
2315 'fraction' => '0.5000000',
2316 'feedback' => 'Feedback for half credit answer',
2317 'feedbackformat' => '1',
2318 ),
2319 ),
2320 'single' => '1',
2321 'shuffleanswers' => '1',
2322 'correctfeedback' => '',
2323 'correctfeedbackformat' => '1',
2324 'partiallycorrectfeedback' => '',
2325 'partiallycorrectfeedbackformat' => '1',
2326 'incorrectfeedback' => '',
2327 'incorrectfeedbackformat' => '1',
2328 'answernumbering' => '0',
2329 ),
2330 'maxgrade' => '2.0000000',
2331 ),
2332 5 => (object) array(
2333 'id' => '24',
2334 'category' => '2',
2335 'parent' => '19',
2336 'name' => 'Cloze',
2337 'questiontext' => '{2:MCH:a. Wrong answer#Feedback for this wrong answer~b. Another wrong answer#Feedback for the other wrong answer~=c. Correct answer#Feedback for correct answer~%50%d. Answer that gives half the credit#Feedback for half credit answer}',
2338 'questiontextformat' => '0',
2339 'generalfeedback' => '',
2340 'generalfeedbackformat' => '1',
2341 'defaultgrade' => '2.0000000',
2342 'penalty' => '0.0000000',
2343 'qtype' => 'multichoice',
2344 'length' => '1',
2345 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+QGvRpd',
2346 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+03GsSs',
2347 'hidden' => '0',
2348 'timecreated' => '1306341881',
2349 'timemodified' => '1306341881',
2350 'createdby' => '2',
2351 'modifiedby' => '2',
2352 'options' => (object) array(
2353 'id' => '5',
2354 'question' => '24',
2355 'layout' => '2',
2356 'answers' => array(
2357 42 => (object) array(
2358 'id' => '42',
2359 'question' => '24',
2360 'answer' => 'a. Wrong answer',
2361 'answerformat' => '1',
2362 'fraction' => '0.0000000',
2363 'feedback' => 'Feedback for this wrong answer',
2364 'feedbackformat' => '1',
2365 ),
2366 43 => (object) array(
2367 'id' => '43',
2368 'question' => '24',
2369 'answer' => 'b. Another wrong answer',
2370 'answerformat' => '1',
2371 'fraction' => '0.0000000',
2372 'feedback' => 'Feedback for the other wrong answer',
2373 'feedbackformat' => '1',
2374 ),
2375 44 => (object) array(
2376 'id' => '44',
2377 'question' => '24',
2378 'answer' => 'c. Correct answer',
2379 'answerformat' => '1',
2380 'fraction' => '1.0000000',
2381 'feedback' => 'Feedback for correct answer',
2382 'feedbackformat' => '1',
2383 ),
2384 45 => (object) array(
2385 'id' => '45',
2386 'question' => '24',
2387 'answer' => 'd. Answer that gives half the credit',
2388 'answerformat' => '1',
2389 'fraction' => '0.5000000',
2390 'feedback' => 'Feedback for half credit answer',
2391 'feedbackformat' => '1',
2392 ),
2393 ),
2394 'single' => '1',
2395 'shuffleanswers' => '1',
2396 'correctfeedback' => '',
2397 'correctfeedbackformat' => '1',
2398 'partiallycorrectfeedback' => '',
2399 'partiallycorrectfeedbackformat' => '1',
2400 'incorrectfeedback' => '',
2401 'incorrectfeedbackformat' => '1',
2402 'answernumbering' => '0',
2403 ),
2404 'maxgrade' => '2.0000000',
2405 ),
2406 6 => (object) array(
2407 'id' => '25',
2408 'category' => '2',
2409 'parent' => '19',
2410 'name' => 'Cloze',
2411 'questiontext' => '{1:SHORTANSWER_C:moodle#Feedback for moodle in lower case ~=MOODLE#Feedback for MOODLE in upper case ~%50%Moodle#Feedback for only first letter in upper case}',
2412 'questiontextformat' => '0',
2413 'generalfeedback' => '',
2414 'generalfeedbackformat' => '1',
2415 'defaultgrade' => '1.0000000',
2416 'penalty' => '0.0000000',
2417 'qtype' => 'shortanswer',
2418 'length' => '1',
2419 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+n9ETJC',
2420 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+Bvqo6c',
2421 'hidden' => '0',
2422 'timecreated' => '1306341881',
2423 'timemodified' => '1306341881',
2424 'createdby' => '2',
2425 'modifiedby' => '2',
2426 'options' => (object) array(
2427 'answers' => array(
2428 46 => (object) array(
2429 'id' => '46',
2430 'question' => '25',
2431 'answer' => 'moodle',
2432 'answerformat' => '0',
2433 'fraction' => '0.0000000',
2434 'feedback' => 'Feedback for moodle in lower case',
2435 'feedbackformat' => '1',
2436 ),
2437 47 => (object) array(
2438 'id' => '47',
2439 'question' => '25',
2440 'answer' => 'MOODLE',
2441 'answerformat' => '0',
2442 'fraction' => '1.0000000',
2443 'feedback' => 'Feedback for MOODLE in upper case',
2444 'feedbackformat' => '1',
2445 ),
2446 48 => (object) array(
2447 'id' => '48',
2448 'question' => '25',
2449 'answer' => 'Moodle',
2450 'answerformat' => '0',
2451 'fraction' => '0.5000000',
2452 'feedback' => 'Feedback for only first letter in upper case',
2453 'feedbackformat' => '1',
2454 ),
2455 ),
2456 'usecase' => '1',
2457 ),
2458 'maxgrade' => '1.0000000',
2459 ),
2460 7 => (object) array(
2461 'id' => '26',
2462 'category' => '2',
2463 'parent' => '19',
2464 'name' => 'Cloze',
2465 'questiontext' => '{:MULTICHOICE:=Yes#Correct~No#We have a different opinion}',
2466 'questiontextformat' => '0',
2467 'generalfeedback' => '',
2468 'generalfeedbackformat' => '1',
2469 'defaultgrade' => '1.0000000',
2470 'penalty' => '0.0000000',
2471 'qtype' => 'multichoice',
2472 'length' => '1',
2473 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+0YjnZ7',
2474 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+1giLRX',
2475 'hidden' => '0',
2476 'timecreated' => '1306341881',
2477 'timemodified' => '1306341881',
2478 'createdby' => '2',
2479 'modifiedby' => '2',
2480 'options' => (object) array(
2481 'id' => '6',
2482 'question' => '26',
2483 'layout' => '0',
2484 'answers' => array(
2485 49 => (object) array(
2486 'id' => '49',
2487 'question' => '26',
2488 'answer' => 'Yes',
2489 'answerformat' => '1',
2490 'fraction' => '1.0000000',
2491 'feedback' => 'Correct',
2492 'feedbackformat' => '1',
2493 ),
2494 50 => (object) array(
2495 'id' => '50',
2496 'question' => '26',
2497 'answer' => 'No',
2498 'answerformat' => '1',
2499 'fraction' => '0.0000000',
2500 'feedback' => 'We have a different opinion',
2501 'feedbackformat' => '1',
2502 ),
2503 ),
2504 'single' => '1',
2505 'shuffleanswers' => '1',
2506 'correctfeedback' => '',
2507 'correctfeedbackformat' => '1',
2508 'partiallycorrectfeedback' => '',
2509 'partiallycorrectfeedbackformat' => '1',
2510 'incorrectfeedback' => '',
2511 'incorrectfeedbackformat' => '1',
2512 'answernumbering' => '0',
2513 ),
2514 'maxgrade' => '1.0000000',
2515 ),
2516 8 => (object) array(
2517 'id' => '27',
2518 'category' => '2',
2519 'parent' => '19',
2520 'name' => 'Cloze',
2521 'questiontext' => '{3:NUMERICAL:=3:2}',
2522 'questiontextformat' => '0',
2523 'generalfeedback' => '',
2524 'generalfeedbackformat' => '1',
2525 'defaultgrade' => '3.0000000',
2526 'penalty' => '0.0000000',
2527 'qtype' => 'numerical',
2528 'length' => '1',
2529 'stamp' => 'tjh238.vledev2.open.ac.uk+110525164441+glbCBN',
2530 'version' => 'tjh238.vledev2.open.ac.uk+110525164441+xWusxR',
2531 'hidden' => '0',
2532 'timecreated' => '1306341881',
2533 'timemodified' => '1306341881',
2534 'createdby' => '2',
2535 'modifiedby' => '2',
2536 'options' => (object) array(
2537 'answers' => array(
2538 51 => (object) array(
2539 'id' => '51',
2540 'question' => '27',
2541 'answer' => '3',
2542 'answerformat' => '0',
2543 'fraction' => '1.0000000',
2544 'feedback' => '',
2545 'feedbackformat' => '1',
2546 'tolerance' => '2',
2547 ),
2548 ),
2549 'units' => array(
2550 ),
2551 'unitgradingtype' => '0',
2552 'unitpenalty' => '1.0000000',
2553 'showunits' => '3',
2554 'unitsleft' => '0',
2555 'instructions' => '',
2556 'instructionsformat' => '1',
2557 ),
2558 'maxgrade' => '3.0000000',
2559 ),
2560 ),
2561 ),
2562 'defaultmark' => '13.0000000',
2563 );
2564 $qsession = (object) array(
2565 'id' => '109',
2566 'attemptid' => '18',
2567 'questionid' => '19',
2568 'newest' => '299',
2569 'newgraded' => '299',
2570 'sumpenalty' => '5.2000000',
2571 'manualcomment' => '',
2572 'manualcommentformat' => '1',
2573 'flagged' => '0',
2574 );
2575 $qstates = array(
2576 292 => (object) array(
2577 'id' => '292',
2578 'attempt' => '18',
2579 'question' => '19',
2580 'seq_number' => '0',
2581 'answer' => '1-,2-,3-,4-,5-,6-,7-,8-',
2582 'timestamp' => '1306425784',
2583 'event' => '0',
2584 'grade' => '0.0000000',
2585 'raw_grade' => '0.0000000',
2586 'penalty' => '0.0000000',
2587 ),
2588 294 => (object) array(
2589 'id' => '294',
2590 'attempt' => '18',
2591 'question' => '19',
2592 'seq_number' => '1',
2593 'answer' => '1-32,2-asdgf,3-saedf,4-39,5-43,6-sadf,7-,8-',
2594 'timestamp' => '1306425801',
2595 'event' => '3',
2596 'grade' => '0.5000000',
2597 'raw_grade' => '0.5000000',
2598 'penalty' => '1.3000000',
2599 ),
2600 295 => (object) array(
2601 'id' => '295',
2602 'attempt' => '18',
2603 'question' => '19',
2604 'seq_number' => '2',
2605 'answer' => '1-31,2-asdgf,3-28.3,4-40,5-44,6-MOODLE,7-49,8-13',
2606 'timestamp' => '1306425836',
2607 'event' => '3',
2608 'grade' => '5.7000000',
2609 'raw_grade' => '7.0000000',
2610 'penalty' => '1.3000000',
2611 ),
2612 296 => (object) array(
2613 'id' => '296',
2614 'attempt' => '18',
2615 'question' => '19',
2616 'seq_number' => '3',
2617 'answer' => '1-31,2-Correct answer,3-23.8,4-40,5-44,6-MOODLE,7-49,8-3',
2618 'timestamp' => '1306425886',
2619 'event' => '3',
2620 'grade' => '9.4000000',
2621 'raw_grade' => '12.0000000',
2622 'penalty' => '1.3000000',
2623 ),
2624 299 => (object) array(
2625 'id' => '299',
2626 'attempt' => '18',
2627 'question' => '19',
2628 'seq_number' => '4',
2629 'answer' => '1-31,2-Correct answer,3-23.8,4-40,5-44,6-MOODLE,7-49,8-3',
2630 'timestamp' => '1306425886',
2631 'event' => '6',
2632 'grade' => '9.4000000',
2633 'raw_grade' => '12.0000000',
2634 'penalty' => '1.3000000',
2635 ),
2636 );
2637
2638 $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
2639
2640 $expectedqa = (object) array(
2641 'behaviour' => 'adaptivenopenalty',
2642 'questionid' => 19,
2643 'variant' => 1,
2644 'maxmark' => 13.0000000,
2645 'minfraction' => 0,
2646 'flagged' => 0,
2647 'questionsummary' => 'This question consists of some text with an answer embedded right here {Wrong answer; Another wrong answer; Correct answer; Answer that gives half the credit}
2648
2649and right after that you will have to deal with this short answer _____
2650
2651and finally we have a floating point number _____.
2652
2653The multichoice question can also be shown in the vertical display of the standard moodle multiple choice. {1. Wrong answer; 2. Another wrong answer; 3. Correct answer; 4. Answer that gives half the credit}
2654
2655Or in an horizontal display that is included here in a table {a. Wrong answer; b. Another wrong answer; c. Correct answer; d. Answer that gives half the credit}
2656
2657A shortanswer question where case must match. Write moodle in upper case letters _____
2658
2659Note that addresses like www.moodle.org and smileys :-) all work as normal:
2660
2661a) How good is this? {Yes; No}
2662
2663b) What grade would you give it? _____',
2664 'rightanswer' => 'part 1: Correct answer; part 2: Correct answer; part 3: 23.8; part 4: 3. Correct answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 3',
2665 'responsesummary' => 'part 1: Correct answer; part 2: Correct answer; part 3: 23.8; part 4: 3. Correct answer; part 5: c. Correct answer; part 6: MOODLE; part 7: Yes; part 8: 3',
2666 'timemodified' => 1306425886,
2667 'steps' => array(
2668 0 => (object) array(
2669 'sequencenumber' => 0,
2670 'state' => 'todo',
2671 'fraction' => null,
2672 'timecreated' => 1306425784,
2673 'userid' => 3,
2674 'data' => array('_sub1_order' => '29,30,31,32',
2675 '_sub3_separators' => '.$,', '_sub4_order' => '38,39,40,41',
2676 '_sub5_order' => '42,43,44,45', '_sub7_order' => '49,50',
2677 '_sub8_separators' => '.$,'),
2678 ),
2679 1 => (object) array(
2680 'sequencenumber' => 1,
2681 'state' => 'todo',
2682 'fraction' => 0.038461538461538464,
2683 'timecreated' => 1306425801,
2684 'userid' => 3,
2685 'data' => array('sub1_answer' => '3', 'sub2_answer' => 'asdgf',
2686 'sub3_answer' => 'saedf', 'sub4_answer' => '1',
2687 'sub5_answer' => '1', 'sub6_answer' => 'sadf',
2688 '-_try' => '1',
2689 '-_rawfraction' => '0.038461538461538464', '-submit' => '1'),
2690 ),
2691 2 => (object) array(
2692 'sequencenumber' => 2,
2693 'state' => 'todo',
2694 'fraction' => 0.43846153846153845,
2695 'timecreated' => 1306425836,
2696 'userid' => 3,
2697 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'asdgf',
2698 'sub3_answer' => '28.3', 'sub4_answer' => '2',
2699 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE',
2700 'sub7_answer' => '0', 'sub8_answer' => '13', '-_try' => '2',
2701 '-_rawfraction' => '0.53846153846153845', '-submit' => '1'),
2702 ),
2703 3 => (object) array(
2704 'sequencenumber' => 3,
2705 'state' => 'todo',
2706 'fraction' => 0.72307692307692311,
2707 'timecreated' => 1306425886,
2708 'userid' => 3,
2709 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'Correct answer',
2710 'sub3_answer' => '23.8', 'sub4_answer' => '2',
2711 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE',
2712 'sub7_answer' => '0', 'sub8_answer' => '3', '-_try' => '3',
2713 '-_rawfraction' => '0.92307692307692311', '-submit' => '1'),
2714 ),
2715 4 => (object) array(
2716 'sequencenumber' => 4,
2717 'state' => 'gradedpartial',
2718 'fraction' => 0.72307692307692311,
2719 'timecreated' => 1306425886,
2720 'userid' => 3,
2721 'data' => array('sub1_answer' => '2', 'sub2_answer' => 'Correct answer',
2722 'sub3_answer' => '23.8', 'sub4_answer' => '2',
2723 'sub5_answer' => '2', 'sub6_answer' => 'MOODLE',
2724 'sub7_answer' => '0', 'sub8_answer' => '3', '-_try' => '3',
2725 '-_rawfraction' => '0.92307692307692311', '-finish' => '1'),
2726 ),
2727 ),
2728 );
2729
2730 $this->compare_qas($expectedqa, $qa);
2731 }
2732}