ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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) @global type $ilDB. More...
 

Protected Member Functions

 readTestAssignments ()
 Read assignments @global 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.

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 @global type $ilDB.

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

+ 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) @global type $ilDB.

Parameters
type$a_container_id

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

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

References $ilDB, and $query.

◆ 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.

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 }

Referenced by getTestByObjective().

+ 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.

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 }

◆ 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.

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 }
getAssignmentByObjective($a_objective_id, $a_type)
Get assignment by objective.
getSettings()
get objective settings

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

+ 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.

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 }

References $tests, and getSettings().

+ 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.

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 }

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

+ Here is the call graph for this function:

◆ isSeparateTest()

ilLOTestAssignments::isSeparateTest (   $a_test_ref_id)

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

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 }

References getSettings().

+ 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.

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(DB_FETCHMODE_OBJECT))
60 {
61 return $row->container_id;
62 }
63 return 0;
64 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilLOSettings\isObjectiveTest().

+ Here is the caller graph for this function:

◆ readTestAssignments()

ilLOTestAssignments::readTestAssignments ( )
protected

Read assignments @global type $ilDB.

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

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(DB_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.

References $ilDB, $query, $res, $row, DB_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,
  $a_objective_id 
)

to xml

Parameters
ilXmlWriter$writer

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

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(
295 'refId' => $assignment->getTestRefId(),
296 'testType' => $assignment->getAssignmentType()
297 )
298 );
299 }
300 }
getAssignments()
Get assignments.
xmlElement($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

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: