ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  }
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 91 of file class.ilLOTestAssignments.php.

References $ilDB, and $query.

92  {
93  global $ilDB;
94 
95  $query = 'DELETE FROM loc_tst_assignments ' .
96  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer');
97  $ilDB->manipulate($query);
98  }
$query
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 212 of file class.ilLOTestAssignments.php.

References $a_type.

Referenced by getTestByObjective().

213  {
214  foreach ($this->assignments as $assignment) {
215  if (
216  ($assignment->getObjectiveId() == $a_objective_id) &&
217  ($assignment->getAssignmentType() == $a_type)
218  ) {
219  return $assignment;
220  }
221  }
222  return false;
223  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ getAssignments()

ilLOTestAssignments::getAssignments ( )

Get assignments.

Returns
ilLOTestAssignment[]

Definition at line 81 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 100 of file class.ilLOTestAssignments.php.

References $a_type, and array.

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

◆ getContainerId()

ilLOTestAssignments::getContainerId ( )

Definition at line 63 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 72 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 136 of file class.ilLOTestAssignments.php.

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

137  {
138  switch ($a_type) {
140  if (!$this->getSettings()->hasSeparateInitialTests()) {
141  return $this->getSettings()->getInitialTest();
142  }
143  break;
144 
146  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
147  return $this->getSettings()->getQualifiedTest();
148  }
149  break;
150  }
151 
152  $assignment = $this->getAssignmentByObjective($a_objective_id, $a_type);
153  if ($assignment) {
154  return $assignment->getTestRefId();
155  }
156  return 0;
157  }
getSettings()
get objective settings
$a_type
Definition: workflow.php:92
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 115 of file class.ilLOTestAssignments.php.

References array, and getSettings().

116  {
117  $tests = array();
118  if ($this->getSettings()->getInitialTest()) {
119  $tests[] = $this->getSettings()->getInitialTest();
120  }
121  if ($this->getSettings()->getQualifiedTest()) {
122  $tests[] = $this->getSettings()->getQualifiedTest();
123  }
124  foreach ($this->assignments as $assignment) {
125  $tests[] = $assignment->getTestRefId();
126  }
127  return $tests;
128  }
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 178 of file class.ilLOTestAssignments.php.

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

179  {
180  if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
181  if ($this->getSettings()->getInitialTest() == $a_test_ref_id) {
183  }
184  } elseif ($this->getSettings()->worksWithInitialTest()) {
185  foreach ($this->assignments as $assignment) {
186  if ($assignment->getTestRefId() == $a_test_ref_id) {
188  }
189  }
190  }
191  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
192  if ($this->getSettings()->getQualifiedTest() == $a_test_ref_id) {
194  }
195  } else {
196  foreach ($this->assignments as $assignment) {
197  if ($assignment->getTestRefId() == $a_test_ref_id) {
199  }
200  }
201  }
203  }
getSettings()
get objective settings
+ Here is the call graph for this function:

◆ isSeparateTest()

ilLOTestAssignments::isSeparateTest (   $a_test_ref_id)

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

References getSettings().

160  {
161  if (!$this->getSettings()->hasSeparateInitialTests()) {
162  if ($this->getSettings()->getInitialTest() == $a_test_ref_id) {
163  return false;
164  }
165  }
166  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
167  if ($this->getSettings()->getQualifiedTest() == $a_test_ref_id) {
168  return false;
169  }
170  }
171  return true;
172  }
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 50 of file class.ilLOTestAssignments.php.

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

Referenced by ilLOSettings\isObjectiveTest().

51  {
52  global $ilDB;
53 
54  $query = 'SELECT container_id FROM loc_tst_assignments ' .
55  'WHERE tst_ref_id = ' . $ilDB->quote($a_test_ref_id, 'integer');
56  $res = $ilDB->query($query);
57  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
58  return $row->container_id;
59  }
60  return 0;
61  }
foreach($_POST as $key=> $value) $res
$query
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 273 of file class.ilLOTestAssignments.php.

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

Referenced by ilTestLP\resetCustomLPDataForUserIds().

274  {
275  global $ilDB;
276 
277  $objectives = array();
278 
279  $query = 'SELECT objective_id FROM loc_tst_assignments ' .
280  'WHERE tst_ref_id = ' . $ilDB->quote($a_test_ref_id, 'integer');
281  $res = $ilDB->query($query);
282  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
283  $objectives[] = $row->objective_id;
284  }
285  return $objectives;
286  }
foreach($_POST as $key=> $value) $res
$query
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 229 of file class.ilLOTestAssignments.php.

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

Referenced by __construct().

230  {
231  global $ilDB;
232 
233  $query = 'SELECT assignment_id FROM loc_tst_assignments ' .
234  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer');
235  $res = $ilDB->query($query);
236  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
237  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
238  $assignment = new ilLOTestAssignment($row->assignment_id);
239 
240  $this->assignments[] = $assignment;
241  }
242  }
foreach($_POST as $key=> $value) $res
$query
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 248 of file class.ilLOTestAssignments.php.

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

249  {
250  foreach ($this->getAssignments() as $assignment) {
251  if ($assignment->getObjectiveId() != $a_objective_id) {
252  continue;
253  }
254 
255  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
256  $writer->xmlElement(
257  'Test',
258  array(
259  'type' => ilLOXmlWriter::TYPE_TST_PO,
260  'refId' => $assignment->getTestRefId(),
261  'testType' => $assignment->getAssignmentType()
262  )
263  );
264  }
265  }
getAssignments()
Get assignments.
Create styles array
The data for the language used.
xmlElement($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

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: