ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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)
 
 toXml (ilXmlWriter $writer)
 To xml. More...
 

Static Public Member Functions

static lookupObjectivesOfQuestion ($a_qid)
 Lookup objective for test question @global type $ilDB. More...
 
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 202 of file class.ilCourseObjectiveQuestion.php.

203 {
204 global $ilDB;
205
206 $query = "UPDATE crs_objective_tst ".
207 "SET tst_status = ".$this->db->quote($this->getTestStatus() ,'integer')." ".
208 "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
209 "AND ref_id = ".$this->db->quote($this->getTestRefId() ,'integer')." ";
210 $res = $ilDB->manipulate($query);
211
212
213 // CHECK if entry already exists
214 $query = "SELECT * FROM crs_objective_tst ".
215 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
216 "AND ref_id = ".$ilDB->quote($this->getTestRefId() ,'integer')."";
217
218 $res = $this->db->query($query);
219 if($res->numRows())
220 {
221 return false;
222 }
223
224 // Check for existing limit
225 $query = "SELECT tst_limit_p FROM crs_objective_tst ".
226 "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
227 "AND tst_status = ".$this->db->quote($this->getTestStatus() ,'integer')." ";
228
229 $res = $this->db->query($query);
230
231 $limit = 100;
232 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
233 {
234 $limit = $row->tst_limit_p;
235 }
236
237 $next_id = $ilDB->nextId('crs_objective_tst');
238 $query = "INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) ".
239 "VALUES( ".
240 $ilDB->quote($next_id,'integer').", ".
241 $ilDB->quote($this->getObjectiveId() ,'integer').", ".
242 $ilDB->quote($this->getTestRefId() ,'integer').", ".
243 $ilDB->quote($this->getTestObjId() ,'integer').", ".
244 $ilDB->quote($this->getTestStatus() ,'integer').", ".
245 $this->db->quote($limit ,'integer')." ".
246 ")";
247 $res = $ilDB->manipulate($query);
248
249 return true;
250 }
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 252 of file class.ilCourseObjectiveQuestion.php.

253 {
254 global $ilDB;
255
256 // Delete questions
257 $query = "DELETE FROM crs_objective_qst ".
258 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
259 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,'integer')." ";
260 $res = $ilDB->manipulate($query);
261
262 // delete tst entries
263 $query = "DELETE FROM crs_objective_tst ".
264 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
265 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,'integer')." ";
266 $res = $ilDB->manipulate($query);
267
268 unset($this->tests[$a_test_ref_id]);
269
270 return true;
271 }

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 812 of file class.ilCourseObjectiveQuestion.php.

813 {
814 global $ilDB,$tree;
815
816 include_once './Modules/Test/classes/class.ilObjTest.php';
817 include_once('Modules/Course/classes/class.ilCourseObjective.php');
818
820 $container_ref_id = current($container_ref_ids);
821
822 // Read test data
823 $query = "SELECT * FROM crs_objective_tst ".
824 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
825 $res = $this->db->query($query);
826 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
827 {
828 $this->tests[$row->ref_id]['test_objective_id'] = $row->test_objective_id;
829 $this->tests[$row->ref_id]['ref_id'] = $row->ref_id;
830 $this->tests[$row->ref_id]['obj_id'] = $row->obj_id;
831 $this->tests[$row->ref_id]['status'] = $row->tst_status;
832 $this->tests[$row->ref_id]['limit'] = $row->tst_limit_p;
833 }
834
835 $this->questions = array();
836 $query = "SELECT * FROM crs_objective_qst coq ".
837 "JOIN qpl_questions qq ON coq.question_id = qq.question_id ".
838 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
839 "ORDER BY title";
840
841 $res = $this->db->query($query);
842 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
843 {
844 if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
845 {
846 $this->__deleteTest($row->ref_id);
847 continue;
848 }
849 if(!$question = ilObjTest::_instanciateQuestion($row->question_id))
850 {
851 $this->delete($row->question_id);
852 continue;
853 }
854
855 $qst['ref_id'] = $row->ref_id;
856 $qst['obj_id'] = $row->obj_id;
857 $qst['question_id'] = $row->question_id;
858 $qst['qst_ass_id'] = $row->qst_ass_id;
859 $qst['title'] = $question->getTitle();
860 $qst['description'] = $question->getComment();
861 $qst['test_type'] = $this->tests[$row->ref_id]['status'];
862 $qst['points'] = $question->getPoints();
863
864 $this->questions[$row->qst_ass_id] = $qst;
865 }
866
867 return true;
868 }
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 178 of file class.ilCourseObjectiveQuestion.php.

179 {
180 global $tree;
181
182 return $tree->getSubTree($tree->getNodeData($a_container_ref_id),true,'tst');
183 }

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 371 of file class.ilCourseObjectiveQuestion.php.

372 {
373 global $ilDB;
374
375 $query = "SELECT * FROM crs_objective_tst ".
376 "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id ,'integer')." ";
377
378 $res = $ilDB->query($query);
379 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
380 {
381 $test['test_objective_id'] = $row->test_objective_id;
382 $test['objective_id'] = $row->objective_id;
383 $test['ref_id'] = $row->ref_id;
384 $test['obj_id'] = $row->obj_id;
385 $test['tst_status'] = $row->tst_status;
386 $test['tst_limit'] = $row->tst_limit_p;
387 }
388
389 return $test ? $test : array();
390 }
$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 878 of file class.ilCourseObjectiveQuestion.php.

879 {
880 global $ilDB;
881
882 $query = "SELECT co.objective_id FROM crs_objectives co JOIN ".
883 "crs_objective_tst cot ON co.objective_id = cot.objective_id ".
884 "WHERE crs_id = ".$ilDB->quote($a_course_id ,'integer')." ";
885 $res = $ilDB->query($query);
886 return $res->numRows() ? true : false;
887 }

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 890 of file class.ilCourseObjectiveQuestion.php.

891 {
892 global $ilDB;
893
894 $query = "SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj ".
895 "WHERE crs_qst.objective_id = crs_obj.objective_id ".
896 "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id ,'integer') ." ".
897 "AND ref_id = ".$ilDB->quote($a_tst_ref_id ,'integer')." ".
898 "AND question_id = ".$ilDB->quote($a_question_id ,'integer')." ";
899
900 $res = $ilDB->query($query);
901 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
902 {
903 $objective_id = $row->objective_id;
904 }
905
906 return $objective_id ? $objective_id : 0;
907 }

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 89 of file class.ilCourseObjectiveQuestion.php.

90 {
91 global $ilDB;
92
93 $query = "SELECT qst_ass_id FROM crs_objective_qst ".
94 "WHERE ref_id = ".$ilDB->quote($a_test_id ,'integer')." ".
95 "AND objective_id = ".$ilDB->quote($a_objective_id ,'integer');
96 $res = $ilDB->query($query);
97 return $res->numRows() ? true : false;
98 }

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 608 of file class.ilCourseObjectiveQuestion.php.

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

References assQuestion\_getMaximumPoints().

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

+ 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 283 of file class.ilCourseObjectiveQuestion.php.

284 {
285 global $ilDB;
286
287 $query = "UPDATE crs_objective_tst ".
288 "SET tst_limit_p = ".$ilDB->quote($a_limit ,'integer')." ".
289 "WHERE tst_status = ".$ilDB->quote($a_status ,'integer')." ".
290 "AND objective_id = ".$ilDB->quote($a_objective_id ,'integer');
291 $res = $ilDB->manipulate($query);
292 return true;
293 }

References $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\saveQuestionOverview().

+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveQuestion::add ( )

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

686 {
687 global $ilDB;
688
689 $query = "DELETE FROM crs_objective_qst ".
690 "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
691 "AND question_id = ".$this->db->quote($this->getQuestionId() ,'integer')." ";
692 $res = $ilDB->manipulate($query);
693
694 $next_id = $ilDB->nextId('crs_objective_qst');
695 $query = "INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) ".
696 "VALUES( ".
697 $ilDB->quote($next_id,'integer').", ".
698 $ilDB->quote($this->getObjectiveId() ,'integer').", ".
699 $ilDB->quote($this->getTestRefId() ,'integer').", ".
700 $ilDB->quote($this->getTestObjId() ,'integer').", ".
701 $ilDB->quote($this->getQuestionId() ,'integer').
702 ")";
703 $res = $ilDB->manipulate($query);
704
705 $this->__addTest();
706
707 $this->__read();
708
709 return true;
710 }

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 109 of file class.ilCourseObjectiveQuestion.php.

110 {
111 global $ilObjDataCache,$ilLog,$ilDB;
112
113 include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
114 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
115 $mappings = $cwo->getMappings();
116 foreach($this->getQuestions() as $question)
117 {
118 $mapping_key = $question['ref_id'].'_question_'.$question['question_id'];
119 if(!isset($mappings[$mapping_key]) or !$mappings[$mapping_key])
120 {
121 continue;
122 }
123 $question_ref_id = $question['ref_id'];
124 $question_obj_id = $question['obj_id'];
125 $question_qst_id = $question['question_id'];
126 $new_ref_id = $mappings[$question_ref_id];
127 $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
128
129 if($new_obj_id == $question_obj_id)
130 {
131 ilLoggerFactory::getLogger('crs')->info('Test has been linked. Keeping question id');
132 // Object has been linked
133 $new_question_id = $question_qst_id;
134 }
135 else
136 {
137 $new_question_info = $mappings[$question_ref_id.'_question_'.$question_qst_id];
138 $new_question_arr = explode('_',$new_question_info);
139 if(!isset($new_question_arr[2]) or !$new_question_arr[2])
140 {
141 ilLoggerFactory::getLogger('crs')->debug('found invalid format of question id mapping: ' . print_r($new_question_arr,TRUE));
142 continue;
143 }
144 $new_question_id = $new_question_arr[2];
145 ilLoggerFactory::getLogger('crs')->info('New question id is: '.$new_question_id);
146 }
147
148 ilLoggerFactory::getLogger('crs')->debug('Copying question assignments');
149 $new_question = new ilCourseObjectiveQuestion($a_new_objective);
150 $new_question->setTestRefId($new_ref_id);
151 $new_question->setTestObjId($new_obj_id);
152 $new_question->setQuestionId($new_question_id);
153 $new_question->add();
154 }
155
156 // Copy tests
157 foreach($this->getTests() as $test)
158 {
159 $new_test_id = $mappings["$test[ref_id]"];
160
161 $query = "UPDATE crs_objective_tst ".
162 "SET tst_status = ".$this->db->quote($test['tst_status'] ,'integer').", ".
163 "tst_limit_p = ".$this->db->quote($test['tst_limit'] ,'integer')." ".
164 "WHERE objective_id = ".$this->db->quote($a_new_objective ,'integer')." ".
165 "AND ref_id = ".$this->db->quote($new_test_id ,'integer');
166 $res = $ilDB->manipulate($query);
167 }
168 }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static getLogger($a_component_id)
Get component logger.

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

+ Here is the call graph for this function:

◆ delete()

ilCourseObjectiveQuestion::delete (   $qst_id)

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

712 {
713 global $ilDB;
714
715 if(!$qst_id)
716 {
717 return false;
718 }
719
720 $query = "SELECT * FROM crs_objective_qst ".
721 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
722
723 $res = $this->db->query($query);
724 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
725 {
726 $test_rid = $row->ref_id;
727 $test_oid = $row->obj_id;
728 }
729
730 $query = "DELETE FROM crs_objective_qst ".
731 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
732 $res = $ilDB->manipulate($query);
733
734 // delete test if it was the last question
735 $query = "SELECT * FROM crs_objective_qst ".
736 "WHERE ref_id = ".$ilDB->quote($test_rid ,'integer')." ".
737 "AND obj_id = ".$ilDB->quote($test_oid ,'integer')." ".
738 "AND objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
739
740 $res = $this->db->query($query);
741 if(!$res->numRows())
742 {
743 $this->__deleteTest($test_rid);
744 }
745
746 return true;
747 }

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 795 of file class.ilCourseObjectiveQuestion.php.

796 {
797 global $ilDB;
798
799 $query = "DELETE FROM crs_objective_qst ".
800 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
801 $res = $ilDB->manipulate($query);
802
803 $query = "DELETE FROM crs_objective_tst ".
804 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
805 $res = $ilDB->manipulate($query);
806
807 return true;
808 }

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

+ Here is the call graph for this function:

◆ deleteByTestType()

ilCourseObjectiveQuestion::deleteByTestType (   $a_type)

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

765 {
766 global $ilDB;
767
768
769 // Read tests by type
770 $deletable_refs = array();
771 foreach((array) $this->tests as $tst_data)
772 {
773 if($tst_data['status'] == $a_type)
774 {
775 $deletable_refs[] = $tst_data['ref_id'];
776 }
777 }
778
779 $query = 'DELETE from crs_objective_tst '.
780 'WHERE objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
781 'AND tst_status = '.$ilDB->quote($a_type,'integer');
782 $ilDB->manipulate($query);
783
784
785 $query = 'DELETE from crs_objective_tst '.
786 'WHERE objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
787 'AND '.$ilDB->in('ref_id',$deletable_refs,false,'integer');
788 $ilDB->manipulate($query);
789
790 return true;
791 }

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 750 of file class.ilCourseObjectiveQuestion.php.

751 {
752 global $ilDB;
753
754 $query = 'DELETE FROM crs_objective_tst '.
755 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,'integer');
756 $ilDB->manipulate($query);
757
758 $query = 'DELETE FROM crs_objective_qst '.
759 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,'integer');
760 $ilDB->manipulate($query);
761 }

References $ilDB, and $query.

Referenced by ilLOEditorGUI\deleteTest(), and ilLOEditorGUI\deleteTests().

+ Here is the caller graph for this function:

◆ getFinalTestPoints()

ilCourseObjectiveQuestion::getFinalTestPoints ( )

get final test points

@access public

Returns

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

438 {
439 foreach($this->getFinalTestQuestions() as $question)
440 {
441 $points += $question['points'];
442 }
443 return $points ? $points : 0;
444 }
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 490 of file class.ilCourseObjectiveQuestion.php.

491 {
492 foreach($this->questions as $question)
493 {
494 if($question['test_type'] == self::TYPE_FINAL_TEST)
495 {
496 $final[] = $question;
497 }
498 }
499 return $final ? $final : array();
500 }

Referenced by getFinalTestPoints().

+ Here is the caller graph for this function:

◆ getFinalTests()

ilCourseObjectiveQuestion::getFinalTests ( )

get final tests

@access public

Returns

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

360 {
361 foreach($this->tests as $test)
362 {
363 if($test['status'] == self::TYPE_FINAL_TEST)
364 {
365 $final[] = $test;
366 }
367 }
368 return $final ? $final : array();
369 }

References $test.

◆ getMaxPointsByObjective()

ilCourseObjectiveQuestion::getMaxPointsByObjective ( )

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

560 {
561 include_once './Modules/Test/classes/class.ilObjTest.php';
562
563 $points = 0;
564 foreach($this->getQuestions() as $question)
565 {
566 $tmp_test =& ilObjectFactory::getInstanceByRefId($question['ref_id']);
567
568 $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
569
570 $points += $tmp_question->getMaximumPoints();
571
572 unset($tmp_question);
573 unset($tmp_test);
574 }
575 return $points;
576 }
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 578 of file class.ilCourseObjectiveQuestion.php.

579 {
580 $points = 0;
581
582 $tmp_test =& ilObjectFactory::getInstanceByRefId($a_test_ref_id);
583
584 foreach($this->getQuestions() as $question)
585 {
586 if($question['ref_id'] == $a_test_ref_id)
587 {
588 $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
589
590 $points += $tmp_question->getMaximumPoints();
591
592 unset($tmp_question);
593 }
594 }
595 unset($tmp_test);
596
597 return $points;
598 }

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 615 of file class.ilCourseObjectiveQuestion.php.

616 {
617 $counter = 0;
618
619 foreach($this->getQuestions() as $question)
620 {
621 if($question['ref_id'] == $a_test_ref_id)
622 {
623 ++$counter;
624 }
625 }
626 return $counter;
627 }

References getQuestions().

+ Here is the call graph for this function:

◆ getObjectiveId()

ilCourseObjectiveQuestion::getObjectiveId ( )

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

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

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 523 of file class.ilCourseObjectiveQuestion.php.

524 {
525 return $this->questions[$question_id] ? $this->questions[$question_id] : array();
526 }

◆ getQuestionId()

ilCourseObjectiveQuestion::getQuestionId ( )

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

554 {
555 return $this->question_id;
556 }

Referenced by add().

+ Here is the caller graph for this function:

◆ getQuestions()

ilCourseObjectiveQuestion::getQuestions ( )

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

394 {
395 return $this->questions ? $this->questions : array();
396 }

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 629 of file class.ilCourseObjectiveQuestion.php.

630 {
631 foreach($this->getQuestions() as $question)
632 {
633 if($question['ref_id'] == $a_test_ref_id)
634 {
635 $qst[] = $question['question_id'];
636 }
637 }
638 return $qst ? $qst : array();
639 }

References getQuestions().

Referenced by toXml().

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

◆ getQuestionsOfTest()

ilCourseObjectiveQuestion::getQuestionsOfTest (   $a_test_id)

Get questions of test.

@access public

Parameters
inttest id

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

512 {
513 foreach($this->getQuestions() as $qst)
514 {
515 if($a_test_id == $qst['obj_id'])
516 {
517 $questions[] = $qst;
518 }
519 }
520 return $questions ? $questions : array();
521 }

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 422 of file class.ilCourseObjectiveQuestion.php.

423 {
424 foreach($this->getSelfAssessmentQuestions() as $question)
425 {
426 $points += $question['points'];
427 }
428 return $points ? $points : 0;
429 }
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 404 of file class.ilCourseObjectiveQuestion.php.

405 {
406 foreach($this->questions as $question)
407 {
408 if($question['test_type'] == self::TYPE_SELF_ASSESSMENT)
409 {
410 $self[] = $question;
411 }
412 }
413 return $self ? $self : array();
414 }
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 341 of file class.ilCourseObjectiveQuestion.php.

342 {
343 foreach($this->tests as $test)
344 {
345 if($test['status'] == self::TYPE_SELF_ASSESSMENT)
346 {
347 $self[] = $test;
348 }
349 }
350 return $self ? $self : array();
351 }

References $test, and TYPE_SELF_ASSESSMENT.

◆ getTestObjId()

ilCourseObjectiveQuestion::getTestObjId ( )

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

546 {
547 return $this->tst_obj_id ? $this->tst_obj_id : 0;
548 }

Referenced by __addTest(), and add().

+ Here is the caller graph for this function:

◆ getTestRefId()

ilCourseObjectiveQuestion::getTestRefId ( )

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

538 {
539 return $this->tst_ref_id ? $this->tst_ref_id : 0;
540 }

Referenced by __addTest(), and add().

+ Here is the caller graph for this function:

◆ getTests()

ilCourseObjectiveQuestion::getTests ( )

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

309 {
310 global $ilDB;
311
312 $query = "SELECT * FROM crs_objective_tst cot ".
313 "JOIN object_data obd ON cot.obj_id = obd.obj_id ".
314 "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
315 "ORDER BY title ";
316
317 $res = $this->db->query($query);
318 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
319 {
320 $test['test_objective_id'] = $row->test_objective_id;
321 $test['objective_id'] = $row->objective_id;
322 $test['ref_id'] = $row->ref_id;
323 $test['obj_id'] = $row->obj_id;
324 $test['tst_status'] = $row->tst_status;
325 $test['tst_limit'] = $row->tst_limit_p;
326 $test['title'] = $row->title;
327
328 $tests[] = $test;
329 }
330
331 return $tests ? $tests : array();
332 }

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

Referenced by cloneDependencies(), and toXml().

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

◆ getTestStatus()

ilCourseObjectiveQuestion::getTestStatus ( )

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

191 {
192 return (int) $this->tst_status;
193 }

Referenced by __addTest(), and updateTest().

+ Here is the caller graph for this function:

◆ getTestSuggestedLimit()

ilCourseObjectiveQuestion::getTestSuggestedLimit ( )

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

199 {
200 return (int) $this->tst_limit;
201 }

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 471 of file class.ilCourseObjectiveQuestion.php.

472 {
473 foreach($this->questions as $question)
474 {
475 if($question['question_id'] == $a_question_id)
476 {
477 return $question['test_type'] == self::TYPE_FINAL_TEST;
478 }
479 }
480 return false;
481
482 }

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 452 of file class.ilCourseObjectiveQuestion.php.

453 {
454 foreach($this->questions as $question)
455 {
456 if($question['question_id'] == $a_question_id)
457 {
458 return $question['test_type'] == self::TYPE_SELF_ASSESSMENT;
459 }
460 }
461 return false;
462 }

References TYPE_SELF_ASSESSMENT.

◆ lookupObjectivesOfQuestion()

static ilCourseObjectiveQuestion::lookupObjectivesOfQuestion (   $a_qid)
static

Lookup objective for test question @global type $ilDB.

Parameters
type$a_test_ref_id
type$a_qid
Returns
int

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

65 {
66 global $ilDB;
67
68 $query = 'SELECT objective_id FROM crs_objective_qst '.
69 'WHERE question_id = '.$ilDB->quote($a_qid,'integer');
70 $res = $ilDB->query($query);
71 $objectiveIds = array();
72 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
73 {
74 $objectiveIds[] = $row->objective_id;
75 }
76 return $objectiveIds;
77 }

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

Referenced by ilLOTestQuestionAdapter\lookupObjectiveIdByFixedQuestionId().

+ Here is the caller graph for this function:

◆ lookupQuestionsByObjective()

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

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

911 {
912 global $ilDB;
913
914 $query = 'SELECT question_id FROM crs_objective_qst '.
915 'WHERE objective_id = '.$ilDB->quote($a_objective,'integer').' '.
916 'AND obj_id = '.$ilDB->quote($a_test_id,'integer');
917 $res = $ilDB->query($query);
918
919 $questions = array();
920 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
921 {
922 $questions[] = $row->question_id;
923 }
924 return (array) $questions;
925 }

References $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 927 of file class.ilCourseObjectiveQuestion.php.

928 {
929 global $ilDB;
930
931 $query = 'SELECT tst_limit_p FROM crs_objective_tst '.
932 'WHERE objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
933 'AND obj_id = '.$ilDB->quote($a_test_id,'integer');
934 $res = $ilDB->query($query);
935 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
936 {
937 return (int) $row->tst_limit_p;
938 }
939 return 0;
940 }

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 549 of file class.ilCourseObjectiveQuestion.php.

550 {
551 $this->question_id = $a_question_id;
552 }

◆ setTestObjId()

ilCourseObjectiveQuestion::setTestObjId (   $a_obj_id)

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

542 {
543 $this->tst_obj_id = $a_obj_id;
544 }

◆ setTestRefId()

ilCourseObjectiveQuestion::setTestRefId (   $a_ref_id)

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

534 {
535 $this->tst_ref_id = $a_ref_id;
536 }

◆ setTestStatus()

ilCourseObjectiveQuestion::setTestStatus (   $a_status)

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

187 {
188 $this->tst_status = $a_status;
189 }

◆ setTestSuggestedLimit()

ilCourseObjectiveQuestion::setTestSuggestedLimit (   $a_limit)

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

195 {
196 $this->tst_limit = $a_limit;
197 }

◆ toXml()

ilCourseObjectiveQuestion::toXml ( ilXmlWriter  $writer)

To xml.

Parameters
ilXmlWriter$writer

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

947 {
948 foreach($this->getTests() as $test)
949 {
950 include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
951 $writer->xmlStartTag(
952 'Test',
953 array(
955 'refId' => $test['ref_id'],
956 'testType' => $test['tst_status'],
957 'limit' => $test['tst_limit']
958 )
959 );
960
961 // questions
962 foreach($this->getQuestionsByTest($test['ref_id']) as $question_id)
963 {
964 $writer->xmlElement('Question', array('id' => $question_id));
965 }
966 $writer->xmlEndTag('Test');
967 }
968
969 }
xmlEndTag($tag)
Writes an endtag.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)

References $test, getQuestionsByTest(), getTests(), ilLOXmlWriter\TYPE_TST_ALL, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ updateLimits()

ilCourseObjectiveQuestion::updateLimits ( )

update limits

@access public

Parameters

return

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

649 {
650 global $ilDB;
651
652 foreach($this->tests as $ref_id => $test_data)
653 {
654 switch($test_data['status'])
655 {
657 $points = $this->getSelfAssessmentPoints();
658 break;
659
661 $points = $this->getFinalTestPoints();
662 break;
663 }
664 if($test_data['limit'] == -1 or $test_data['limit'] > $points)
665 {
666 switch($test_data['status'])
667 {
669 $points = $this->getSelfAssessmentPoints();
670 break;
671
673 $points = $this->getFinalTestPoints();
674 break;
675 }
676 $query = "UPDATE crs_objective_tst ".
677 "SET tst_limit = ".$this->db->quote($points ,'integer')." ".
678 "WHERE test_objective_id = ".$this->db->quote($test_data['test_objective_id'] ,'integer')." ";
679 $res = $ilDB->manipulate($query);
680 }
681 }
682 }
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 295 of file class.ilCourseObjectiveQuestion.php.

296 {
297 global $ilDB;
298
299 $query = "UPDATE crs_objective_tst ".
300 "SET tst_status = ".$ilDB->quote($this->getTestStatus() ,'integer').", ".
301 "tst_limit_p = ".$ilDB->quote($this->getTestSuggestedLimit() ,'integer')." ".
302 "WHERE test_objective_id = ".$ilDB->quote($a_objective_id ,'integer')."";
303 $res = $ilDB->manipulate($query);
304
305 return true;
306 }

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: