ILIAS  release_4-4 Revision
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)
 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 ()
 
 __read ()
 

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 __read().

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

Member Function Documentation

◆ __read()

ilCourseObjectiveMaterials::__read ( )

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

References $query, $res, $row, ilObject\_getAllReferences(), ilCourseObjective\_lookupContainerIdByObjectiveId(), DB_FETCHMODE_OBJECT, and getObjectiveId().

Referenced by __construct().

383  {
384  global $tree,$ilDB;
385 
386  include_once('Modules/Course/classes/class.ilCourseObjective.php');
387  $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
388  $container_ref_id = current($container_ref_ids);
389 
390  $this->lms = array();
391  $query = "SELECT lm_ass_id,lm.ref_id,lm.obj_id,lm.type FROM crs_objective_lm lm ".
392  "JOIN object_reference obr ON lm.ref_id = obr.ref_id ".
393  "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
394  "LEFT JOIN lm_data lmd ON lmd.obj_id = lm.obj_id ".
395  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId(),'integer')." ".
396  "ORDER BY obd.title,lmd.title";
397 
398  $res = $this->db->query($query);
399  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
400  {
401  if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
402  {
403  $this->delete($row->lm_ass_id);
404  continue;
405  }
406  $lm['ref_id'] = $row->ref_id;
407  $lm['obj_id'] = $row->obj_id;
408  $lm['type'] = $row->type;
409  $lm['lm_ass_id'] = $row->lm_ass_id;
410 
411  $this->lms[$row->lm_ass_id] = $lm;
412  }
413  return true;
414  }
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
static _getAllReferences($a_id)
get all reference ids of object
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ 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 200 of file class.ilCourseObjectiveMaterials.php.

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

Referenced by ilCourseObjectivePresentationGUI\__getOtherResources(), and ilCourseObjectivePresentationGUI\__showLearningMaterials().

201  {
202  global $ilDB;
203 
204  $query = "SELECT DISTINCT(com.ref_id) ref_id FROM crs_objectives co ".
205  "JOIN crs_objective_lm com ON co.objective_id = com.objective_id ".
206  "JOIN object_reference obr ON com.ref_id = obr.ref_id ".
207  "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
208  "WHERE co.crs_id = ".$ilDB->quote($a_container_id,'integer')." ".
209  "ORDER BY obd.title ";
210 
211  $res = $ilDB->query($query);
212  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
213  {
214  $ref_ids[] = $row->ref_id;
215  }
216  return $ref_ids ? $ref_ids : array();
217  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _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 163 of file class.ilCourseObjectiveMaterials.php.

References ilUtil\sortArray().

Referenced by ilCourseObjectivesGUI\materialAssignment().

164  {
165  global $tree,$ilDB;
166 
167  $all_materials = $tree->getSubTree($tree->getNodeData($a_container_id),true);
168  $all_materials = ilUtil::sortArray($all_materials,'title','asc');
169 
170  // Filter
171  foreach($all_materials as $material)
172  {
173  switch($material['type'])
174  {
175  case 'tst':
176  case 'fold':
177  case 'grp':
178  case 'rolf':
179  case 'crs':
180  case 'sess':
181  case 'itgr':
182  continue;
183 
184  default:
185  $assignable[] = $material;
186  break;
187  }
188  }
189  return $assignable ? $assignable : array();
190  }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
+ 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 137 of file class.ilCourseObjectiveMaterials.php.

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

Referenced by ilObjectActivation\getItemsByObjective().

138  {
139  global $ilDB;
140 
141  $query = "SELECT DISTINCT(ref_id) ref_id FROM crs_objective_lm ".
142  "WHERE objective_id = ".$ilDB->quote($a_objective_id ,'integer')." ";
143  $res = $ilDB->query($query);
144  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
145  {
146  $ref_ids[] = $row->ref_id;
147  }
148  return $ref_ids ? $ref_ids : array();
149  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveMaterials::add ( )

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

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

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

◆ checkExists()

ilCourseObjectiveMaterials::checkExists ( )

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

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

316  {
317  global $ilDB;
318 
319  if($this->getLMObjId())
320  {
321  $query = "SELECT * FROM crs_objective_lm ".
322  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
323  "AND ref_id = ".$ilDB->quote($this->getLMRefId() ,'integer')." ".
324  "AND obj_id = ".$ilDB->quote($this->getLMObjId() ,'integer')." ";
325  }
326  else
327  {
328  $query = "SELECT * FROM crs_objective_lm ".
329  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
330  "AND ref_id = ".$ilDB->quote($this->getLMRefId() ,'integer')." ";
331  }
332 
333  $res = $this->db->query($query);
334 
335  return $res->numRows() ? true : false;
336  }
+ 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  {
70  #$ilLog->write(__METHOD__.': 2');
71  // Copy action omit ?
72  if(!isset($mappings["$material[ref_id]"]) or !$mappings["$material[ref_id]"])
73  {
74  continue;
75  }
76  #$ilLog->write(__METHOD__.': 3');
77  $material_ref_id = $material['ref_id'];
78  $material_rbac_obj_id = $ilObjDataCache->lookupObjId($material_ref_id);
79  $material_obj_id = $material['obj_id'];
80  $new_ref_id = $mappings[$material_ref_id];
81  $new_rbac_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
82  #$ilLog->write(__METHOD__.': 4');
83 
84  // Link
85  if($new_rbac_obj_id == $material_rbac_obj_id)
86  {
87  #$ilLog->write(__METHOD__.': 5');
88  $ilLog->write(__METHOD__.': Material has been linked. Keeping object id.');
89  $new_obj_id = $material_obj_id;
90  }
91  elseif($material['type'] == 'st')
92  {
93  #$ilLog->write(__METHOD__.': 6');
94  // Chapter assignment
95  $new_material_info = isset($mappings[$material_ref_id.'_'.$material_obj_id]) ?
96  $mappings[$material_ref_id.'_'.$material_obj_id] :
97  array();
98  $new_material_arr = explode('_',$new_material_info);
99  if(!isset($new_material_arr[1]) or !$new_material_arr[1])
100  {
101  $ilLog->write(__METHOD__.': No mapping found for chapter: '.$material_obj_id);
102  continue;
103  }
104  $new_obj_id = $new_material_arr[1];
105  $ilLog->write(__METHOD__.': New material id is: '.$new_obj_id);
106  }
107  else
108  {
109  #$ilLog->write(__METHOD__.': 7');
110  // Any type
111  $new_obj_id = $ilObjDataCache->lookupObjId($mappings[$material_ref_id]);
112  }
113 
114  #$ilLog->write(__METHOD__.': 8');
115  $new_material = new ilCourseObjectiveMaterials($a_new_objective);
116  #$ilLog->write(__METHOD__.': 8.1');
117  $new_material->setLMRefId($new_ref_id);
118  #$ilLog->write(__METHOD__.': 8.2');
119  $new_material->setLMObjId($new_obj_id);
120  #$ilLog->write(__METHOD__.': 8.3');
121  $new_material->setType($material['type']);
122  #$ilLog->write(__METHOD__.': 8.4');
123  $new_material->add();
124  #$ilLog->write(__METHOD__.': 9');
125 
126  }
127  }
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 355 of file class.ilCourseObjectiveMaterials.php.

References $query, and $res.

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

◆ deleteAll()

ilCourseObjectiveMaterials::deleteAll ( )

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

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

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

◆ getChapters()

ilCourseObjectiveMaterials::getChapters ( )

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

225  {
226  foreach($this->lms as $lm_data)
227  {
228  if($lm_data['type'] == 'st')
229  {
230  $chapters[] = $lm_data;
231  }
232  if($lm_data['type'] == 'pg')
233  {
234  $chapters[] = $lm_data;
235  }
236  }
237  return $chapters ? $chapters : array();
238  }

◆ getLM()

ilCourseObjectiveMaterials::getLM (   $lm_id)

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

241  {
242  return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
243  }

◆ getLMObjId()

ilCourseObjectiveMaterials::getLMObjId ( )

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

Referenced by add(), and checkExists().

263  {
264  return $this->lm_obj_id ? $this->lm_obj_id : 0;
265  }
+ Here is the caller graph for this function:

◆ getLMRefId()

ilCourseObjectiveMaterials::getLMRefId ( )

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

Referenced by add(), and checkExists().

255  {
256  return $this->lm_ref_id ? $this->lm_ref_id : 0;
257  }
+ Here is the caller graph for this function:

◆ getMaterials()

ilCourseObjectiveMaterials::getMaterials ( )

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

Referenced by cloneDependencies().

220  {
221  return $this->lms ? $this->lms : array();
222  }
+ Here is the caller graph for this function:

◆ getObjectiveId()

ilCourseObjectiveMaterials::getObjectiveId ( )

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

References $objective_id.

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

+ Here is the caller graph for this function:

◆ getType()

ilCourseObjectiveMaterials::getType ( )

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

Referenced by add().

271  {
272  return $this->type;
273  }
+ Here is the caller graph for this function:

◆ isAssigned()

ilCourseObjectiveMaterials::isAssigned (   $a_ref_id)

Check if material is assigned.

public

Parameters
intref id
Returns
bool

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

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

284  {
285  global $ilDB;
286 
287  $query = "SELECT * FROM crs_objective_lm ".
288  "WHERE ref_id = ".$this->db->quote($a_ref_id ,'integer')." ".
289  "AND objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
290  "AND type != 'st' AND type != 'pg' ";
291  $res = $this->db->query($query);
292  return $res->numRows() ? true : false;
293  }
+ 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 303 of file class.ilCourseObjectiveMaterials.php.

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

304  {
305  global $ilDB;
306 
307  $query = "SELECT * FROM crs_objective_lm ".
308  "WHERE ref_id = ".$this->db->quote($a_ref_id ,'integer')." ".
309  "AND obj_id = ".$this->db->quote($a_obj_id ,'integer')." ".
310  "AND objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
311  "AND (type = 'st' OR type = 'pg')";
312  $res = $this->db->query($query);
313  return $res->numRows() ? true : false;
314  }
+ Here is the call graph for this function:

◆ setLMObjId()

ilCourseObjectiveMaterials::setLMObjId (   $a_obj_id)

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

259  {
260  $this->lm_obj_id = $a_obj_id;
261  }

◆ setLMRefId()

ilCourseObjectiveMaterials::setLMRefId (   $a_ref_id)

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

251  {
252  $this->lm_ref_id = $a_ref_id;
253  }

◆ setType()

ilCourseObjectiveMaterials::setType (   $a_type)

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

267  {
268  $this->type = $a_type;
269  }

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: