ILIAS  release_8 Revision v8.24
ilLOTestAssignments Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLOTestAssignments:

Public Member Functions

 __construct (int $a_container_id)
 
 getContainerId ()
 
 getSettings ()
 
 getAssignments ()
 Get assignments. More...
 
 getAssignmentsByType (int $a_type)
 Get assignments by type. More...
 
 getTests ()
 
 getTestByObjective (int $a_objective_id, int $a_type)
 
 isSeparateTest (int $a_test_ref_id)
 
 getTypeByTest (int $a_test_ref_id)
 
 getAssignmentByObjective (int $a_objective_id, int $a_type)
 
 toXml (ilXmlWriter $writer, int $a_objective_id)
 

Static Public Member Functions

static getInstance (int $a_container_id)
 
static lookupContainerForTest (int $a_test_ref_id)
 
static deleteByContainer (int $a_container_id)
 
static lookupObjectivesForTest (int $a_test_ref_id)
 

Protected Member Functions

 readTestAssignments ()
 

Protected Attributes

ilDBInterface $db
 

Private Attributes

int $container_id = 0
 
array $assignments = []
 
ilLOSettings $settings
 

Static Private Attributes

static array $instances = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Settings for LO courses

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 24 of file class.ilLOTestAssignments.php.

Constructor & Destructor Documentation

◆ __construct()

ilLOTestAssignments::__construct ( int  $a_container_id)

Definition at line 37 of file class.ilLOTestAssignments.php.

38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42
43 $this->container_id = $a_container_id;
44 $this->settings = ilLOSettings::getInstanceByObjId($a_container_id);
45 $this->readTestAssignments();
46 }
static getInstanceByObjId(int $a_obj_id)
global $DIC
Definition: feed.php:28

References $DIC, ilLOSettings\getInstanceByObjId(), readTestAssignments(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ deleteByContainer()

static ilLOTestAssignments::deleteByContainer ( int  $a_container_id)
static

Definition at line 90 of file class.ilLOTestAssignments.php.

90 : void
91 {
92 global $DIC;
93
94 $ilDB = $DIC->database();
95 $query = 'DELETE FROM loc_tst_assignments ' .
96 'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer');
97 $ilDB->manipulate($query);
98 }
$query

References $DIC, $ilDB, and $query.

◆ getAssignmentByObjective()

ilLOTestAssignments::getAssignmentByObjective ( int  $a_objective_id,
int  $a_type 
)

Definition at line 198 of file class.ilLOTestAssignments.php.

199 {
200 foreach ($this->assignments as $assignment) {
201 if (
202 ($assignment->getObjectiveId() === $a_objective_id) &&
203 ($assignment->getAssignmentType() === $a_type)
204 ) {
205 return $assignment;
206 }
207 }
208 return null;
209 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by getTestByObjective().

+ Here is the caller graph for this function:

◆ getAssignments()

ilLOTestAssignments::getAssignments ( )

Get assignments.

Returns
ilLOTestAssignment[]

Definition at line 85 of file class.ilLOTestAssignments.php.

85 : array
86 {
87 return $this->assignments;
88 }

References $assignments.

Referenced by toXml().

+ Here is the caller graph for this function:

◆ getAssignmentsByType()

ilLOTestAssignments::getAssignmentsByType ( int  $a_type)

Get assignments by type.

Returns
ilLOTestAssignment[]

Definition at line 104 of file class.ilLOTestAssignments.php.

104 : array
105 {
106 $by_type = array();
107 foreach ($this->assignments as $assignment) {
108 if ($assignment->getAssignmentType() === $a_type) {
109 $by_type[] = $assignment;
110 }
111 }
112 return $by_type;
113 }

◆ getContainerId()

ilLOTestAssignments::getContainerId ( )

Definition at line 71 of file class.ilLOTestAssignments.php.

71 : int
72 {
74 }

References $container_id.

Referenced by readTestAssignments().

+ Here is the caller graph for this function:

◆ getInstance()

◆ getSettings()

ilLOTestAssignments::getSettings ( )

Definition at line 76 of file class.ilLOTestAssignments.php.

77 {
78 return $this->settings;
79 }
Settings for LO courses.

References $settings.

Referenced by getTestByObjective(), getTests(), getTypeByTest(), and isSeparateTest().

+ Here is the caller graph for this function:

◆ getTestByObjective()

ilLOTestAssignments::getTestByObjective ( int  $a_objective_id,
int  $a_type 
)

Definition at line 133 of file class.ilLOTestAssignments.php.

133 : int
134 {
135 switch ($a_type) {
137 if (!$this->getSettings()->hasSeparateInitialTests()) {
138 return $this->getSettings()->getInitialTest();
139 }
140 break;
141
143 if (!$this->getSettings()->hasSeparateQualifiedTests()) {
144 return $this->getSettings()->getQualifiedTest();
145 }
146 break;
147 }
148
149 $assignment = $this->getAssignmentByObjective($a_objective_id, $a_type);
150 if ($assignment) {
151 return $assignment->getTestRefId();
152 }
153 return 0;
154 }
getAssignmentByObjective(int $a_objective_id, int $a_type)

References getAssignmentByObjective(), getSettings(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

Referenced by ilLOTestQuestionAdapter\lookupRelevantObjectiveIdsForTest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTests()

ilLOTestAssignments::getTests ( )
Returns
int[]

Definition at line 118 of file class.ilLOTestAssignments.php.

118 : array
119 {
120 $tests = array();
121 if ($this->getSettings()->getInitialTest()) {
122 $tests[] = $this->getSettings()->getInitialTest();
123 }
124 if ($this->getSettings()->getQualifiedTest()) {
125 $tests[] = $this->getSettings()->getQualifiedTest();
126 }
127 foreach ($this->assignments as $assignment) {
128 $tests[] = $assignment->getTestRefId();
129 }
130 return $tests;
131 }

References getSettings().

+ Here is the call graph for this function:

◆ getTypeByTest()

ilLOTestAssignments::getTypeByTest ( int  $a_test_ref_id)

Definition at line 171 of file class.ilLOTestAssignments.php.

171 : int
172 {
173 if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
174 if ($this->getSettings()->getInitialTest() == $a_test_ref_id) {
176 }
177 } elseif ($this->getSettings()->worksWithInitialTest()) {
178 foreach ($this->assignments as $assignment) {
179 if ($assignment->getTestRefId() == $a_test_ref_id) {
181 }
182 }
183 }
184 if (!$this->getSettings()->hasSeparateQualifiedTests()) {
185 if ($this->getSettings()->getQualifiedTest() == $a_test_ref_id) {
187 }
188 } else {
189 foreach ($this->assignments as $assignment) {
190 if ($assignment->getTestRefId() == $a_test_ref_id) {
192 }
193 }
194 }
196 }

References getSettings(), ilLOSettings\TYPE_TEST_INITIAL, ilLOSettings\TYPE_TEST_QUALIFIED, and ilLOSettings\TYPE_TEST_UNDEFINED.

Referenced by ilLOTestQuestionAdapter\lookupRelevantObjectiveIdsForTest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSeparateTest()

ilLOTestAssignments::isSeparateTest ( int  $a_test_ref_id)

Definition at line 156 of file class.ilLOTestAssignments.php.

156 : bool
157 {
158 if (!$this->getSettings()->hasSeparateInitialTests()) {
159 if ($this->getSettings()->getInitialTest() == $a_test_ref_id) {
160 return false;
161 }
162 }
163 if (!$this->getSettings()->hasSeparateQualifiedTests()) {
164 if ($this->getSettings()->getQualifiedTest() == $a_test_ref_id) {
165 return false;
166 }
167 }
168 return true;
169 }

References getSettings().

+ Here is the call graph for this function:

◆ lookupContainerForTest()

static ilLOTestAssignments::lookupContainerForTest ( int  $a_test_ref_id)
static

Definition at line 56 of file class.ilLOTestAssignments.php.

56 : int
57 {
58 global $DIC;
59
60 $ilDB = $DIC['ilDB'];
61
62 $query = 'SELECT container_id FROM loc_tst_assignments ' .
63 'WHERE tst_ref_id = ' . $ilDB->quote($a_test_ref_id, 'integer');
64 $res = $ilDB->query($query);
65 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
66 return $row->container_id;
67 }
68 return 0;
69 }
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLOSettings\isObjectiveTest(), and ilTestLP\resetCustomLPDataForUserIds().

+ Here is the caller graph for this function:

◆ lookupObjectivesForTest()

static ilLOTestAssignments::lookupObjectivesForTest ( int  $a_test_ref_id)
static

Definition at line 240 of file class.ilLOTestAssignments.php.

240 : array
241 {
242 global $DIC;
243
244 $ilDB = $DIC->database();
245 $objectives = [];
246 $query = 'SELECT objective_id FROM loc_tst_assignments ' .
247 'WHERE tst_ref_id = ' . $ilDB->quote($a_test_ref_id, 'integer');
248 $res = $ilDB->query($query);
249 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
250 $objectives[] = $row->objective_id;
251 }
252 return $objectives;
253 }
$objectives

References $DIC, $ilDB, $objectives, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilTestLP\resetCustomLPDataForUserIds().

+ Here is the caller graph for this function:

◆ readTestAssignments()

ilLOTestAssignments::readTestAssignments ( )
protected

Definition at line 211 of file class.ilLOTestAssignments.php.

211 : void
212 {
213 $query = 'SELECT assignment_id FROM loc_tst_assignments ' .
214 'WHERE container_id = ' . $this->db->quote($this->getContainerId(), 'integer');
215 $res = $this->db->query($query);
216 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
217 $assignment = new ilLOTestAssignment($row->assignment_id);
218
219 $this->assignments[] = $assignment;
220 }
221 }

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, and getContainerId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXml()

ilLOTestAssignments::toXml ( ilXmlWriter  $writer,
int  $a_objective_id 
)

Definition at line 223 of file class.ilLOTestAssignments.php.

223 : void
224 {
225 foreach ($this->getAssignments() as $assignment) {
226 if ($assignment->getObjectiveId() != $a_objective_id) {
227 continue;
228 }
229 $writer->xmlElement(
230 'Test',
231 array(
233 'refId' => $assignment->getTestRefId(),
234 'testType' => $assignment->getAssignmentType()
235 )
236 );
237 }
238 }
getAssignments()
Get assignments.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

References getAssignments(), ilLOXmlWriter\TYPE_TST_PO, and ilXmlWriter\xmlElement().

+ Here is the call graph for this function:

Field Documentation

◆ $assignments

array ilLOTestAssignments::$assignments = []
private

Definition at line 32 of file class.ilLOTestAssignments.php.

Referenced by getAssignments().

◆ $container_id

int ilLOTestAssignments::$container_id = 0
private

Definition at line 28 of file class.ilLOTestAssignments.php.

Referenced by getContainerId().

◆ $db

ilDBInterface ilLOTestAssignments::$db
protected

Definition at line 35 of file class.ilLOTestAssignments.php.

◆ $instances

array ilLOTestAssignments::$instances = []
staticprivate

Definition at line 26 of file class.ilLOTestAssignments.php.

◆ $settings

ilLOSettings ilLOTestAssignments::$settings
private

Definition at line 33 of file class.ilLOTestAssignments.php.

Referenced by getSettings().


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