46 $this->objective_id = $a_objective_id;
62 global $ilObjDataCache,
$ilLog;
64 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
66 $mappings = $cwo->getMappings();
67 #$ilLog->write(__METHOD__.': 1');
70 #$ilLog->write(__METHOD__.': 2');
72 if(!isset($mappings[$material[
'ref_id']]) or !$mappings[$material[
'ref_id']])
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');
85 if($new_rbac_obj_id == $material_rbac_obj_id)
87 #$ilLog->write(__METHOD__.': 5');
88 $ilLog->write(__METHOD__.
': Material has been linked. Keeping object id.');
89 $new_obj_id = $material_obj_id;
91 elseif($material[
'type'] ==
'st' or $material[
'type'] ==
'pg')
94 #$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($material,TRUE));
95 #$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($mappings,TRUE));
97 #$ilLog->write(__METHOD__.': 6');
99 $new_material_info = isset($mappings[$material_ref_id.
'_'.$material_obj_id]) ?
100 $mappings[$material_ref_id.
'_'.$material_obj_id] :
102 $new_material_arr = explode(
'_',$new_material_info);
103 if(!isset($new_material_arr[1]) or !$new_material_arr[1])
105 $ilLog->write(__METHOD__.
': No mapping found for chapter: '.$material_obj_id);
108 $new_obj_id = $new_material_arr[1];
109 $ilLog->write(__METHOD__.
': New material id is: '.$new_obj_id);
113 #$ilLog->write(__METHOD__.': 7');
115 $new_obj_id = $ilObjDataCache->lookupObjId($mappings[$material_ref_id]);
118 #$ilLog->write(__METHOD__.': 8');
120 #$ilLog->write(__METHOD__.': 8.1');
121 $new_material->setLMRefId($new_ref_id);
122 #$ilLog->write(__METHOD__.': 8.2');
123 $new_material->setLMObjId($new_obj_id);
124 #$ilLog->write(__METHOD__.': 8.3');
125 $new_material->setType($material[
'type']);
126 #$ilLog->write(__METHOD__.': 8.4');
127 $new_material->add();
128 #$ilLog->write(__METHOD__.': 9');
145 $query =
"SELECT DISTINCT(ref_id) ref_id FROM crs_objective_lm ".
146 "WHERE objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
150 $ref_ids[] =
$row->ref_id;
152 return $ref_ids ? $ref_ids : array();
171 $all_materials = $tree->getSubTree($tree->getNodeData($a_container_id),
true);
175 foreach($all_materials as $material)
177 switch($material[
'type'])
186 $assignable[] = $material;
196 $assignable[] = $material;
200 return $assignable ? $assignable : array();
215 $query =
"SELECT DISTINCT(com.ref_id) ref_id FROM crs_objectives co ".
216 "JOIN crs_objective_lm com ON co.objective_id = com.objective_id ".
217 "JOIN object_reference obr ON com.ref_id = obr.ref_id ".
218 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
219 "WHERE co.crs_id = ".$ilDB->quote($a_container_id,
'integer').
" ".
220 "ORDER BY obd.title ";
225 $ref_ids[] =
$row->ref_id;
227 return $ref_ids ? $ref_ids : array();
232 return $this->lms ? $this->lms : array();
237 foreach($this->lms as $lm_data)
239 if($lm_data[
'type'] ==
'st')
241 $chapters[] = $lm_data;
243 if($lm_data[
'type'] ==
'pg')
245 $chapters[] = $lm_data;
248 return $chapters ? $chapters : array();
253 return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
263 $this->lm_ref_id = $a_ref_id;
267 return $this->lm_ref_id ? $this->lm_ref_id : 0;
271 $this->lm_obj_id = $a_obj_id;
275 return $this->lm_obj_id ? $this->lm_obj_id : 0;
279 $this->type = $a_type;
298 $query =
"SELECT * FROM crs_objective_lm ".
299 "WHERE ref_id = ".$this->db->quote($a_ref_id ,
'integer').
" ".
300 "AND objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
301 "AND type != 'st' AND type != 'pg' ";
307 return $res->numRows() ?
true :
false;
312 return $row[
"lm_ass_id"];
329 $query =
"SELECT * FROM crs_objective_lm ".
330 "WHERE ref_id = ".$this->db->quote($a_ref_id ,
'integer').
" ".
331 "AND obj_id = ".$this->db->quote($a_obj_id ,
'integer').
" ".
332 "AND objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
333 "AND (type = 'st' OR type = 'pg')";
335 return $res->numRows() ?
true :
false;
343 $query =
"SELECT * FROM crs_objective_lm ".
344 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
345 "AND ref_id = ".$ilDB->quote($this->
getLMRefId() ,
'integer').
" ".
346 "AND obj_id = ".$ilDB->quote($this->
getLMObjId() ,
'integer').
" ";
350 $query =
"SELECT * FROM crs_objective_lm ".
351 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
352 "AND ref_id = ".$ilDB->quote($this->
getLMRefId() ,
'integer').
" ";
357 return $res->numRows() ?
true :
false;
364 $next_id = $ilDB->nextId(
'crs_objective_lm');
365 $query =
"INSERT INTO crs_objective_lm (lm_ass_id,objective_id,ref_id,obj_id,type) ".
367 $ilDB->quote($next_id,
'integer').
", ".
369 $ilDB->quote($this->
getLMRefId() ,
'integer').
", ".
370 $ilDB->quote($this->
getLMObjId() ,
'integer').
", ".
371 $ilDB->quote($this->
getType() ,
'text').
377 function delete($lm_id)
386 $query =
"DELETE FROM crs_objective_lm ".
387 "WHERE lm_ass_id = ".$ilDB->quote($lm_id ,
'integer').
" ";
397 $query =
"DELETE FROM crs_objective_lm ".
398 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
416 $query =
"UPDATE crs_objective_lm ".
417 "SET position = ".$this->db->quote((
string) $a_position ,
'integer').
" ".
418 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
419 "AND lm_ass_id = ".$ilDB->quote($a_ass_id,
"integer");
430 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
432 $container_ref_id = current($container_ref_ids);
436 $this->lms = array();
437 $query =
"SELECT position,lm_ass_id,lm.ref_id,lm.obj_id,lm.type FROM crs_objective_lm lm ".
438 "JOIN object_reference obr ON lm.ref_id = obr.ref_id ".
439 "JOIN object_data obd ON obr.obj_id = obd.obj_id ".
440 "LEFT JOIN lm_data lmd ON lmd.obj_id = lm.obj_id ".
441 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId(),
'integer').
" ".
442 "ORDER BY position,obd.title,lmd.title";
447 if(!$tree->isInTree(
$row->ref_id) or !$tree->isGrandChild($container_ref_id,
$row->ref_id))
449 $this->
delete(
$row->lm_ass_id);
452 $lm[
'ref_id'] =
$row->ref_id;
453 $lm[
'obj_id'] =
$row->obj_id;
454 $lm[
'type'] =
$row->type;
455 $lm[
'lm_ass_id'] =
$row->lm_ass_id;
456 $lm[
'position'] =
$row->position;
458 $this->lms[
$row->lm_ass_id] = $lm;