ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assClozeSelectGapTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  protected $backupGlobals = false;
14 
15  protected function setUp()
16  {
17  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
18  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
19  ilUnitUtil::performInitialisation();
20  } else {
21  chdir(dirname(__FILE__));
22  chdir('../../../');
23  }
24  }
25 
27  {
28  // Arrange
29  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
30 
31  // Act
32  $instance = new assClozeSelectGap(1); // 1 - select gap
33 
34  $this->assertInstanceOf('assClozeSelectGap', $instance);
35  }
36 
38  {
39  // Arrange
40  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
41  $instance = new assClozeSelectGap(1); // 1 - select gap
42  $expected = true;
43 
44  $actual = $instance->getShuffle();
45 
46  $this->assertEquals($expected, $actual);
47  }
48 
50  {
51  // Arrange
52  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
53  $instance = new assClozeSelectGap(1); // 1 - select gap
54  $expected = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
55 
56  $actual = $instance->getItems(new ilArrayElementShuffler());
57  $this->assertNotEquals($expected, $actual);
58  }
59 
61  {
62  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
63  $instance = new assClozeSelectGap(1); // 1 - select gap
64 
65  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
66  $item1 = new assAnswerCloze('Bert', 1.0, 0);
67  $item2 = new assAnswerCloze('Fred', 2.0, 2);
68  $item3 = new assAnswerCloze('Karl', 4, 1);
69  $item4 = new assAnswerCloze('Esther', 4, 3);
70  $item5 = new assAnswerCloze('Herbert', 1.0, 4);
71  $item6 = new assAnswerCloze('Karina', 1.0, 5);
72  $item7 = new assAnswerCloze('Helmut', 1.0, 6);
73  $item8 = new assAnswerCloze('Kerstin', 1.0, 7);
74 
75  $instance->addItem($item1);
76  $instance->addItem($item2);
77  $instance->addItem($item3);
78  $instance->addItem($item4);
79  $instance->addItem($item5);
80  $instance->addItem($item6);
81  $instance->addItem($item7);
82  $instance->addItem($item8);
83 
84  $instance->setType(true);
85 
86  $expected = array($item1, $item2, $item3, $item4, $item5, $item6, $item7, $item8);
87 
88  $actual = $instance->getItems(new ilArrayElementShuffler());
89 
90  $this->assertNotEquals($expected, $actual);
91  }
92 
94  {
95  require_once 'Services/Randomization/classes/class.ilArrayElementOrderKeeper.php';
96  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
97  $instance = new assClozeSelectGap(1); // 1 - select gap
98 
99  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
100  $item1 = new assAnswerCloze('Bert', 1.0, 0);
101  $item2 = new assAnswerCloze('Fred', 2.0, 1);
102  $item3 = new assAnswerCloze('Karl', 4, 2);
103  $item4 = new assAnswerCloze('Esther', 4, 3);
104 
105  $instance->addItem($item1);
106  $instance->addItem($item2);
107  $instance->addItem($item3);
108  $instance->addItem($item4);
109 
110  $instance->setType(false);
111 
112  $expected = array($item1, $item2, $item3, $item4);
113  $actual = $instance->getItems(new ilArrayElementOrderKeeper());
114 
115  $this->assertEquals($expected, $actual);
116  }
117 }
Class for cloze question numeric answers.
Class for cloze question select gaps.
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27