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 ,
'integer').
" ".
73 "AND objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
75 return $res->numRows() ?
true :
false;
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'] ,
'integer').
", ".
138 "tst_limit = ".$this->db->quote($test[
'tst_limit'] ,
'integer').
" ".
139 "WHERE objective_id = ".$this->db->quote($a_new_objective ,
'integer').
" ".
140 "AND ref_id = ".$this->db->quote($new_test_id ,
'integer');
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() ,
'integer').
" ".
183 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
184 "AND ref_id = ".$this->db->quote($this->
getTestRefId() ,
'integer').
" ";
189 $query =
"SELECT * FROM crs_objective_tst ".
190 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
191 "AND ref_id = ".$ilDB->quote($this->
getTestRefId() ,
'integer').
"";
200 $query =
"SELECT tst_limit FROM crs_objective_tst ".
201 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
202 "AND tst_status = ".$this->db->quote($this->
getTestStatus() ,
'integer').
" ";
209 $limit =
$row->tst_limit;
212 $next_id = $ilDB->nextId(
'crs_objective_tst');
213 $query =
"INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit) ".
215 $ilDB->quote($next_id,
'integer').
", ".
220 $this->db->quote($limit ,
'integer').
" ".
232 $query =
"DELETE FROM crs_objective_qst ".
233 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
234 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,
'integer').
" ";
238 $query =
"DELETE FROM crs_objective_tst ".
239 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
240 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,
'integer').
" ";
243 unset($this->tests[$a_test_ref_id]);
262 $query =
"UPDATE crs_objective_tst ".
263 "SET tst_limit = ".$ilDB->quote($a_limit ,
'integer').
" ".
264 "WHERE tst_status = ".$ilDB->quote($a_status ,
'integer').
" ".
265 "AND objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
274 $query =
"UPDATE crs_objective_tst ".
275 "SET tst_status = ".$ilDB->quote($this->
getTestStatus() ,
'integer').
", ".
277 "WHERE test_objective_id = ".$ilDB->quote($a_objective_id ,
'integer').
"";
287 $query =
"SELECT * FROM crs_objective_tst cot ".
288 "JOIN object_data obd ON cot.obj_id = obd.obj_id ".
289 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
295 $test[
'test_objective_id'] =
$row->test_objective_id;
296 $test[
'objective_id'] =
$row->objective_id;
318 foreach($this->tests as
$test)
325 return $self ? $self : array();
336 foreach($this->tests as
$test)
338 if($test[
'status'] == self::TYPE_FINAL_TEST)
343 return $final ? $final : array();
350 $query =
"SELECT * FROM crs_objective_tst ".
351 "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id ,
'integer').
" ";
356 $test[
'test_objective_id'] =
$row->test_objective_id;
357 $test[
'objective_id'] =
$row->objective_id;
370 return $this->questions ? $this->questions : array();
381 foreach($this->questions as $question)
388 return $self ? $self : array();
401 $points += $question[
'points'];
416 $points += $question[
'points'];
429 foreach($this->questions as $question)
431 if($question[
'question_id'] == $a_question_id)
448 foreach($this->questions as $question)
450 if($question[
'question_id'] == $a_question_id)
467 foreach($this->questions as $question)
469 if($question[
'test_type'] == self::TYPE_FINAL_TEST)
471 $final[] = $question;
474 return $final ? $final : array();
490 if($a_test_id == $qst[
'obj_id'])
500 return $this->questions[$question_id] ? $this->questions[$question_id] : array();
510 $this->tst_ref_id = $a_ref_id;
514 return $this->tst_ref_id ? $this->tst_ref_id : 0;
518 $this->tst_obj_id = $a_obj_id;
522 return $this->tst_obj_id ? $this->tst_obj_id : 0;
526 $this->question_id = $a_question_id;
530 return $this->question_id;
536 include_once
'./Modules/Test/classes/class.ilObjTest.php';
545 $points += $tmp_question->getMaximumPoints();
547 unset($tmp_question);
561 if($question[
'ref_id'] == $a_test_ref_id)
565 $points += $tmp_question->getMaximumPoints();
567 unset($tmp_question);
585 include_once(
'Modules/TestQuestionPool/classes/class.assQuestion.php');
596 if($question[
'ref_id'] == $a_test_ref_id)
608 if($question[
'ref_id'] == $a_test_ref_id)
610 $qst[] = $question[
'question_id'];
613 return $qst ? $qst : array();
627 foreach($this->tests as
$ref_id => $test_data)
629 switch($test_data[
'status'])
635 case self::TYPE_FINAL_TEST:
639 if($test_data[
'limit'] == -1 or $test_data[
'limit'] >
$points)
641 switch($test_data[
'status'])
647 case self::TYPE_FINAL_TEST:
651 $query =
"UPDATE crs_objective_tst ".
652 "SET tst_limit = ".$this->db->quote(
$points ,
'integer').
" ".
653 "WHERE test_objective_id = ".$this->db->quote($test_data[
'test_objective_id'] ,
'integer').
" ";
664 $query =
"DELETE FROM crs_objective_qst ".
665 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
666 "AND question_id = ".$this->db->quote($this->
getQuestionId() ,
'integer').
" ";
669 $next_id = $ilDB->nextId(
'crs_objective_qst');
670 $query =
"INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) ".
672 $ilDB->quote($next_id,
'integer').
", ".
686 function delete($qst_id)
695 $query =
"SELECT * FROM crs_objective_qst ".
696 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,
'integer').
" ";
701 $test_rid =
$row->ref_id;
702 $test_oid =
$row->obj_id;
705 $query =
"DELETE FROM crs_objective_qst ".
706 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,
'integer').
" ";
710 $query =
"SELECT * FROM crs_objective_qst ".
711 "WHERE ref_id = ".$ilDB->quote($test_rid ,
'integer').
" ".
712 "AND obj_id = ".$ilDB->quote($test_oid ,
'integer').
" ".
713 "AND objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
728 $query =
"DELETE FROM crs_objective_qst ".
729 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
732 $query =
"DELETE FROM crs_objective_tst ".
733 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
745 include_once
'./Modules/Test/classes/class.ilObjTest.php';
746 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
749 $container_ref_id = current($container_ref_ids);
752 $query =
"SELECT * FROM crs_objective_tst ".
753 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
757 $this->tests[
$row->ref_id][
'test_objective_id'] =
$row->test_objective_id;
758 $this->tests[
$row->ref_id][
'ref_id'] =
$row->ref_id;
759 $this->tests[
$row->ref_id][
'obj_id'] =
$row->obj_id;
760 $this->tests[
$row->ref_id][
'status'] =
$row->tst_status;
761 $this->tests[
$row->ref_id][
'limit'] =
$row->tst_limit;
764 $this->questions = array();
765 $query =
"SELECT * FROM crs_objective_qst coq ".
766 "JOIN qpl_questions qq ON coq.question_id = qq.question_id ".
767 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
773 if(!$tree->isInTree(
$row->ref_id) or !$tree->isGrandChild($container_ref_id,
$row->ref_id))
780 $this->
delete(
$row->question_id);
784 $qst[
'ref_id'] =
$row->ref_id;
785 $qst[
'obj_id'] =
$row->obj_id;
786 $qst[
'question_id'] =
$row->question_id;
787 $qst[
'qst_ass_id'] =
$row->qst_ass_id;
788 $qst[
'title'] = $question->getTitle();
789 $qst[
'description'] = $question->getComment();
790 $qst[
'test_type'] = $this->tests[
$row->ref_id][
'status'];
791 $qst[
'points'] = $question->getPoints();
793 $this->questions[
$row->qst_ass_id] = $qst;
811 $query =
"SELECT co.objective_id FROM crs_objectives co JOIN ".
812 "crs_objective_tst cot ON co.objective_id = cot.objective_id ".
813 "WHERE crs_id = ".$ilDB->quote($a_course_id ,
'integer').
" ";
815 return $res->numRows() ?
true :
false;
819 function _isAssigned($a_objective_id,$a_tst_ref_id,$a_question_id)
823 $query =
"SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj ".
824 "WHERE crs_qst.objective_id = crs_obj.objective_id ".
825 "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id ,
'integer') .
" ".
826 "AND ref_id = ".$ilDB->quote($a_tst_ref_id ,
'integer').
" ".
827 "AND question_id = ".$ilDB->quote($a_question_id ,
'integer').
" ";