-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathwalkthrough_test.php
executable file
·628 lines (524 loc) · 26.2 KB
/
walkthrough_test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* These tests walks a question through the interactive behaviour
*
* @package qtype_gapfill
* @copyright 2012 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/question/type/gapfill/tests/helper.php');
/**
* Unit tests for the gapfill question type.
*
* @copyright 2012 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_draggable_items() {
/* This checks that the bug from line 130 of questiontype is fixed
that line should read
if (!in_array($a->answer, $question->allanswers,true)) {
Without the final true only one draggable will display */
$questiontext = "[1.0] [1.00]";
$options = [
'disableregex' => 1,
'noduplicates' => 0,
'delimitchars' => '[]',
'optionsaftertext' => false
];
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext, $options);
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
$this->check_output_contains('1.0');
$this->check_output_contains('1.00');
}
public function test_deferred_feedback_unanswered() {
// Create a gapfill question.
$gapfill = qtype_gapfill_test_helper::make_question();
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
/* Check the initial state. */
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
// Save an correct response.
$this->process_submission(array('p1' => '', 'p2' => ''));
$this->check_step_count(2);
$this->check_current_state(question_state::$todo);
$this->quba->finish_all_questions();
$this->check_step_count(3);
$this->check_current_state(question_state::$gaveup);
$this->check_current_mark(null);
}
public function test_deferred_with_correct() {
// Create a gapfill question.
$gapfill = qtype_gapfill_test_helper::make_question();
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
// Save an correct response.
$this->process_submission(array('p1' => 'cat', 'p2' => 'mat'));
$this->check_step_count(2);
$this->check_current_state(question_state::$complete);
$this->quba->finish_all_questions();
$this->check_step_count(3);
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(2);
$this->quba->finish_all_questions();
}
public function test_deferred_with_incorrect() {
// Create a gapfill question.
$gapfill = qtype_gapfill_test_helper::make_question();
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
// Save an correct response.
$this->process_submission(array('p1' => 'dog', 'p2' => 'cat'));
$this->check_step_count(2);
$this->check_current_state(question_state::$complete);
$this->quba->finish_all_questions();
$this->check_step_count(3);
$this->check_current_state(question_state::$gradedwrong);
$this->check_current_mark(0);
}
public function test_no_regex_or() {
/* Tests a feature introduced with Gapfill 1.8 where
* the | operator will be recognised as a separator for
* multiple options when regex is turned off. Useful where
* the answers contain characters considered special by
* the regex parser.
*/
$questiontext = "A programming question with multiple
correct answers to a single field
[getSize();| printSize();| 7/2]. The handling of
| is done with regex disabled so the (), ; and / cause
no problems";
$options = [
'disableregex' => 1,
'noduplicates' => 0,
'delimitchars' => '[]',
'optionsaftertext' => false
];
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext, $options);
$maxmark = 1;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
$this->process_submission(array('p1' => 'getSize();'));
$this->quba->finish_all_questions();
$this->check_step_count(3);
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(1);
}
public function test_deferred_with_partially_correct() {
// Create a gapfill question.
$gapfill = qtype_gapfill_test_helper::make_question();
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
// Save an correct response.
$this->process_submission(array('p1' => 'cat', 'p2' => 'dog'));
$this->check_step_count(2);
$this->check_current_state(question_state::$complete);
$this->quba->finish_all_questions();
$this->check_step_count(3);
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(1);
}
public function test_deferred_with_blanks() {
// Create a gapfill question.
$questiontext = "The [cat] sat on the [mat]";
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext);
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
$this->process_submission(array('p1' => 'cat', 'p2' => ''));
$this->quba->finish_all_questions();
$this->check_step_count(3);
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(1);
}
public function test_extended_characters() {
/* Testing extended characters, including a word that ends with an accent
* there were issues using strtolower which only works with plain ascci.
* This has been replaced with Moodles own core_text::strtolower($answergiven,'UTF-8');
* A full test would include regex on and off and case sensitivity on and off
*/
$questiontext = "Moscow is the capital of [Россия], The French word for boy is [garçon]. A word that
ends with an accent is [andrà] ";
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext);
$maxmark = 3;
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
$this->process_submission(array('p1' => 'Россия', 'p2' => 'garçon', 'p3' => 'andrà' ));
$this->quba->finish_all_questions();
$this->check_step_count(3);
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(3);
}
public function test_interactive_with_correct() {
// Create a gapfill question.
$gapfill = qtype_gapfill_test_helper::make_question();
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'interactive', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
// Save a correct response.
$this->process_submission(array('p0' => 'cat', 'p1' => 'mat'));
$this->check_step_count(2);
$this->check_current_state(question_state::$todo);
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
// Submit saved response.
$this->process_submission(array('-submit' => 1, 'p1' => 'cat', 'p2' => 'mat'));
$this->check_step_count(3);
// Verify.
$this->check_current_state(question_state::$gradedright);
$this->check_current_output(
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
$this->check_current_mark(2);
// Finish the attempt.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedright);
}
public function test_interactive_wildcard_with_correct() {
// Create a gapfill question.
$questiontext = " The [cat|dog] sat on the [mat] ";
$gapfill = qtype_gapfill_test_helper::make_question($questiontext);
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'interactive', $maxmark);
$this->check_current_output(
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_step_count(1);
// Save a correct response.
$this->process_submission(array('p0' => 'cat', 'p1' => 'mat'));
$this->check_step_count(2);
$this->check_current_output(
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
$this->check_current_state(question_state::$todo);
/*There was a word boundary bug in the regex previously that has been addressed by adding
*a leading \b( and trailing )\b where the | character is found in the gap. This could be
*checked further by processing adog as an answer. acat and doga would have been spotted previously
*because of the leading ^ and trailing $ in the regex */
$this->process_submission(array('-submit' => 1, 'p1' => 'catty', 'p2' => 'mat'));
$this->check_step_count(3);
// Verify.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(1);
$this->start_attempt_at_question($gapfill, 'interactive', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_step_count(1);
// Submit correct resonse.
$this->process_submission(array('-submit' => 1, 'p1' => 'cat', 'p2' => 'mat'));
$this->check_step_count(2);
// Verify.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(2);
// Finish the attempt.
}
public function test_disableregex() {
$questiontext = 'for([$i]=0;$<10;$i++)';
$options = [
'disableregex' => 1,
'noduplicates' => 0,
'delimitchars' => '[]',
'optionsaftertext' => false
];
$gapfill = qtype_gapfill_test_helper::make_question($questiontext, $options);
$this->start_attempt_at_question($gapfill, 'interactive', $gapfill->gapstofill);
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_step_count(1);
$this->process_submission(array('-submit' => 1, 'p1' => '$i'));
$this->check_step_count(2);
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(1);
$this->quba->finish_all_questions();
}
public function test_interactive_discard_duplicates() {
/* this is for the scenario where you have multiple fields
* and each field could take any value. The marking is designed
* to asssure that the student cannot get credited more than once
* for each value, i.e. so if the answer is gold,silver, bronze
* they cannot get 3 marks by entereing gold, gold and gold
*/
/* Create a gapfill question and set noduplicates to true */
$questiontext = '
What are the colors of the Olympic medals?
[gold|silver|bronze]
[gold|silver|bronze]
[gold|silver|bronze] ';
$options = [
'disableregex' => 1,
'noduplicates' => 1,
'delimitchars' => '[]',
'optionsaftertext' => false
];
/* answer with duplicate values, only one of each duplicate should get a mark */
$submission = array('-submit' => 1, 'p1' => 'gold', 'p2' => 'silver', 'p3' => 'silver');
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext, $options);
$this->start_attempt_at_question($gapfill, 'interactive', $gapfill->gapstofill);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_step_count(1);
$this->check_current_output(
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_no_hint_visible_expectation());
$this->check_current_mark(null);
// Save a correct response.
$this->process_submission($submission);
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(2);
$this->check_step_count(2);
}
public function test_no_duplicate_draggables() {
$qtext = 'Bicycles have [wheels]. Cars have [wheels|engines].';
$gapfill = qtype_gapfill_test_helper::make_question($qtext);
$this->start_attempt_at_question($gapfill, 'interactive', $gapfill->gapstofill);
// Confirm draggables are unique, i.e. wheels appears only once.
$this->assertEquals(2, count($gapfill->allanswers));
}
public function test_get_letter_hints() {
$gapfill = qtype_gapfill_test_helper::make_question();
$gapfill->hints = [
new question_hint(1, 'This is the first hint.', FORMAT_HTML),
new question_hint(2, 'This is the second hint.', FORMAT_HTML),
];
$this->start_attempt_at_question($gapfill, 'interactive', $gapfill->gapstofill);
$this->process_submission([ '-submit' => 1, 'p1' => 'cat', 'p2' => 'cat']);
$this->process_submission(array('-tryagain' => 1));
$qa = $this->quba->get_question_attempt($this->slot);
/*normally lots of things in inputattributes */
$inputattributes = [];
$rightanswer = 'cat';
$currentanswer = '';
$hint = $gapfill->get_letter_hints($qa, $inputattributes, $rightanswer, $currentanswer);
/*The hint is the first letter of the correct answer */
$this->assertEquals($hint['value'], 'c');
$this->process_submission([ '-submit' => 1, 'p1' => 'cat', 'p2' => 'cat']);
$this->process_submission(array('-tryagain' => 1));
$hint = $gapfill->get_letter_hints($qa, $inputattributes, $rightanswer, $currentanswer);
/* add another letter of the correct answer */
$this->assertEquals($hint['value'], 'ca');
}
public function test_interactive_grade_for_blank() {
/* this is for the scenario where you have multiple fields
* and each field could take any value. The marking is designed
* to asssure that the student cannot get credited more than once
* for each value, i.e. so if the answer is gold,silver, bronze
* they cannot get 3 marks by entereing gold, gold and gold
*/
/* Create a gapfill question that gives a mark where one response
* is designed to be blank, i.e. [!!] */
$questiontext = '
[one] sat on the [two] [!!] ';
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext);
$this->start_attempt_at_question($gapfill, 'interactive', $gapfill->gapstofill);
/* answer with duplicate values, only one of each duplicate should get a mark */
/* save answer */
$submission = array('p1' => 'one', 'p2' => 'two', 'p3' => '');
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_step_count(1);
// Save a correct response.
$this->process_submission($submission);
$this->check_current_output(
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_validation_error_expectation()
, $this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
$this->check_current_mark(null);
// Save a correct response.
$submission = array('-submit' => 1, 'p1' => 'one', 'p2' => 'two', 'p3' => '');
$this->process_submission($submission);
$this->check_current_mark(3);
$this->check_current_state(question_state::$gradedright);
/* start again but put a value in the field expecting a blank */
$this->start_attempt_at_question($gapfill, 'interactive', $gapfill->gapstofill);
$submission = array('p1' => 'one', 'p2' => 'two', 'p3' => "three");
$this->process_submission($submission);
$this->check_step_count(2);
$this->check_current_mark(null);
$this->check_current_state(question_state::$todo);
$this->check_current_output(
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
$submission = array('-submit' => 1, 'p1' => 'one', 'p2' => 'two', 'p3' => "three");
$this->process_submission($submission);
$this->check_current_mark(2);
$this->check_current_state(question_state::$gradedpartial);
$this->check_step_count(3);
$this->quba->finish_all_questions();
}
public function test_matching_divs() {
$questiontext = "The [cat] sat on the [mat]";
// Defaults to optionsaftertext being false.
$gapfill = qtype_gapfill_test_helper::make_question($questiontext);
$this->start_attempt_at_question($gapfill, 'immediatefeedback');
$html = $this->quba->render_question($this->slot, $this->displayoptions);
$divstarts = substr_count($html, "<div");
$divends = substr_count($html, "</div>");
$this->assertEquals($divstarts, $divends, ' Mismatch in opening and closing div tags');
$options = [
'disableregex' => 1,
'noduplicates' => 0,
'delimitchars' => '[]',
'optionsaftertext' => true
];
$gapfill = qtype_gapfill_test_helper::make_question($questiontext);
$this->start_attempt_at_question($gapfill, 'immediatefeedback');
$html = $this->quba->render_question($this->slot, $this->displayoptions);
$divstarts = substr_count($html, "<div");
$divends = substr_count($html, "</div>");
$this->assertEquals($divstarts, $divends, ' Mismatch in opening and closing div tags');
}
public function test_get_aftergap_text() {
$questiontext = "The [cat] sat on the [mat]";
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext);
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'immediatefeedback', $maxmark);
$this->process_submission(array('-submit' => 1, 'p1' => 'cat', 'p2' => 'dog'));
$html = $this->quba->render_question($this->slot, $this->displayoptions);
$this->assertStringContainsString("[mat]", $html );
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext);
$maxmark = 2;
$this->start_attempt_at_question($gapfill, 'immediatefeedback', $maxmark);
$this->process_submission(array('-submit' => 1, 'p1' => 'cat', 'p2' => 'mat'));
$html = $this->quba->render_question($this->slot, $this->displayoptions);
$this->assertStringNotContainsString("[mat]", $html );
}
public function test_deferred_grade_for_blank() {
/* this is for the scenario where you have multiple fields
* and each field could take any value. The marking is designed
* to asssure that the student cannot get credited more than once
* for each value, i.e. so if the answer is gold,silver, bronze
* they cannot get 3 marks by entereing gold, gold and gold
*/
/* Create a gapfill question that gives a mark where one response
* is designed to be blank, i.e. [!!] */
$questiontext = '
[one] sat on the [two] [!!] ';
$gapfill = qtype_gapfill_test_helper::make_question( $questiontext);
$this->start_attempt_at_question($gapfill, 'deferredfeedback', $gapfill->gapstofill);
/* A mark for a blank submission where the gap is [!!] */
$submission = array('p1' => 'one', 'p2' => 'two', 'p3' => '');
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_step_count(1);
// Save a correct response.
$this->process_submission($submission);
$this->check_current_output(
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_validation_error_expectation(),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_no_hint_visible_expectation());
$this->process_submission(array('-finish' => 1));
$this->check_current_mark(3);
$this->check_current_state(question_state::$gradedright);
$this->quba->finish_all_questions();
}
public function test_immediatefeedback_with_correct() {
// Create a gapfill question.
$gapfill = qtype_gapfill_test_helper::make_question();
$maxmark = 2;
$gapfill->showanswers = true;
$this->start_attempt_at_question($gapfill, 'immediatefeedback', $maxmark);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_step_count(1);
// Save a correct response.
$this->process_submission(array('p0' => 'cat', 'p1' => 'cat'));
$this->check_step_count(2);
$this->check_current_mark(null);
$this->check_current_state(question_state::$todo);
// Submit saved response.
$this->process_submission(array('-submit' => 1, 'p1' => 'cat', 'p2' => 'mat'));
$this->check_step_count(3);
// Verify.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(2);
// Finish the attempt.
}
public function test_get_gapsize() {
$gapfill = qtype_gapfill_test_helper::make_question( "");
$this->assertEquals($gapfill->get_size("one"), 3);
$this->assertEquals($gapfill->get_size("one|twleve"), 6);
}
}