ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References defined.

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  }
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ test_flushAnswers_shouldClearAnswers()

assMultipleChoiceTest::test_flushAnswers_shouldClearAnswers ( )

Definition at line 133 of file assMultipleChoiceTest.php.

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

◆ test_getAdditionalTableName_shouldReturnAdditionalTableName()

assMultipleChoiceTest::test_getAdditionalTableName_shouldReturnAdditionalTableName ( )

Definition at line 149 of file assMultipleChoiceTest.php.

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

◆ test_getAnswerCount_shouldReturnCount()

assMultipleChoiceTest::test_getAnswerCount_shouldReturnCount ( )

Definition at line 122 of file assMultipleChoiceTest.php.

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

◆ test_getAnswerTableName_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getAnswerTableName_shouldReturnAnswerTableName ( )

Definition at line 155 of file assMultipleChoiceTest.php.

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

◆ test_getMaximumPoints_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getMaximumPoints_shouldReturnAnswerTableName ( )

Definition at line 161 of file assMultipleChoiceTest.php.

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

◆ test_getMaximumPointsIfMoreForUnchecked_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getMaximumPointsIfMoreForUnchecked_shouldReturnAnswerTableName ( )

Definition at line 168 of file assMultipleChoiceTest.php.

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

◆ test_getMaximumPointsMixed_shouldReturnAnswerTableName()

assMultipleChoiceTest::test_getMaximumPointsMixed_shouldReturnAnswerTableName ( )

Definition at line 175 of file assMultipleChoiceTest.php.

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

◆ test_getQuestionType_shouldReturnQuestionType()

assMultipleChoiceTest::test_getQuestionType_shouldReturnQuestionType ( )

Definition at line 143 of file assMultipleChoiceTest.php.

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

◆ test_getThumbPrefix_shouldReturnString()

assMultipleChoiceTest::test_getThumbPrefix_shouldReturnString ( )

Definition at line 110 of file assMultipleChoiceTest.php.

111  {
112  $obj = new assMultipleChoice();
113  $this->assertEquals('thumb.', $obj->getThumbPrefix());
114  }
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 98 of file assMultipleChoiceTest.php.

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

◆ test_setOutputType_shouldReturngetOutputType()

assMultipleChoiceTest::test_setOutputType_shouldReturngetOutputType ( )

Definition at line 116 of file assMultipleChoiceTest.php.

117  {
118  $obj = new assMultipleChoice();
119  $obj->setOutputType(0);
120  $this->assertEquals(0, $obj->getOutputType());
121  }
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: