ILIAS  Release_5_0_x_branch Revision 61816
 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
 setActive ($a_stat)
 isActive ()
 setPasses ($a_passes)
 getPasses ()
 arePassesLimited ()
 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 ()
 _deleteAll ($course_id)

Static Public Member Functions

static _lookupContainerIdByObjectiveId ($a_objective_id)
 Get container of object.
static _getCountObjectives ($a_obj_id, $a_activated_only=false)
 get count objectives
static lookupMaxPasses ($a_objective_id)
static lookupObjectiveTitle ($a_objective_id)
static _getObjectiveIds ($course_id, $a_activated_only=false)

Data Fields

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

Protected Attributes

 $active = true
 $passes = 0

Detailed Description

class ilcourseobjective

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilCourseObjective.php 57672 2015-01-30 12:47:06Z smeyer

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

Member Function Documentation

ilCourseObjective::__getCreated ( )

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

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

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

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

References $ilDB, $query, $res, $row, __setCreated(), __setPosition(), DB_FETCHMODE_OBJECT, getObjectiveId(), setActive(), setDescription(), setObjectiveId(), setPasses(), 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))
{
// begin-patch lok
$this->setActive($row->active);
$this->setPasses($row->passes);
// end-patch lok
$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 383 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 375 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 438 of file class.ilCourseObjective.php.

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

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

Referenced by ilObjCourse\delete().

{
global $ilDB;
// begin-patch lok
$ids = ilCourseObjective::_getObjectiveIds($course_id,false);
// end-patch lok
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,
  $a_activated_only = false 
)
static

get count objectives

public

Parameters
intobj_id
Returns

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

References _getObjectiveIds().

Referenced by ilLOEditorStatus\getObjectivesStatus(), and ilObjCourseGUI\getTabs().

{
return count(ilCourseObjective::_getObjectiveIds($a_obj_id,$a_activated_only));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCourseObjective::_getObjectiveIds (   $course_id,
  $a_activated_only = false 
)
static

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

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

Referenced by ilLOEditorStatus\__construct(), _deleteAll(), ilCourseObjectiveResult\_getAccomplished(), _getCountObjectives(), ilLPStatusObjectives\_getStatusInfo(), ilCourseObjectiveResult\_getSuggested(), ilLOEditorGUI\activateObjectives(), ilContainerObjectiveGUI\buildObjectiveMap(), ilLOEditorGUI\deactivateObjectives(), ilLPStatusObjectives\determineStatus(), ilLOEditorStatus\getObjectivesStatus(), ilCourseObjectiveResult\getStatus(), ilTrQuery\getUserObjectiveMatrix(), ilCourseObjectivesGUI\listObjectives(), ilLOEditorGUI\listObjectives(), ilCourseObjectivesGUI\questionOverview(), ilLPCollectionOfObjectives\read(), ilCourseObjectiveResult\readStatus(), ilObjCourseGUI\redirectLocToTestObject(), ilCourseObjectiveResult\reset(), and ilContainerObjectiveGUI\showObjectives().

{
global $ilDB;
if($a_activated_only)
{
$query = "SELECT objective_id FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($course_id ,'integer')." ".
'AND active = '.$ilDB->quote(1,'integer').' '.
"ORDER BY position";
}
else
{
$query = "SELECT objective_id FROM crs_objectives ".
"WHERE crs_id = ".$ilDB->quote($course_id ,'integer')." ".
"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 47 of file class.ilCourseObjective.php.

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

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

{
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 211 of file class.ilCourseObjective.php.

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

{
global $ilDB;
// begin-patch lok
$next_id = $ilDB->nextId('crs_objectives');
$query = "INSERT INTO crs_objectives (crs_id,objective_id,active,title,description,position,created,passes) ".
"VALUES( ".
$ilDB->quote($this->course_obj->getId() ,'integer').", ".
$ilDB->quote($next_id,'integer').", ".
$ilDB->quote($this->isActive(),'integer').', '.
$ilDB->quote($this->getTitle() ,'text').", ".
$ilDB->quote($this->getDescription() ,'text').", ".
$ilDB->quote($this->__getLastPosition() + 1 ,'integer').", ".
$ilDB->quote(time() ,'integer').", ".
$ilDB->quote($this->getPasses(),'integer').' '.
")";
$res = $ilDB->manipulate($query);
// end-patch lok
// 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::arePassesLimited ( )

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

{
return $this->passes > 0;
}
ilCourseObjective::delete ( )

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

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

Referenced by add(), ilContainerObjectiveGUI\buildAccordionTitle(), and update().

{
return $this->description;
}

+ Here is the caller graph for this function:

ilCourseObjective::getObjectiveId ( )

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

References $objective_id.

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

{
}

+ Here is the caller graph for this function:

ilCourseObjective::getPasses ( )

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

References $passes.

Referenced by add(), and update().

{
return $this->passes;
}

+ Here is the caller graph for this function:

ilCourseObjective::getTitle ( )

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

Referenced by add(), ilContainerObjectiveGUI\buildAccordionTitle(), 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 113 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);
$new_objective->setActive($row->active);
$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 25 of file class.ilCourseObjective.php.

References $course_obj, $ilDB, 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::isActive ( )

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

References $active.

Referenced by add(), and update().

{
return $this->active;
}

+ Here is the caller graph for this function:

static ilCourseObjective::lookupMaxPasses (   $a_objective_id)
static

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

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

Referenced by ilContainerObjectiveGUI\addItemDetails(), ilLOEditorStatus\checkNumberOfTries(), and ilLOUtils\lookupMaxAttempts().

{
global $ilDB;
$query = 'SELECT passes from crs_objectives '.
'WHERE objective_id = '.$ilDB->quote($a_objective_id,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return (int) $row->passes;
}
return 0;
}

+ Here is the caller graph for this function:

static ilCourseObjective::lookupObjectiveTitle (   $a_objective_id)
static

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

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

Referenced by ilLOEditorGUI\executeCommand(), ilPortfolioPageGUI\getCoursesOfUser(), ilTrMatrixTableGUI\getItems(), and ilContainerObjectiveGUI\renderTest().

{
global $ilDB;
$query = 'SELECT title 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->title;
}
return "";
}

+ Here is the caller graph for this function:

ilCourseObjective::moveDown ( )

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

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

References $ilDB, $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::setActive (   $a_stat)

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

Referenced by __read().

{
$this->active = $a_stat;
}

+ Here is the caller graph for this function:

ilCourseObjective::setDescription (   $a_description)

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

Referenced by __read().

{
$this->objective_id = $a_objective_id;
}

+ Here is the caller graph for this function:

ilCourseObjective::setPasses (   $a_passes)

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

Referenced by __read().

{
$this->passes = $a_passes;
}

+ Here is the caller graph for this function:

ilCourseObjective::setTitle (   $a_title)

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

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

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

+ Here is the call graph for this function:

ilCourseObjective::validate ( )

validate

public

Parameters
@return

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

References $ilDB, $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::$active = true
protected

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

Referenced by isActive().

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

ilCourseObjective::$passes = 0
protected

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

Referenced by getPasses().


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