ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilCourseObjectiveQuestion Class Reference

class ilcourseobjectiveQuestion More...

+ Inheritance diagram for ilCourseObjectiveQuestion:
+ Collaboration diagram for ilCourseObjectiveQuestion:

Public Member Functions

 ilCourseObjectiveQuestion ($a_objective_id)
 
 cloneDependencies ($a_new_objective, $a_copy_id)
 clone objective questions More...
 
 setTestStatus ($a_status)
 
 getTestStatus ()
 
 setTestSuggestedLimit ($a_limit)
 
 getTestSuggestedLimit ()
 
 __addTest ()
 
 __deleteTest ($a_test_ref_id)
 
 updateTest ($a_objective_id)
 
 getTests ()
 
 getSelfAssessmentTests ()
 get self assessment tests More...
 
 getFinalTests ()
 get final tests More...
 
 _getTest ($a_test_objective_id)
 
 getQuestions ()
 
 getSelfAssessmentQuestions ()
 get self assessment questions More...
 
 getSelfAssessmentPoints ()
 get self assessment points More...
 
 getFinalTestPoints ()
 get final test points More...
 
 isSelfAssessmentQuestion ($a_question_id)
 check if question is self assessment question More...
 
 isFinalTestQuestion ($a_question_id)
 is final test question More...
 
 getFinalTestQuestions ()
 get final test questions More...
 
 getQuestionsOfTest ($a_test_id)
 Get questions of test. More...
 
 getQuestion ($question_id)
 
 getObjectiveId ()
 
 setTestRefId ($a_ref_id)
 
 getTestRefId ()
 
 setTestObjId ($a_obj_id)
 
 getTestObjId ()
 
 setQuestionId ($a_question_id)
 
 getQuestionId ()
 
 getMaxPointsByObjective ()
 
 getMaxPointsByTest ($a_test_ref_id)
 
 getNumberOfQuestionsByTest ($a_test_ref_id)
 
 getQuestionsByTest ($a_test_ref_id)
 
 updateLimits ()
 update limits More...
 
 add ()
 
 delete ($qst_id)
 
 deleteByTestType ($a_type)
 
 deleteAll ()
 
 __read ()
 
 _hasTests ($a_course_id)
 @access public More...
 
 _isAssigned ($a_objective_id, $a_tst_ref_id, $a_question_id)
 

Static Public Member Functions

static _isTestAssignedToObjective ($a_test_id, $a_objective_id)
 Check if test is assigned to objective. More...
 
static _getAssignableTests ($a_container_ref_id)
 Get assignable tests. More...
 
static _updateTestLimits ($a_objective_id, $a_status, $a_limit)
 update test limits More...
 
static _lookupMaximumPointsOfQuestion ($a_question_id)
 lookup maximimum point More...
 
static deleteTest ($a_tst_ref_id)
 
static lookupQuestionsByObjective ($a_test_id, $a_objective)
 
static loookupTestLimit ($a_test_id, $a_objective_id)
 

Data Fields

const TYPE_SELF_ASSESSMENT = 0
 
const TYPE_FINAL_TEST = 1
 
 $db = null
 
 $objective_id = null
 
 $questions
 

Protected Attributes

 $tests = array()
 

Detailed Description

class ilcourseobjectiveQuestion

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file class.ilCourseObjectiveQuestion.php.

Member Function Documentation

◆ __addTest()

ilCourseObjectiveQuestion::__addTest ( )

Definition at line 177 of file class.ilCourseObjectiveQuestion.php.

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 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, getObjectiveId(), getTestObjId(), getTestRefId(), and getTestStatus().

Referenced by add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __deleteTest()

ilCourseObjectiveQuestion::__deleteTest (   $a_test_ref_id)

Definition at line 227 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, $res, and getObjectiveId().

Referenced by __read(), and delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __read()

ilCourseObjectiveQuestion::__read ( )

Definition at line 787 of file class.ilCourseObjectiveQuestion.php.

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 }
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getAllReferences($a_id)
get all reference ids of object

References $ilDB, $query, $res, $row, __deleteTest(), ilObject\_getAllReferences(), ilObjTest\_instanciateQuestion(), ilCourseObjective\_lookupContainerIdByObjectiveId(), DB_FETCHMODE_OBJECT, and getObjectiveId().

Referenced by add(), and ilCourseObjectiveQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAssignableTests()

static ilCourseObjectiveQuestion::_getAssignableTests (   $a_container_ref_id)
static

Get assignable tests.

@access public

Parameters

Definition at line 153 of file class.ilCourseObjectiveQuestion.php.

154 {
155 global $tree;
156
157 return $tree->getSubTree($tree->getNodeData($a_container_ref_id),true,'tst');
158 }

Referenced by ilCourseObjectivesGUI\finalTestAssignment(), and ilCourseObjectivesGUI\selfAssessmentAssignment().

+ Here is the caller graph for this function:

◆ _getTest()

ilCourseObjectiveQuestion::_getTest (   $a_test_objective_id)

Definition at line 346 of file class.ilCourseObjectiveQuestion.php.

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 }
$test
Definition: Utf8Test.php:85

References $ilDB, $query, $res, $row, $test, and DB_FETCHMODE_OBJECT.

◆ _hasTests()

ilCourseObjectiveQuestion::_hasTests (   $a_course_id)

@access public

Parameters

return

Definition at line 853 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\setSubTabs().

+ Here is the caller graph for this function:

◆ _isAssigned()

ilCourseObjectiveQuestion::_isAssigned (   $a_objective_id,
  $a_tst_ref_id,
  $a_question_id 
)

Definition at line 865 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $objective_id, $query, $res, $row, and DB_FETCHMODE_OBJECT.

◆ _isTestAssignedToObjective()

static ilCourseObjectiveQuestion::_isTestAssignedToObjective (   $a_test_id,
  $a_objective_id 
)
static

Check if test is assigned to objective.

@access public

Parameters
inttest ref_id
intobjective_id
Returns
boolean success

Definition at line 67 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, and $res.

◆ _lookupMaximumPointsOfQuestion()

static ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion (   $a_question_id)
static

lookup maximimum point

@access public

Parameters
intquestion id
Returns

Definition at line 583 of file class.ilCourseObjectiveQuestion.php.

584 {
585 include_once('Modules/TestQuestionPool/classes/class.assQuestion.php');
586 return assQuestion::_getMaximumPoints($a_question_id);
587 }
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.

References assQuestion\_getMaximumPoints().

Referenced by ilLOTestQuestionAdapter\updateFixedQuestions(), and ilLOTestQuestionAdapter\updateRandomQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _updateTestLimits()

static ilCourseObjectiveQuestion::_updateTestLimits (   $a_objective_id,
  $a_status,
  $a_limit 
)
static

update test limits

@access public

Parameters
intobjective_id
intstatus
intlimit
Returns

Definition at line 258 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\saveQuestionOverview().

+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveQuestion::add ( )

Definition at line 660 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, $res, __addTest(), __read(), getObjectiveId(), getQuestionId(), getTestObjId(), and getTestRefId().

+ Here is the call graph for this function:

◆ cloneDependencies()

ilCourseObjectiveQuestion::cloneDependencies (   $a_new_objective,
  $a_copy_id 
)

clone objective questions

@access public

Parameters
intsource objective
inttarget objective
intcopy id

Definition at line 87 of file class.ilCourseObjectiveQuestion.php.

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 }
static _getInstance($a_copy_id)
Get instance of copy wizard options.

References $ilDB, $ilLog, $query, $res, $test, ilCopyWizardOptions\_getInstance(), getQuestions(), getTests(), and ilCourseObjectiveQuestion().

+ Here is the call graph for this function:

◆ delete()

ilCourseObjectiveQuestion::delete (   $qst_id)

Definition at line 686 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, $res, $row, __deleteTest(), DB_FETCHMODE_OBJECT, and getObjectiveId().

+ Here is the call graph for this function:

◆ deleteAll()

ilCourseObjectiveQuestion::deleteAll ( )

Definition at line 770 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, $res, and getObjectiveId().

+ Here is the call graph for this function:

◆ deleteByTestType()

ilCourseObjectiveQuestion::deleteByTestType (   $a_type)

Definition at line 739 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, and getObjectiveId().

+ Here is the call graph for this function:

◆ deleteTest()

static ilCourseObjectiveQuestion::deleteTest (   $a_tst_ref_id)
static

Definition at line 725 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, and $query.

Referenced by ilLOEditorGUI\deleteTest().

+ Here is the caller graph for this function:

◆ getFinalTestPoints()

ilCourseObjectiveQuestion::getFinalTestPoints ( )

get final test points

@access public

Returns

Definition at line 412 of file class.ilCourseObjectiveQuestion.php.

413 {
414 foreach($this->getFinalTestQuestions() as $question)
415 {
416 $points += $question['points'];
417 }
418 return $points ? $points : 0;
419 }
getFinalTestQuestions()
get final test questions

References getFinalTestQuestions().

Referenced by updateLimits().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFinalTestQuestions()

ilCourseObjectiveQuestion::getFinalTestQuestions ( )

get final test questions

@access public

Returns

Definition at line 465 of file class.ilCourseObjectiveQuestion.php.

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 }

Referenced by getFinalTestPoints().

+ Here is the caller graph for this function:

◆ getFinalTests()

ilCourseObjectiveQuestion::getFinalTests ( )

get final tests

@access public

Returns

Definition at line 334 of file class.ilCourseObjectiveQuestion.php.

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 }

References $test.

◆ getMaxPointsByObjective()

ilCourseObjectiveQuestion::getMaxPointsByObjective ( )

Definition at line 534 of file class.ilCourseObjectiveQuestion.php.

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 }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id

References ilObjTest\_instanciateQuestion(), ilObjectFactory\getInstanceByRefId(), and getQuestions().

+ Here is the call graph for this function:

◆ getMaxPointsByTest()

ilCourseObjectiveQuestion::getMaxPointsByTest (   $a_test_ref_id)

Definition at line 553 of file class.ilCourseObjectiveQuestion.php.

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 }

References ilObjTest\_instanciateQuestion(), ilObjectFactory\getInstanceByRefId(), and getQuestions().

+ Here is the call graph for this function:

◆ getNumberOfQuestionsByTest()

ilCourseObjectiveQuestion::getNumberOfQuestionsByTest (   $a_test_ref_id)

Definition at line 590 of file class.ilCourseObjectiveQuestion.php.

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 }

References getQuestions().

+ Here is the call graph for this function:

◆ getObjectiveId()

ilCourseObjectiveQuestion::getObjectiveId ( )

Definition at line 503 of file class.ilCourseObjectiveQuestion.php.

504 {
505 return $this->objective_id;
506 }

References $objective_id.

Referenced by __addTest(), __deleteTest(), __read(), add(), delete(), deleteAll(), deleteByTestType(), and getTests().

+ Here is the caller graph for this function:

◆ getQuestion()

ilCourseObjectiveQuestion::getQuestion (   $question_id)

Definition at line 498 of file class.ilCourseObjectiveQuestion.php.

499 {
500 return $this->questions[$question_id] ? $this->questions[$question_id] : array();
501 }

◆ getQuestionId()

ilCourseObjectiveQuestion::getQuestionId ( )

Definition at line 528 of file class.ilCourseObjectiveQuestion.php.

529 {
530 return $this->question_id;
531 }

Referenced by add().

+ Here is the caller graph for this function:

◆ getQuestions()

ilCourseObjectiveQuestion::getQuestions ( )

Definition at line 368 of file class.ilCourseObjectiveQuestion.php.

369 {
370 return $this->questions ? $this->questions : array();
371 }

Referenced by cloneDependencies(), getMaxPointsByObjective(), getMaxPointsByTest(), getNumberOfQuestionsByTest(), getQuestionsByTest(), and getQuestionsOfTest().

+ Here is the caller graph for this function:

◆ getQuestionsByTest()

ilCourseObjectiveQuestion::getQuestionsByTest (   $a_test_ref_id)

Definition at line 604 of file class.ilCourseObjectiveQuestion.php.

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 }

References getQuestions().

+ Here is the call graph for this function:

◆ getQuestionsOfTest()

ilCourseObjectiveQuestion::getQuestionsOfTest (   $a_test_id)

Get questions of test.

@access public

Parameters
inttest id

Definition at line 486 of file class.ilCourseObjectiveQuestion.php.

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 }

References $questions, and getQuestions().

+ Here is the call graph for this function:

◆ getSelfAssessmentPoints()

ilCourseObjectiveQuestion::getSelfAssessmentPoints ( )

get self assessment points

@access public

Returns

Definition at line 397 of file class.ilCourseObjectiveQuestion.php.

398 {
399 foreach($this->getSelfAssessmentQuestions() as $question)
400 {
401 $points += $question['points'];
402 }
403 return $points ? $points : 0;
404 }
getSelfAssessmentQuestions()
get self assessment questions

References getSelfAssessmentQuestions().

Referenced by updateLimits().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelfAssessmentQuestions()

ilCourseObjectiveQuestion::getSelfAssessmentQuestions ( )

get self assessment questions

@access public

Returns

Definition at line 379 of file class.ilCourseObjectiveQuestion.php.

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 }
const TYPE_SELF_ASSESSMENT

References TYPE_SELF_ASSESSMENT.

Referenced by getSelfAssessmentPoints().

+ Here is the caller graph for this function:

◆ getSelfAssessmentTests()

ilCourseObjectiveQuestion::getSelfAssessmentTests ( )

get self assessment tests

@access public

Parameters

return

Definition at line 316 of file class.ilCourseObjectiveQuestion.php.

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 }

References $test, and TYPE_SELF_ASSESSMENT.

◆ getTestObjId()

ilCourseObjectiveQuestion::getTestObjId ( )

Definition at line 520 of file class.ilCourseObjectiveQuestion.php.

521 {
522 return $this->tst_obj_id ? $this->tst_obj_id : 0;
523 }

Referenced by __addTest(), and add().

+ Here is the caller graph for this function:

◆ getTestRefId()

ilCourseObjectiveQuestion::getTestRefId ( )

Definition at line 512 of file class.ilCourseObjectiveQuestion.php.

513 {
514 return $this->tst_ref_id ? $this->tst_ref_id : 0;
515 }

Referenced by __addTest(), and add().

+ Here is the caller graph for this function:

◆ getTests()

ilCourseObjectiveQuestion::getTests ( )

Definition at line 283 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, $res, $row, $test, $tests, DB_FETCHMODE_OBJECT, and getObjectiveId().

Referenced by cloneDependencies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTestStatus()

ilCourseObjectiveQuestion::getTestStatus ( )

Definition at line 165 of file class.ilCourseObjectiveQuestion.php.

166 {
167 return (int) $this->tst_status;
168 }

Referenced by __addTest(), and updateTest().

+ Here is the caller graph for this function:

◆ getTestSuggestedLimit()

ilCourseObjectiveQuestion::getTestSuggestedLimit ( )

Definition at line 173 of file class.ilCourseObjectiveQuestion.php.

174 {
175 return (int) $this->tst_limit;
176 }

Referenced by updateTest().

+ Here is the caller graph for this function:

◆ ilCourseObjectiveQuestion()

ilCourseObjectiveQuestion::ilCourseObjectiveQuestion (   $a_objective_id)

Definition at line 45 of file class.ilCourseObjectiveQuestion.php.

46 {
47 global $ilDB;
48
49 $this->db =& $ilDB;
50
51 $this->objective_id = $a_objective_id;
52
53 $this->__read();
54 }

References $ilDB, and __read().

Referenced by cloneDependencies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFinalTestQuestion()

ilCourseObjectiveQuestion::isFinalTestQuestion (   $a_question_id)

is final test question

@access public

Parameters
intquestion id
Returns

Definition at line 446 of file class.ilCourseObjectiveQuestion.php.

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 }

References TYPE_FINAL_TEST.

◆ isSelfAssessmentQuestion()

ilCourseObjectiveQuestion::isSelfAssessmentQuestion (   $a_question_id)

check if question is self assessment question

Parameters
intquestion id @access public
Returns

Definition at line 427 of file class.ilCourseObjectiveQuestion.php.

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 }

References TYPE_SELF_ASSESSMENT.

◆ lookupQuestionsByObjective()

static ilCourseObjectiveQuestion::lookupQuestionsByObjective (   $a_test_id,
  $a_objective 
)
static

Definition at line 885 of file class.ilCourseObjectiveQuestion.php.

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 }
$GLOBALS['ct_recipient']

References $GLOBALS, $ilDB, $query, $questions, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilLOEditorStatus\lookupQuestionsAssigned(), and ilLOTestQuestionAdapter\updateFixedQuestions().

+ Here is the caller graph for this function:

◆ loookupTestLimit()

static ilCourseObjectiveQuestion::loookupTestLimit (   $a_test_id,
  $a_objective_id 
)
static

Definition at line 904 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilLOUtils\lookupObjectiveRequiredPercentage().

+ Here is the caller graph for this function:

◆ setQuestionId()

ilCourseObjectiveQuestion::setQuestionId (   $a_question_id)

Definition at line 524 of file class.ilCourseObjectiveQuestion.php.

525 {
526 $this->question_id = $a_question_id;
527 }

◆ setTestObjId()

ilCourseObjectiveQuestion::setTestObjId (   $a_obj_id)

Definition at line 516 of file class.ilCourseObjectiveQuestion.php.

517 {
518 $this->tst_obj_id = $a_obj_id;
519 }

◆ setTestRefId()

ilCourseObjectiveQuestion::setTestRefId (   $a_ref_id)

Definition at line 508 of file class.ilCourseObjectiveQuestion.php.

509 {
510 $this->tst_ref_id = $a_ref_id;
511 }

◆ setTestStatus()

ilCourseObjectiveQuestion::setTestStatus (   $a_status)

Definition at line 161 of file class.ilCourseObjectiveQuestion.php.

162 {
163 $this->tst_status = $a_status;
164 }

◆ setTestSuggestedLimit()

ilCourseObjectiveQuestion::setTestSuggestedLimit (   $a_limit)

Definition at line 169 of file class.ilCourseObjectiveQuestion.php.

170 {
171 $this->tst_limit = $a_limit;
172 }

◆ updateLimits()

ilCourseObjectiveQuestion::updateLimits ( )

update limits

@access public

Parameters

return

Definition at line 623 of file class.ilCourseObjectiveQuestion.php.

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 }
getSelfAssessmentPoints()
get self assessment points
$ref_id
Definition: sahs_server.php:39

References $ilDB, $query, $ref_id, $res, getFinalTestPoints(), getSelfAssessmentPoints(), TYPE_FINAL_TEST, and TYPE_SELF_ASSESSMENT.

+ Here is the call graph for this function:

◆ updateTest()

ilCourseObjectiveQuestion::updateTest (   $a_objective_id)

Definition at line 270 of file class.ilCourseObjectiveQuestion.php.

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 }

References $ilDB, $query, $res, getTestStatus(), and getTestSuggestedLimit().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilCourseObjectiveQuestion::$db = null

Definition at line 39 of file class.ilCourseObjectiveQuestion.php.

◆ $objective_id

ilCourseObjectiveQuestion::$objective_id = null

Definition at line 41 of file class.ilCourseObjectiveQuestion.php.

Referenced by _isAssigned(), and getObjectiveId().

◆ $questions

ilCourseObjectiveQuestion::$questions

◆ $tests

ilCourseObjectiveQuestion::$tests = array()
protected

Definition at line 43 of file class.ilCourseObjectiveQuestion.php.

Referenced by getTests().

◆ TYPE_FINAL_TEST

◆ TYPE_SELF_ASSESSMENT


The documentation for this class was generated from the following file: