ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilCourseObjectiveQuestion.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
35{
37 const TYPE_FINAL_TEST = 1;
38
39 public $db = null;
40
41 public $objective_id = null;
42 public $questions;
43 protected $tests = array();
44
45 function ilCourseObjectiveQuestion($a_objective_id)
46 {
47 global $ilDB;
48
49 $this->db =& $ilDB;
50
51 $this->objective_id = $a_objective_id;
52
53 $this->__read();
54 }
55
56
67 public static function _isTestAssignedToObjective($a_test_id,$a_objective_id)
68 {
69 global $ilDB;
70
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');
74 $res = $ilDB->query($query);
75 return $res->numRows() ? true : false;
76 }
77
87 public function cloneDependencies($a_new_objective,$a_copy_id)
88 {
89 global $ilObjDataCache,$ilLog,$ilDB;
90
91 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
92 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
93 $mappings = $cwo->getMappings();
94 foreach($this->getQuestions() as $question)
95 {
96 if(!isset($mappings["$question[ref_id]"]) or !$mappings["$question[ref_id]"])
97 {
98 continue;
99 }
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);
105
106 if($new_obj_id == $question_obj_id)
107 {
108 $ilLog->write(__METHOD__.': Test has been linked. Keeping question id.');
109 // Object has been linked
110 $new_question_id = $question_qst_id;
111 }
112 else
113 {
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])
117 {
118 continue;
119 }
120 $new_question_id = $new_question_arr[1];
121 $ilLog->write(__METHOD__.': New question id is: '.$new_question_id);
122 }
123
124 $new_question = new ilCourseObjectiveQuestion($a_new_objective);
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();
129 }
130
131 // Copy tests
132 foreach($this->getTests() as $test)
133 {
134 $new_test_id = $mappings["$test[ref_id]"];
135
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');
141 $res = $ilDB->manipulate($query);
142 }
143 }
144
153 public static function _getAssignableTests($a_container_ref_id)
154 {
155 global $tree;
156
157 return $tree->getSubTree($tree->getNodeData($a_container_ref_id),true,'tst');
158 }
159
160 // ######################################################## Methods for test table
161 function setTestStatus($a_status)
162 {
163 $this->tst_status = $a_status;
164 }
165 function getTestStatus()
166 {
167 return (int) $this->tst_status;
168 }
169 function setTestSuggestedLimit($a_limit)
170 {
171 $this->tst_limit = $a_limit;
172 }
174 {
175 return (int) $this->tst_limit;
176 }
177 function __addTest()
178 {
179 global $ilDB;
180
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')." ";
185 $res = $ilDB->manipulate($query);
186
187
188 // CHECK if entry already exists
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')."";
192
193 $res = $this->db->query($query);
194 if($res->numRows())
195 {
196 return false;
197 }
198
199 // Check for existing limit
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')." ";
203
204 $res = $this->db->query($query);
205
206 $limit = 100;
207 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
208 {
209 $limit = $row->tst_limit_p;
210 }
211
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) ".
214 "VALUES( ".
215 $ilDB->quote($next_id,'integer').", ".
216 $ilDB->quote($this->getObjectiveId() ,'integer').", ".
217 $ilDB->quote($this->getTestRefId() ,'integer').", ".
218 $ilDB->quote($this->getTestObjId() ,'integer').", ".
219 $ilDB->quote($this->getTestStatus() ,'integer').", ".
220 $this->db->quote($limit ,'integer')." ".
221 ")";
222 $res = $ilDB->manipulate($query);
223
224 return true;
225 }
226
227 function __deleteTest($a_test_ref_id)
228 {
229 global $ilDB;
230
231 // Delete questions
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')." ";
235 $res = $ilDB->manipulate($query);
236
237 // delete tst entries
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')." ";
241 $res = $ilDB->manipulate($query);
242
243 unset($this->tests[$a_test_ref_id]);
244
245 return true;
246 }
247
258 public static function _updateTestLimits($a_objective_id,$a_status,$a_limit)
259 {
260 global $ilDB;
261
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');
266 $res = $ilDB->manipulate($query);
267 return true;
268 }
269
270 function updateTest($a_objective_id)
271 {
272 global $ilDB;
273
274 $query = "UPDATE crs_objective_tst ".
275 "SET tst_status = ".$ilDB->quote($this->getTestStatus() ,'integer').", ".
276 "tst_limit_p = ".$ilDB->quote($this->getTestSuggestedLimit() ,'integer')." ".
277 "WHERE test_objective_id = ".$ilDB->quote($a_objective_id ,'integer')."";
278 $res = $ilDB->manipulate($query);
279
280 return true;
281 }
282
283 function getTests()
284 {
285 global $ilDB;
286
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')." ".
290 "ORDER BY title ";
291
292 $res = $this->db->query($query);
293 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
294 {
295 $test['test_objective_id'] = $row->test_objective_id;
296 $test['objective_id'] = $row->objective_id;
297 $test['ref_id'] = $row->ref_id;
298 $test['obj_id'] = $row->obj_id;
299 $test['tst_status'] = $row->tst_status;
300 $test['tst_limit'] = $row->tst_limit_p;
301 $test['title'] = $row->title;
302
303 $tests[] = $test;
304 }
305
306 return $tests ? $tests : array();
307 }
308
316 public function getSelfAssessmentTests()
317 {
318 foreach($this->tests as $test)
319 {
320 if($test['status'] == self::TYPE_SELF_ASSESSMENT)
321 {
322 $self[] = $test;
323 }
324 }
325 return $self ? $self : array();
326 }
327
334 public function getFinalTests()
335 {
336 foreach($this->tests as $test)
337 {
338 if($test['status'] == self::TYPE_FINAL_TEST)
339 {
340 $final[] = $test;
341 }
342 }
343 return $final ? $final : array();
344 }
345
346 function _getTest($a_test_objective_id)
347 {
348 global $ilDB;
349
350 $query = "SELECT * FROM crs_objective_tst ".
351 "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id ,'integer')." ";
352
353 $res = $ilDB->query($query);
354 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
355 {
356 $test['test_objective_id'] = $row->test_objective_id;
357 $test['objective_id'] = $row->objective_id;
358 $test['ref_id'] = $row->ref_id;
359 $test['obj_id'] = $row->obj_id;
360 $test['tst_status'] = $row->tst_status;
361 $test['tst_limit'] = $row->tst_limit_p;
362 }
363
364 return $test ? $test : array();
365 }
366
367 // ############################################################# METHODS for question table
368 function getQuestions()
369 {
370 return $this->questions ? $this->questions : array();
371 }
372
380 {
381 foreach($this->questions as $question)
382 {
383 if($question['test_type'] == self::TYPE_SELF_ASSESSMENT)
384 {
385 $self[] = $question;
386 }
387 }
388 return $self ? $self : array();
389 }
390
397 public function getSelfAssessmentPoints()
398 {
399 foreach($this->getSelfAssessmentQuestions() as $question)
400 {
401 $points += $question['points'];
402 }
403 return $points ? $points : 0;
404 }
405
412 public function getFinalTestPoints()
413 {
414 foreach($this->getFinalTestQuestions() as $question)
415 {
416 $points += $question['points'];
417 }
418 return $points ? $points : 0;
419 }
420
427 public function isSelfAssessmentQuestion($a_question_id)
428 {
429 foreach($this->questions as $question)
430 {
431 if($question['question_id'] == $a_question_id)
432 {
433 return $question['test_type'] == self::TYPE_SELF_ASSESSMENT;
434 }
435 }
436 return false;
437 }
438
446 public function isFinalTestQuestion($a_question_id)
447 {
448 foreach($this->questions as $question)
449 {
450 if($question['question_id'] == $a_question_id)
451 {
452 return $question['test_type'] == self::TYPE_FINAL_TEST;
453 }
454 }
455 return false;
456
457 }
458
465 public function getFinalTestQuestions()
466 {
467 foreach($this->questions as $question)
468 {
469 if($question['test_type'] == self::TYPE_FINAL_TEST)
470 {
471 $final[] = $question;
472 }
473 }
474 return $final ? $final : array();
475 }
476
477
478
486 public function getQuestionsOfTest($a_test_id)
487 {
488 foreach($this->getQuestions() as $qst)
489 {
490 if($a_test_id == $qst['obj_id'])
491 {
492 $questions[] = $qst;
493 }
494 }
495 return $questions ? $questions : array();
496 }
497
498 function getQuestion($question_id)
499 {
500 return $this->questions[$question_id] ? $this->questions[$question_id] : array();
501 }
502
503 function getObjectiveId()
504 {
505 return $this->objective_id;
506 }
507
508 function setTestRefId($a_ref_id)
509 {
510 $this->tst_ref_id = $a_ref_id;
511 }
512 function getTestRefId()
513 {
514 return $this->tst_ref_id ? $this->tst_ref_id : 0;
515 }
516 function setTestObjId($a_obj_id)
517 {
518 $this->tst_obj_id = $a_obj_id;
519 }
520 function getTestObjId()
521 {
522 return $this->tst_obj_id ? $this->tst_obj_id : 0;
523 }
524 function setQuestionId($a_question_id)
525 {
526 $this->question_id = $a_question_id;
527 }
528 function getQuestionId()
529 {
530 return $this->question_id;
531 }
532
533
535 {
536 include_once './Modules/Test/classes/class.ilObjTest.php';
537
538 $points = 0;
539 foreach($this->getQuestions() as $question)
540 {
541 $tmp_test =& ilObjectFactory::getInstanceByRefId($question['ref_id']);
542
543 $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
544
545 $points += $tmp_question->getMaximumPoints();
546
547 unset($tmp_question);
548 unset($tmp_test);
549 }
550 return $points;
551 }
552
553 function getMaxPointsByTest($a_test_ref_id)
554 {
555 $points = 0;
556
557 $tmp_test =& ilObjectFactory::getInstanceByRefId($a_test_ref_id);
558
559 foreach($this->getQuestions() as $question)
560 {
561 if($question['ref_id'] == $a_test_ref_id)
562 {
563 $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
564
565 $points += $tmp_question->getMaximumPoints();
566
567 unset($tmp_question);
568 }
569 }
570 unset($tmp_test);
571
572 return $points;
573 }
574
583 public static function _lookupMaximumPointsOfQuestion($a_question_id)
584 {
585 include_once('Modules/TestQuestionPool/classes/class.assQuestion.php');
586 return assQuestion::_getMaximumPoints($a_question_id);
587 }
588
589
590 function getNumberOfQuestionsByTest($a_test_ref_id)
591 {
592 $counter = 0;
593
594 foreach($this->getQuestions() as $question)
595 {
596 if($question['ref_id'] == $a_test_ref_id)
597 {
598 ++$counter;
599 }
600 }
601 return $counter;
602 }
603
604 function getQuestionsByTest($a_test_ref_id)
605 {
606 foreach($this->getQuestions() as $question)
607 {
608 if($question['ref_id'] == $a_test_ref_id)
609 {
610 $qst[] = $question['question_id'];
611 }
612 }
613 return $qst ? $qst : array();
614 }
615
623 public function updateLimits()
624 {
625 global $ilDB;
626
627 foreach($this->tests as $ref_id => $test_data)
628 {
629 switch($test_data['status'])
630 {
632 $points = $this->getSelfAssessmentPoints();
633 break;
634
636 $points = $this->getFinalTestPoints();
637 break;
638 }
639 if($test_data['limit'] == -1 or $test_data['limit'] > $points)
640 {
641 switch($test_data['status'])
642 {
644 $points = $this->getSelfAssessmentPoints();
645 break;
646
648 $points = $this->getFinalTestPoints();
649 break;
650 }
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')." ";
654 $res = $ilDB->manipulate($query);
655 }
656 }
657 }
658
659
660 function add()
661 {
662 global $ilDB;
663
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')." ";
667 $res = $ilDB->manipulate($query);
668
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) ".
671 "VALUES( ".
672 $ilDB->quote($next_id,'integer').", ".
673 $ilDB->quote($this->getObjectiveId() ,'integer').", ".
674 $ilDB->quote($this->getTestRefId() ,'integer').", ".
675 $ilDB->quote($this->getTestObjId() ,'integer').", ".
676 $ilDB->quote($this->getQuestionId() ,'integer').
677 ")";
678 $res = $ilDB->manipulate($query);
679
680 $this->__addTest();
681
682 $this->__read();
683
684 return true;
685 }
686 function delete($qst_id)
687 {
688 global $ilDB;
689
690 if(!$qst_id)
691 {
692 return false;
693 }
694
695 $query = "SELECT * FROM crs_objective_qst ".
696 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
697
698 $res = $this->db->query($query);
699 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
700 {
701 $test_rid = $row->ref_id;
702 $test_oid = $row->obj_id;
703 }
704
705 $query = "DELETE FROM crs_objective_qst ".
706 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
707 $res = $ilDB->manipulate($query);
708
709 // delete test if it was the last question
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')." ";
714
715 $res = $this->db->query($query);
716 if(!$res->numRows())
717 {
718 $this->__deleteTest($test_rid);
719 }
720
721 return true;
722 }
723
724 // begin-patch lok
725 public static function deleteTest($a_tst_ref_id)
726 {
727 global $ilDB;
728
729 $query = 'DELETE FROM crs_objective_tst '.
730 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,'integer');
731 $ilDB->manipulate($query);
732
733 $query = 'DELETE FROM crs_objective_qst '.
734 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,'integer');
735 $ilDB->manipulate($query);
736 }
737
738
739 public function deleteByTestType($a_type)
740 {
741 global $ilDB;
742
743
744 // Read tests by type
745 $deletable_refs = array();
746 foreach((array) $this->tests as $tst_data)
747 {
748 if($tst_data['status'] == $a_type)
749 {
750 $deletable_refs[] = $tst_data['ref_id'];
751 }
752 }
753
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);
758
759
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);
764
765 return true;
766 }
767 // end-patch lok
768
769
770 function deleteAll()
771 {
772 global $ilDB;
773
774 $query = "DELETE FROM crs_objective_qst ".
775 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
776 $res = $ilDB->manipulate($query);
777
778 $query = "DELETE FROM crs_objective_tst ".
779 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
780 $res = $ilDB->manipulate($query);
781
782 return true;
783 }
784
785
786 // PRIVATE
787 function __read()
788 {
789 global $ilDB,$tree;
790
791 include_once './Modules/Test/classes/class.ilObjTest.php';
792 include_once('Modules/Course/classes/class.ilCourseObjective.php');
793
795 $container_ref_id = current($container_ref_ids);
796
797 // Read test data
798 $query = "SELECT * FROM crs_objective_tst ".
799 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
800 $res = $this->db->query($query);
801 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
802 {
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;
808 }
809
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')." ".
814 "ORDER BY title";
815
816 $res = $this->db->query($query);
817 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
818 {
819 if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
820 {
821 $this->__deleteTest($row->ref_id);
822 continue;
823 }
824 if(!$question = ilObjTest::_instanciateQuestion($row->question_id))
825 {
826 $this->delete($row->question_id);
827 continue;
828 }
829
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();
838
839 $this->questions[$row->qst_ass_id] = $qst;
840 }
841
842 return true;
843 }
844
845 // STATIC
853 public function _hasTests($a_course_id)
854 {
855 global $ilDB;
856
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')." ";
860 $res = $ilDB->query($query);
861 return $res->numRows() ? true : false;
862 }
863
864
865 function _isAssigned($a_objective_id,$a_tst_ref_id,$a_question_id)
866 {
867 global $ilDB;
868
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')." ";
874
875 $res = $ilDB->query($query);
876 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
877 {
878 $objective_id = $row->objective_id;
879 }
880
881 return $objective_id ? $objective_id : 0;
882 }
883
884 // begin-patch lok
885 public static function lookupQuestionsByObjective($a_test_id, $a_objective)
886 {
887 global $ilDB;
888
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');
892 $res = $ilDB->query($query);
893
894 $GLOBALS['ilLog']->write($query);
895
896 $questions = array();
897 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
898 {
899 $questions[] = $row->question_id;
900 }
901 return (array) $questions;
902 }
903
904 public static function loookupTestLimit($a_test_id, $a_objective_id)
905 {
906 global $ilDB;
907
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');
911 $res = $ilDB->query($query);
912 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
913 {
914 return (int) $row->tst_limit_p;
915 }
916 return 0;
917 }
918
919 // end-patch lok
920
921}
922?>
$test
Definition: Utf8Test.php:85
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
class ilcourseobjectiveQuestion
cloneDependencies($a_new_objective, $a_copy_id)
clone objective questions
isFinalTestQuestion($a_question_id)
is final test question
getQuestionsOfTest($a_test_id)
Get questions of test.
getFinalTestQuestions()
get final test questions
getSelfAssessmentTests()
get self assessment tests
static lookupQuestionsByObjective($a_test_id, $a_objective)
static _updateTestLimits($a_objective_id, $a_status, $a_limit)
update test limits
_isAssigned($a_objective_id, $a_tst_ref_id, $a_question_id)
getSelfAssessmentPoints()
get self assessment points
getSelfAssessmentQuestions()
get self assessment questions
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point
static loookupTestLimit($a_test_id, $a_objective_id)
static _getAssignableTests($a_container_ref_id)
Get assignable tests.
isSelfAssessmentQuestion($a_question_id)
check if question is self assessment question
static _isTestAssignedToObjective($a_test_id, $a_objective_id)
Check if test is assigned to objective.
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
const TYPE_SELF_ASSESSMENT
$ref_id
Definition: sahs_server.php:39
global $ilDB