ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseObjective Class Reference

class ilcourseobjective More...

+ Inheritance diagram for ilCourseObjective:
+ Collaboration diagram for ilCourseObjective:

Public Member Functions

 ilCourseObjective (&$course_obj, $a_objective_id=0)
 ilClone ($a_target_id, $a_copy_id)
 clone objectives
 setTitle ($a_title)
 getTitle ()
 setDescription ($a_description)
 getDescription ()
 setObjectiveId ($a_objective_id)
 getObjectiveId ()
 add ()
 update ()
 writePosition ($a_position)
 write position
 validate ()
 validate
 delete ()
 moveUp ()
 moveDown ()
 __setPosition ($a_position)
 __getPosition ()
 __setCreated ($a_created)
 __getCreated ()
 __read ()
 __getOrderColumn ()
 __updateTop ()
 __getLastPosition ()
 _getObjectiveIds ($course_id)
 _deleteAll ($course_id)

Static Public Member Functions

static _lookupContainerIdByObjectiveId ($a_objective_id)
 Get container of object.
static _getCountObjectives ($a_obj_id)
 get count objectives

Data Fields

 $db = null
 $course_obj = null
 $objective_id = null

Detailed Description

class ilcourseobjective

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 13 of file class.ilCourseObjective.php.

Member Function Documentation

ilCourseObjective::__getCreated ( )

Definition at line 319 of file class.ilCourseObjective.php.

{
return $this->created;
}
ilCourseObjective::__getLastPosition ( )

Definition at line 379 of file class.ilCourseObjective.php.

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

Referenced by add(), and moveDown().

{
global $ilDB;
$query = "SELECT MAX(position) pos FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->pos;
}
return 0;
}

+ Here is the caller graph for this function:

ilCourseObjective::__getOrderColumn ( )

Definition at line 350 of file class.ilCourseObjective.php.

References ilContainer\SORT_ACTIVATION, ilContainer\SORT_MANUAL, and ilContainer\SORT_TITLE.

{
switch($this->course_obj->getOrderType())
{
return 'ORDER BY position';
return 'ORDER BY title';
return 'ORDER BY create';
}
return false;
}
ilCourseObjective::__getPosition ( )

Definition at line 311 of file class.ilCourseObjective.php.

Referenced by __updateTop(), moveDown(), and moveUp().

{
return $this->position;
}

+ Here is the caller graph for this function:

ilCourseObjective::__read ( )

Definition at line 325 of file class.ilCourseObjective.php.

References $query, $res, $row, __setCreated(), __setPosition(), DB_FETCHMODE_OBJECT, getObjectiveId(), setDescription(), setObjectiveId(), and setTitle().

Referenced by ilCourseObjective(), moveDown(), and moveUp().

{
global $ilDB;
if($this->getObjectiveId())
{
$query = "SELECT * FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ".
"AND objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setObjectiveId($row->objective_id);
$this->setTitle($row->title);
$this->setDescription($row->description);
$this->__setPosition($row->position);
$this->__setCreated($row->created);
}
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjective::__setCreated (   $a_created)

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

Referenced by __read().

{
$this->created = $a_created;
}

+ Here is the caller graph for this function:

ilCourseObjective::__setPosition (   $a_position)

Definition at line 307 of file class.ilCourseObjective.php.

Referenced by __read().

{
$this->position = $a_position;
}

+ Here is the caller graph for this function:

ilCourseObjective::__updateTop ( )

Definition at line 366 of file class.ilCourseObjective.php.

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

{
global $ilDB;
$query = "UPDATE crs_objectives ".
"SET position = position - 1 ".
"WHERE position > ".$ilDB->quote($this->__getPosition() ,'integer')." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::_deleteAll (   $course_id)

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

References $in, $query, $res, _getObjectiveIds(), and ilLPStatusWrapper\_refreshStatus().

Referenced by ilObjCourse\delete().

{
global $ilDB;
if(!count($ids))
{
return true;
}
$in = $ilDB->in('objective_id',$ids,false,'integer');
$query = "DELETE FROM crs_objective_lm WHERE ".$in;
$res = $ilDB->manipulate($query);
$query = "DELETE FROM crs_objective_tst WHERE ".$in;
$res = $ilDB->manipulate($query);
$query = "DELETE FROM crs_objective_qst WHERE ".$in;
$res = $ilDB->manipulate($query);
$query = "DELETE FROM crs_objectives WHERE crs_id = ".$ilDB->quote($course_id ,'integer');
$res = $ilDB->manipulate($query);
// refresh learning progress status after deleting objectives
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCourseObjective::_getCountObjectives (   $a_obj_id)
static

get count objectives

public

Parameters
intobj_id
Returns

Definition at line 64 of file class.ilCourseObjective.php.

References $query, and $res.

Referenced by ilObjCourseGUI\getTabs().

{
global $ilDB;
$query = "SELECT * FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
$res = $ilDB->query($query);
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

ilCourseObjective::_getObjectiveIds (   $course_id)
static ilCourseObjective::_lookupContainerIdByObjectiveId (   $a_objective_id)
static

Get container of object.

public

Parameters
intobjective id

Definition at line 42 of file class.ilCourseObjective.php.

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

Referenced by ilCourseObjectiveMaterials\__read(), and ilCourseObjectiveQuestion\__read().

{
global $ilDB;
$query = "SELECT crs_id FROM crs_objectives ".
"WHERE objective_id = ".$ilDB->quote($a_objective_id ,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->crs_id;
}
return false;
}

+ Here is the caller graph for this function:

ilCourseObjective::add ( )

Definition at line 151 of file class.ilCourseObjective.php.

References $query, $res, __getLastPosition(), ilLPStatusWrapper\_refreshStatus(), getDescription(), and getTitle().

{
global $ilDB;
$next_id = $ilDB->nextId('crs_objectives');
$query = "INSERT INTO crs_objectives (crs_id,objective_id,title,description,position,created) ".
"VALUES( ".
$ilDB->quote($this->course_obj->getId() ,'integer').", ".
$ilDB->quote($next_id,'integer').", ".
$ilDB->quote($this->getTitle() ,'text').", ".
$ilDB->quote($this->getDescription() ,'text').", ".
$ilDB->quote($this->__getLastPosition() + 1 ,'integer').", ".
$ilDB->quote(time() ,'integer')." ".
")";
$res = $ilDB->manipulate($query);
// refresh learning progress status after adding new objective
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
ilLPStatusWrapper::_refreshStatus($this->course_obj->getId());
return $this->objective_id = $next_id;
}

+ Here is the call graph for this function:

ilCourseObjective::delete ( )

Definition at line 217 of file class.ilCourseObjective.php.

References $query, $res, ilLPStatusWrapper\_refreshStatus(), and getObjectiveId().

{
global $ilDB;
include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
$tmp_obj_qst =& new ilCourseObjectiveQuestion($this->getObjectiveId());
$tmp_obj_qst->deleteAll();
include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
$tmp_obj_lm =& new ilCourseObjectiveMaterials($this->getObjectiveId());
$tmp_obj_lm->deleteAll();
$query = "DELETE FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ".
"AND objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
$res = $ilDB->manipulate($query);
// refresh learning progress status after deleting objective
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
ilLPStatusWrapper::_refreshStatus($this->course_obj->getId());
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::getDescription ( )

Definition at line 138 of file class.ilCourseObjective.php.

Referenced by add(), and update().

{
return $this->description;
}

+ Here is the caller graph for this function:

ilCourseObjective::getObjectiveId ( )

Definition at line 146 of file class.ilCourseObjective.php.

References $objective_id.

Referenced by __read(), delete(), moveDown(), moveUp(), update(), and writePosition().

{
}

+ Here is the caller graph for this function:

ilCourseObjective::getTitle ( )

Definition at line 130 of file class.ilCourseObjective.php.

References $title.

Referenced by add(), update(), and validate().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilCourseObjective::ilClone (   $a_target_id,
  $a_copy_id 
)

clone objectives

public

Parameters
inttarget id
intcopy id

Definition at line 82 of file class.ilCourseObjective.php.

References $ilLog, $objective_id, $query, $res, $row, DB_FETCHMODE_OBJECT, ilObjectFactory\getInstanceByRefId(), and ilCourseObjective().

{
global $ilLog;
$ilLog->write(__METHOD__.': Start cloning learning objectives...');
$query = "SELECT * FROM crs_objectives ".
"WHERE crs_id = ".$this->db->quote($this->course_obj->getId() ,'integer').' '.
"ORDER BY position ";
$res = $this->db->query($query);
if(!$res->numRows())
{
$ilLog->write(__METHOD__.': ... no objectives found.');
return true;
}
if(!is_object($new_course = ilObjectFactory::getInstanceByRefId($a_target_id,false)))
{
$ilLog->write(__METHOD__.': Cannot init new course object.');
return true;
}
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$new_objective = new ilCourseObjective($new_course);
$new_objective->setTitle($row->title);
$new_objective->setDescription($row->description);
$objective_id = $new_objective->add();
$ilLog->write(__METHOD__.': Added new objective nr: '.$objective_id);
// Clone crs_objective_tst entries
include_once('Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
$objective_qst = new ilCourseObjectiveQuestion($row->objective_id);
$objective_qst->cloneDependencies($objective_id,$a_copy_id);
$ilLog->write(__METHOD__.': Finished objective question dependencies: '.$objective_id);
// Clone crs_objective_lm entries (assigned course materials)
include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
$objective_material = new ilCourseObjectiveMaterials($row->objective_id);
$objective_material->cloneDependencies($objective_id,$a_copy_id);
}
$ilLog->write(__METHOD__.': Finished cloning objectives.');
}

+ Here is the call graph for this function:

ilCourseObjective::ilCourseObjective ( $course_obj,
  $a_objective_id = 0 
)

Definition at line 20 of file class.ilCourseObjective.php.

References $course_obj, and __read().

Referenced by ilClone().

{
global $ilDB;
$this->db =& $ilDB;
$this->course_obj =& $course_obj;
$this->objective_id = $a_objective_id;
if($this->objective_id)
{
$this->__read();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjective::moveDown ( )

Definition at line 275 of file class.ilCourseObjective.php.

References $query, $res, __getLastPosition(), __getPosition(), __read(), and getObjectiveId().

{
global $ilDB;
if(!$this->getObjectiveId())
{
return false;
}
// Stop if position is last
if($this->__getPosition() == $this->__getLastPosition())
{
return false;
}
$query = "UPDATE crs_objectives ".
"SET position = position - 1 ".
"WHERE position = ".$ilDB->quote($this->__getPosition() + 1 ,'integer')." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
$res = $ilDB->manipulate($query);
$query = "UPDATE crs_objectives ".
"SET position = position + 1 ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
$res = $ilDB->manipulate($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::moveUp ( )

Definition at line 244 of file class.ilCourseObjective.php.

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

{
global $ilDB;
if(!$this->getObjectiveId())
{
return false;
}
// Stop if position is first
if($this->__getPosition() == 1)
{
return false;
}
$query = "UPDATE crs_objectives ".
"SET position = position + 1 ".
"WHERE position = ".$ilDB->quote($this->__getPosition() - 1 ,'integer')." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
$res = $ilDB->manipulate($query);
$query = "UPDATE crs_objectives ".
"SET position = position - 1 ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
$res = $ilDB->manipulate($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::setDescription (   $a_description)

Definition at line 134 of file class.ilCourseObjective.php.

Referenced by __read().

{
$this->description = $a_description;
}

+ Here is the caller graph for this function:

ilCourseObjective::setObjectiveId (   $a_objective_id)

Definition at line 142 of file class.ilCourseObjective.php.

Referenced by __read().

{
$this->objective_id = $a_objective_id;
}

+ Here is the caller graph for this function:

ilCourseObjective::setTitle (   $a_title)

Definition at line 126 of file class.ilCourseObjective.php.

Referenced by __read().

{
$this->title = $a_title;
}

+ Here is the caller graph for this function:

ilCourseObjective::update ( )

Definition at line 174 of file class.ilCourseObjective.php.

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

{
global $ilDB;
$query = "UPDATE crs_objectives ".
"SET title = ".$ilDB->quote($this->getTitle() ,'text').", ".
"description = ".$ilDB->quote($this->getDescription() ,'text')." ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')."";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::validate ( )

validate

public

Parameters
@return

Definition at line 212 of file class.ilCourseObjective.php.

References getTitle().

{
return (bool) strlen($this->getTitle());
}

+ Here is the call graph for this function:

ilCourseObjective::writePosition (   $a_position)

write position

public

Parameters
intnew position
Returns

Definition at line 195 of file class.ilCourseObjective.php.

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

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

+ Here is the call graph for this function:

Field Documentation

ilCourseObjective::$course_obj = null

Definition at line 17 of file class.ilCourseObjective.php.

Referenced by ilCourseObjective().

ilCourseObjective::$db = null

Definition at line 15 of file class.ilCourseObjective.php.

ilCourseObjective::$objective_id = null

Definition at line 18 of file class.ilCourseObjective.php.

Referenced by getObjectiveId(), and ilClone().


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