class ilCourseObjectiveMaterials More...
Public Member Functions | |
| __construct ($a_objective_id) | |
| cloneDependencies ($a_new_objective, $a_copy_id) | |
| clone objective materials | |
| 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. | |
| isChapterAssigned ($a_ref_id, $a_obj_id) | |
| Check if chapter is assigned. | |
| checkExists () | |
| add () | |
| delete ($lm_id) | |
| deleteAll () | |
| __read () | |
Static Public Member Functions | |
| static | _getAssignableMaterials ($a_container_id) |
| Get an array of course material ids that can be assigned to learning objectives No tst, fold and grp. | |
| static | _getAllAssignedMaterials ($a_container_id) |
| Get all assigned materials. | |
Data Fields | |
| $db = null | |
| $objective_id = null | |
| $lms | |
class ilCourseObjectiveMaterials
Definition at line 33 of file class.ilCourseObjectiveMaterials.php.
| ilCourseObjectiveMaterials::__construct | ( | $ | a_objective_id | ) |
Definition at line 40 of file class.ilCourseObjectiveMaterials.php.
References __read().
{
global $ilDB;
$this->db =& $ilDB;
$this->objective_id = $a_objective_id;
$this->__read();
}
Here is the call graph for this function:| ilCourseObjectiveMaterials::__read | ( | ) |
Definition at line 350 of file class.ilCourseObjectiveMaterials.php.
References $res, ilObject::_getAllReferences(), ilCourseObjective::_lookupContainerIdByObjectiveId(), and getObjectiveId().
Referenced by __construct().
{
global $tree,$ilDB;
include_once('Modules/Course/classes/class.ilCourseObjective.php');
$container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
$container_ref_id = current($container_ref_ids);
$this->lms = array();
$query = "SELECT lm_ass_id,lm.ref_id,lm.obj_id,lm.type FROM crs_objective_lm as lm ".
"JOIN object_reference as obr ON lm.ref_id = obr.ref_id ".
"JOIN object_data as obd ON obr.obj_id = obd.obj_id ".
"LEFT JOIN lm_data as lmd ON lmd.obj_id = lm.obj_id ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
"ORDER BY obd.title,lmd.title";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
{
$this->delete($row->lm_ass_id);
continue;
}
$lm['ref_id'] = $row->ref_id;
$lm['obj_id'] = $row->obj_id;
$lm['type'] = $row->type;
$lm['lm_ass_id'] = $row->lm_ass_id;
$this->lms[$row->lm_ass_id] = $lm;
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| static ilCourseObjectiveMaterials::_getAllAssignedMaterials | ( | $ | a_container_id | ) | [static] |
Get all assigned materials.
public
| in |
Definition at line 176 of file class.ilCourseObjectiveMaterials.php.
References $res.
Referenced by ilCourseObjectivePresentationGUI::__getOtherResources(), and ilCourseObjectivePresentationGUI::__showLearningMaterials().
{
global $ilDB;
$query = "SELECT DISTINCT(com.ref_id) as ref_id FROM crs_objectives as co ".
"JOIN crs_objective_lm as com ON co.objective_id = com.objective_id ".
"JOIN object_reference as obr ON com.ref_id = obr.ref_id ".
"JOIN object_data as obd ON obr.obj_id = obd.obj_id ".
"WHERE co.crs_id = ".$ilDB->quote($a_container_id)." ".
"ORDER BY obd.title ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$ref_ids[] = $row->ref_id;
}
return $ref_ids ? $ref_ids : array();
}
Here is the caller graph for this function:| 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
| int | obj id of course |
Definition at line 141 of file class.ilCourseObjectiveMaterials.php.
References ilUtil::sortArray().
Referenced by ilCourseObjectivesGUI::listMaterialAssignment().
{
global $tree,$ilDB;
$all_materials = $tree->getSubTree($tree->getNodeData($a_container_id),true);
$all_materials = ilUtil::sortArray($all_materials,'title','asc');
// Filter
foreach($all_materials as $material)
{
switch($material['type'])
{
case 'tst':
case 'fold':
case 'grp':
case 'rolf':
case 'crs':
continue;
default:
$assignable[] = $material;
break;
}
}
return $assignable ? $assignable : array();
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilCourseObjectiveMaterials::add | ( | ) |
Definition at line 306 of file class.ilCourseObjectiveMaterials.php.
References getLMObjId(), getLMRefId(), getObjectiveId(), and getType().
{
global $ilDB;
$query = "INSERT INTO crs_objective_lm ".
"SET objective_id = ".$ilDB->quote($this->getObjectiveId()).", ".
"ref_id = ".$ilDB->quote($this->getLMRefId()).", ".
"obj_id = ".$ilDB->quote($this->getLMObjId()).", ".
"type = ".$ilDB->quote($this->getType())."";
$this->db->query($query);
return true;
}
Here is the call graph for this function:| ilCourseObjectiveMaterials::checkExists | ( | ) |
Definition at line 283 of file class.ilCourseObjectiveMaterials.php.
References $res, getLMObjId(), getLMRefId(), and getObjectiveId().
{
global $ilDB;
if($this->getLMObjId())
{
$query = "SELECT * FROM crs_objective_lm ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
"AND ref_id = ".$ilDB->quote($this->getLMRefId())." ".
"AND obj_id = ".$ilDB->quote($this->getLMObjId())." ";
}
else
{
$query = "SELECT * FROM crs_objective_lm ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
"AND ref_id = ".$ilDB->quote($this->getLMRefId())." ";
}
$res = $this->db->query($query);
return $res->numRows() ? true : false;
}
Here is the call graph for this function:| ilCourseObjectiveMaterials::cloneDependencies | ( | $ | a_new_objective, | |
| $ | a_copy_id | |||
| ) |
clone objective materials
public
| int | source objective | |
| int | target objective | |
| int | copy id |
Definition at line 60 of file class.ilCourseObjectiveMaterials.php.
References $ilLog, ilCopyWizardOptions::_getInstance(), and getMaterials().
{
global $ilObjDataCache,$ilLog;
include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
$cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
$mappings = $cwo->getMappings();
#$ilLog->write(__METHOD__.': 1');
foreach($this->getMaterials() as $material)
{
#$ilLog->write(__METHOD__.': 2');
// Copy action omit ?
if(!isset($mappings["$material[ref_id]"]) or !$mappings["$material[ref_id]"])
{
continue;
}
#$ilLog->write(__METHOD__.': 3');
$material_ref_id = $material['ref_id'];
$material_rbac_obj_id = $ilObjDataCache->lookupObjId($material_ref_id);
$material_obj_id = $material['obj_id'];
$new_ref_id = $mappings[$material_ref_id];
$new_rbac_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
#$ilLog->write(__METHOD__.': 4');
// Link
if($new_rbac_obj_id == $material_rbac_obj_id)
{
#$ilLog->write(__METHOD__.': 5');
$ilLog->write(__METHOD__.': Material has been linked. Keeping object id.');
$new_obj_id = $material_obj_id;
}
elseif($material['type'] == 'st')
{
#$ilLog->write(__METHOD__.': 6');
// Chapter assignment
$new_material_info = isset($mappings[$material_ref_id.'_'.$material_obj_id]) ?
$mappings[$material_ref_id.'_'.$material_obj_id] :
array();
$new_material_arr = explode('_',$new_material_info);
if(!isset($new_material_arr[1]) or !$new_material_arr[1])
{
$ilLog->write(__METHOD__.': No mapping found for chapter: '.$material_obj_id);
continue;
}
$new_obj_id = $new_material_arr[1];
$ilLog->write(__METHOD__.': New material id is: '.$new_obj_id);
}
else
{
#$ilLog->write(__METHOD__.': 7');
// Any type
$new_obj_id = $ilObjDataCache->lookupObjId($mappings[$material_ref_id]);
}
#$ilLog->write(__METHOD__.': 8');
$new_material = new ilCourseObjectiveMaterials($a_new_objective);
#$ilLog->write(__METHOD__.': 8.1');
$new_material->setLMRefId($new_ref_id);
#$ilLog->write(__METHOD__.': 8.2');
$new_material->setLMObjId($new_obj_id);
#$ilLog->write(__METHOD__.': 8.3');
$new_material->setType($material['type']);
#$ilLog->write(__METHOD__.': 8.4');
$new_material->add();
#$ilLog->write(__METHOD__.': 9');
}
}
Here is the call graph for this function:| ilCourseObjectiveMaterials::delete | ( | $ | lm_id | ) |
Definition at line 320 of file class.ilCourseObjectiveMaterials.php.
{
global $ilDB;
if(!$lm_id)
{
return false;
}
$query = "DELETE FROM crs_objective_lm ".
"WHERE lm_ass_id = ".$ilDB->quote($lm_id)." ";
$this->db->query($query);
return true;
}
| ilCourseObjectiveMaterials::deleteAll | ( | ) |
Definition at line 337 of file class.ilCourseObjectiveMaterials.php.
References getObjectiveId().
{
global $ilDB;
$query = "DELETE FROM crs_objective_lm ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ";
$this->db->query($query);
return true;
}
Here is the call graph for this function:| ilCourseObjectiveMaterials::getChapters | ( | ) |
Definition at line 200 of file class.ilCourseObjectiveMaterials.php.
{
foreach($this->lms as $lm_data)
{
if($lm_data['type'] == 'st')
{
$chapters[] = $lm_data;
}
}
return $chapters ? $chapters : array();
}
| ilCourseObjectiveMaterials::getLM | ( | $ | lm_id | ) |
Definition at line 212 of file class.ilCourseObjectiveMaterials.php.
{
return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
}
| ilCourseObjectiveMaterials::getLMObjId | ( | ) |
Definition at line 234 of file class.ilCourseObjectiveMaterials.php.
Referenced by add(), and checkExists().
{
return $this->lm_obj_id ? $this->lm_obj_id : 0;
}
Here is the caller graph for this function:| ilCourseObjectiveMaterials::getLMRefId | ( | ) |
Definition at line 226 of file class.ilCourseObjectiveMaterials.php.
Referenced by add(), and checkExists().
{
return $this->lm_ref_id ? $this->lm_ref_id : 0;
}
Here is the caller graph for this function:| ilCourseObjectiveMaterials::getMaterials | ( | ) |
Definition at line 195 of file class.ilCourseObjectiveMaterials.php.
Referenced by cloneDependencies().
{
return $this->lms ? $this->lms : array();
}
Here is the caller graph for this function:| ilCourseObjectiveMaterials::getObjectiveId | ( | ) |
Definition at line 217 of file class.ilCourseObjectiveMaterials.php.
Referenced by __read(), add(), checkExists(), deleteAll(), isAssigned(), and isChapterAssigned().
{
return $this->objective_id;
}
Here is the caller graph for this function:| ilCourseObjectiveMaterials::getType | ( | ) |
Definition at line 242 of file class.ilCourseObjectiveMaterials.php.
Referenced by add().
{
return $this->type;
}
Here is the caller graph for this function:| ilCourseObjectiveMaterials::isAssigned | ( | $ | a_ref_id | ) |
Check if material is assigned.
public
| int | ref id |
Definition at line 255 of file class.ilCourseObjectiveMaterials.php.
References $res, and getObjectiveId().
{
$query = "SELECT * FROM crs_objective_lm ".
"WHERE ref_id = ".$this->db->quote($a_ref_id)." ".
"AND objective_id = ".$this->db->quote($this->getObjectiveId())." ".
"AND type != 'st'";
$res = $this->db->query($query);
return $res->numRows() ? true : false;
}
Here is the call graph for this function:| ilCourseObjectiveMaterials::isChapterAssigned | ( | $ | a_ref_id, | |
| $ | a_obj_id | |||
| ) |
Check if chapter is assigned.
public
| int | ref id |
Definition at line 273 of file class.ilCourseObjectiveMaterials.php.
References $res, and getObjectiveId().
{
$query = "SELECT * FROM crs_objective_lm ".
"WHERE ref_id = ".$this->db->quote($a_ref_id)." ".
"AND obj_id = ".$this->db->quote($a_obj_id)." ".
"AND objective_id = ".$this->db->quote($this->getObjectiveId())." ".
"AND type = 'st'";
$res = $this->db->query($query);
return $res->numRows() ? true : false;
}
Here is the call graph for this function:| ilCourseObjectiveMaterials::setLMObjId | ( | $ | a_obj_id | ) |
Definition at line 230 of file class.ilCourseObjectiveMaterials.php.
{
$this->lm_obj_id = $a_obj_id;
}
| ilCourseObjectiveMaterials::setLMRefId | ( | $ | a_ref_id | ) |
Definition at line 222 of file class.ilCourseObjectiveMaterials.php.
{
$this->lm_ref_id = $a_ref_id;
}
| ilCourseObjectiveMaterials::setType | ( | $ | a_type | ) |
Definition at line 238 of file class.ilCourseObjectiveMaterials.php.
{
$this->type = $a_type;
}
| ilCourseObjectiveMaterials::$db = null |
Definition at line 35 of file class.ilCourseObjectiveMaterials.php.
| ilCourseObjectiveMaterials::$lms |
Definition at line 38 of file class.ilCourseObjectiveMaterials.php.
| ilCourseObjectiveMaterials::$objective_id = null |
Definition at line 37 of file class.ilCourseObjectiveMaterials.php.
1.7.1