ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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
 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 _getAssignedMaterials ($a_objective_id)
 get assigned materials
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

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

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:

Member Function Documentation

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

{
global $tree,$ilDB;
include_once('Modules/Course/classes/class.ilCourseObjective.php');
$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 lm ".
"JOIN object_reference obr ON lm.ref_id = obr.ref_id ".
"JOIN object_data obd ON obr.obj_id = obd.obj_id ".
"LEFT JOIN lm_data lmd ON lmd.obj_id = lm.obj_id ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId(),'integer')." ".
"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

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

{
global $ilDB;
$query = "SELECT DISTINCT(com.ref_id) ref_id FROM crs_objectives co ".
"JOIN crs_objective_lm com ON co.objective_id = com.objective_id ".
"JOIN object_reference obr ON com.ref_id = obr.ref_id ".
"JOIN object_data obd ON obr.obj_id = obd.obj_id ".
"WHERE co.crs_id = ".$ilDB->quote($a_container_id,'integer')." ".
"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

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

{
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':
case 'sess':
case 'itgr':
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:

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

{
global $ilDB;
$query = "SELECT DISTINCT(ref_id) ref_id FROM crs_objective_lm ".
"WHERE objective_id = ".$ilDB->quote($a_objective_id ,'integer')." ";
$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:

ilCourseObjectiveMaterials::add ( )

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

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

{
global $ilDB;
$next_id = $ilDB->nextId('crs_objective_lm');
$query = "INSERT INTO crs_objective_lm (lm_ass_id,objective_id,ref_id,obj_id,type) ".
"VALUES( ".
$ilDB->quote($next_id, 'integer').", ".
$ilDB->quote($this->getObjectiveId() ,'integer').", ".
$ilDB->quote($this->getLMRefId() ,'integer').", ".
$ilDB->quote($this->getLMObjId() ,'integer').", ".
$ilDB->quote($this->getType() ,'text').
")";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

ilCourseObjectiveMaterials::checkExists ( )

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

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

{
global $ilDB;
if($this->getLMObjId())
{
$query = "SELECT * FROM crs_objective_lm ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
"AND ref_id = ".$ilDB->quote($this->getLMRefId() ,'integer')." ".
"AND obj_id = ".$ilDB->quote($this->getLMObjId() ,'integer')." ";
}
else
{
$query = "SELECT * FROM crs_objective_lm ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
"AND ref_id = ".$ilDB->quote($this->getLMRefId() ,'integer')." ";
}
$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

Parameters
intsource objective
inttarget objective
intcopy 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');
$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 355 of file class.ilCourseObjectiveMaterials.php.

References $query, and $res.

{
global $ilDB;
if(!$lm_id)
{
return false;
}
$query = "DELETE FROM crs_objective_lm ".
"WHERE lm_ass_id = ".$ilDB->quote($lm_id ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}
ilCourseObjectiveMaterials::deleteAll ( )

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

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

{
global $ilDB;
$query = "DELETE FROM crs_objective_lm ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

ilCourseObjectiveMaterials::getChapters ( )

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

{
foreach($this->lms as $lm_data)
{
if($lm_data['type'] == 'st')
{
$chapters[] = $lm_data;
}
if($lm_data['type'] == 'pg')
{
$chapters[] = $lm_data;
}
}
return $chapters ? $chapters : array();
}
ilCourseObjectiveMaterials::getLM (   $lm_id)

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

{
return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
}
ilCourseObjectiveMaterials::getLMObjId ( )

Definition at line 262 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 254 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 219 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 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:

ilCourseObjectiveMaterials::getType ( )

Definition at line 270 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

Parameters
intref id
Returns
bool

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

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

{
global $ilDB;
$query = "SELECT * FROM crs_objective_lm ".
"WHERE ref_id = ".$this->db->quote($a_ref_id ,'integer')." ".
"AND objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
"AND type != 'st' AND type != 'pg' ";
$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

Parameters
intref id
Returns
bool

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

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

{
global $ilDB;
$query = "SELECT * FROM crs_objective_lm ".
"WHERE ref_id = ".$this->db->quote($a_ref_id ,'integer')." ".
"AND obj_id = ".$this->db->quote($a_obj_id ,'integer')." ".
"AND objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
"AND (type = 'st' OR type = 'pg')";
$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 258 of file class.ilCourseObjectiveMaterials.php.

{
$this->lm_obj_id = $a_obj_id;
}
ilCourseObjectiveMaterials::setLMRefId (   $a_ref_id)

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

{
$this->lm_ref_id = $a_ref_id;
}
ilCourseObjectiveMaterials::setType (   $a_type)

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

{
$this->type = $a_type;
}

Field Documentation

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.

Referenced by getObjectiveId().


The documentation for this class was generated from the following file: