Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 184... Línea 184...
184
        } else {
184
        } else {
185
            return [$heading, 0];
185
            return [$heading, 0];
186
        }
186
        }
187
    }
187
    }
Línea 188... Línea 188...
188
 
188
 
189
    public function test_get_quiz_slots() {
189
    public function test_get_quiz_slots(): void {
190
        $quizobj = $this->create_test_quiz([
190
        $quizobj = $this->create_test_quiz([
191
                ['TF1', 1, 'truefalse'],
191
                ['TF1', 1, 'truefalse'],
192
                ['TF2', 1, 'truefalse'],
192
                ['TF2', 1, 'truefalse'],
193
        ]);
193
        ]);
Línea 196... Línea 196...
196
        // Are the correct slots returned?
196
        // Are the correct slots returned?
197
        $slots = $structure->get_slots();
197
        $slots = $structure->get_slots();
198
        $this->assertCount(2, $structure->get_slots());
198
        $this->assertCount(2, $structure->get_slots());
199
    }
199
    }
Línea 200... Línea 200...
200
 
200
 
201
    public function test_quiz_has_one_section_by_default() {
201
    public function test_quiz_has_one_section_by_default(): void {
202
        $quizobj = $this->create_test_quiz([
202
        $quizobj = $this->create_test_quiz([
203
                ['TF1', 1, 'truefalse'],
203
                ['TF1', 1, 'truefalse'],
204
        ]);
204
        ]);
Línea 211... Línea 211...
211
        $this->assertEquals(1, $section->firstslot);
211
        $this->assertEquals(1, $section->firstslot);
212
        $this->assertEquals('', $section->heading);
212
        $this->assertEquals('', $section->heading);
213
        $this->assertEquals(0, $section->shufflequestions);
213
        $this->assertEquals(0, $section->shufflequestions);
214
    }
214
    }
Línea 215... Línea 215...
215
 
215
 
216
    public function test_get_sections() {
216
    public function test_get_sections(): void {
217
        $quizobj = $this->create_test_quiz([
217
        $quizobj = $this->create_test_quiz([
218
                'Heading 1*',
218
                'Heading 1*',
219
                ['TF1', 1, 'truefalse'],
219
                ['TF1', 1, 'truefalse'],
220
                'Heading 2*',
220
                'Heading 2*',
Línea 234... Línea 234...
234
        $this->assertEquals(2, $section->firstslot);
234
        $this->assertEquals(2, $section->firstslot);
235
        $this->assertEquals('Heading 2', $section->heading);
235
        $this->assertEquals('Heading 2', $section->heading);
236
        $this->assertEquals(1, $section->shufflequestions);
236
        $this->assertEquals(1, $section->shufflequestions);
237
    }
237
    }
Línea 238... Línea 238...
238
 
238
 
239
    public function test_remove_section_heading() {
239
    public function test_remove_section_heading(): void {
240
        $quizobj = $this->create_test_quiz([
240
        $quizobj = $this->create_test_quiz([
241
                'Heading 1',
241
                'Heading 1',
242
                ['TF1', 1, 'truefalse'],
242
                ['TF1', 1, 'truefalse'],
243
                'Heading 2',
243
                'Heading 2',
Línea 255... Línea 255...
255
                ['TF1', 1, 'truefalse'],
255
                ['TF1', 1, 'truefalse'],
256
                ['TF2', 2, 'truefalse'],
256
                ['TF2', 2, 'truefalse'],
257
        ], $structure);
257
        ], $structure);
258
    }
258
    }
Línea 259... Línea 259...
259
 
259
 
260
    public function test_cannot_remove_first_section() {
260
    public function test_cannot_remove_first_section(): void {
261
        $quizobj = $this->create_test_quiz([
261
        $quizobj = $this->create_test_quiz([
262
                'Heading 1',
262
                'Heading 1',
263
                ['TF1', 1, 'truefalse'],
263
                ['TF1', 1, 'truefalse'],
264
        ]);
264
        ]);
Línea 269... Línea 269...
269
 
269
 
270
        $this->expectException(\coding_exception::class);
270
        $this->expectException(\coding_exception::class);
271
        $structure->remove_section_heading($section->id);
271
        $structure->remove_section_heading($section->id);
Línea 272... Línea 272...
272
    }
272
    }
273
 
273
 
274
    public function test_move_slot_to_the_same_place_does_nothing() {
274
    public function test_move_slot_to_the_same_place_does_nothing(): void {
275
        $quizobj = $this->create_test_quiz([
275
        $quizobj = $this->create_test_quiz([
276
                ['TF1', 1, 'truefalse'],
276
                ['TF1', 1, 'truefalse'],
277
                ['TF2', 1, 'truefalse'],
277
                ['TF2', 1, 'truefalse'],
Línea 289... Línea 289...
289
                ['TF2', 1, 'truefalse'],
289
                ['TF2', 1, 'truefalse'],
290
                ['TF3', 2, 'truefalse'],
290
                ['TF3', 2, 'truefalse'],
291
        ], $structure);
291
        ], $structure);
292
    }
292
    }
Línea 293... Línea 293...
293
 
293
 
294
    public function test_move_slot_end_of_one_page_to_start_of_next() {
294
    public function test_move_slot_end_of_one_page_to_start_of_next(): void {
295
        $quizobj = $this->create_test_quiz([
295
        $quizobj = $this->create_test_quiz([
296
                ['TF1', 1, 'truefalse'],
296
                ['TF1', 1, 'truefalse'],
297
                ['TF2', 1, 'truefalse'],
297
                ['TF2', 1, 'truefalse'],
298
                ['TF3', 2, 'truefalse'],
298
                ['TF3', 2, 'truefalse'],
Línea 309... Línea 309...
309
                ['TF2', 2, 'truefalse'],
309
                ['TF2', 2, 'truefalse'],
310
                ['TF3', 2, 'truefalse'],
310
                ['TF3', 2, 'truefalse'],
311
        ], $structure);
311
        ], $structure);
312
    }
312
    }
Línea 313... Línea 313...
313
 
313
 
314
    public function test_move_last_slot_to_previous_page_emptying_the_last_page() {
314
    public function test_move_last_slot_to_previous_page_emptying_the_last_page(): void {
315
        $quizobj = $this->create_test_quiz([
315
        $quizobj = $this->create_test_quiz([
316
                ['TF1', 1, 'truefalse'],
316
                ['TF1', 1, 'truefalse'],
317
                ['TF2', 2, 'truefalse'],
317
                ['TF2', 2, 'truefalse'],
318
        ]);
318
        ]);
Línea 327... Línea 327...
327
                ['TF1', 1, 'truefalse'],
327
                ['TF1', 1, 'truefalse'],
328
                ['TF2', 1, 'truefalse'],
328
                ['TF2', 1, 'truefalse'],
329
        ], $structure);
329
        ], $structure);
330
    }
330
    }
Línea 331... Línea 331...
331
 
331
 
332
    public function test_end_of_one_section_to_start_of_next() {
332
    public function test_end_of_one_section_to_start_of_next(): void {
333
        $quizobj = $this->create_test_quiz([
333
        $quizobj = $this->create_test_quiz([
334
                ['TF1', 1, 'truefalse'],
334
                ['TF1', 1, 'truefalse'],
335
                ['TF2', 1, 'truefalse'],
335
                ['TF2', 1, 'truefalse'],
336
                'Heading',
336
                'Heading',
Línea 349... Línea 349...
349
                ['TF2', 2, 'truefalse'],
349
                ['TF2', 2, 'truefalse'],
350
                ['TF3', 2, 'truefalse'],
350
                ['TF3', 2, 'truefalse'],
351
        ], $structure);
351
        ], $structure);
352
    }
352
    }
Línea 353... Línea 353...
353
 
353
 
354
    public function test_start_of_one_section_to_end_of_previous() {
354
    public function test_start_of_one_section_to_end_of_previous(): void {
355
        $quizobj = $this->create_test_quiz([
355
        $quizobj = $this->create_test_quiz([
356
                ['TF1', 1, 'truefalse'],
356
                ['TF1', 1, 'truefalse'],
357
                'Heading',
357
                'Heading',
358
                ['TF2', 2, 'truefalse'],
358
                ['TF2', 2, 'truefalse'],
Línea 370... Línea 370...
370
                ['TF2', 1, 'truefalse'],
370
                ['TF2', 1, 'truefalse'],
371
                'Heading',
371
                'Heading',
372
                ['TF3', 2, 'truefalse'],
372
                ['TF3', 2, 'truefalse'],
373
        ], $structure);
373
        ], $structure);
374
    }
374
    }
375
    public function test_move_slot_on_same_page() {
375
    public function test_move_slot_on_same_page(): void {
376
        $quizobj = $this->create_test_quiz([
376
        $quizobj = $this->create_test_quiz([
377
                ['TF1', 1, 'truefalse'],
377
                ['TF1', 1, 'truefalse'],
378
                ['TF2', 1, 'truefalse'],
378
                ['TF2', 1, 'truefalse'],
379
                ['TF3', 1, 'truefalse'],
379
                ['TF3', 1, 'truefalse'],
380
        ]);
380
        ]);
Línea 390... Línea 390...
390
                ['TF3', 1, 'truefalse'],
390
                ['TF3', 1, 'truefalse'],
391
                ['TF2', 1, 'truefalse'],
391
                ['TF2', 1, 'truefalse'],
392
        ], $structure);
392
        ], $structure);
393
    }
393
    }
Línea 394... Línea 394...
394
 
394
 
395
    public function test_move_slot_up_onto_previous_page() {
395
    public function test_move_slot_up_onto_previous_page(): void {
396
        $quizobj = $this->create_test_quiz([
396
        $quizobj = $this->create_test_quiz([
397
                ['TF1', 1, 'truefalse'],
397
                ['TF1', 1, 'truefalse'],
398
                ['TF2', 2, 'truefalse'],
398
                ['TF2', 2, 'truefalse'],
399
                ['TF3', 2, 'truefalse'],
399
                ['TF3', 2, 'truefalse'],
Línea 410... Línea 410...
410
                ['TF3', 1, 'truefalse'],
410
                ['TF3', 1, 'truefalse'],
411
                ['TF2', 2, 'truefalse'],
411
                ['TF2', 2, 'truefalse'],
412
        ], $structure);
412
        ], $structure);
413
    }
413
    }
Línea 414... Línea 414...
414
 
414
 
415
    public function test_move_slot_emptying_a_page_renumbers_pages() {
415
    public function test_move_slot_emptying_a_page_renumbers_pages(): void {
416
        $quizobj = $this->create_test_quiz([
416
        $quizobj = $this->create_test_quiz([
417
                ['TF1', 1, 'truefalse'],
417
                ['TF1', 1, 'truefalse'],
418
                ['TF2', 2, 'truefalse'],
418
                ['TF2', 2, 'truefalse'],
419
                ['TF3', 3, 'truefalse'],
419
                ['TF3', 3, 'truefalse'],
Línea 430... Línea 430...
430
                ['TF3', 2, 'truefalse'],
430
                ['TF3', 2, 'truefalse'],
431
                ['TF2', 2, 'truefalse'],
431
                ['TF2', 2, 'truefalse'],
432
        ], $structure);
432
        ], $structure);
433
    }
433
    }
Línea 434... Línea 434...
434
 
434
 
435
    public function test_move_slot_too_small_page_number_detected() {
435
    public function test_move_slot_too_small_page_number_detected(): void {
436
        $quizobj = $this->create_test_quiz([
436
        $quizobj = $this->create_test_quiz([
437
                ['TF1', 1, 'truefalse'],
437
                ['TF1', 1, 'truefalse'],
438
                ['TF2', 2, 'truefalse'],
438
                ['TF2', 2, 'truefalse'],
439
                ['TF3', 3, 'truefalse'],
439
                ['TF3', 3, 'truefalse'],
Línea 444... Línea 444...
444
        $idmoveafter = $structure->get_question_in_slot(2)->slotid;
444
        $idmoveafter = $structure->get_question_in_slot(2)->slotid;
445
        $this->expectException(\coding_exception::class);
445
        $this->expectException(\coding_exception::class);
446
        $structure->move_slot($idtomove, $idmoveafter, '1');
446
        $structure->move_slot($idtomove, $idmoveafter, '1');
447
    }
447
    }
Línea 448... Línea 448...
448
 
448
 
449
    public function test_move_slot_too_large_page_number_detected() {
449
    public function test_move_slot_too_large_page_number_detected(): void {
450
        $quizobj = $this->create_test_quiz([
450
        $quizobj = $this->create_test_quiz([
451
                ['TF1', 1, 'truefalse'],
451
                ['TF1', 1, 'truefalse'],
452
                ['TF2', 2, 'truefalse'],
452
                ['TF2', 2, 'truefalse'],
453
                ['TF3', 3, 'truefalse'],
453
                ['TF3', 3, 'truefalse'],
Línea 458... Línea 458...
458
        $idmoveafter = $structure->get_question_in_slot(2)->slotid;
458
        $idmoveafter = $structure->get_question_in_slot(2)->slotid;
459
        $this->expectException(\coding_exception::class);
459
        $this->expectException(\coding_exception::class);
460
        $structure->move_slot($idtomove, $idmoveafter, '4');
460
        $structure->move_slot($idtomove, $idmoveafter, '4');
461
    }
461
    }
Línea 462... Línea 462...
462
 
462
 
463
    public function test_move_slot_within_section() {
463
    public function test_move_slot_within_section(): void {
464
        $quizobj = $this->create_test_quiz([
464
        $quizobj = $this->create_test_quiz([
465
                'Heading 1',
465
                'Heading 1',
466
                ['TF1', 1, 'truefalse'],
466
                ['TF1', 1, 'truefalse'],
467
                ['TF2', 1, 'truefalse'],
467
                ['TF2', 1, 'truefalse'],
Línea 482... Línea 482...
482
                'Heading 2',
482
                'Heading 2',
483
                ['TF3', 2, 'truefalse'],
483
                ['TF3', 2, 'truefalse'],
484
        ], $structure);
484
        ], $structure);
485
    }
485
    }
Línea 486... Línea 486...
486
 
486
 
487
    public function test_move_slot_to_new_section() {
487
    public function test_move_slot_to_new_section(): void {
488
        $quizobj = $this->create_test_quiz([
488
        $quizobj = $this->create_test_quiz([
489
                'Heading 1',
489
                'Heading 1',
490
                ['TF1', 1, 'truefalse'],
490
                ['TF1', 1, 'truefalse'],
491
                ['TF2', 1, 'truefalse'],
491
                ['TF2', 1, 'truefalse'],
Línea 506... Línea 506...
506
                ['TF3', 2, 'truefalse'],
506
                ['TF3', 2, 'truefalse'],
507
                ['TF2', 2, 'truefalse'],
507
                ['TF2', 2, 'truefalse'],
508
        ], $structure);
508
        ], $structure);
509
    }
509
    }
Línea 510... Línea 510...
510
 
510
 
511
    public function test_move_slot_to_start() {
511
    public function test_move_slot_to_start(): void {
512
        $quizobj = $this->create_test_quiz([
512
        $quizobj = $this->create_test_quiz([
513
                'Heading 1',
513
                'Heading 1',
514
                ['TF1', 1, 'truefalse'],
514
                ['TF1', 1, 'truefalse'],
515
                'Heading 2',
515
                'Heading 2',
Línea 529... Línea 529...
529
                'Heading 2',
529
                'Heading 2',
530
                ['TF2', 2, 'truefalse'],
530
                ['TF2', 2, 'truefalse'],
531
        ], $structure);
531
        ], $structure);
532
    }
532
    }
Línea 533... Línea 533...
533
 
533
 
534
    public function test_move_slot_down_to_start_of_second_section() {
534
    public function test_move_slot_down_to_start_of_second_section(): void {
535
        $quizobj = $this->create_test_quiz([
535
        $quizobj = $this->create_test_quiz([
536
                'Heading 1',
536
                'Heading 1',
537
                ['TF1', 1, 'truefalse'],
537
                ['TF1', 1, 'truefalse'],
538
                ['TF2', 1, 'truefalse'],
538
                ['TF2', 1, 'truefalse'],
Línea 553... Línea 553...
553
                ['TF2', 2, 'truefalse'],
553
                ['TF2', 2, 'truefalse'],
554
                ['TF3', 2, 'truefalse'],
554
                ['TF3', 2, 'truefalse'],
555
        ], $structure);
555
        ], $structure);
556
    }
556
    }
Línea 557... Línea 557...
557
 
557
 
558
    public function test_move_first_slot_down_to_start_of_page_2() {
558
    public function test_move_first_slot_down_to_start_of_page_2(): void {
559
        $quizobj = $this->create_test_quiz([
559
        $quizobj = $this->create_test_quiz([
560
                'Heading 1',
560
                'Heading 1',
561
                ['TF1', 1, 'truefalse'],
561
                ['TF1', 1, 'truefalse'],
562
                ['TF2', 2, 'truefalse'],
562
                ['TF2', 2, 'truefalse'],
Línea 572... Línea 572...
572
                ['TF1', 1, 'truefalse'],
572
                ['TF1', 1, 'truefalse'],
573
                ['TF2', 1, 'truefalse'],
573
                ['TF2', 1, 'truefalse'],
574
        ], $structure);
574
        ], $structure);
575
    }
575
    }
Línea 576... Línea 576...
576
 
576
 
577
    public function test_move_first_slot_to_same_place_on_page_1() {
577
    public function test_move_first_slot_to_same_place_on_page_1(): void {
578
        $quizobj = $this->create_test_quiz([
578
        $quizobj = $this->create_test_quiz([
579
                'Heading 1',
579
                'Heading 1',
580
                ['TF1', 1, 'truefalse'],
580
                ['TF1', 1, 'truefalse'],
581
                ['TF2', 2, 'truefalse'],
581
                ['TF2', 2, 'truefalse'],
Línea 591... Línea 591...
591
                ['TF1', 1, 'truefalse'],
591
                ['TF1', 1, 'truefalse'],
592
                ['TF2', 2, 'truefalse'],
592
                ['TF2', 2, 'truefalse'],
593
        ], $structure);
593
        ], $structure);
594
    }
594
    }
Línea 595... Línea 595...
595
 
595
 
596
    public function test_move_first_slot_to_before_page_1() {
596
    public function test_move_first_slot_to_before_page_1(): void {
597
        $quizobj = $this->create_test_quiz([
597
        $quizobj = $this->create_test_quiz([
598
                'Heading 1',
598
                'Heading 1',
599
                ['TF1', 1, 'truefalse'],
599
                ['TF1', 1, 'truefalse'],
600
                ['TF2', 2, 'truefalse'],
600
                ['TF2', 2, 'truefalse'],
Línea 610... Línea 610...
610
                ['TF1', 1, 'truefalse'],
610
                ['TF1', 1, 'truefalse'],
611
                ['TF2', 2, 'truefalse'],
611
                ['TF2', 2, 'truefalse'],
612
        ], $structure);
612
        ], $structure);
613
    }
613
    }
Línea 614... Línea 614...
614
 
614
 
615
    public function test_move_slot_up_to_start_of_second_section() {
615
    public function test_move_slot_up_to_start_of_second_section(): void {
616
        $quizobj = $this->create_test_quiz([
616
        $quizobj = $this->create_test_quiz([
617
                'Heading 1',
617
                'Heading 1',
618
                ['TF1', 1, 'truefalse'],
618
                ['TF1', 1, 'truefalse'],
619
                'Heading 2',
619
                'Heading 2',
Línea 638... Línea 638...
638
                'Heading 3',
638
                'Heading 3',
639
                ['TF4', 3, 'truefalse'],
639
                ['TF4', 3, 'truefalse'],
640
        ], $structure);
640
        ], $structure);
641
    }
641
    }
Línea 642... Línea 642...
642
 
642
 
643
    public function test_move_slot_does_not_violate_heading_unique_key() {
643
    public function test_move_slot_does_not_violate_heading_unique_key(): void {
644
        $quizobj = $this->create_test_quiz([
644
        $quizobj = $this->create_test_quiz([
645
                'Heading 1',
645
                'Heading 1',
646
                ['TF1', 1, 'truefalse'],
646
                ['TF1', 1, 'truefalse'],
647
                'Heading 2',
647
                'Heading 2',
Línea 666... Línea 666...
666
                'Heading 3',
666
                'Heading 3',
667
                ['TF3', 3, 'truefalse'],
667
                ['TF3', 3, 'truefalse'],
668
        ], $structure);
668
        ], $structure);
669
    }
669
    }
Línea 670... Línea 670...
670
 
670
 
671
    public function test_quiz_remove_slot() {
671
    public function test_quiz_remove_slot(): void {
672
        $quizobj = $this->create_test_quiz([
672
        $quizobj = $this->create_test_quiz([
673
                ['TF1', 1, 'truefalse'],
673
                ['TF1', 1, 'truefalse'],
674
                ['TF2', 1, 'truefalse'],
674
                ['TF2', 1, 'truefalse'],
675
                'Heading 2',
675
                'Heading 2',
Línea 685... Línea 685...
685
                'Heading 2',
685
                'Heading 2',
686
                ['TF3', 2, 'truefalse'],
686
                ['TF3', 2, 'truefalse'],
687
        ], $structure);
687
        ], $structure);
688
    }
688
    }
Línea 689... Línea 689...
689
 
689
 
690
    public function test_quiz_removing_a_random_question_deletes_the_question() {
690
    public function test_quiz_removing_a_random_question_deletes_the_question(): void {
Línea 691... Línea 691...
691
        global $DB;
691
        global $DB;
692
 
692
 
Línea 720... Línea 720...
720
    }
720
    }
Línea 721... Línea 721...
721
 
721
 
722
    /**
722
    /**
723
     * Unit test to make sue it is not possible to remove all slots in a section at once.
723
     * Unit test to make sue it is not possible to remove all slots in a section at once.
724
     */
724
     */
725
    public function test_cannot_remove_all_slots_in_a_section() {
725
    public function test_cannot_remove_all_slots_in_a_section(): void {
726
        $quizobj = $this->create_test_quiz([
726
        $quizobj = $this->create_test_quiz([
727
            ['TF1', 1, 'truefalse'],
727
            ['TF1', 1, 'truefalse'],
728
            ['TF2', 1, 'truefalse'],
728
            ['TF2', 1, 'truefalse'],
729
            'Heading 2',
729
            'Heading 2',
Línea 734... Línea 734...
734
        $structure->remove_slot(1);
734
        $structure->remove_slot(1);
735
        $this->expectException(\coding_exception::class);
735
        $this->expectException(\coding_exception::class);
736
        $structure->remove_slot(2);
736
        $structure->remove_slot(2);
737
    }
737
    }
Línea 738... Línea 738...
738
 
738
 
739
    public function test_cannot_remove_last_slot_in_a_section() {
739
    public function test_cannot_remove_last_slot_in_a_section(): void {
740
        $quizobj = $this->create_test_quiz([
740
        $quizobj = $this->create_test_quiz([
741
                ['TF1', 1, 'truefalse'],
741
                ['TF1', 1, 'truefalse'],
742
                ['TF2', 1, 'truefalse'],
742
                ['TF2', 1, 'truefalse'],
743
                'Heading 2',
743
                'Heading 2',
Línea 747... Línea 747...
747
 
747
 
748
        $this->expectException(\coding_exception::class);
748
        $this->expectException(\coding_exception::class);
749
        $structure->remove_slot(3);
749
        $structure->remove_slot(3);
Línea 750... Línea 750...
750
    }
750
    }
751
 
751
 
752
    public function test_can_remove_last_question_in_a_quiz() {
752
    public function test_can_remove_last_question_in_a_quiz(): void {
753
        $quizobj = $this->create_test_quiz([
753
        $quizobj = $this->create_test_quiz([
754
                'Heading 1',
754
                'Heading 1',
755
                ['TF1', 1, 'truefalse'],
755
                ['TF1', 1, 'truefalse'],
Línea 770... Línea 770...
770
                'Heading 1',
770
                'Heading 1',
771
                ['TF2', 1, 'truefalse'],
771
                ['TF2', 1, 'truefalse'],
772
        ], $structure);
772
        ], $structure);
773
    }
773
    }
Línea 774... Línea 774...
774
 
774
 
775
    public function test_add_question_updates_headings() {
775
    public function test_add_question_updates_headings(): void {
776
        $quizobj = $this->create_test_quiz([
776
        $quizobj = $this->create_test_quiz([
777
                ['TF1', 1, 'truefalse'],
777
                ['TF1', 1, 'truefalse'],
778
                'Heading 2',
778
                'Heading 2',
779
                ['TF2', 2, 'truefalse'],
779
                ['TF2', 2, 'truefalse'],
Línea 793... Línea 793...
793
                'Heading 2',
793
                'Heading 2',
794
                ['TF2', 2, 'truefalse'],
794
                ['TF2', 2, 'truefalse'],
795
        ], $structure);
795
        ], $structure);
796
    }
796
    }
Línea 797... Línea 797...
797
 
797
 
798
    public function test_add_question_updates_headings_even_with_one_question_sections() {
798
    public function test_add_question_updates_headings_even_with_one_question_sections(): void {
799
        $quizobj = $this->create_test_quiz([
799
        $quizobj = $this->create_test_quiz([
800
                'Heading 1',
800
                'Heading 1',
801
                ['TF1', 1, 'truefalse'],
801
                ['TF1', 1, 'truefalse'],
802
                'Heading 2',
802
                'Heading 2',
Línea 822... Línea 822...
822
                'Heading 3',
822
                'Heading 3',
823
                ['TF3', 3, 'truefalse'],
823
                ['TF3', 3, 'truefalse'],
824
        ], $structure);
824
        ], $structure);
825
    }
825
    }
Línea 826... Línea 826...
826
 
826
 
827
    public function test_add_question_at_end_does_not_update_headings() {
827
    public function test_add_question_at_end_does_not_update_headings(): void {
828
        $quizobj = $this->create_test_quiz([
828
        $quizobj = $this->create_test_quiz([
829
                ['TF1', 1, 'truefalse'],
829
                ['TF1', 1, 'truefalse'],
830
                'Heading 2',
830
                'Heading 2',
831
                ['TF2', 2, 'truefalse'],
831
                ['TF2', 2, 'truefalse'],
Línea 845... Línea 845...
845
                ['TF2', 2, 'truefalse'],
845
                ['TF2', 2, 'truefalse'],
846
                ['TF3', 2, 'truefalse'],
846
                ['TF3', 2, 'truefalse'],
847
        ], $structure);
847
        ], $structure);
848
    }
848
    }
Línea 849... Línea 849...
849
 
849
 
850
    public function test_remove_page_break() {
850
    public function test_remove_page_break(): void {
851
        $quizobj = $this->create_test_quiz([
851
        $quizobj = $this->create_test_quiz([
852
                ['TF1', 1, 'truefalse'],
852
                ['TF1', 1, 'truefalse'],
853
                ['TF2', 2, 'truefalse'],
853
                ['TF2', 2, 'truefalse'],
854
        ]);
854
        ]);
Línea 862... Línea 862...
862
                ['TF1', 1, 'truefalse'],
862
                ['TF1', 1, 'truefalse'],
863
                ['TF2', 1, 'truefalse'],
863
                ['TF2', 1, 'truefalse'],
864
        ], $structure);
864
        ], $structure);
865
    }
865
    }
Línea 866... Línea 866...
866
 
866
 
867
    public function test_add_page_break() {
867
    public function test_add_page_break(): void {
868
        $quizobj = $this->create_test_quiz([
868
        $quizobj = $this->create_test_quiz([
869
                ['TF1', 1, 'truefalse'],
869
                ['TF1', 1, 'truefalse'],
870
                ['TF2', 1, 'truefalse'],
870
                ['TF2', 1, 'truefalse'],
871
        ]);
871
        ]);
Línea 879... Línea 879...
879
                ['TF1', 1, 'truefalse'],
879
                ['TF1', 1, 'truefalse'],
880
                ['TF2', 2, 'truefalse'],
880
                ['TF2', 2, 'truefalse'],
881
        ], $structure);
881
        ], $structure);
882
    }
882
    }
Línea 883... Línea 883...
883
 
883
 
884
    public function test_update_question_dependency() {
884
    public function test_update_question_dependency(): void {
885
        $quizobj = $this->create_test_quiz([
885
        $quizobj = $this->create_test_quiz([
886
                ['TF1', 1, 'truefalse'],
886
                ['TF1', 1, 'truefalse'],
887
                ['TF2', 1, 'truefalse'],
887
                ['TF2', 1, 'truefalse'],
888
        ]);
888
        ]);
Línea 937... Línea 937...
937
 
937
 
938
        // Test returns false if no change.
938
        // Test returns false if no change.
939
        $this->assertFalse($structure->update_slot_grade_item($slot, null));
939
        $this->assertFalse($structure->update_slot_grade_item($slot, null));
Línea -... Línea 940...
-
 
940
    }
-
 
941
 
-
 
942
    public function test_cannot_set_nonnull_slot_grade_item_for_description(): void {
-
 
943
        $quizobj = $this->create_test_quiz([
-
 
944
                ['Info', 1, 'description'],
-
 
945
        ]);
-
 
946
        /** @var \mod_quiz_generator $quizgenerator */
-
 
947
        $quizgenerator = $this->getDataGenerator()->get_plugin_generator('mod_quiz');
-
 
948
        $gradeitem = $quizgenerator->create_grade_item(
-
 
949
            ['quizid' => $quizobj->get_quizid(), 'name' => 'Awesomeness!']);
-
 
950
        $structure = structure::create_for_quiz($quizobj);
-
 
951
 
-
 
952
        $this->expectException(\coding_exception::class);
-
 
953
        $structure->update_slot_grade_item($structure->get_slot_by_number(1), $gradeitem->id);
940
    }
954
    }
941
 
955
 
942
    /**
956
    /**
943
     * Test for can_add_random_questions.
957
     * Test for can_add_random_questions.
944
     */
958
     */
Línea 945... Línea 959...
945
    public function test_can_add_random_questions() {
959
    public function test_can_add_random_questions(): void {
946
        $this->resetAfterTest();
960
        $this->resetAfterTest();
Línea 964... Línea 978...
964
    /**
978
    /**
965
     * Test to get the version information for a question to show in the version selection dropdown.
979
     * Test to get the version information for a question to show in the version selection dropdown.
966
     *
980
     *
967
     * @covers ::get_question_version_info
981
     * @covers ::get_question_version_info
968
     */
982
     */
969
    public function test_get_version_choices_for_slot() {
983
    public function test_get_version_choices_for_slot(): void {
970
        $this->resetAfterTest();
984
        $this->resetAfterTest();
Línea 971... Línea 985...
971
 
985
 
Línea 972... Línea 986...
972
        $quizobj = $this->create_test_quiz([]);
986
        $quizobj = $this->create_test_quiz([]);
Línea 997... Línea 1011...
997
    /**
1011
    /**
998
     * Test the current user have '...use' capability over the question(s) in a given slot.
1012
     * Test the current user have '...use' capability over the question(s) in a given slot.
999
     *
1013
     *
1000
     * @covers ::has_use_capability
1014
     * @covers ::has_use_capability
1001
     */
1015
     */
1002
    public function test_has_use_capability() {
1016
    public function test_has_use_capability(): void {
1003
        $this->resetAfterTest();
1017
        $this->resetAfterTest();
Línea 1004... Línea 1018...
1004
 
1018
 
1005
        // Create a quiz with question.
1019
        // Create a quiz with question.
1006
        $quizobj = $this->create_test_quiz([]);
1020
        $quizobj = $this->create_test_quiz([]);