ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules 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 More...
 
 setTitle ($a_title)
 
 getTitle ()
 
 setDescription ($a_description)
 
 getDescription ()
 
 setObjectiveId ($a_objective_id)
 
 getObjectiveId ()
 
 add ()
 
 update ()
 
 writePosition ($a_position)
 write position More...
 
 validate ()
 validate More...
 
 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. More...
 
static _getCountObjectives ($a_obj_id)
 get count objectives More...
 

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

◆ __getCreated()

ilCourseObjective::__getCreated ( )

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

320  {
321  return $this->created;
322  }

◆ __getLastPosition()

ilCourseObjective::__getLastPosition ( )

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

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

Referenced by add(), and moveDown().

380  {
381  global $ilDB;
382 
383  $query = "SELECT MAX(position) pos FROM crs_objectives ".
384  "WHERE crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
385 
386  $res = $this->db->query($query);
387  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
388  {
389  return $row->pos;
390  }
391  return 0;
392  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ __getOrderColumn()

ilCourseObjective::__getOrderColumn ( )

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

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

351  {
352  switch($this->course_obj->getOrderType())
353  {
355  return 'ORDER BY position';
356 
358  return 'ORDER BY title';
359 
361  return 'ORDER BY create';
362  }
363  return false;
364  }

◆ __getPosition()

ilCourseObjective::__getPosition ( )

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

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

312  {
313  return $this->position;
314  }
+ Here is the caller graph for this function:

◆ __read()

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

326  {
327  global $ilDB;
328 
329  if($this->getObjectiveId())
330  {
331  $query = "SELECT * FROM crs_objectives ".
332  "WHERE crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ".
333  "AND objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
334 
335 
336  $res = $this->db->query($query);
337  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
338  {
339  $this->setObjectiveId($row->objective_id);
340  $this->setTitle($row->title);
341  $this->setDescription($row->description);
342  $this->__setPosition($row->position);
343  $this->__setCreated($row->created);
344  }
345  return true;
346  }
347  return false;
348  }
setObjectiveId($a_objective_id)
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setDescription($a_description)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __setCreated()

ilCourseObjective::__setCreated (   $a_created)

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

Referenced by __read().

316  {
317  $this->created = $a_created;
318  }
+ Here is the caller graph for this function:

◆ __setPosition()

ilCourseObjective::__setPosition (   $a_position)

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

Referenced by __read().

308  {
309  $this->position = $a_position;
310  }
+ Here is the caller graph for this function:

◆ __updateTop()

ilCourseObjective::__updateTop ( )

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

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

367  {
368  global $ilDB;
369 
370  $query = "UPDATE crs_objectives ".
371  "SET position = position - 1 ".
372  "WHERE position > ".$ilDB->quote($this->__getPosition() ,'integer')." ".
373  "AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
374  $res = $ilDB->manipulate($query);
375 
376  return true;
377  }
+ Here is the call graph for this function:

◆ _deleteAll()

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

413  {
414  global $ilDB;
415 
416  $ids = ilCourseObjective::_getObjectiveIds($course_id);
417 
418  if(!count($ids))
419  {
420  return true;
421  }
422 
423  $in = $ilDB->in('objective_id',$ids,false,'integer');
424 
425 
426  $query = "DELETE FROM crs_objective_lm WHERE ".$in;
427  $res = $ilDB->manipulate($query);
428 
429  $query = "DELETE FROM crs_objective_tst WHERE ".$in;
430  $res = $ilDB->manipulate($query);
431 
432  $query = "DELETE FROM crs_objective_qst WHERE ".$in;
433  $res = $ilDB->manipulate($query);
434 
435  $query = "DELETE FROM crs_objectives WHERE crs_id = ".$ilDB->quote($course_id ,'integer');
436  $res = $ilDB->manipulate($query);
437 
438  // refresh learning progress status after deleting objectives
439  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
441 
442  return true;
443  }
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getCountObjectives()

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

65  {
66  global $ilDB;
67 
68  $query = "SELECT * FROM crs_objectives ".
69  "WHERE crs_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
70  $res = $ilDB->query($query);
71  return $res->numRows() ? true : false;
72  }
+ Here is the caller graph for this function:

◆ _getObjectiveIds()

ilCourseObjective::_getObjectiveIds (   $course_id)

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

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

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

396  {
397  global $ilDB;
398 
399  $query = "SELECT objective_id FROM crs_objectives ".
400  "WHERE crs_id = ".$ilDB->quote($course_id ,'integer')." ".
401  "ORDER BY position";
402 
403  $res = $ilDB->query($query);
404  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
405  {
406  $ids[] = $row->objective_id;
407  }
408 
409  return $ids ? $ids : array();
410  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _lookupContainerIdByObjectiveId()

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

43  {
44  global $ilDB;
45 
46  $query = "SELECT crs_id FROM crs_objectives ".
47  "WHERE objective_id = ".$ilDB->quote($a_objective_id ,'integer');
48  $res = $ilDB->query($query);
49  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
50  {
51  return $row->crs_id;
52  }
53  return false;
54  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ add()

ilCourseObjective::add ( )

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

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

152  {
153  global $ilDB;
154 
155  $next_id = $ilDB->nextId('crs_objectives');
156  $query = "INSERT INTO crs_objectives (crs_id,objective_id,title,description,position,created) ".
157  "VALUES( ".
158  $ilDB->quote($this->course_obj->getId() ,'integer').", ".
159  $ilDB->quote($next_id,'integer').", ".
160  $ilDB->quote($this->getTitle() ,'text').", ".
161  $ilDB->quote($this->getDescription() ,'text').", ".
162  $ilDB->quote($this->__getLastPosition() + 1 ,'integer').", ".
163  $ilDB->quote(time() ,'integer')." ".
164  ")";
165  $res = $ilDB->manipulate($query);
166 
167  // refresh learning progress status after adding new objective
168  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
169  ilLPStatusWrapper::_refreshStatus($this->course_obj->getId());
170 
171  return $this->objective_id = $next_id;
172  }
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
+ Here is the call graph for this function:

◆ delete()

ilCourseObjective::delete ( )

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

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

218  {
219  global $ilDB;
220 
221  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
222 
223  $tmp_obj_qst =& new ilCourseObjectiveQuestion($this->getObjectiveId());
224  $tmp_obj_qst->deleteAll();
225 
226  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
227 
228  $tmp_obj_lm =& new ilCourseObjectiveMaterials($this->getObjectiveId());
229  $tmp_obj_lm->deleteAll();
230 
231 
232  $query = "DELETE FROM crs_objectives ".
233  "WHERE crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ".
234  "AND objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
235  $res = $ilDB->manipulate($query);
236 
237  // refresh learning progress status after deleting objective
238  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
239  ilLPStatusWrapper::_refreshStatus($this->course_obj->getId());
240 
241  return true;
242  }
class ilCourseObjectiveMaterials
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
class ilcourseobjectiveQuestion
+ Here is the call graph for this function:

◆ getDescription()

ilCourseObjective::getDescription ( )

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

Referenced by add(), and update().

139  {
140  return $this->description;
141  }
+ Here is the caller graph for this function:

◆ getObjectiveId()

ilCourseObjective::getObjectiveId ( )

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

References $objective_id.

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

147  {
148  return $this->objective_id;
149  }
+ Here is the caller graph for this function:

◆ getTitle()

ilCourseObjective::getTitle ( )

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

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

131  {
132  return $this->title;
133  }
+ Here is the caller graph for this function:

◆ ilClone()

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, $query, $res, $row, DB_FETCHMODE_OBJECT, ilObjectFactory\getInstanceByRefId(), and ilCourseObjective().

83  {
84  global $ilLog;
85 
86  $ilLog->write(__METHOD__.': Start cloning learning objectives...');
87 
88  $query = "SELECT * FROM crs_objectives ".
89  "WHERE crs_id = ".$this->db->quote($this->course_obj->getId() ,'integer').' '.
90  "ORDER BY position ";
91  $res = $this->db->query($query);
92  if(!$res->numRows())
93  {
94  $ilLog->write(__METHOD__.': ... no objectives found.');
95  return true;
96  }
97 
98  if(!is_object($new_course = ilObjectFactory::getInstanceByRefId($a_target_id,false)))
99  {
100  $ilLog->write(__METHOD__.': Cannot init new course object.');
101  return true;
102  }
103  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
104  {
105  $new_objective = new ilCourseObjective($new_course);
106  $new_objective->setTitle($row->title);
107  $new_objective->setDescription($row->description);
108  $objective_id = $new_objective->add();
109  $ilLog->write(__METHOD__.': Added new objective nr: '.$objective_id);
110 
111  // Clone crs_objective_tst entries
112  include_once('Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
113  $objective_qst = new ilCourseObjectiveQuestion($row->objective_id);
114  $objective_qst->cloneDependencies($objective_id,$a_copy_id);
115 
116  $ilLog->write(__METHOD__.': Finished objective question dependencies: '.$objective_id);
117 
118  // Clone crs_objective_lm entries (assigned course materials)
119  include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
120  $objective_material = new ilCourseObjectiveMaterials($row->objective_id);
121  $objective_material->cloneDependencies($objective_id,$a_copy_id);
122  }
123  $ilLog->write(__METHOD__.': Finished cloning objectives.');
124  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
class ilCourseObjectiveMaterials
ilCourseObjective(&$course_obj, $a_objective_id=0)
class ilcourseobjectiveQuestion
+ Here is the call graph for this function:

◆ ilCourseObjective()

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

21  {
22  global $ilDB;
23 
24  $this->db =& $ilDB;
25  $this->course_obj =& $course_obj;
26 
27  $this->objective_id = $a_objective_id;
28  if($this->objective_id)
29  {
30  $this->__read();
31  }
32  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveDown()

ilCourseObjective::moveDown ( )

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

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

276  {
277  global $ilDB;
278 
279  if(!$this->getObjectiveId())
280  {
281  return false;
282  }
283  // Stop if position is last
284  if($this->__getPosition() == $this->__getLastPosition())
285  {
286  return false;
287  }
288 
289  $query = "UPDATE crs_objectives ".
290  "SET position = position - 1 ".
291  "WHERE position = ".$ilDB->quote($this->__getPosition() + 1 ,'integer')." ".
292  "AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
293  $res = $ilDB->manipulate($query);
294 
295  $query = "UPDATE crs_objectives ".
296  "SET position = position + 1 ".
297  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
298  "AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
299  $res = $ilDB->manipulate($query);
300 
301  $this->__read();
302 
303  return true;
304  }
+ Here is the call graph for this function:

◆ moveUp()

ilCourseObjective::moveUp ( )

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

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

245  {
246  global $ilDB;
247 
248  if(!$this->getObjectiveId())
249  {
250  return false;
251  }
252  // Stop if position is first
253  if($this->__getPosition() == 1)
254  {
255  return false;
256  }
257 
258  $query = "UPDATE crs_objectives ".
259  "SET position = position + 1 ".
260  "WHERE position = ".$ilDB->quote($this->__getPosition() - 1 ,'integer')." ".
261  "AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
262  $res = $ilDB->manipulate($query);
263 
264  $query = "UPDATE crs_objectives ".
265  "SET position = position - 1 ".
266  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
267  "AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')." ";
268  $res = $ilDB->manipulate($query);
269 
270  $this->__read();
271 
272  return true;
273  }
+ Here is the call graph for this function:

◆ setDescription()

ilCourseObjective::setDescription (   $a_description)

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

Referenced by __read().

135  {
136  $this->description = $a_description;
137  }
+ Here is the caller graph for this function:

◆ setObjectiveId()

ilCourseObjective::setObjectiveId (   $a_objective_id)

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

Referenced by __read().

143  {
144  $this->objective_id = $a_objective_id;
145  }
+ Here is the caller graph for this function:

◆ setTitle()

ilCourseObjective::setTitle (   $a_title)

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

Referenced by __read().

127  {
128  $this->title = $a_title;
129  }
+ Here is the caller graph for this function:

◆ update()

ilCourseObjective::update ( )

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

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

175  {
176  global $ilDB;
177 
178  $query = "UPDATE crs_objectives ".
179  "SET title = ".$ilDB->quote($this->getTitle() ,'text').", ".
180  "description = ".$ilDB->quote($this->getDescription() ,'text')." ".
181  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
182  "AND crs_id = ".$ilDB->quote($this->course_obj->getId() ,'integer')."";
183  $res = $ilDB->manipulate($query);
184 
185  return true;
186  }
+ Here is the call graph for this function:

◆ validate()

ilCourseObjective::validate ( )

validate

public

Parameters

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

References getTitle().

213  {
214  return (bool) strlen($this->getTitle());
215  }
+ Here is the call graph for this function:

◆ writePosition()

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

196  {
197  global $ilDB;
198 
199  $query = "UPDATE crs_objectives ".
200  "SET position = ".$this->db->quote((string) $a_position ,'integer')." ".
201  "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ";
202  $res = $ilDB->manipulate($query);
203  }
+ Here is the call graph for this function:

Field Documentation

◆ $course_obj

ilCourseObjective::$course_obj = null

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

Referenced by ilCourseObjective().

◆ $db

ilCourseObjective::$db = null

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

◆ $objective_id

ilCourseObjective::$objective_id = null

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

Referenced by getObjectiveId().


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