48 $this->objective_id = $a_objective_id;
49 if($this->objective_id)
67 $query =
"SELECT crs_id FROM crs_objectives ".
68 "WHERE objective_id = ".$ilDB->quote($a_objective_id);
69 $res = $ilDB->query($query);
89 $query =
"SELECT * FROM crs_objectives ".
90 "WHERE crs_id = ".$ilDB->quote($a_obj_id).
" ";
91 $res = $ilDB->query($query);
92 return $res->numRows() ?
true :
false;
103 public function ilClone($a_target_id,$a_copy_id)
107 $ilLog->write(__METHOD__.
': Start cloning learning objectives...');
109 $query =
"SELECT * FROM crs_objectives ".
110 "WHERE crs_id = ".$this->db->quote($this->course_obj->getId()).
111 "ORDER BY position ";
112 $res = $this->db->query($query);
115 $ilLog->write(__METHOD__.
': ... no objectives found.');
121 $ilLog->write(__METHOD__.
': Cannot init new course object.');
127 $new_objective->setTitle($row->title);
128 $new_objective->setDescription($row->description);
130 $ilLog->write(__METHOD__.
': Added new objective nr: '.
$objective_id);
133 include_once(
'Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
137 $ilLog->write(__METHOD__.
': Finished objective question dependencies: '.
$objective_id);
140 include_once(
'Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
142 $objective_material->cloneDependencies(
$objective_id,$a_copy_id);
144 $ilLog->write(__METHOD__.
': Finished cloning objectives.');
149 $this->title = $a_title;
157 $this->description = $a_description;
161 return $this->description;
165 $this->objective_id = $a_objective_id;
176 $query =
"INSERT INTO crs_objectives ".
177 "SET crs_id = ".$ilDB->quote($this->course_obj->getId()).
", ".
178 "title = ".$ilDB->quote($this->getTitle()).
", ".
179 "description = ".$ilDB->quote($this->getDescription()).
", ".
180 "position = ".$ilDB->quote($this->__getLastPosition() + 1).
", ".
181 "created = ".$ilDB->quote(time());
183 $this->db->query($query);
185 return $this->objective_id = $this->db->getLastInsertId();
192 $query =
"UPDATE crs_objectives ".
193 "SET title = ".$ilDB->quote($this->
getTitle()).
", ".
195 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
196 "AND crs_id = ".$ilDB->quote($this->course_obj->getId()).
"";
198 $this->db->query($query);
212 $query =
"UPDATE crs_objectives ".
213 "SET position = ".$this->db->quote((
string) $a_position).
" ".
214 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId()).
" ";
215 $this->db->query($query);
227 return (
bool) strlen($this->
getTitle());
234 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
237 $tmp_obj_qst->deleteAll();
239 include_once
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
242 $tmp_obj_lm->deleteAll();
245 $query =
"DELETE FROM crs_objectives ".
246 "WHERE crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ".
247 "AND objective_id = ".$ilDB->quote($this->getObjectiveId()).
" ";
249 $this->db->query($query);
268 $query =
"UPDATE crs_objectives ".
269 "SET position = position + 1 ".
270 "WHERE position = ".$ilDB->quote($this->
__getPosition() - 1).
" ".
271 "AND crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ";
273 $this->db->query($query);
275 $query =
"UPDATE crs_objectives ".
276 "SET position = position - 1 ".
277 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
278 "AND crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ";
280 $this->db->query($query);
301 $query =
"UPDATE crs_objectives ".
302 "SET position = position - 1 ".
303 "WHERE position = ".$ilDB->quote($this->
__getPosition() + 1).
" ".
304 "AND crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ";
306 $this->db->query($query);
308 $query =
"UPDATE crs_objectives ".
309 "SET position = position + 1 ".
310 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
311 "AND crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ";
313 $this->db->query($query);
323 $this->position = $a_position;
327 return $this->position;
331 $this->created = $a_created;
335 return $this->created;
345 $query =
"SELECT * FROM crs_objectives ".
346 "WHERE crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ".
347 "AND objective_id = ".$ilDB->quote($this->getObjectiveId()).
" ";
350 $res = $this->db->query($query);
366 switch($this->course_obj->getOrderType())
369 return 'ORDER BY position';
372 return 'ORDER BY title';
375 return 'ORDER BY create';
384 $query =
"UPDATE crs_objectives ".
385 "SET position = position - 1 ".
386 "WHERE position > ".$ilDB->quote($this->
__getPosition()).
" ".
387 "AND crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ";
389 $this->db->query($query);
398 $query =
"SELECT MAX(position) AS pos FROM crs_objectives ".
399 "WHERE crs_id = ".$ilDB->quote($this->course_obj->getId()).
" ";
401 $res = $this->db->query($query);
414 $query =
"SELECT objective_id FROM crs_objectives ".
415 "WHERE crs_id = ".$ilDB->quote($course_id).
" ".
418 $res = $ilDB->query($query);
421 $ids[] = $row->objective_id;
424 return $ids ? $ids : array();
441 $query =
"DELETE FROM crs_objective_lm WHERE objective_id ".$in;
442 $ilDB->query($query);
444 $query =
"DELETE FROM crs_objective_tst WHERE objective_id ".$in;
445 $ilDB->query($query);
447 $query =
"DELETE FROM crs_objective_qst WHERE objective_id ".$in;
448 $ilDB->query($query);
450 $query =
"DELETE FROM crs_objectives WHERE crs_id = ".$ilDB->quote($course_id);
451 $ilDB->query($query);