27 $this->objective_id = $a_objective_id;
28 if($this->objective_id)
46 $query =
"SELECT crs_id FROM crs_objectives ".
47 "WHERE objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
68 $query =
"SELECT * FROM crs_objectives ".
69 "WHERE crs_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
71 return $res->numRows() ?
true :
false;
82 public function ilClone($a_target_id,$a_copy_id)
86 $ilLog->write(__METHOD__.
': Start cloning learning objectives...');
88 $query =
"SELECT * FROM crs_objectives ".
89 "WHERE crs_id = ".$this->db->quote($this->course_obj->getId() ,
'integer').
' '.
94 $ilLog->write(__METHOD__.
': ... no objectives found.');
100 $ilLog->write(__METHOD__.
': Cannot init new course object.');
106 $new_objective->setTitle(
$row->title);
107 $new_objective->setDescription(
$row->description);
109 $ilLog->write(__METHOD__.
': Added new objective nr: '.
$objective_id);
112 include_once(
'Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
116 $ilLog->write(__METHOD__.
': Finished objective question dependencies: '.
$objective_id);
119 include_once(
'Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
121 $objective_material->cloneDependencies(
$objective_id,$a_copy_id);
123 $ilLog->write(__METHOD__.
': Finished cloning objectives.');
128 $this->title = $a_title;
136 $this->description = $a_description;
140 return $this->description;
144 $this->objective_id = $a_objective_id;
155 $next_id = $ilDB->nextId(
'crs_objectives');
156 $query =
"INSERT INTO crs_objectives (crs_id,objective_id,title,description,position,created) ".
158 $ilDB->quote($this->course_obj->getId() ,
'integer').
", ".
159 $ilDB->quote($next_id,
'integer').
", ".
160 $ilDB->quote($this->
getTitle() ,
'text').
", ".
163 $ilDB->quote(time() ,
'integer').
" ".
168 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
171 return $this->objective_id = $next_id;
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').
"";
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').
" ";
214 return (
bool) strlen($this->
getTitle());
221 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
224 $tmp_obj_qst->deleteAll();
226 include_once
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
229 $tmp_obj_lm->deleteAll();
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').
" ";
238 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
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').
" ";
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').
" ";
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').
" ";
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').
" ";
309 $this->position = $a_position;
313 return $this->position;
317 $this->created = $a_created;
321 return $this->created;
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').
" ";
352 switch($this->course_obj->getOrderType())
355 return 'ORDER BY position';
358 return 'ORDER BY title';
361 return 'ORDER BY create';
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').
" ";
383 $query =
"SELECT MAX(position) pos FROM crs_objectives ".
384 "WHERE crs_id = ".$ilDB->quote($this->course_obj->getId() ,
'integer').
" ";
399 $query =
"SELECT objective_id FROM crs_objectives ".
400 "WHERE crs_id = ".$ilDB->quote($course_id ,
'integer').
" ".
406 $ids[] =
$row->objective_id;
409 return $ids ? $ids : array();
423 $in = $ilDB->in(
'objective_id',$ids,
false,
'integer');
426 $query =
"DELETE FROM crs_objective_lm WHERE ".$in;
429 $query =
"DELETE FROM crs_objective_tst WHERE ".$in;
432 $query =
"DELETE FROM crs_objective_qst WHERE ".$in;
435 $query =
"DELETE FROM crs_objectives WHERE crs_id = ".$ilDB->quote($course_id ,
'integer');
439 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");