ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assMultipleChoiceTest Class Reference

Unit tests for single choice questions. More...

+ Inheritance diagram for assMultipleChoiceTest:
+ Collaboration diagram for assMultipleChoiceTest:

Public Member Functions

 test_isComplete_shouldReturnTrue ()
 Create a sample question and save it to the database. More...
 
 test_getThumbPrefix_shouldReturnString ()
 
 test_setOutputType_shouldReturngetOutputType ()
 
 test_getAnswerCount_shouldReturnCount ()
 
 test_flushAnswers_shouldClearAnswers ()
 
 test_getQuestionType_shouldReturnQuestionType ()
 
 test_getAdditionalTableName_shouldReturnAdditionalTableName ()
 
 test_getAnswerTableName_shouldReturnAnswerTableName ()
 
 test_getMaximumPoints_shouldReturnAnswerTableName ()
 
 test_getMaximumPointsIfMoreForUnchecked_shouldReturnAnswerTableName ()
 
 test_getMaximumPointsMixed_shouldReturnAnswerTableName ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

Unit tests for single choice questions.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 13 of file assMultipleChoiceTest.php.

Member Function Documentation

◆ setUp()

assMultipleChoiceTest::setUp ( )
protected

Definition at line 17 of file assMultipleChoiceTest.php.

18  {
19  require_once './Modules/TestQuestionPool/classes/class.assMultipleChoice.php';
20  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
21  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
22  ilUnitUtil::performInitialisation();
23  } else {
24  chdir(dirname(__FILE__));
25  chdir('../../../');
26  }
27  require_once './Services/Utilities/classes/class.ilUtil.php';
28  }

◆ test_flushAnswers_shouldClearAnswers()

assMultipleChoiceTest::test_flushAnswers_shouldClearAnswers ( )

Definition at line 134 of file assMultipleChoiceTest.php.

135  {
136  $obj = new assMultipleChoice();
137  $obj->addAnswer('1', 1, 0, 0);
138  $obj->addAnswer('1', 1, 0, 1);
139  $this->assertEquals(2, $obj->getAnswerCount());
140  $obj->flushAnswers();
141  $this->assertEquals(0, $obj->getAnswerCount());
142  }
Class for multiple choice tests.

◆ test_getAdditionalTableName_shouldReturnAdditionalTableName()

assMultipleChoiceTest::test_getAdditionalTableName_shouldReturnAdditionalTableName ( )

Definition at line 150 of file assMultipleChoiceTest.php.

151  {
152  $obj = new assMultipleChoice();
153  $this->assertEquals('qpl_qst_mc', $obj->getAdditionalTableName());
154  }
Class for multiple choice tests.

◆ test_getAnswerCount_shouldReturnCount()

assMultipleChoiceTest::test_getAnswerCount_shouldReturnCount ( )

Definition at line 123 of file assMultipleChoiceTest.php.

124  {
125  $obj = new assMultipleChoice();
126  $this->assertEquals(0, $obj->getAnswerCount());
127  $obj->addAnswer('Points for checked', 1, 0, 0);
128  $obj->addAnswer('Points for unchecked', 0, 1, 1);
129  $this->assertEquals(2, $obj->getAnswerCount());
130  $obj->deleteAnswer(0);
131  $this->assertEquals(1, $obj->getAnswerCount());
132  }
Class for multiple choice tests.

◆ test_getAnswerTableName_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getAnswerTableName_shouldReturnAnswerTableName ( )

Definition at line 156 of file assMultipleChoiceTest.php.

157  {
158  $obj = new assMultipleChoice();
159  $this->assertEquals('qpl_a_mc', $obj->getAnswerTableName());
160  }
Class for multiple choice tests.

◆ test_getMaximumPoints_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getMaximumPoints_shouldReturnAnswerTableName ( )

Definition at line 162 of file assMultipleChoiceTest.php.

163  {
164  $obj = new assMultipleChoice();
165  $obj->addAnswer('Points for checked', 1, 0, 0);
166  $obj->addAnswer('Points for checked', 1, 0, 1);
167  $this->assertEquals(2, $obj->getMaximumPoints());
168  }
Class for multiple choice tests.

◆ test_getMaximumPointsIfMoreForUnchecked_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getMaximumPointsIfMoreForUnchecked_shouldReturnAnswerTableName ( )

Definition at line 169 of file assMultipleChoiceTest.php.

170  {
171  $obj = new assMultipleChoice();
172  $obj->addAnswer('Points for unchecked', 0, 1, 0);
173  $obj->addAnswer('Points for unchecked', 0, 1, 1);
174  $this->assertEquals(2, $obj->getMaximumPoints());
175  }
Class for multiple choice tests.

◆ test_getMaximumPointsMixed_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getMaximumPointsMixed_shouldReturnAnswerTableName ( )

Definition at line 176 of file assMultipleChoiceTest.php.

177  {
178  $obj = new assMultipleChoice();
179  $obj->addAnswer('Points for unchecked', 0, 1, 0);
180  $obj->addAnswer('Points for unchecked', 0, 1, 1);
181  $this->assertEquals(2, $obj->getMaximumPoints());
182  $obj->addAnswer('Points for checked', 1, 0, 2);
183  $obj->addAnswer('Points for checked', 1, 0, 3);
184  $this->assertEquals(4, $obj->getMaximumPoints());
185  $obj->addAnswer('Points for checked', 1, 1, 4);
186  $obj->addAnswer('Points for checked', 1, 1, 5);
187  $this->assertEquals(6, $obj->getMaximumPoints());
188  }
Class for multiple choice tests.

◆ test_getQuestionType_shouldReturnQuestionType()

assMultipleChoiceTest::test_getQuestionType_shouldReturnQuestionType ( )

Definition at line 144 of file assMultipleChoiceTest.php.

145  {
146  $obj = new assMultipleChoice();
147  $this->assertEquals('assMultipleChoice', $obj->getQuestionType());
148  }
Class for multiple choice tests.

◆ test_getThumbPrefix_shouldReturnString()

assMultipleChoiceTest::test_getThumbPrefix_shouldReturnString ( )

Definition at line 111 of file assMultipleChoiceTest.php.

112  {
113  $obj = new assMultipleChoice();
114  $this->assertEquals('thumb.', $obj->getThumbPrefix());
115  }
Class for multiple choice tests.

◆ test_isComplete_shouldReturnTrue()

assMultipleChoiceTest::test_isComplete_shouldReturnTrue ( )

Create a sample question and save it to the database.

Parameters
integer$obj_idObject ID of the containing question pool object (optional)
Returns
integer ID of the newly created question Question creation test
Parameters

Definition at line 99 of file assMultipleChoiceTest.php.

100  {
101  $obj = new assMultipleChoice();
102  $this->assertEquals(false, $obj->isComplete());
103  $obj->setTitle('Tilte');
104  $obj->setAuthor('Me or another');
105  $obj->setQuestion('My great Question.');
106  $obj->addAnswer('Super simple single Choice', 1);
107 
108  $this->assertEquals(true, $obj->isComplete());
109  }
Class for multiple choice tests.

◆ test_setOutputType_shouldReturngetOutputType()

assMultipleChoiceTest::test_setOutputType_shouldReturngetOutputType ( )

Definition at line 117 of file assMultipleChoiceTest.php.

118  {
119  $obj = new assMultipleChoice();
120  $obj->setOutputType(0);
121  $this->assertEquals(0, $obj->getOutputType());
122  }
Class for multiple choice tests.

Field Documentation

◆ $backupGlobals

assMultipleChoiceTest::$backupGlobals = false
protected

Definition at line 15 of file assMultipleChoiceTest.php.


The documentation for this class was generated from the following file: