ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilLOTestAssignments Class Reference

Settings for LO courses. More...

+ Collaboration diagram for ilLOTestAssignments:

Public Member Functions

 __construct ($a_container_id)
 Constructor. More...
 
 getContainerId ()
 
 getSettings ()
 get objective settings More...
 
 getAssignments ()
 Get assignments. More...
 
 getAssignmentsByType ($a_type)
 
 getTests ()
 Get all assigned tests. More...
 
 getTestByObjective ($a_objective_id, $a_type)
 
 isSeparateTest ($a_test_ref_id)
 
 getTypeByTest ($a_test_ref_id)
 Get test type by test id. More...
 
 getAssignmentByObjective ($a_objective_id, $a_type)
 Get assignment by objective. More...
 
 toXml (ilXmlWriter $writer, $a_objective_id)
 to xml More...
 

Static Public Member Functions

static getInstance ($a_container_id)
 Get instance by container id. More...
 
static lookupContainerForTest ($a_test_ref_id)
 
static deleteByContainer ($a_container_id)
 Delete assignments by container id (obj_id of course) type $ilDB. More...
 
static lookupObjectivesForTest ($a_test_ref_id)
 Get all objectives that are assigned to given test. More...
 

Protected Member Functions

 readTestAssignments ()
 Read assignments type $ilDB. More...
 

Private Attributes

 $container_id = 0
 
 $assignments = array()
 
 $settings = null
 

Static Private Attributes

static $instances = array()
 

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilLOTestAssignments::__construct (   $a_container_id)

Constructor.

Parameters
type$a_container_id

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

References ilLOSettings\getInstanceByObjId(), readTestAssignments(), and settings().

25  {
26  $this->container_id = $a_container_id;
27 
28  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
29  $this->settings = ilLOSettings::getInstanceByObjId($a_container_id);
30  $this->readTestAssignments();
31 
32  }
static getInstanceByObjId($a_obj_id)
get singleton instance
readTestAssignments()
Read assignments type $ilDB.
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteByContainer()

static ilLOTestAssignments::deleteByContainer (   $a_container_id)
static

Delete assignments by container id (obj_id of course) type $ilDB.

Parameters
type$a_container_id

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

References $ilDB, and $query.

95  {
96  global $ilDB;
97 
98  $query = 'DELETE FROM loc_tst_assignments '.
99  'WHERE container_id = '.$ilDB->quote($a_container_id,'integer');
100  $ilDB->manipulate($query);
101  }
global $ilDB

◆ getAssignmentByObjective()

ilLOTestAssignments::getAssignmentByObjective (   $a_objective_id,
  $a_type 
)

Get assignment by objective.

Parameters
type$a_objective_id
typeinitial or final
Returns
ilLOTestAssignment

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

References $a_type.

Referenced by getTestByObjective().

242  {
243 
244  foreach($this->assignments as $assignment)
245  {
246  if(
247  ($assignment->getObjectiveId() == $a_objective_id) &&
248  ($assignment->getAssignmentType() == $a_type)
249  )
250  {
251  return $assignment;
252  }
253  }
254  return FALSE;
255  }
$a_type
Definition: workflow.php:93
+ Here is the caller graph for this function:

◆ getAssignments()

ilLOTestAssignments::getAssignments ( )

Get assignments.

Returns
ilLOTestAssignment[]

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

References $assignments.

Referenced by toXml().

+ Here is the caller graph for this function:

◆ getAssignmentsByType()

ilLOTestAssignments::getAssignmentsByType (   $a_type)

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

References $a_type, and array.

104  {
105  $by_type = array();
106  foreach($this->assignments as $assignment)
107  {
108  if($assignment->getAssignmentType() == $a_type)
109  {
110  $by_type[] = $assignment;
111  }
112  }
113  return $by_type;
114  }
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.

◆ getContainerId()

ilLOTestAssignments::getContainerId ( )

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

References $container_id.

Referenced by readTestAssignments().

+ Here is the caller graph for this function:

◆ getInstance()

◆ getSettings()

ilLOTestAssignments::getSettings ( )

get objective settings

Returns
ilLOSettings

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

References $settings.

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

+ Here is the caller graph for this function:

◆ getTestByObjective()

ilLOTestAssignments::getTestByObjective (   $a_objective_id,
  $a_type 
)
Parameters
type$a_objective_id
type$a_type
Returns
int

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

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

145  {
146  switch($a_type)
147  {
149  if(!$this->getSettings()->hasSeparateInitialTests())
150  {
151  return $this->getSettings()->getInitialTest();
152  }
153  break;
154 
156  if(!$this->getSettings()->hasSeparateQualifiedTests())
157  {
158  return $this->getSettings()->getQualifiedTest();
159  }
160  break;
161  }
162 
163  $assignment = $this->getAssignmentByObjective($a_objective_id, $a_type);
164  if($assignment)
165  {
166  return $assignment->getTestRefId();
167  }
168  return 0;
169  }
getSettings()
get objective settings
$a_type
Definition: workflow.php:93
getAssignmentByObjective($a_objective_id, $a_type)
Get assignment by objective.
+ Here is the call graph for this function:

◆ getTests()

ilLOTestAssignments::getTests ( )

Get all assigned tests.

Returns
type

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

References array, and getSettings().

121  {
122  $tests = array();
123  if($this->getSettings()->getInitialTest())
124  {
125  $tests[] = $this->getSettings()->getInitialTest();
126  }
127  if($this->getSettings()->getQualifiedTest())
128  {
129  $tests[] = $this->getSettings()->getQualifiedTest();
130  }
131  foreach($this->assignments as $assignment)
132  {
133  $tests[] = $assignment->getTestRefId();
134  }
135  return $tests;
136  }
getSettings()
get objective settings
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getTypeByTest()

ilLOTestAssignments::getTypeByTest (   $a_test_ref_id)

Get test type by test id.

Parameters
type$a_test_ref_id

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

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

195  {
196  if($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests())
197  {
198  if($this->getSettings()->getInitialTest() == $a_test_ref_id)
199  {
201  }
202  }
203  elseif($this->getSettings()->worksWithInitialTest())
204  {
205  foreach($this->assignments as $assignment)
206  {
207  if($assignment->getTestRefId() == $a_test_ref_id)
208  {
210  }
211  }
212 
213  }
214  if(!$this->getSettings()->hasSeparateQualifiedTests())
215  {
216  if($this->getSettings()->getQualifiedTest() == $a_test_ref_id)
217  {
219  }
220  }
221  else
222  {
223  foreach($this->assignments as $assignment)
224  {
225  if($assignment->getTestRefId() == $a_test_ref_id)
226  {
228  }
229  }
230  }
232  }
getSettings()
get objective settings
+ Here is the call graph for this function:

◆ isSeparateTest()

ilLOTestAssignments::isSeparateTest (   $a_test_ref_id)

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

References getSettings().

172  {
173  if(!$this->getSettings()->hasSeparateInitialTests())
174  {
175  if($this->getSettings()->getInitialTest() == $a_test_ref_id)
176  {
177  return FALSE;
178  }
179  }
180  if(!$this->getSettings()->hasSeparateQualifiedTests())
181  {
182  if($this->getSettings()->getQualifiedTest() == $a_test_ref_id)
183  {
184  return FALSE;
185  }
186  }
187  return TRUE;
188  }
getSettings()
get objective settings
+ Here is the call graph for this function:

◆ lookupContainerForTest()

static ilLOTestAssignments::lookupContainerForTest (   $a_test_ref_id)
static
Parameters
type$a_test_ref_id

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

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

Referenced by ilLOSettings\isObjectiveTest().

53  {
54  global $ilDB;
55 
56  $query = 'SELECT container_id FROM loc_tst_assignments '.
57  'WHERE tst_ref_id = '.$ilDB->quote($a_test_ref_id,'integer');
58  $res = $ilDB->query($query);
59  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
60  {
61  return $row->container_id;
62  }
63  return 0;
64  }
global $ilDB
+ Here is the caller graph for this function:

◆ lookupObjectivesForTest()

static ilLOTestAssignments::lookupObjectivesForTest (   $a_test_ref_id)
static

Get all objectives that are assigned to given test.

Parameters
int$a_test_ref_id
Returns
array

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

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilTestLP\resetCustomLPDataForUserIds().

309  {
310  global $ilDB;
311 
312  $objectives = array();
313 
314  $query = 'SELECT objective_id FROM loc_tst_assignments '.
315  'WHERE tst_ref_id = '.$ilDB->quote($a_test_ref_id,'integer');
316  $res = $ilDB->query($query);
317  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
318  {
319  $objectives[] = $row->objective_id;
320  }
321  return $objectives;
322  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ readTestAssignments()

ilLOTestAssignments::readTestAssignments ( )
protected

Read assignments type $ilDB.

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

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

Referenced by __construct().

262  {
263  global $ilDB;
264 
265  $query = 'SELECT assignment_id FROM loc_tst_assignments '.
266  'WHERE container_id = '.$ilDB->quote($this->getContainerId(),'integer');
267  $res = $ilDB->query($query);
268  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
269  {
270  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
271  $assignment = new ilLOTestAssignment($row->assignment_id);
272 
273  $this->assignments[] = $assignment;
274  }
275  }
Settings for LO courses.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXml()

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

to xml

Parameters
ilXmlWriter$writer

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

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

282  {
283  foreach($this->getAssignments() as $assignment)
284  {
285  if($assignment->getObjectiveId() != $a_objective_id)
286  {
287  continue;
288  }
289 
290  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
291  $writer->xmlElement(
292  'Test',
293  array(
294  'type' => ilLOXmlWriter::TYPE_TST_PO,
295  'refId' => $assignment->getTestRefId(),
296  'testType' => $assignment->getAssignmentType()
297  )
298  );
299  }
300  }
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
getAssignments()
Get assignments.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Field Documentation

◆ $assignments

ilLOTestAssignments::$assignments = array()
private

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

Referenced by getAssignments().

◆ $container_id

ilLOTestAssignments::$container_id = 0
private

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

Referenced by getContainerId().

◆ $instances

ilLOTestAssignments::$instances = array()
staticprivate

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

◆ $settings

ilLOTestAssignments::$settings = null
private

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

Referenced by getSettings().


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