ILIAS  Release_3_10_x_branch Revision 61812
 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 smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilCourseObjective.php 17216 2008-08-21 16:26:00Z smeyer

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

Member Function Documentation

ilCourseObjective::__getCreated ( )

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

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

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

References $res, and DB_FETCHMODE_OBJECT.

Referenced by moveDown().

{
global $ilDB;
$query = "SELECT MAX(position) AS pos FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($this->course_obj->getId())." ";
$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 364 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 325 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 339 of file class.ilCourseObjective.php.

References $res, __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())." ".
"AND objective_id = ".$ilDB->quote($this->getObjectiveId())." ";
$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 329 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 321 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 380 of file class.ilCourseObjective.php.

References __getPosition().

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

+ Here is the call graph for this function:

ilCourseObjective::_deleteAll (   $course_id)

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

References $in, _getObjectiveIds(), and ilUtil\quoteArray().

Referenced by ilObjCourse\delete().

{
global $ilDB;
if(!count($ids))
{
return true;
}
$in = "IN (";
$in .= implode(",",ilUtil::quoteArray($ids));
$in .= ")";
$query = "DELETE FROM crs_objective_lm WHERE objective_id ".$in;
$ilDB->query($query);
$query = "DELETE FROM crs_objective_tst WHERE objective_id ".$in;
$ilDB->query($query);
$query = "DELETE FROM crs_objective_qst WHERE objective_id ".$in;
$ilDB->query($query);
$query = "DELETE FROM crs_objectives WHERE crs_id = ".$ilDB->quote($course_id);
$ilDB->query($query);
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 85 of file class.ilCourseObjective.php.

References $res.

Referenced by ilObjCourseGUI\getTabs().

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

+ Here is the caller graph for this function:

ilCourseObjective::_getObjectiveIds (   $course_id)

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

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilCourseObjectivePresentationGUI\__showInfo(), ilCourseObjectivePresentationGUI\__showObjectives(), _deleteAll(), ilCourseObjectiveResult\_getAccomplished(), ilLPCollections\_getItems(), ilLPStatusObjectives\_getStatusInfo(), ilCourseObjectiveResult\_getSuggested(), ilCourseObjectiveResult\getStatus(), ilContainerObjectiveGUI\initDetails(), ilCourseObjectivesGUI\listObjectives(), ilCourseObjectivesGUI\questionOverview(), ilCourseObjectiveResult\readStatus(), ilCourseObjectiveResult\reset(), and ilContainerObjectiveGUI\showObjectives().

{
global $ilDB;
$query = "SELECT objective_id FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($course_id)." ".
"ORDER BY position";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$ids[] = $row->objective_id;
}
return $ids ? $ids : array();
}

+ Here is the caller graph for this function:

static ilCourseObjective::_lookupContainerIdByObjectiveId (   $a_objective_id)
static

Get container of object.

public

Parameters
intobjective id

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

References $res, 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);
$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 172 of file class.ilCourseObjective.php.

{
global $ilDB;
$query = "INSERT INTO crs_objectives ".
"SET crs_id = ".$ilDB->quote($this->course_obj->getId()).", ".
"title = ".$ilDB->quote($this->getTitle()).", ".
"description = ".$ilDB->quote($this->getDescription()).", ".
"position = ".$ilDB->quote($this->__getLastPosition() + 1).", ".
"created = ".$ilDB->quote(time());
$this->db->query($query);
return $this->objective_id = $this->db->getLastInsertId();
}
ilCourseObjective::delete ( )

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

References 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())." ".
"AND objective_id = ".$ilDB->quote($this->getObjectiveId())." ";
$this->db->query($query);
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::getDescription ( )

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

Referenced by update().

{
return $this->description;
}

+ Here is the caller graph for this function:

ilCourseObjective::getObjectiveId ( )

Definition at line 167 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 151 of file class.ilCourseObjective.php.

References $title.

Referenced by 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 103 of file class.ilCourseObjective.php.

References $ilLog, $objective_id, $res, 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()).
"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 41 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 287 of file class.ilCourseObjective.php.

References __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)." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId())." ";
$this->db->query($query);
$query = "UPDATE crs_objectives ".
"SET position = position + 1 ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId())." ";
$this->db->query($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::moveUp ( )

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

References __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)." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId())." ";
$this->db->query($query);
$query = "UPDATE crs_objectives ".
"SET position = position - 1 ".
"WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
"AND crs_id = ".$ilDB->quote($this->course_obj->getId())." ";
$this->db->query($query);
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilCourseObjective::setDescription (   $a_description)

Definition at line 155 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 163 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 147 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 188 of file class.ilCourseObjective.php.

References getDescription(), getObjectiveId(), and getTitle().

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

+ Here is the call graph for this function:

ilCourseObjective::validate ( )

validate

public

Parameters
@return

Definition at line 225 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 210 of file class.ilCourseObjective.php.

References getObjectiveId().

{
$query = "UPDATE crs_objectives ".
"SET position = ".$this->db->quote((string) $a_position)." ".
"WHERE objective_id = ".$this->db->quote($this->getObjectiveId())." ";
$this->db->query($query);
}

+ Here is the call graph for this function:

Field Documentation

ilCourseObjective::$course_obj = null

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

Referenced by ilCourseObjective().

ilCourseObjective::$db = null

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

ilCourseObjective::$objective_id = null

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

Referenced by getObjectiveId(), and ilClone().


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