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')
93 #$ilLog->write(__METHOD__.': 6');
95 $new_material_info = isset($mappings[$material_ref_id.
'_'.$material_obj_id]) ?
96 $mappings[$material_ref_id.
'_'.$material_obj_id] :
98 $new_material_arr = explode(
'_',$new_material_info);
99 if(!isset($new_material_arr[1]) or !$new_material_arr[1])
101 $ilLog->write(__METHOD__.
': No mapping found for chapter: '.$material_obj_id);
104 $new_obj_id = $new_material_arr[1];
105 $ilLog->write(__METHOD__.
': New material id is: '.$new_obj_id);
109 #$ilLog->write(__METHOD__.': 7');
111 $new_obj_id = $ilObjDataCache->lookupObjId($mappings[$material_ref_id]);
114 #$ilLog->write(__METHOD__.': 8');
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');
141 $query =
"SELECT DISTINCT(ref_id) AS ref_id FROM crs_objective_lm ".
142 "WHERE objective_id = ".$ilDB->quote($a_objective_id).
" ";
143 $res = $ilDB->query($query);
146 $ref_ids[] = $row->ref_id;
148 return $ref_ids ? $ref_ids : array();
167 $all_materials = $tree->getSubTree($tree->getNodeData($a_container_id),
true);
171 foreach($all_materials as $material)
173 switch($material[
'type'])
184 $assignable[] = $material;
188 return $assignable ? $assignable : array();
203 $query =
"SELECT DISTINCT(com.ref_id) as ref_id FROM crs_objectives as co ".
204 "JOIN crs_objective_lm as com ON co.objective_id = com.objective_id ".
205 "JOIN object_reference as obr ON com.ref_id = obr.ref_id ".
206 "JOIN object_data as obd ON obr.obj_id = obd.obj_id ".
207 "WHERE co.crs_id = ".$ilDB->quote($a_container_id).
" ".
208 "ORDER BY obd.title ";
210 $res = $ilDB->query($query);
213 $ref_ids[] = $row->ref_id;
215 return $ref_ids ? $ref_ids : array();
220 return $this->lms ? $this->lms : array();
225 foreach($this->lms as $lm_data)
227 if($lm_data[
'type'] ==
'st')
229 $chapters[] = $lm_data;
231 if($lm_data[
'type'] ==
'pg')
233 $chapters[] = $lm_data;
236 return $chapters ? $chapters : array();
241 return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
251 $this->lm_ref_id = $a_ref_id;
255 return $this->lm_ref_id ? $this->lm_ref_id : 0;
259 $this->lm_obj_id = $a_obj_id;
263 return $this->lm_obj_id ? $this->lm_obj_id : 0;
267 $this->type = $a_type;
284 $query =
"SELECT * FROM crs_objective_lm ".
285 "WHERE ref_id = ".$this->db->quote($a_ref_id).
" ".
286 "AND objective_id = ".$this->db->quote($this->
getObjectiveId()).
" ".
287 "AND type != 'st' AND type != 'pg' ";
288 $res = $this->db->query($query);
289 return $res->numRows() ?
true :
false;
302 $query =
"SELECT * FROM crs_objective_lm ".
303 "WHERE ref_id = ".$this->db->quote($a_ref_id).
" ".
304 "AND obj_id = ".$this->db->quote($a_obj_id).
" ".
305 "AND objective_id = ".$this->db->quote($this->
getObjectiveId()).
" ".
306 "AND (type = 'st' OR type = 'pg')";
307 $res = $this->db->query($query);
308 return $res->numRows() ?
true :
false;
316 $query =
"SELECT * FROM crs_objective_lm ".
317 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
318 "AND ref_id = ".$ilDB->quote($this->
getLMRefId()).
" ".
319 "AND obj_id = ".$ilDB->quote($this->
getLMObjId()).
" ";
323 $query =
"SELECT * FROM crs_objective_lm ".
324 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
325 "AND ref_id = ".$ilDB->quote($this->
getLMRefId()).
" ";
328 $res = $this->db->query($query);
330 return $res->numRows() ?
true :
false;
337 $query =
"INSERT INTO crs_objective_lm ".
339 "ref_id = ".$ilDB->quote($this->
getLMRefId()).
", ".
340 "obj_id = ".$ilDB->quote($this->
getLMObjId()).
", ".
341 "type = ".$ilDB->quote($this->
getType()).
"";
343 $this->db->query($query);
347 function delete($lm_id)
356 $query =
"DELETE FROM crs_objective_lm ".
357 "WHERE lm_ass_id = ".$ilDB->quote($lm_id).
" ";
359 $this->db->query($query);
368 $query =
"DELETE FROM crs_objective_lm ".
369 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ";
371 $this->db->query($query);
381 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
383 $container_ref_id = current($container_ref_ids);
385 $this->lms = array();
386 $query =
"SELECT lm_ass_id,lm.ref_id,lm.obj_id,lm.type FROM crs_objective_lm as lm ".
387 "JOIN object_reference as obr ON lm.ref_id = obr.ref_id ".
388 "JOIN object_data as obd ON obr.obj_id = obd.obj_id ".
389 "LEFT JOIN lm_data as lmd ON lmd.obj_id = lm.obj_id ".
390 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
391 "ORDER BY obd.title,lmd.title";
393 $res = $this->db->query($query);
396 if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
398 $this->
delete($row->lm_ass_id);
401 $lm[
'ref_id'] = $row->ref_id;
402 $lm[
'obj_id'] = $row->obj_id;
403 $lm[
'type'] = $row->type;
404 $lm[
'lm_ass_id'] = $row->lm_ass_id;
406 $this->lms[$row->lm_ass_id] = $lm;