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_p = ".$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_p 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_p;
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_p) ".
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_p = ".$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'];
403 return $points ? $points : 0;
416 $points += $question[
'points'];
418 return $points ? $points : 0;
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').
" ";
729 $query =
'DELETE FROM crs_objective_tst '.
730 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,
'integer');
731 $ilDB->manipulate(
$query);
733 $query =
'DELETE FROM crs_objective_qst '.
734 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,
'integer');
735 $ilDB->manipulate(
$query);
745 $deletable_refs = array();
746 foreach((array) $this->tests as $tst_data)
748 if($tst_data[
'status'] == $a_type)
750 $deletable_refs[] = $tst_data[
'ref_id'];
754 $query =
'DELETE from crs_objective_tst '.
755 'WHERE objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer').
' '.
756 'AND tst_status = '.$ilDB->quote($a_type,
'integer');
757 $ilDB->manipulate(
$query);
760 $query =
'DELETE from crs_objective_tst '.
761 'WHERE objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer').
' '.
762 'AND '.$ilDB->in(
'ref_id',$deletable_refs,
false,
'integer');
763 $ilDB->manipulate(
$query);
774 $query =
"DELETE FROM crs_objective_qst ".
775 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
778 $query =
"DELETE FROM crs_objective_tst ".
779 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
791 include_once
'./Modules/Test/classes/class.ilObjTest.php';
792 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
795 $container_ref_id = current($container_ref_ids);
798 $query =
"SELECT * FROM crs_objective_tst ".
799 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
803 $this->tests[
$row->ref_id][
'test_objective_id'] =
$row->test_objective_id;
804 $this->tests[
$row->ref_id][
'ref_id'] =
$row->ref_id;
805 $this->tests[
$row->ref_id][
'obj_id'] =
$row->obj_id;
806 $this->tests[
$row->ref_id][
'status'] =
$row->tst_status;
807 $this->tests[
$row->ref_id][
'limit'] =
$row->tst_limit_p;
810 $this->questions = array();
811 $query =
"SELECT * FROM crs_objective_qst coq ".
812 "JOIN qpl_questions qq ON coq.question_id = qq.question_id ".
813 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
819 if(!$tree->isInTree(
$row->ref_id) or !$tree->isGrandChild($container_ref_id,
$row->ref_id))
826 $this->
delete(
$row->question_id);
830 $qst[
'ref_id'] =
$row->ref_id;
831 $qst[
'obj_id'] =
$row->obj_id;
832 $qst[
'question_id'] =
$row->question_id;
833 $qst[
'qst_ass_id'] =
$row->qst_ass_id;
834 $qst[
'title'] = $question->getTitle();
835 $qst[
'description'] = $question->getComment();
836 $qst[
'test_type'] = $this->tests[
$row->ref_id][
'status'];
837 $qst[
'points'] = $question->getPoints();
839 $this->questions[
$row->qst_ass_id] = $qst;
857 $query =
"SELECT co.objective_id FROM crs_objectives co JOIN ".
858 "crs_objective_tst cot ON co.objective_id = cot.objective_id ".
859 "WHERE crs_id = ".$ilDB->quote($a_course_id ,
'integer').
" ";
861 return $res->numRows() ?
true :
false;
865 function _isAssigned($a_objective_id,$a_tst_ref_id,$a_question_id)
869 $query =
"SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj ".
870 "WHERE crs_qst.objective_id = crs_obj.objective_id ".
871 "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id ,
'integer') .
" ".
872 "AND ref_id = ".$ilDB->quote($a_tst_ref_id ,
'integer').
" ".
873 "AND question_id = ".$ilDB->quote($a_question_id ,
'integer').
" ";
889 $query =
'SELECT question_id FROM crs_objective_qst '.
890 'WHERE objective_id = '.$ilDB->quote($a_objective,
'integer').
' '.
891 'AND obj_id = '.$ilDB->quote($a_test_id,
'integer');
908 $query =
'SELECT tst_limit_p FROM crs_objective_tst '.
909 'WHERE objective_id = '.$ilDB->quote($a_objective_id,
'integer').
' '.
910 'AND obj_id = '.$ilDB->quote($a_test_id,
'integer');
914 return (
int)
$row->tst_limit_p;