ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCourseObjectiveMaterials Class Reference

class ilCourseObjectiveMaterials More...

+ Collaboration diagram for ilCourseObjectiveMaterials:

Public Member Functions

 __construct ($a_objective_id)
 
 cloneDependencies ($a_new_objective, $a_copy_id)
 clone objective materials More...
 
 getMaterials ()
 
 getChapters ()
 
 getLM ($lm_id)
 
 getObjectiveId ()
 
 setLMRefId ($a_ref_id)
 
 getLMRefId ()
 
 setLMObjId ($a_obj_id)
 
 getLMObjId ()
 
 setType ($a_type)
 
 getType ()
 
 isAssigned ($a_ref_id, $a_get_id=false)
 Check if material is assigned. More...
 
 isChapterAssigned ($a_ref_id, $a_obj_id)
 Check if chapter is assigned. More...
 
 checkExists ()
 
 add ()
 
 delete ($lm_id)
 
 deleteAll ()
 
 writePosition ($a_ass_id, $a_position)
 write position More...
 
 __read ()
 
 toXml (ilXmlWriter $writer)
 

Static Public Member Functions

static _getAssignedMaterials ($a_objective_id)
 get assigned materials More...
 
static _getAssignableMaterials ($a_container_id)
 Get an array of course material ids that can be assigned to learning objectives No tst, fold and grp. More...
 
static _getAllAssignedMaterials ($a_container_id)
 Get all assigned materials. More...
 

Data Fields

 $db = null
 
 $objective_id = null
 
 $lms
 

Detailed Description

class ilCourseObjectiveMaterials

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
lass.ilCourseObjectiveMaterials.php 13383 2007-03-02 10:54:46 +0000 (Fr, 02 Mrz 2007) smeyer

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

Constructor & Destructor Documentation

◆ __construct()

ilCourseObjectiveMaterials::__construct (   $a_objective_id)

Definition at line 40 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, and __read().

41  {
42  global $ilDB;
43 
44  $this->db =&$ilDB;
45 
46  $this->objective_id = $a_objective_id;
47 
48  $this->__read();
49  }
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilCourseObjectiveMaterials::__read ( )

Definition at line 405 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, $row, ilObject\_getAllReferences(), ilCourseObjective\_lookupContainerIdByObjectiveId(), array, ilDBConstants\FETCHMODE_OBJECT, and getObjectiveId().

Referenced by __construct().

406  {
407  global $tree,$ilDB;
408 
409  include_once('Modules/Course/classes/class.ilCourseObjective.php');
410  $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
411  $container_ref_id = current($container_ref_ids);
412 
413  // begin-patch lok
414 
415  $this->lms = array();
416  $query = "SELECT position,lm_ass_id,lm.ref_id,lm.obj_id,lm.type FROM crs_objective_lm lm " .
417  "JOIN object_reference obr ON lm.ref_id = obr.ref_id " .
418  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
419  "LEFT JOIN lm_data lmd ON lmd.obj_id = lm.obj_id " .
420  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
421  "ORDER BY position,obd.title,lmd.title";
422 
423  $res = $this->db->query($query);
424  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
425  if (!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id, $row->ref_id)) {
426  $this->delete($row->lm_ass_id);
427  continue;
428  }
429  $lm['ref_id'] = $row->ref_id;
430  $lm['obj_id'] = $row->obj_id;
431  $lm['type'] = $row->type;
432  $lm['lm_ass_id'] = $row->lm_ass_id;
433  $lm['position'] = $row->position;
434 
435  $this->lms[$row->lm_ass_id] = $lm;
436  }
437 
438  // end-patch lok
439 
440  return true;
441  }
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
static _getAllReferences($a_id)
get all reference ids of object
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAllAssignedMaterials()

static ilCourseObjectiveMaterials::_getAllAssignedMaterials (   $a_container_id)
static

Get all assigned materials.

public

Parameters
in

Definition at line 201 of file class.ilCourseObjectiveMaterials.php.

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

202  {
203  global $ilDB;
204 
205  $query = "SELECT DISTINCT(com.ref_id) ref_id FROM crs_objectives co " .
206  "JOIN crs_objective_lm com ON co.objective_id = com.objective_id " .
207  "JOIN object_reference obr ON com.ref_id = obr.ref_id " .
208  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
209  "WHERE co.crs_id = " . $ilDB->quote($a_container_id, 'integer') . " " .
210  "ORDER BY obd.title ";
211 
212  $res = $ilDB->query($query);
213  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
214  $ref_ids[] = $row->ref_id;
215  }
216  return $ref_ids ? $ref_ids : array();
217  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB

◆ _getAssignableMaterials()

static ilCourseObjectiveMaterials::_getAssignableMaterials (   $a_container_id)
static

Get an array of course material ids that can be assigned to learning objectives No tst, fold and grp.

public

Parameters
intobj id of course
Returns
array data of course materials

Definition at line 157 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $type, ilObject\_lookupObjId(), array, ilLOTestAssignments\getInstance(), ilUtil\sortArray(), and ilLOSettings\TYPE_TEST_UNDEFINED.

Referenced by ilCourseObjectivesGUI\materialAssignment().

158  {
159  global $tree,$ilDB;
160 
161  $container_obj_id = ilObject::_lookupObjId($a_container_id);
162 
163  $all_materials = $tree->getSubTree($tree->getNodeData($a_container_id), true);
164  $all_materials = ilUtil::sortArray($all_materials, 'title', 'asc');
165 
166  // Filter
167  foreach ($all_materials as $material) {
168  switch ($material['type']) {
169  case 'tst':
170 
171  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
172  $type = ilLOTestAssignments::getInstance($container_obj_id)->getTypeByTest($material['child']);
174  continue;
175  } else {
176  $assignable[] = $material;
177  }
178  break;
179 
180  case 'crs':
181  case 'rolf':
182  case 'itgr':
183  continue;
184 
185  default:
186  $assignable[] = $material;
187  break;
188  }
189  }
190  return $assignable ? $assignable : array();
191  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getInstance($a_container_id)
Get instance by container id.
$type
static _lookupObjId($a_id)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAssignedMaterials()

static ilCourseObjectiveMaterials::_getAssignedMaterials (   $a_objective_id)
static

get assigned materials

public

Parameters
intobjective_id
Returns

Definition at line 132 of file class.ilCourseObjectiveMaterials.php.

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

Referenced by ilContainerObjectiveGUI\buildObjectiveMap(), and ilObjectActivation\getItemsByObjective().

133  {
134  global $ilDB;
135 
136  $query = "SELECT DISTINCT(ref_id) ref_id FROM crs_objective_lm " .
137  "WHERE objective_id = " . $ilDB->quote($a_objective_id, 'integer');
138  $res = $ilDB->query($query);
139  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
140  $ref_ids[] = $row->ref_id;
141  }
142  return $ref_ids ? $ref_ids : array();
143  }
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:

◆ add()

ilCourseObjectiveMaterials::add ( )

Definition at line 340 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, getLMObjId(), getLMRefId(), getObjectiveId(), and getType().

341  {
342  global $ilDB;
343 
344  $next_id = $ilDB->nextId('crs_objective_lm');
345  $query = "INSERT INTO crs_objective_lm (lm_ass_id,objective_id,ref_id,obj_id,type) " .
346  "VALUES( " .
347  $ilDB->quote($next_id, 'integer') . ", " .
348  $ilDB->quote($this->getObjectiveId(), 'integer') . ", " .
349  $ilDB->quote($this->getLMRefId(), 'integer') . ", " .
350  $ilDB->quote($this->getLMObjId(), 'integer') . ", " .
351  $ilDB->quote($this->getType(), 'text') .
352  ")";
353  $res = $ilDB->manipulate($query);
354 
355  return (int) $next_id;
356  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ checkExists()

ilCourseObjectiveMaterials::checkExists ( )

Definition at line 320 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, getLMObjId(), getLMRefId(), and getObjectiveId().

321  {
322  global $ilDB;
323 
324  if ($this->getLMObjId()) {
325  $query = "SELECT * FROM crs_objective_lm " .
326  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
327  "AND ref_id = " . $ilDB->quote($this->getLMRefId(), 'integer') . " " .
328  "AND obj_id = " . $ilDB->quote($this->getLMObjId(), 'integer') . " ";
329  } else {
330  $query = "SELECT * FROM crs_objective_lm " .
331  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
332  "AND ref_id = " . $ilDB->quote($this->getLMRefId(), 'integer') . " ";
333  }
334 
335  $res = $this->db->query($query);
336 
337  return $res->numRows() ? true : false;
338  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ cloneDependencies()

ilCourseObjectiveMaterials::cloneDependencies (   $a_new_objective,
  $a_copy_id 
)

clone objective materials

public

Parameters
intsource objective
inttarget objective
intcopy id

Definition at line 60 of file class.ilCourseObjectiveMaterials.php.

References $ilLog, ilCopyWizardOptions\_getInstance(), and getMaterials().

61  {
62  global $ilObjDataCache,$ilLog;
63 
64  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
65  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
66  $mappings = $cwo->getMappings();
67  #$ilLog->write(__METHOD__.': 1');
68  foreach ($this->getMaterials() as $material) {
69  #$ilLog->write(__METHOD__.': 2');
70  // Copy action omit ?
71  if (!isset($mappings[$material['ref_id']]) or !$mappings[$material['ref_id']]) {
72  continue;
73  }
74  #$ilLog->write(__METHOD__.': 3');
75  $material_ref_id = $material['ref_id'];
76  $material_rbac_obj_id = $ilObjDataCache->lookupObjId($material_ref_id);
77  $material_obj_id = $material['obj_id'];
78  $new_ref_id = $mappings[$material_ref_id];
79  $new_rbac_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
80  #$ilLog->write(__METHOD__.': 4');
81 
82  // Link
83  if ($new_rbac_obj_id == $material_rbac_obj_id) {
84  #$ilLog->write(__METHOD__.': 5');
85  $ilLog->write(__METHOD__ . ': Material has been linked. Keeping object id.');
86  $new_obj_id = $material_obj_id;
87  } elseif ($material['type'] == 'st' or $material['type'] == 'pg') {
88 
89  #$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($material,TRUE));
90  #$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($mappings,TRUE));
91 
92  #$ilLog->write(__METHOD__.': 6');
93  // Chapter assignment
94  $new_material_info = isset($mappings[$material_ref_id . '_' . $material_obj_id]) ?
95  $mappings[$material_ref_id . '_' . $material_obj_id] :
96  '';
97  $new_material_arr = explode('_', $new_material_info);
98  if (!isset($new_material_arr[1]) or !$new_material_arr[1]) {
99  $ilLog->write(__METHOD__ . ': No mapping found for chapter: ' . $material_obj_id);
100  continue;
101  }
102  $new_obj_id = $new_material_arr[1];
103  $ilLog->write(__METHOD__ . ': New material id is: ' . $new_obj_id);
104  } else {
105  #$ilLog->write(__METHOD__.': 7');
106  // Any type
107  $new_obj_id = $ilObjDataCache->lookupObjId($mappings[$material_ref_id]);
108  }
109 
110  #$ilLog->write(__METHOD__.': 8');
111  $new_material = new ilCourseObjectiveMaterials($a_new_objective);
112  #$ilLog->write(__METHOD__.': 8.1');
113  $new_material->setLMRefId($new_ref_id);
114  #$ilLog->write(__METHOD__.': 8.2');
115  $new_material->setLMObjId($new_obj_id);
116  #$ilLog->write(__METHOD__.': 8.3');
117  $new_material->setType($material['type']);
118  #$ilLog->write(__METHOD__.': 8.4');
119  $new_material->add();
120  #$ilLog->write(__METHOD__.': 9');
121  }
122  }
class ilCourseObjectiveMaterials
static _getInstance($a_copy_id)
Get instance of copy wizard options.
+ Here is the call graph for this function:

◆ delete()

ilCourseObjectiveMaterials::delete (   $lm_id)

Definition at line 357 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, and $res.

358  {
359  global $ilDB;
360 
361  if (!$lm_id) {
362  return false;
363  }
364 
365  $query = "DELETE FROM crs_objective_lm " .
366  "WHERE lm_ass_id = " . $ilDB->quote($lm_id, 'integer') . " ";
367  $res = $ilDB->manipulate($query);
368 
369  return true;
370  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ deleteAll()

ilCourseObjectiveMaterials::deleteAll ( )

Definition at line 372 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, and getObjectiveId().

373  {
374  global $ilDB;
375 
376  $query = "DELETE FROM crs_objective_lm " .
377  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
378  $res = $ilDB->manipulate($query);
379  return true;
380  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ getChapters()

ilCourseObjectiveMaterials::getChapters ( )

Definition at line 224 of file class.ilCourseObjectiveMaterials.php.

References array.

225  {
226  foreach ($this->lms as $lm_data) {
227  if ($lm_data['type'] == 'st') {
228  $chapters[] = $lm_data;
229  }
230  if ($lm_data['type'] == 'pg') {
231  $chapters[] = $lm_data;
232  }
233  }
234  return $chapters ? $chapters : array();
235  }
Create styles array
The data for the language used.

◆ getLM()

ilCourseObjectiveMaterials::getLM (   $lm_id)

Definition at line 237 of file class.ilCourseObjectiveMaterials.php.

References array.

238  {
239  return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
240  }
Create styles array
The data for the language used.

◆ getLMObjId()

ilCourseObjectiveMaterials::getLMObjId ( )

Definition at line 259 of file class.ilCourseObjectiveMaterials.php.

Referenced by add(), and checkExists().

260  {
261  return $this->lm_obj_id ? $this->lm_obj_id : 0;
262  }
+ Here is the caller graph for this function:

◆ getLMRefId()

ilCourseObjectiveMaterials::getLMRefId ( )

Definition at line 251 of file class.ilCourseObjectiveMaterials.php.

Referenced by add(), and checkExists().

252  {
253  return $this->lm_ref_id ? $this->lm_ref_id : 0;
254  }
+ Here is the caller graph for this function:

◆ getMaterials()

ilCourseObjectiveMaterials::getMaterials ( )

Definition at line 219 of file class.ilCourseObjectiveMaterials.php.

References array.

Referenced by cloneDependencies(), and toXml().

220  {
221  return $this->lms ? $this->lms : array();
222  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getObjectiveId()

ilCourseObjectiveMaterials::getObjectiveId ( )

Definition at line 242 of file class.ilCourseObjectiveMaterials.php.

References $objective_id.

Referenced by __read(), add(), checkExists(), deleteAll(), isAssigned(), isChapterAssigned(), and writePosition().

+ Here is the caller graph for this function:

◆ getType()

ilCourseObjectiveMaterials::getType ( )

Definition at line 267 of file class.ilCourseObjectiveMaterials.php.

References $type.

Referenced by add().

268  {
269  return $this->type;
270  }
$type
+ Here is the caller graph for this function:

◆ isAssigned()

ilCourseObjectiveMaterials::isAssigned (   $a_ref_id,
  $a_get_id = false 
)

Check if material is assigned.

public

Parameters
intref id
Returns
bool

Definition at line 280 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, $row, and getObjectiveId().

281  {
282  global $ilDB;
283 
284  $query = "SELECT * FROM crs_objective_lm " .
285  "WHERE ref_id = " . $this->db->quote($a_ref_id, 'integer') . " " .
286  "AND objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
287  "AND type != 'st' AND type != 'pg' ";
288  $res = $this->db->query($query);
289 
290  // begin-patch lok
291  if (!$a_get_id) {
292  return $res->numRows() ? true : false;
293  } else {
294  $row = $this->db->fetchAssoc($res);
295  return $row["lm_ass_id"];
296  }
297  // end-patch lok
298  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ isChapterAssigned()

ilCourseObjectiveMaterials::isChapterAssigned (   $a_ref_id,
  $a_obj_id 
)

Check if chapter is assigned.

public

Parameters
intref id
Returns
bool

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

References $ilDB, $query, $res, and getObjectiveId().

309  {
310  global $ilDB;
311 
312  $query = "SELECT * FROM crs_objective_lm " .
313  "WHERE ref_id = " . $this->db->quote($a_ref_id, 'integer') . " " .
314  "AND obj_id = " . $this->db->quote($a_obj_id, 'integer') . " " .
315  "AND objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
316  "AND (type = 'st' OR type = 'pg')";
317  $res = $this->db->query($query);
318  return $res->numRows() ? true : false;
319  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ setLMObjId()

ilCourseObjectiveMaterials::setLMObjId (   $a_obj_id)

Definition at line 255 of file class.ilCourseObjectiveMaterials.php.

256  {
257  $this->lm_obj_id = $a_obj_id;
258  }

◆ setLMRefId()

ilCourseObjectiveMaterials::setLMRefId (   $a_ref_id)

Definition at line 247 of file class.ilCourseObjectiveMaterials.php.

248  {
249  $this->lm_ref_id = $a_ref_id;
250  }

◆ setType()

ilCourseObjectiveMaterials::setType (   $a_type)

Definition at line 263 of file class.ilCourseObjectiveMaterials.php.

References $a_type.

264  {
265  $this->type = $a_type;
266  }
$a_type
Definition: workflow.php:92

◆ toXml()

ilCourseObjectiveMaterials::toXml ( ilXmlWriter  $writer)
Parameters
ilXmlWriter$writer

Definition at line 449 of file class.ilCourseObjectiveMaterials.php.

References array, getMaterials(), and ilXmlWriter\xmlElement().

450  {
451  foreach ($this->getMaterials() as $material) {
452  $writer->xmlElement(
453  'Material',
454  array(
455  'refId' => $material['ref_id'],
456  'objId' => $material['obj_id'],
457  'type' => $material['type'],
458  'position' => $material['position']
459  )
460  );
461  }
462  return true;
463  }
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:

◆ writePosition()

ilCourseObjectiveMaterials::writePosition (   $a_ass_id,
  $a_position 
)

write position

public

Parameters
intnew position
Returns

Definition at line 391 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, and getObjectiveId().

392  {
393  global $ilDB;
394 
395  $query = "UPDATE crs_objective_lm " .
396  "SET position = " . $this->db->quote((string) $a_position, 'integer') . " " .
397  "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
398  "AND lm_ass_id = " . $ilDB->quote($a_ass_id, "integer");
399  $res = $ilDB->manipulate($query);
400  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilCourseObjectiveMaterials::$db = null

Definition at line 35 of file class.ilCourseObjectiveMaterials.php.

◆ $lms

ilCourseObjectiveMaterials::$lms

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

◆ $objective_id

ilCourseObjectiveMaterials::$objective_id = null

Definition at line 37 of file class.ilCourseObjectiveMaterials.php.

Referenced by getObjectiveId().


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