48 $this->objective_id = $a_objective_id;
66 $ilObjDataCache = $DIC[
'ilObjDataCache'];
69 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
71 $mappings = $cwo->getMappings();
72 #$ilLog->write(__METHOD__.': 1'); 74 #$ilLog->write(__METHOD__.': 2'); 76 if (!isset($mappings[$material[
'ref_id']])
or !$mappings[$material[
'ref_id']]) {
79 #$ilLog->write(__METHOD__.': 3'); 80 $material_ref_id = $material[
'ref_id'];
81 $material_rbac_obj_id = $ilObjDataCache->lookupObjId($material_ref_id);
82 $material_obj_id = $material[
'obj_id'];
83 $new_ref_id = $mappings[$material_ref_id];
84 $new_rbac_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
85 #$ilLog->write(__METHOD__.': 4'); 88 if ($new_rbac_obj_id == $material_rbac_obj_id) {
89 #$ilLog->write(__METHOD__.': 5'); 90 $ilLog->write(__METHOD__ .
': Material has been linked. Keeping object id.');
91 $new_obj_id = $material_obj_id;
92 } elseif ($material[
'type'] ==
'st' or $material[
'type'] ==
'pg') {
94 #$GLOBALS['DIC']['ilLog']->write(__METHOD__.': '.print_r($material,TRUE)); 95 #$GLOBALS['DIC']['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]) {
104 $ilLog->write(__METHOD__ .
': No mapping found for chapter: ' . $material_obj_id);
107 $new_obj_id = $new_material_arr[1];
108 $ilLog->write(__METHOD__ .
': New material id is: ' . $new_obj_id);
110 #$ilLog->write(__METHOD__.': 7'); 112 $new_obj_id = $ilObjDataCache->lookupObjId($mappings[$material_ref_id]);
115 #$ilLog->write(__METHOD__.': 8'); 117 #$ilLog->write(__METHOD__.': 8.1'); 118 $new_material->setLMRefId($new_ref_id);
119 #$ilLog->write(__METHOD__.': 8.2'); 120 $new_material->setLMObjId($new_obj_id);
121 #$ilLog->write(__METHOD__.': 8.3'); 122 $new_material->setType($material[
'type']);
123 #$ilLog->write(__METHOD__.': 8.4'); 124 $new_material->add();
125 #$ilLog->write(__METHOD__.': 9'); 141 $ilDB = $DIC[
'ilDB'];
143 $query =
"SELECT DISTINCT(ref_id) ref_id FROM crs_objective_lm " .
144 "WHERE objective_id = " .
$ilDB->quote($a_objective_id,
'integer');
147 $ref_ids[] =
$row->ref_id;
149 return $ref_ids ? $ref_ids : array();
168 $tree = $DIC[
'tree'];
169 $ilDB = $DIC[
'ilDB'];
173 $all_materials =
$tree->getSubTree(
$tree->getNodeData($a_container_id),
true);
177 foreach ($all_materials as $material) {
178 switch ($material[
'type']) {
181 include_once
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
186 $assignable[] = $material;
196 $assignable[] = $material;
200 return $assignable ? $assignable : array();
215 $ilDB = $DIC[
'ilDB'];
217 $query =
"SELECT DISTINCT(com.ref_id) ref_id FROM crs_objectives co " .
218 "JOIN crs_objective_lm com ON co.objective_id = com.objective_id " .
219 "JOIN object_reference obr ON com.ref_id = obr.ref_id " .
220 "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
221 "WHERE co.crs_id = " .
$ilDB->quote($a_container_id,
'integer') .
" " .
222 "ORDER BY obd.title ";
226 $ref_ids[] =
$row->ref_id;
228 return $ref_ids ? $ref_ids : array();
233 return $this->lms ? $this->lms : array();
238 foreach ($this->lms as $lm_data) {
239 if ($lm_data[
'type'] ==
'st') {
240 $chapters[] = $lm_data;
242 if ($lm_data[
'type'] ==
'pg') {
243 $chapters[] = $lm_data;
246 return $chapters ? $chapters : array();
251 return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
261 $this->lm_ref_id = $a_ref_id;
265 return $this->lm_ref_id ? $this->lm_ref_id : 0;
269 $this->lm_obj_id = $a_obj_id;
273 return $this->lm_obj_id ? $this->lm_obj_id : 0;
296 $ilDB = $DIC[
'ilDB'];
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' ";
306 return $res->numRows() ? true :
false;
309 return $row[
"lm_ass_id"];
326 $ilDB = $DIC[
'ilDB'];
328 $query =
"SELECT * FROM crs_objective_lm " .
329 "WHERE ref_id = " . $this->db->quote($a_ref_id,
'integer') .
" " .
330 "AND obj_id = " . $this->db->quote($a_obj_id,
'integer') .
" " .
331 "AND objective_id = " . $this->db->quote($this->
getObjectiveId(),
'integer') .
" " .
332 "AND (type = 'st' OR type = 'pg')";
334 return $res->numRows() ? true :
false;
340 $ilDB = $DIC[
'ilDB'];
343 $query =
"SELECT * FROM crs_objective_lm " .
348 $query =
"SELECT * FROM crs_objective_lm " .
355 return $res->numRows() ? true :
false;
362 $ilDB = $DIC[
'ilDB'];
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') .
", " .
375 return (
int) $next_id;
377 public function delete($lm_id)
381 $ilDB = $DIC[
'ilDB'];
387 $query =
"DELETE FROM crs_objective_lm " .
388 "WHERE lm_ass_id = " .
$ilDB->quote($lm_id,
'integer') .
" ";
398 $ilDB = $DIC[
'ilDB'];
400 $query =
"DELETE FROM crs_objective_lm " .
419 $ilDB = $DIC[
'ilDB'];
421 $query =
"UPDATE crs_objective_lm " .
422 "SET position = " . $this->db->quote((
string) $a_position,
'integer') .
" " .
423 "WHERE objective_id = " . $this->db->quote($this->
getObjectiveId(),
'integer') .
" " .
424 "AND lm_ass_id = " .
$ilDB->quote($a_ass_id,
"integer");
435 $tree = $DIC[
'tree'];
436 $ilDB = $DIC[
'ilDB'];
438 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
440 $container_ref_id = current($container_ref_ids);
444 $this->lms = array();
445 $query =
"SELECT position,lm_ass_id,lm.ref_id,lm.obj_id,lm.type FROM crs_objective_lm lm " .
446 "JOIN object_reference obr ON lm.ref_id = obr.ref_id " .
447 "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
448 "LEFT JOIN lm_data lmd ON lmd.obj_id = lm.obj_id " .
450 "ORDER BY position,obd.title,lmd.title";
455 $this->
delete(
$row->lm_ass_id);
458 $lm[
'ref_id'] =
$row->ref_id;
459 $lm[
'obj_id'] =
$row->obj_id;
460 $lm[
'type'] =
$row->type;
461 $lm[
'lm_ass_id'] =
$row->lm_ass_id;
462 $lm[
'position'] =
$row->position;
464 $this->lms[
$row->lm_ass_id] = $lm;
484 'refId' => $material[
'ref_id'],
485 'objId' => $material[
'obj_id'],
486 'type' => $material[
'type'],
487 'position' => $material[
'position']
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.
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
writePosition($a_ass_id, $a_position)
write position
isAssigned($a_ref_id, $a_get_id=false)
Check if material is assigned.
static _getAllReferences($a_id)
get all reference ids of object
class ilCourseObjectiveMaterials
static _getInstance($a_copy_id)
Get instance of copy wizard options.
foreach($_POST as $key=> $value) $res
static _getAllAssignedMaterials($a_container_id)
Get all assigned materials.
static _lookupObjId($a_id)
isChapterAssigned($a_ref_id, $a_obj_id)
Check if chapter is assigned.
static _getAssignedMaterials($a_objective_id)
get assigned materials
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
cloneDependencies($a_new_objective, $a_copy_id)
clone objective materials
static _getAssignableMaterials($a_container_id)
Get an array of course material ids that can be assigned to learning objectives No tst...
const TYPE_TEST_UNDEFINED
__construct($a_objective_id)
toXml(ilXmlWriter $writer)