ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilLOTestAssignments Class Reference

Settings for LO courses. 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

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 25 of file class.ilLOTestAssignments.php.

Constructor & Destructor Documentation

◆ __construct()

ilLOTestAssignments::__construct ( int  $a_container_id)

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

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

39  {
40  global $DIC;
41 
42  $this->db = $DIC->database();
43 
44  $this->container_id = $a_container_id;
45  $this->settings = ilLOSettings::getInstanceByObjId($a_container_id);
46  $this->readTestAssignments();
47  }
global $DIC
Definition: shib_login.php:26
static getInstanceByObjId(int $a_obj_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteByContainer()

static ilLOTestAssignments::deleteByContainer ( int  $a_container_id)
static

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

References $DIC, and $ilDB.

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

◆ getAssignmentByObjective()

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

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

References null.

Referenced by getTestByObjective().

200  {
201  foreach ($this->assignments as $assignment) {
202  if (
203  ($assignment->getObjectiveId() === $a_objective_id) &&
204  ($assignment->getAssignmentType() === $a_type)
205  ) {
206  return $assignment;
207  }
208  }
209  return null;
210  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Settings for LO courses.
+ Here is the caller graph for this function:

◆ getAssignments()

ilLOTestAssignments::getAssignments ( )

Get assignments.

Returns
ilLOTestAssignment[]

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

References $assignments.

Referenced by toXml().

86  : array
87  {
88  return $this->assignments;
89  }
+ Here is the caller graph for this function:

◆ getAssignmentsByType()

ilLOTestAssignments::getAssignmentsByType ( int  $a_type)

Get assignments by type.

Returns
ilLOTestAssignment[]

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

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

◆ getContainerId()

ilLOTestAssignments::getContainerId ( )

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

References $container_id.

Referenced by readTestAssignments().

72  : int
73  {
74  return $this->container_id;
75  }
+ Here is the caller graph for this function:

◆ getInstance()

◆ getSettings()

ilLOTestAssignments::getSettings ( )

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

References $settings.

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

77  : ilLOSettings
78  {
79  return $this->settings;
80  }
Settings for LO courses.
+ Here is the caller graph for this function:

◆ getTestByObjective()

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

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

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

Referenced by ilLOTestQuestionAdapter\lookupRelevantObjectiveIdsForTest().

134  : int
135  {
136  switch ($a_type) {
138  if (!$this->getSettings()->hasSeparateInitialTests()) {
139  return $this->getSettings()->getInitialTest();
140  }
141  break;
142 
144  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
145  return $this->getSettings()->getQualifiedTest();
146  }
147  break;
148  }
149 
150  $assignment = $this->getAssignmentByObjective($a_objective_id, $a_type);
151  if ($assignment) {
152  return $assignment->getTestRefId();
153  }
154  return 0;
155  }
getAssignmentByObjective(int $a_objective_id, int $a_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTests()

ilLOTestAssignments::getTests ( )
Returns
int[]

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

References getSettings().

119  : array
120  {
121  $tests = array();
122  if ($this->getSettings()->getInitialTest()) {
123  $tests[] = $this->getSettings()->getInitialTest();
124  }
125  if ($this->getSettings()->getQualifiedTest()) {
126  $tests[] = $this->getSettings()->getQualifiedTest();
127  }
128  foreach ($this->assignments as $assignment) {
129  $tests[] = $assignment->getTestRefId();
130  }
131  return $tests;
132  }
+ Here is the call graph for this function:

◆ getTypeByTest()

ilLOTestAssignments::getTypeByTest ( int  $a_test_ref_id)

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

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

Referenced by ilLOTestQuestionAdapter\lookupRelevantObjectiveIdsForTest().

172  : int
173  {
174  if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
175  if ($this->getSettings()->getInitialTest() == $a_test_ref_id) {
177  }
178  } elseif ($this->getSettings()->worksWithInitialTest()) {
179  foreach ($this->assignments as $assignment) {
180  if ($assignment->getTestRefId() == $a_test_ref_id && $assignment->getAssignmentType() == ilLOSettings::TYPE_TEST_INITIAL) {
182  }
183  }
184  }
185  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
186  if ($this->getSettings()->getQualifiedTest() == $a_test_ref_id) {
188  }
189  } else {
190  foreach ($this->assignments as $assignment) {
191  if ($assignment->getTestRefId() == $a_test_ref_id && $assignment->getAssignmentType() == ilLOSettings::TYPE_TEST_QUALIFIED) {
193  }
194  }
195  }
197  }
+ 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 157 of file class.ilLOTestAssignments.php.

References getSettings().

157  : bool
158  {
159  if (!$this->getSettings()->hasSeparateInitialTests()) {
160  if ($this->getSettings()->getInitialTest() == $a_test_ref_id) {
161  return false;
162  }
163  }
164  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
165  if ($this->getSettings()->getQualifiedTest() == $a_test_ref_id) {
166  return false;
167  }
168  }
169  return true;
170  }
+ Here is the call graph for this function:

◆ lookupContainerForTest()

static ilLOTestAssignments::lookupContainerForTest ( int  $a_test_ref_id)
static

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

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

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

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

◆ lookupObjectivesForTest()

static ilLOTestAssignments::lookupObjectivesForTest ( int  $a_test_ref_id)
static

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

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

Referenced by ilTestLP\resetCustomLPDataForUserIds().

241  : array
242  {
243  global $DIC;
244 
245  $ilDB = $DIC->database();
246  $objectives = [];
247  $query = 'SELECT objective_id FROM loc_tst_assignments ' .
248  'WHERE tst_ref_id = ' . $ilDB->quote($a_test_ref_id, 'integer');
249  $res = $ilDB->query($query);
250  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
251  $objectives[] = $row->objective_id;
252  }
253  return $objectives;
254  }
$res
Definition: ltiservices.php:66
$objectives
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ readTestAssignments()

ilLOTestAssignments::readTestAssignments ( )
protected

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

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

Referenced by __construct().

212  : void
213  {
214  $query = 'SELECT assignment_id FROM loc_tst_assignments ' .
215  'WHERE container_id = ' . $this->db->quote($this->getContainerId(), 'integer');
216  $res = $this->db->query($query);
217  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
218  $assignment = new ilLOTestAssignment($row->assignment_id);
219 
220  $this->assignments[] = $assignment;
221  }
222  }
$res
Definition: ltiservices.php:66
Settings for LO courses.
+ 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 224 of file class.ilLOTestAssignments.php.

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

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

Field Documentation

◆ $assignments

array ilLOTestAssignments::$assignments = []
private

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

Referenced by getAssignments().

◆ $container_id

int ilLOTestAssignments::$container_id = 0
private

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

Referenced by getContainerId().

◆ $db

ilDBInterface ilLOTestAssignments::$db
protected

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

◆ $instances

array ilLOTestAssignments::$instances = []
staticprivate

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

◆ $settings

ilLOSettings ilLOTestAssignments::$settings
private

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

Referenced by getSettings().


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