51 $this->objective_id = $a_objective_id;
71 $query =
"SELECT qst_ass_id FROM crs_objective_qst ".
72 "WHERE ref_id = ".$ilDB->quote($a_test_id).
" ".
73 "AND objective_id = ".$ilDB->quote($a_objective_id);
74 $res = $ilDB->query($query);
75 return $res->numRows() ?
true :
false;
89 global $ilObjDataCache,
$ilLog;
91 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
93 $mappings = $cwo->getMappings();
96 if(!isset($mappings[
"$question[ref_id]"]) or !$mappings[
"$question[ref_id]"])
100 $question_ref_id = $question[
'ref_id'];
101 $question_obj_id = $question[
'obj_id'];
102 $question_qst_id = $question[
'question_id'];
103 $new_ref_id = $mappings[$question_ref_id];
104 $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
106 if($new_obj_id == $question_obj_id)
108 $ilLog->write(__METHOD__.
': Test has been linked. Keeping question id.');
110 $new_question_id = $question_qst_id;
114 $new_question_info = $mappings[$question_ref_id.
'_'.$question_qst_id];
115 $new_question_arr = explode(
'_',$new_question_info);
116 if(!isset($new_question_arr[1]) or !$new_question_arr[1])
120 $new_question_id = $new_question_arr[1];
121 $ilLog->write(__METHOD__.
': New question id is: '.$new_question_id);
125 $new_question->setTestRefId($new_ref_id);
126 $new_question->setTestObjId($new_obj_id);
127 $new_question->setQuestionId($new_question_id);
128 $new_question->add();
134 $new_test_id = $mappings[
"$test[ref_id]"];
136 $query =
"UPDATE crs_objective_tst ".
137 "SET tst_status = ".$this->db->quote($test[
'tst_status']).
", ".
138 "tst_limit = ".$this->db->quote($test[
'tst_limit']).
" ".
139 "WHERE objective_id = ".$this->db->quote($a_new_objective).
" ".
140 "AND ref_id = ".$this->db->quote($new_test_id);
141 $this->db->query($query);
157 return $tree->getSubTree($tree->getNodeData($a_container_ref_id),
true,
'tst');
163 $this->tst_status = $a_status;
167 return (
int) $this->tst_status;
171 $this->tst_limit = $a_limit;
175 return (
int) $this->tst_limit;
181 $query =
"UPDATE crs_objective_tst ".
182 "SET tst_status = ".$this->db->quote($this->
getTestStatus()).
" ".
183 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId()).
" ".
184 "AND ref_id = ".$this->db->quote($this->
getTestRefId()).
" ";
185 $this->db->query($query);
189 $query =
"SELECT * FROM crs_objective_tst ".
190 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
193 $res = $this->db->query($query);
200 $query =
"SELECT tst_limit FROM crs_objective_tst ".
201 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId()).
" ".
202 "AND tst_status = ".$this->db->quote($this->
getTestStatus()).
" ";
204 $res = $this->db->query($query);
209 $limit = $row->tst_limit;
212 $query =
"INSERT INTO crs_objective_tst ".
217 "tst_limit = ".$this->db->quote($limit).
" ";
219 $this->db->query($query);
229 $query =
"DELETE FROM crs_objective_qst ".
230 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
231 "AND ref_id = ".$ilDB->quote($a_test_ref_id).
" ";
233 $this->db->query($query);
236 $query =
"DELETE FROM crs_objective_tst ".
237 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
238 "AND ref_id = ".$ilDB->quote($a_test_ref_id).
" ";
240 $this->db->query($query);
242 unset($this->tests[$a_test_ref_id]);
261 $query =
"UPDATE crs_objective_tst ".
262 "SET tst_limit = ".$ilDB->quote($a_limit).
" ".
263 "WHERE tst_status = ".$ilDB->quote($a_status).
" ".
264 "AND objective_id = ".$ilDB->quote($a_objective_id);
266 $ilDB->query($query);
274 $query =
"UPDATE crs_objective_tst ".
275 "SET tst_status = ".$ilDB->quote($this->
getTestStatus()).
", ".
277 "WHERE test_objective_id = ".$ilDB->quote($a_objective_id).
"";
279 $this->db->query($query);
288 $query =
"SELECT * FROM crs_objective_tst as cot ".
289 "JOIN object_data as obd ON cot.obj_id = obd.obj_id ".
290 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
293 $res = $this->db->query($query);
296 $test[
'test_objective_id'] = $row->test_objective_id;
297 $test[
'objective_id'] = $row->objective_id;
298 $test[
'ref_id'] = $row->ref_id;
299 $test[
'obj_id'] = $row->obj_id;
300 $test[
'tst_status'] = $row->tst_status;
301 $test[
'tst_limit'] = $row->tst_limit;
302 $test[
'title'] = $row->title;
319 foreach($this->tests as
$test)
326 return $self ? $self : array();
337 foreach($this->tests as
$test)
339 if($test[
'status'] == self::TYPE_FINAL_TEST)
344 return $final ? $final : array();
351 $query =
"SELECT * FROM crs_objective_tst ".
352 "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id).
" ";
354 $res = $ilDB->query($query);
357 $test[
'test_objective_id'] = $row->test_objective_id;
358 $test[
'objective_id'] = $row->objective_id;
359 $test[
'ref_id'] = $row->ref_id;
360 $test[
'obj_id'] = $row->obj_id;
361 $test[
'tst_status'] = $row->tst_status;
362 $test[
'tst_limit'] = $row->tst_limit;
371 return $this->questions ? $this->questions : array();
382 foreach($this->questions as $question)
389 return $self ? $self : array();
402 $points += $question[
'points'];
404 return $points ? $points : 0;
417 $points += $question[
'points'];
419 return $points ? $points : 0;
430 foreach($this->questions as $question)
432 if($question[
'question_id'] == $a_question_id)
449 foreach($this->questions as $question)
451 if($question[
'question_id'] == $a_question_id)
468 foreach($this->questions as $question)
470 if($question[
'test_type'] == self::TYPE_FINAL_TEST)
472 $final[] = $question;
475 return $final ? $final : array();
491 if($a_test_id == $qst[
'obj_id'])
501 return $this->questions[$question_id] ? $this->questions[$question_id] : array();
511 $this->tst_ref_id = $a_ref_id;
515 return $this->tst_ref_id ? $this->tst_ref_id : 0;
519 $this->tst_obj_id = $a_obj_id;
523 return $this->tst_obj_id ? $this->tst_obj_id : 0;
527 $this->question_id = $a_question_id;
531 return $this->question_id;
537 include_once
'./Modules/Test/classes/class.ilObjTest.php';
546 $points += $tmp_question->getMaximumPoints();
548 unset($tmp_question);
562 if($question[
'ref_id'] == $a_test_ref_id)
566 $points += $tmp_question->getMaximumPoints();
568 unset($tmp_question);
586 include_once(
'Modules/TestQuestionPool/classes/class.assQuestion.php');
597 if($question[
'ref_id'] == $a_test_ref_id)
609 if($question[
'ref_id'] == $a_test_ref_id)
611 $qst[] = $question[
'question_id'];
614 return $qst ? $qst : array();
626 foreach($this->tests as
$ref_id => $test_data)
628 switch($test_data[
'status'])
634 case self::TYPE_FINAL_TEST:
638 if($test_data[
'limit'] == -1 or $test_data[
'limit'] > $points)
640 switch($test_data[
'status'])
646 case self::TYPE_FINAL_TEST:
650 $query =
"UPDATE crs_objective_tst ".
651 "SET tst_limit = ".$this->db->quote($points).
" ".
652 "WHERE test_objective_id = ".$this->db->quote($test_data[
'test_objective_id']).
" ";
653 $this->db->query($query);
663 $query =
"DELETE FROM crs_objective_qst ".
664 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId()).
" ".
665 "AND question_id = ".$this->db->quote($this->
getQuestionId()).
" ";
666 $this->db->query($query);
669 $query =
"INSERT INTO crs_objective_qst ".
675 $this->db->query($query);
683 function delete($qst_id)
692 $query =
"SELECT * FROM crs_objective_qst ".
693 "WHERE qst_ass_id = ".$ilDB->quote($qst_id).
" ";
695 $res = $this->db->query($query);
698 $test_rid = $row->ref_id;
699 $test_oid = $row->obj_id;
702 $query =
"DELETE FROM crs_objective_qst ".
703 "WHERE qst_ass_id = ".$ilDB->quote($qst_id).
" ";
705 $this->db->query($query);
708 $query =
"SELECT * FROM crs_objective_qst ".
709 "WHERE ref_id = ".$ilDB->quote($test_rid).
" ".
710 "AND obj_id = ".$ilDB->quote($test_oid).
" ".
714 $res = $this->db->query($query);
727 $query =
"DELETE FROM crs_objective_qst ".
728 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ";
730 $this->db->query($query);
732 $query =
"DELETE FROM crs_objective_tst ".
733 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ";
735 $this->db->query($query);
746 include_once
'./Modules/Test/classes/class.ilObjTest.php';
747 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
750 $container_ref_id = current($container_ref_ids);
753 $query =
"SELECT * FROM crs_objective_tst ".
754 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ";
755 $res = $this->db->query($query);
758 $this->tests[$row->ref_id][
'test_objective_id'] = $row->test_objective_id;
759 $this->tests[$row->ref_id][
'ref_id'] = $row->ref_id;
760 $this->tests[$row->ref_id][
'obj_id'] = $row->obj_id;
761 $this->tests[$row->ref_id][
'status'] = $row->tst_status;
762 $this->tests[$row->ref_id][
'limit'] = $row->tst_limit;
765 $this->questions = array();
766 $query =
"SELECT * FROM crs_objective_qst as coq ".
767 "JOIN qpl_questions as qq ON coq.question_id = qq.question_id ".
768 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId()).
" ".
771 $res = $this->db->query($query);
774 if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
781 $this->
delete($row->question_id);
785 $qst[
'ref_id'] = $row->ref_id;
786 $qst[
'obj_id'] = $row->obj_id;
787 $qst[
'question_id'] = $row->question_id;
788 $qst[
'qst_ass_id'] = $row->qst_ass_id;
789 $qst[
'title'] = $question->getTitle();
790 $qst[
'description'] = $question->getComment();
791 $qst[
'test_type'] = $this->tests[$row->ref_id][
'status'];
792 $qst[
'points'] = $question->getPoints();
794 $this->questions[$row->qst_ass_id] = $qst;
812 $query =
"SELECT co.objective_id FROM crs_objectives AS co JOIN ".
813 "crs_objective_tst AS cot ON co.objective_id = cot.objective_id ".
814 "WHERE crs_id = ".$ilDB->quote($a_course_id).
" ";
815 $res = $ilDB->query($query);
816 return $res->numRows() ?
true :
false;
820 function _isAssigned($a_objective_id,$a_tst_ref_id,$a_question_id)
824 $query =
"SELECT crs_qst.objective_id as objective_id FROM crs_objective_qst as crs_qst, crs_objectives as crs_obj ".
825 "WHERE crs_qst.objective_id = crs_obj.objective_id ".
826 "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id) .
" ".
827 "AND ref_id = ".$ilDB->quote($a_tst_ref_id).
" ".
828 "AND question_id = ".$ilDB->quote($a_question_id).
" ";
830 $res = $ilDB->query($query);