ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCourseObjectiveQuestion Class Reference

class ilcourseobjectiveQuestion More...

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

Public Member Functions

 __construct ($a_objective_id)
 Constructor @global type $ilDB. More...
 
 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...
 
 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 ()
 
 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 _getTest ($a_test_objective_id)
 
static _lookupMaximumPointsOfQuestion ($a_question_id)
 lookup maximimum point More...
 
static deleteTest ($a_tst_ref_id)
 
static _hasTests ($a_course_id)
 @access public More...
 
static _isAssigned ($a_objective_id, $a_tst_ref_id, $a_question_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.

Constructor & Destructor Documentation

◆ __construct()

ilCourseObjectiveQuestion::__construct (   $a_objective_id)

Constructor @global type $ilDB.

Parameters
type$a_objective_id

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

51 {
52 global $DIC;
53
54 $ilDB = $DIC['ilDB'];
55
56 $this->db = $ilDB;
57
58 $this->objective_id = $a_objective_id;
59
60 $this->__read();
61 }
global $DIC
Definition: goto.php:24
global $ilDB

References $DIC, $ilDB, and __read().

+ Here is the call graph for this function:

Member Function Documentation

◆ __addTest()

ilCourseObjectiveQuestion::__addTest ( )

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

212 {
213 global $DIC;
214
215 $ilDB = $DIC['ilDB'];
216
217 $query = "UPDATE crs_objective_tst " .
218 "SET tst_status = " . $this->db->quote($this->getTestStatus(), 'integer') . " " .
219 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
220 "AND ref_id = " . $this->db->quote($this->getTestRefId(), 'integer') . " ";
221 $res = $ilDB->manipulate($query);
222
223
224 // CHECK if entry already exists
225 $query = "SELECT * FROM crs_objective_tst " .
226 "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
227 "AND ref_id = " . $ilDB->quote($this->getTestRefId(), 'integer') . "";
228
229 $res = $this->db->query($query);
230 if ($res->numRows()) {
231 return false;
232 }
233
234 // Check for existing limit
235 $query = "SELECT tst_limit_p FROM crs_objective_tst " .
236 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
237 "AND tst_status = " . $this->db->quote($this->getTestStatus(), 'integer') . " ";
238
239 $res = $this->db->query($query);
240
241 $limit = 100;
242 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
243 $limit = $row->tst_limit_p;
244 }
245
246 $next_id = $ilDB->nextId('crs_objective_tst');
247 $query = "INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) " .
248 "VALUES( " .
249 $ilDB->quote($next_id, 'integer') . ", " .
250 $ilDB->quote($this->getObjectiveId(), 'integer') . ", " .
251 $ilDB->quote($this->getTestRefId(), 'integer') . ", " .
252 $ilDB->quote($this->getTestObjId(), 'integer') . ", " .
253 $ilDB->quote($this->getTestStatus(), 'integer') . ", " .
254 $this->db->quote($limit, 'integer') . " " .
255 ")";
256 $res = $ilDB->manipulate($query);
257
258 return true;
259 }
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, $res, ilDBConstants\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 261 of file class.ilCourseObjectiveQuestion.php.

262 {
263 global $DIC;
264
265 $ilDB = $DIC['ilDB'];
266
267 // Delete questions
268 $query = "DELETE FROM crs_objective_qst " .
269 "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
270 "AND ref_id = " . $ilDB->quote($a_test_ref_id, 'integer') . " ";
271 $res = $ilDB->manipulate($query);
272
273 // delete tst entries
274 $query = "DELETE FROM crs_objective_tst " .
275 "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
276 "AND ref_id = " . $ilDB->quote($a_test_ref_id, 'integer') . " ";
277 $res = $ilDB->manipulate($query);
278
279 unset($this->tests[$a_test_ref_id]);
280
281 return true;
282 }

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

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

Referenced by __construct(), and add().

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

186 {
187 global $DIC;
188
189 $tree = $DIC['tree'];
190
191 return $tree->getSubTree($tree->getNodeData($a_container_ref_id), true, 'tst');
192 }

References $DIC.

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

+ Here is the caller graph for this function:

◆ _getTest()

static ilCourseObjectiveQuestion::_getTest (   $a_test_objective_id)
static

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

384 {
385 global $DIC;
386
387 $ilDB = $DIC['ilDB'];
388
389 $query = "SELECT * FROM crs_objective_tst " .
390 "WHERE test_objective_id = " . $ilDB->quote($a_test_objective_id, 'integer') . " ";
391
392 $res = $ilDB->query($query);
393 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
394 $test['test_objective_id'] = $row->test_objective_id;
395 $test['objective_id'] = $row->objective_id;
396 $test['ref_id'] = $row->ref_id;
397 $test['obj_id'] = $row->obj_id;
398 $test['tst_status'] = $row->tst_status;
399 $test['tst_limit'] = $row->tst_limit_p;
400 }
401
402 return $test ? $test : array();
403 }
$test
Definition: Utf8Test.php:84

References $DIC, $ilDB, $query, $res, $test, and ilDBConstants\FETCHMODE_OBJECT.

◆ _hasTests()

static ilCourseObjectiveQuestion::_hasTests (   $a_course_id)
static

@access public

Parameters

return

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

874 {
875 global $DIC;
876
877 $ilDB = $DIC['ilDB'];
878
879 $query = "SELECT co.objective_id FROM crs_objectives co JOIN " .
880 "crs_objective_tst cot ON co.objective_id = cot.objective_id " .
881 "WHERE crs_id = " . $ilDB->quote($a_course_id, 'integer') . " ";
882 $res = $ilDB->query($query);
883 return $res->numRows() ? true : false;
884 }
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.

References $DIC, $ilDB, $query, $res, and true.

Referenced by ilCourseObjectivesGUI\setSubTabs().

+ Here is the caller graph for this function:

◆ _isAssigned()

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

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

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

References $DIC, $ilDB, $objective_id, $query, $res, and ilDBConstants\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 97 of file class.ilCourseObjectiveQuestion.php.

98 {
99 global $DIC;
100
101 $ilDB = $DIC['ilDB'];
102
103 $query = "SELECT qst_ass_id FROM crs_objective_qst " .
104 "WHERE ref_id = " . $ilDB->quote($a_test_id, 'integer') . " " .
105 "AND objective_id = " . $ilDB->quote($a_objective_id, 'integer');
106 $res = $ilDB->query($query);
107 return $res->numRows() ? true : false;
108 }

References $DIC, $ilDB, $query, $res, and true.

◆ _lookupMaximumPointsOfQuestion()

static ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion (   $a_question_id)
static

lookup maximimum point

@access public

Parameters
intquestion id
Returns

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

606 {
607 include_once('Modules/TestQuestionPool/classes/class.assQuestion.php');
608 return assQuestion::_getMaximumPoints($a_question_id);
609 }
static _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 294 of file class.ilCourseObjectiveQuestion.php.

295 {
296 global $DIC;
297
298 $ilDB = $DIC['ilDB'];
299
300 $query = "UPDATE crs_objective_tst " .
301 "SET tst_limit_p = " . $ilDB->quote($a_limit, 'integer') . " " .
302 "WHERE tst_status = " . $ilDB->quote($a_status, 'integer') . " " .
303 "AND objective_id = " . $ilDB->quote($a_objective_id, 'integer');
304 $res = $ilDB->manipulate($query);
305 return true;
306 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\saveQuestionOverview().

+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveQuestion::add ( )

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

677 {
678 global $DIC;
679
680 $ilDB = $DIC['ilDB'];
681
682 $query = "DELETE FROM crs_objective_qst " .
683 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
684 "AND question_id = " . $this->db->quote($this->getQuestionId(), 'integer') . " ";
685 $res = $ilDB->manipulate($query);
686
687 $next_id = $ilDB->nextId('crs_objective_qst');
688 $query = "INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) " .
689 "VALUES( " .
690 $ilDB->quote($next_id, 'integer') . ", " .
691 $ilDB->quote($this->getObjectiveId(), 'integer') . ", " .
692 $ilDB->quote($this->getTestRefId(), 'integer') . ", " .
693 $ilDB->quote($this->getTestObjId(), 'integer') . ", " .
694 $ilDB->quote($this->getQuestionId(), 'integer') .
695 ")";
696 $res = $ilDB->manipulate($query);
697
698 $this->__addTest();
699
700 $this->__read();
701
702 return true;
703 }

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

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

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

+ Here is the call graph for this function:

◆ delete()

ilCourseObjectiveQuestion::delete (   $qst_id)

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

705 {
706 global $DIC;
707
708 $ilDB = $DIC['ilDB'];
709
710 if (!$qst_id) {
711 return false;
712 }
713
714 $query = "SELECT * FROM crs_objective_qst " .
715 "WHERE qst_ass_id = " . $ilDB->quote($qst_id, 'integer') . " ";
716
717 $res = $this->db->query($query);
718 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
719 $test_rid = $row->ref_id;
720 $test_oid = $row->obj_id;
721 }
722
723 $query = "DELETE FROM crs_objective_qst " .
724 "WHERE qst_ass_id = " . $ilDB->quote($qst_id, 'integer') . " ";
725 $res = $ilDB->manipulate($query);
726
727 // delete test if it was the last question
728 $query = "SELECT * FROM crs_objective_qst " .
729 "WHERE ref_id = " . $ilDB->quote($test_rid, 'integer') . " " .
730 "AND obj_id = " . $ilDB->quote($test_oid, 'integer') . " " .
731 "AND objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
732
733 $res = $this->db->query($query);
734 if (!$res->numRows()) {
735 $this->__deleteTest($test_rid);
736 }
737
738 return true;
739 }

References $DIC, $ilDB, $query, $res, __deleteTest(), ilDBConstants\FETCHMODE_OBJECT, and getObjectiveId().

+ Here is the call graph for this function:

◆ deleteAll()

ilCourseObjectiveQuestion::deleteAll ( )

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

790 {
791 global $DIC;
792
793 $ilDB = $DIC['ilDB'];
794
795 $query = "DELETE FROM crs_objective_qst " .
796 "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
797 $res = $ilDB->manipulate($query);
798
799 $query = "DELETE FROM crs_objective_tst " .
800 "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
801 $res = $ilDB->manipulate($query);
802
803 return true;
804 }

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

+ Here is the call graph for this function:

◆ deleteByTestType()

ilCourseObjectiveQuestion::deleteByTestType (   $a_type)

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

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

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

+ Here is the call graph for this function:

◆ deleteTest()

static ilCourseObjectiveQuestion::deleteTest (   $a_tst_ref_id)
static

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

743 {
744 global $DIC;
745
746 $ilDB = $DIC['ilDB'];
747
748 $query = 'DELETE FROM crs_objective_tst ' .
749 'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id, 'integer');
750 $ilDB->manipulate($query);
751
752 $query = 'DELETE FROM crs_objective_qst ' .
753 'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id, 'integer');
754 $ilDB->manipulate($query);
755 }

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

448 {
449 foreach ($this->getFinalTestQuestions() as $question) {
450 $points += $question['points'];
451 }
452 return $points ? $points : 0;
453 }
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 494 of file class.ilCourseObjectiveQuestion.php.

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

Referenced by getFinalTestPoints().

+ Here is the caller graph for this function:

◆ getFinalTests()

ilCourseObjectiveQuestion::getFinalTests ( )

get final tests

@access public

Returns

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

374 {
375 foreach ($this->tests as $test) {
376 if ($test['status'] == self::TYPE_FINAL_TEST) {
377 $final[] = $test;
378 }
379 }
380 return $final ? $final : array();
381 }

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 $tmp_test = &ilObjectFactory::getInstanceByRefId($question['ref_id']);
566
567 $tmp_question = &ilObjTest::_instanciateQuestion($question['question_id']);
568
569 $points += $tmp_question->getMaximumPoints();
570
571 unset($tmp_question);
572 unset($tmp_test);
573 }
574 return $points;
575 }
static 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 577 of file class.ilCourseObjectiveQuestion.php.

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

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

613 {
614 $counter = 0;
615
616 foreach ($this->getQuestions() as $question) {
617 if ($question['ref_id'] == $a_test_ref_id) {
618 ++$counter;
619 }
620 }
621 return $counter;
622 }

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

407 {
408 return $this->questions ? $this->questions : array();
409 }

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

625 {
626 foreach ($this->getQuestions() as $question) {
627 if ($question['ref_id'] == $a_test_ref_id) {
628 $qst[] = $question['question_id'];
629 }
630 }
631 return $qst ? $qst : array();
632 }

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

514 {
515 foreach ($this->getQuestions() as $qst) {
516 if ($a_test_id == $qst['obj_id']) {
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 433 of file class.ilCourseObjectiveQuestion.php.

434 {
435 foreach ($this->getSelfAssessmentQuestions() as $question) {
436 $points += $question['points'];
437 }
438 return $points ? $points : 0;
439 }
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 417 of file class.ilCourseObjectiveQuestion.php.

418 {
419 foreach ($this->questions as $question) {
420 if ($question['test_type'] == self::TYPE_SELF_ASSESSMENT) {
421 $self[] = $question;
422 }
423 }
424 return $self ? $self : array();
425 }
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 357 of file class.ilCourseObjectiveQuestion.php.

358 {
359 foreach ($this->tests as $test) {
360 if ($test['status'] == self::TYPE_SELF_ASSESSMENT) {
361 $self[] = $test;
362 }
363 }
364 return $self ? $self : array();
365 }

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

324 {
325 global $DIC;
326
327 $ilDB = $DIC['ilDB'];
328
329 $query = "SELECT * FROM crs_objective_tst cot " .
330 "JOIN object_data obd ON cot.obj_id = obd.obj_id " .
331 "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
332 "ORDER BY title ";
333
334 $res = $this->db->query($query);
335 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
336 $test['test_objective_id'] = $row->test_objective_id;
337 $test['objective_id'] = $row->objective_id;
338 $test['ref_id'] = $row->ref_id;
339 $test['obj_id'] = $row->obj_id;
340 $test['tst_status'] = $row->tst_status;
341 $test['tst_limit'] = $row->tst_limit_p;
342 $test['title'] = $row->title;
343
344 $tests[] = $test;
345 }
346
347 return $tests ? $tests : array();
348 }

References $DIC, $ilDB, $query, $res, $test, $tests, ilDBConstants\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 199 of file class.ilCourseObjectiveQuestion.php.

200 {
201 return (int) $this->tst_status;
202 }

Referenced by __addTest(), and updateTest().

+ Here is the caller graph for this function:

◆ getTestSuggestedLimit()

ilCourseObjectiveQuestion::getTestSuggestedLimit ( )

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

208 {
209 return (int) $this->tst_limit;
210 }

Referenced by updateTest().

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

479 {
480 foreach ($this->questions as $question) {
481 if ($question['question_id'] == $a_question_id) {
482 return $question['test_type'] == self::TYPE_FINAL_TEST;
483 }
484 }
485 return false;
486 }

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

462 {
463 foreach ($this->questions as $question) {
464 if ($question['question_id'] == $a_question_id) {
465 return $question['test_type'] == self::TYPE_SELF_ASSESSMENT;
466 }
467 }
468 return false;
469 }

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

72 {
73 global $DIC;
74
75 $ilDB = $DIC['ilDB'];
76
77 $query = 'SELECT objective_id FROM crs_objective_qst ' .
78 'WHERE question_id = ' . $ilDB->quote($a_qid, 'integer');
79 $res = $ilDB->query($query);
80 $objectiveIds = array();
81 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
82 $objectiveIds[] = $row->objective_id;
83 }
84 return $objectiveIds;
85 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\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 908 of file class.ilCourseObjectiveQuestion.php.

909 {
910 global $DIC;
911
912 $ilDB = $DIC['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(ilDBConstants::FETCHMODE_OBJECT)) {
921 $questions[] = $row->question_id;
922 }
923 return (array) $questions;
924 }

References $DIC, $ilDB, $query, $questions, $res, and ilDBConstants\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 926 of file class.ilCourseObjectiveQuestion.php.

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

References $DIC, $ilDB, $query, $res, and ilDBConstants\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 195 of file class.ilCourseObjectiveQuestion.php.

196 {
197 $this->tst_status = $a_status;
198 }

◆ setTestSuggestedLimit()

ilCourseObjectiveQuestion::setTestSuggestedLimit (   $a_limit)

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

204 {
205 $this->tst_limit = $a_limit;
206 }

◆ 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 include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
950 $writer->xmlStartTag(
951 'Test',
952 array(
954 'refId' => $test['ref_id'],
955 'testType' => $test['tst_status'],
956 'limit' => $test['tst_limit']
957 )
958 );
959
960 // questions
961 foreach ($this->getQuestionsByTest($test['ref_id']) as $question_id) {
962 $writer->xmlElement('Question', array('id' => $question_id));
963 }
964 $writer->xmlEndTag('Test');
965 }
966 }
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.

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

642 {
643 global $DIC;
644
645 $ilDB = $DIC['ilDB'];
646
647 foreach ($this->tests as $ref_id => $test_data) {
648 switch ($test_data['status']) {
650 $points = $this->getSelfAssessmentPoints();
651 break;
652
654 $points = $this->getFinalTestPoints();
655 break;
656 }
657 if ($test_data['limit'] == -1 or $test_data['limit'] > $points) {
658 switch ($test_data['status']) {
660 $points = $this->getSelfAssessmentPoints();
661 break;
662
664 $points = $this->getFinalTestPoints();
665 break;
666 }
667 $query = "UPDATE crs_objective_tst " .
668 "SET tst_limit = " . $this->db->quote($points, 'integer') . " " .
669 "WHERE test_objective_id = " . $this->db->quote($test_data['test_objective_id'], 'integer') . " ";
670 $res = $ilDB->manipulate($query);
671 }
672 }
673 }
getSelfAssessmentPoints()
get self assessment points

References $DIC, $ilDB, $query, $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 308 of file class.ilCourseObjectiveQuestion.php.

309 {
310 global $DIC;
311
312 $ilDB = $DIC['ilDB'];
313
314 $query = "UPDATE crs_objective_tst " .
315 "SET tst_status = " . $ilDB->quote($this->getTestStatus(), 'integer') . ", " .
316 "tst_limit_p = " . $ilDB->quote($this->getTestSuggestedLimit(), 'integer') . " " .
317 "WHERE test_objective_id = " . $ilDB->quote($a_objective_id, 'integer') . "";
318 $res = $ilDB->manipulate($query);
319
320 return true;
321 }

References $DIC, $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: