ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
settings()
Definition: settings.php:2
readTestAssignments()
Read assignments type $ilDB.
+ 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 93 of file class.ilLOTestAssignments.php.

References $DIC, $ilDB, and $query.

94  {
95  global $DIC;
96 
97  $ilDB = $DIC['ilDB'];
98 
99  $query = 'DELETE FROM loc_tst_assignments ' .
100  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer');
101  $ilDB->manipulate($query);
102  }
global $DIC
Definition: saml.php:7
$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 216 of file class.ilLOTestAssignments.php.

References $a_type.

Referenced by getTestByObjective().

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

◆ getAssignments()

ilLOTestAssignments::getAssignments ( )

Get assignments.

Returns
ilLOTestAssignment[]

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

References $a_type.

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  }
$a_type
Definition: workflow.php:92

◆ getContainerId()

ilLOTestAssignments::getContainerId ( )

Definition at line 65 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 74 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 140 of file class.ilLOTestAssignments.php.

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

141  {
142  switch ($a_type) {
144  if (!$this->getSettings()->hasSeparateInitialTests()) {
145  return $this->getSettings()->getInitialTest();
146  }
147  break;
148 
150  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
151  return $this->getSettings()->getQualifiedTest();
152  }
153  break;
154  }
155 
156  $assignment = $this->getAssignmentByObjective($a_objective_id, $a_type);
157  if ($assignment) {
158  return $assignment->getTestRefId();
159  }
160  return 0;
161  }
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 119 of file class.ilLOTestAssignments.php.

References $tests, and getSettings().

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  }
getSettings()
get objective settings
$tests
Definition: bench.php:104
+ 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 182 of file class.ilLOTestAssignments.php.

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

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

◆ isSeparateTest()

ilLOTestAssignments::isSeparateTest (   $a_test_ref_id)

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

References getSettings().

164  {
165  if (!$this->getSettings()->hasSeparateInitialTests()) {
166  if ($this->getSettings()->getInitialTest() == $a_test_ref_id) {
167  return false;
168  }
169  }
170  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
171  if ($this->getSettings()->getQualifiedTest() == $a_test_ref_id) {
172  return false;
173  }
174  }
175  return true;
176  }
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 $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLOSettings\isObjectiveTest().

51  {
52  global $DIC;
53 
54  $ilDB = $DIC['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  return $row->container_id;
61  }
62  return 0;
63  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 279 of file class.ilLOTestAssignments.php.

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

Referenced by ilTestLP\resetCustomLPDataForUserIds().

280  {
281  global $DIC;
282 
283  $ilDB = $DIC['ilDB'];
284 
285  $objectives = array();
286 
287  $query = 'SELECT objective_id FROM loc_tst_assignments ' .
288  'WHERE tst_ref_id = ' . $ilDB->quote($a_test_ref_id, 'integer');
289  $res = $ilDB->query($query);
290  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
291  $objectives[] = $row->objective_id;
292  }
293  return $objectives;
294  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ readTestAssignments()

ilLOTestAssignments::readTestAssignments ( )
protected

Read assignments type $ilDB.

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

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

Referenced by __construct().

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

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

255  {
256  foreach ($this->getAssignments() as $assignment) {
257  if ($assignment->getObjectiveId() != $a_objective_id) {
258  continue;
259  }
260 
261  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
262  $writer->xmlElement(
263  'Test',
264  array(
265  'type' => ilLOXmlWriter::TYPE_TST_PO,
266  'refId' => $assignment->getTestRefId(),
267  'testType' => $assignment->getAssignmentType()
268  )
269  );
270  }
271  }
getAssignments()
Get assignments.
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: