ILIAS  Release_5_0_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, $a_get_id=false)
 Check if material is assigned.
 isChapterAssigned ($a_ref_id, $a_obj_id)
 Check if chapter is assigned.
 checkExists ()
 add ()
 delete ($lm_id)
 deleteAll ()
 writePosition ($a_ass_id, $a_position)
 write position
 __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 $ilDB, and __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 426 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $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);
// begin-patch lok
$this->lms = array();
$query = "SELECT position,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 position,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;
$lm['position'] = $row->position;
$this->lms[$row->lm_ass_id] = $lm;
}
// end-patch lok
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 211 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

{
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();
}
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 167 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, ilLOSettings\getInstanceByObjId(), and 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':
if(ilLOSettings::getInstanceByObjId($a_container_id)->isObjectiveTest($material['child']))
{
continue;
}
else
{
$assignable[] = $material;
}
break;
case 'crs':
case 'rolf':
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 141 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilContainerObjectiveGUI\buildObjectiveMap(), and 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 360 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $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 337 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $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' or $material['type'] == 'pg')
{
#$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($material,TRUE));
#$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($mappings,TRUE));
#$ilLog->write(__METHOD__.': 6');
// Chapter assignment
$new_material_info = isset($mappings[$material_ref_id.'_'.$material_obj_id]) ?
$mappings[$material_ref_id.'_'.$material_obj_id] :
'';
$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 377 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $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 393 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $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 235 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 251 of file class.ilCourseObjectiveMaterials.php.

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

Definition at line 273 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 265 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 230 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 256 of file class.ilCourseObjectiveMaterials.php.

References $objective_id.

Referenced by __read(), add(), checkExists(), deleteAll(), isAssigned(), isChapterAssigned(), and writePosition().

{
}

+ Here is the caller graph for this function:

ilCourseObjectiveMaterials::getType ( )

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

Referenced by add().

{
return $this->type;
}

+ Here is the caller graph for this function:

ilCourseObjectiveMaterials::isAssigned (   $a_ref_id,
  $a_get_id = false 
)

Check if material is assigned.

public

Parameters
intref id
Returns
bool

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

References $ilDB, $query, $res, $row, 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);
// begin-patch lok
if(!$a_get_id)
{
return $res->numRows() ? true : false;
}
else
{
$row = $this->db->fetchAssoc($res);
return $row["lm_ass_id"];
}
// end-patch lok
}

+ 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 325 of file class.ilCourseObjectiveMaterials.php.

References $ilDB, $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 269 of file class.ilCourseObjectiveMaterials.php.

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

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

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

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

{
$this->type = $a_type;
}
ilCourseObjectiveMaterials::writePosition (   $a_ass_id,
  $a_position 
)

write position

public

Parameters
intnew position
Returns

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

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

{
global $ilDB;
$query = "UPDATE crs_objective_lm ".
"SET position = ".$this->db->quote((string) $a_position ,'integer')." ".
"WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
"AND lm_ass_id = ".$ilDB->quote($a_ass_id, "integer");
$res = $ilDB->manipulate($query);
}

+ Here is the call graph for this function:

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: