ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCourseObjectiveQuestion Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCourseObjectiveQuestion:

Public Member Functions

 __construct (int $a_objective_id=0)
 
 cloneDependencies (int $a_new_objective, int $a_copy_id)
 
 setTestStatus (int $a_status)
 
 getTestStatus ()
 
 setTestSuggestedLimit (int $a_limit)
 
 getTestSuggestedLimit ()
 
 __addTest ()
 
 __deleteTest (int $a_test_ref_id)
 
 updateTest (int $a_objective_id)
 
 getTests ()
 
 getSelfAssessmentTests ()
 
 getFinalTests ()
 
 getQuestions ()
 
 getSelfAssessmentQuestions ()
 
 getSelfAssessmentPoints ()
 
 getFinalTestPoints ()
 
 isSelfAssessmentQuestion (int $a_question_id)
 
 isFinalTestQuestion (int $a_question_id)
 
 getFinalTestQuestions ()
 
 getQuestionsOfTest (int $a_test_id)
 
 getQuestion (int $question_id)
 
 getObjectiveId ()
 
 setTestRefId (int $a_ref_id)
 
 getTestRefId ()
 
 setTestObjId (int $a_obj_id)
 
 getTestObjId ()
 
 setQuestionId (int $a_question_id)
 
 getQuestionId ()
 
 getMaxPointsByObjective ()
 
 getMaxPointsByTest (int $a_test_ref_id)
 
 getNumberOfQuestionsByTest (int $a_test_ref_id)
 
 getQuestionsByTest (int $a_test_ref_id)
 
 updateLimits ()
 
 add ()
 
 delete (int $qst_id)
 
 deleteByTestType (int $a_type)
 
 deleteAll ()
 
 __read ()
 
 toXml (ilXmlWriter $writer)
 

Static Public Member Functions

static lookupObjectivesOfQuestion (int $a_qid)
 
static _isTestAssignedToObjective (int $a_test_id, int $a_objective_id)
 
static _getAssignableTests (int $a_container_ref_id)
 
static _updateTestLimits (int $a_objective_id, int $a_status, int $a_limit)
 
static _getTest (int $a_test_objective_id)
 
static _lookupMaximumPointsOfQuestion (int $a_question_id)
 
static deleteTest (int $a_tst_ref_id)
 
static _hasTests (int $a_course_id)
 
static _isAssigned (int $a_objective_id, int $a_tst_ref_id, int $a_question_id)
 
static lookupQuestionsByObjective (int $a_test_id, int $a_objective)
 
static loookupTestLimit (int $a_test_id, int $a_objective_id)
 

Data Fields

const TYPE_SELF_ASSESSMENT = 0
 
const TYPE_FINAL_TEST = 1
 

Protected Attributes

ilLogger $logger
 
ilDBInterface $db
 
ilObjectDataCache $objectDataCache
 
ilTree $tree
 

Private Attributes

int $objective_id = 0
 
array $questions = []
 
array $tests = []
 
int $tst_status = 0
 
int $tst_limit = 0
 
int $tst_ref_id = 0
 
int $tst_obj_id = 0
 
int $question_id = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning class ilcourseobjectiveQuestion

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

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

Constructor & Destructor Documentation

◆ __construct()

ilCourseObjectiveQuestion::__construct ( int  $a_objective_id = 0)

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

43 {
44 global $DIC;
45
46 $this->logger = $DIC->logger()->crs();
47 $this->objectDataCache = $DIC['ilObjDataCache'];
48 $this->db = $DIC->database();
49 $this->tree = $DIC->repositoryTree();
50
51 $this->objective_id = $a_objective_id;
52 $this->__read();
53 }
global $DIC
Definition: shib_login.php:26

References $DIC, __read(), ILIAS\Repository\logger(), and ILIAS\Repository\objectDataCache().

+ Here is the call graph for this function:

Member Function Documentation

◆ __addTest()

ilCourseObjectiveQuestion::__addTest ( )

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

172 : void
173 {
174 $query = "UPDATE crs_objective_tst " .
175 "SET tst_status = " . $this->db->quote($this->getTestStatus(), 'integer') . " " .
176 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
177 "AND ref_id = " . $this->db->quote($this->getTestRefId(), 'integer') . " ";
178 $res = $this->db->manipulate($query);
179
180 // CHECK if entry already exists
181 $query = "SELECT * FROM crs_objective_tst " .
182 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
183 "AND ref_id = " . $this->db->quote($this->getTestRefId(), 'integer') . "";
184
185 $res = $this->db->query($query);
186 if ($res->numRows()) {
187 return;
188 }
189
190 // Check for existing limit
191 $query = "SELECT tst_limit_p FROM crs_objective_tst " .
192 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
193 "AND tst_status = " . $this->db->quote($this->getTestStatus(), 'integer') . " ";
194 $res = $this->db->query($query);
195 $limit_in_db = null;
196 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
197 $limit_in_db = (int) $row->tst_limit_p;
198 }
199 // Select correct limit
200 $limit = 100;
201 if (is_null($limit_in_db) && $this->tst_limit > 0 && $this->tst_limit <= 100) {
202 $limit = $this->tst_limit;
203 }
204 if (!is_null($limit_in_db)) {
205 $limit = $limit_in_db;
206 }
207
208 $next_id = $this->db->nextId('crs_objective_tst');
209 $query = "INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) " .
210 "VALUES( " .
211 $this->db->quote($next_id, 'integer') . ", " .
212 $this->db->quote($this->getObjectiveId(), 'integer') . ", " .
213 $this->db->quote($this->getTestRefId(), 'integer') . ", " .
214 $this->db->quote($this->getTestObjId(), 'integer') . ", " .
215 $this->db->quote($this->getTestStatus(), 'integer') . ", " .
216 $this->db->quote($limit, 'integer') . " " .
217 ")";
218 $res = $this->db->manipulate($query);
219 }
$res
Definition: ltiservices.php:69

References $res, $tst_limit, ilDBConstants\FETCHMODE_OBJECT, getObjectiveId(), getTestRefId(), getTestStatus(), and ILIAS\Repository\int().

Referenced by add().

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

◆ __deleteTest()

ilCourseObjectiveQuestion::__deleteTest ( int  $a_test_ref_id)

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

221 : void
222 {
223 // Delete questions
224 $query = "DELETE FROM crs_objective_qst " .
225 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
226 "AND ref_id = " . $this->db->quote($a_test_ref_id, 'integer') . " ";
227 $res = $this->db->manipulate($query);
228
229 // delete tst entries
230 $query = "DELETE FROM crs_objective_tst " .
231 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
232 "AND ref_id = " . $this->db->quote($a_test_ref_id, 'integer') . " ";
233 $res = $this->db->manipulate($query);
234 unset($this->tests[$a_test_ref_id]);
235 }

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

630 : void
631 {
633 $container_ref_id = current($container_ref_ids);
634
635 // Read test data
636 $query = "SELECT * FROM crs_objective_tst " .
637 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " ";
638 $res = $this->db->query($query);
639 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
640 $this->tests[(int) $row->ref_id]['test_objective_id'] = (int) $row->test_objective_id;
641 $this->tests[(int) $row->ref_id]['ref_id'] = (int) $row->ref_id;
642 $this->tests[(int) $row->ref_id]['obj_id'] = (int) $row->obj_id;
643 $this->tests[(int) $row->ref_id]['status'] = (int) $row->tst_status;
644 $this->tests[(int) $row->ref_id]['limit'] = (int) $row->tst_limit_p;
645 }
646
647 $this->questions = array();
648 $query = "SELECT * FROM crs_objective_qst coq " .
649 "JOIN qpl_questions qq ON coq.question_id = qq.question_id " .
650 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
651 "ORDER BY title";
652
653 $res = $this->db->query($query);
654 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
655 if (!array_key_exists((int) $row->ref_id, $this->tests)) {
656 $this->__deleteTest((int) $row->ref_id);
657 continue;
658 }
659 if (!$this->tree->isInTree((int) $row->ref_id) || !$this->tree->isGrandChild(
660 $container_ref_id,
661 (int) $row->ref_id
662 )) {
663 $this->__deleteTest((int) $row->ref_id);
664 continue;
665 }
666 if (($question = ilObjTest::_instanciateQuestion((int) $row->question_id)) === null) {
667 $this->delete((int) $row->question_id);
668 continue;
669 }
670 $qst['ref_id'] = (int) $row->ref_id;
671 $qst['obj_id'] = (int) $row->obj_id;
672 $qst['question_id'] = (int) $row->question_id;
673 $qst['qst_ass_id'] = (int) $row->qst_ass_id;
674 $qst['title'] = $question->getTitle();
675 $qst['description'] = $question->getComment();
676 $qst['test_type'] = (int) $this->tests[(int) $row->ref_id]['status'];
677 $qst['points'] = (float) $question->getPoints();
678
679 $this->questions[(int) $row->qst_ass_id] = $qst;
680 }
681 }
static _lookupContainerIdByObjectiveId(int $a_objective_id)
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getAllReferences(int $id)
get all reference ids for object ID

References $res, __deleteTest(), ilObject\_getAllReferences(), ilObjTest\_instanciateQuestion(), ilCourseObjective\_lookupContainerIdByObjectiveId(), ilDBConstants\FETCHMODE_OBJECT, getObjectiveId(), and ILIAS\Repository\int().

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 ( int  $a_container_ref_id)
static

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

143 : array
144 {
145 global $DIC;
146
147 $tree = $DIC->repositoryTree();
148 return $tree->getSubTree($tree->getNodeData($a_container_ref_id), true, ['tst']);
149 }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node

References $DIC, $tree, ilTree\getNodeData(), and ilTree\getSubTree().

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

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

◆ _getTest()

static ilCourseObjectiveQuestion::_getTest ( int  $a_test_objective_id)
static

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

304 : array
305 {
306 global $DIC;
307
308 $ilDB = $DIC->database();
309 $query = "SELECT * FROM crs_objective_tst " .
310 "WHERE test_objective_id = " . $ilDB->quote($a_test_objective_id, 'integer') . " ";
311
312 $res = $ilDB->query($query);
313 $test = [];
314 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
315 $test['test_objective_id'] = (int) $row->test_objective_id;
316 $test['objective_id'] = (int) $row->objective_id;
317 $test['ref_id'] = (int) $row->ref_id;
318 $test['obj_id'] = (int) $row->obj_id;
319 $test['tst_status'] = (int) $row->tst_status;
320 $test['tst_limit'] = (int) $row->tst_limit_p;
321 }
322
323 return $test;
324 }

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ _hasTests()

static ilCourseObjectiveQuestion::_hasTests ( int  $a_course_id)
static

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

683 : bool
684 {
685 global $DIC;
686
687 $ilDB = $DIC['ilDB'];
688
689 $query = "SELECT co.objective_id FROM crs_objectives co JOIN " .
690 "crs_objective_tst cot ON co.objective_id = cot.objective_id " .
691 "WHERE crs_id = " . $ilDB->quote($a_course_id, 'integer') . " ";
692 $res = $ilDB->query($query);
693 return (bool) $res->numRows();
694 }

References $DIC, $ilDB, and $res.

◆ _isAssigned()

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

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

696 : int
697 {
698 global $DIC;
699
700 $ilDB = $DIC->database();
701 $query = "SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj " .
702 "WHERE crs_qst.objective_id = crs_obj.objective_id " .
703 "AND crs_qst.objective_id = " . $ilDB->quote($a_objective_id, 'integer') . " " .
704 "AND ref_id = " . $ilDB->quote($a_tst_ref_id, 'integer') . " " .
705 "AND question_id = " . $ilDB->quote($a_question_id, 'integer') . " ";
706
707 $res = $ilDB->query($query);
708 $objective_id = 0;
709 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
710 $objective_id = (int) $row->objective_id;
711 }
712 return $objective_id;
713 }

References $DIC, $ilDB, $objective_id, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ _isTestAssignedToObjective()

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

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

73 : bool
74 {
75 global $DIC;
76
77 $ilDB = $DIC->database();
78
79 $query = "SELECT qst_ass_id FROM crs_objective_qst " .
80 "WHERE ref_id = " . $ilDB->quote($a_test_id, 'integer') . " " .
81 "AND objective_id = " . $ilDB->quote($a_objective_id, 'integer');
82 $res = $ilDB->query($query);
83 return (bool) $res->numRows();
84 }

References $DIC, $ilDB, and $res.

◆ _lookupMaximumPointsOfQuestion()

static ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion ( int  $a_question_id)
static

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

470 : float
471 {
472 global $DIC;
473 return $DIC->testQuestion()->getGeneralQuestionProperties($a_question_id)->getAvailablePoints();
474 }

References $DIC.

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

+ Here is the caller graph for this function:

◆ _updateTestLimits()

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

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

237 : void
238 {
239 global $DIC;
240
241 $ilDB = $DIC['ilDB'];
242
243 $query = "UPDATE crs_objective_tst " .
244 "SET tst_limit_p = " . $ilDB->quote($a_limit, 'integer') . " " .
245 "WHERE tst_status = " . $ilDB->quote($a_status, 'integer') . " " .
246 "AND objective_id = " . $ilDB->quote($a_objective_id, 'integer');
247 $res = $ilDB->manipulate($query);
248 }

References $DIC, $ilDB, and $res.

Referenced by ilCourseObjectivesGUI\saveQuestionOverview().

+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveQuestion::add ( )

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

529 : void
530 {
531 $query = "DELETE FROM crs_objective_qst " .
532 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
533 "AND question_id = " . $this->db->quote($this->getQuestionId(), 'integer') . " ";
534 $res = $this->db->manipulate($query);
535
536 $next_id = $this->db->nextId('crs_objective_qst');
537 $query = "INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) " .
538 "VALUES( " .
539 $this->db->quote($next_id, 'integer') . ", " .
540 $this->db->quote($this->getObjectiveId(), 'integer') . ", " .
541 $this->db->quote($this->getTestRefId(), 'integer') . ", " .
542 $this->db->quote($this->getTestObjId(), 'integer') . ", " .
543 $this->db->quote($this->getQuestionId(), 'integer') .
544 ")";
545 $res = $this->db->manipulate($query);
546
547 $this->__addTest();
548 $this->__read();
549 }

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

+ Here is the call graph for this function:

◆ cloneDependencies()

ilCourseObjectiveQuestion::cloneDependencies ( int  $a_new_objective,
int  $a_copy_id 
)

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

86 : void
87 {
88 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
89 $mappings = $cwo->getMappings();
90 foreach ($this->getQuestions() as $question) {
91 $mapping_key = $question['ref_id'] . '_question_' . $question['question_id'];
92 if (!isset($mappings[$mapping_key]) || !$mappings[$mapping_key]) {
93 continue;
94 }
95 $question_ref_id = $question['ref_id'];
96 $question_obj_id = $question['obj_id'];
97 $question_qst_id = $question['question_id'];
98 $new_ref_id = (int) $mappings[$question_ref_id];
99 $new_obj_id = $this->objectDataCache->lookupObjId($new_ref_id);
100
101 if ($new_obj_id == $question_obj_id) {
102 $this->logger->info('Test has been linked. Keeping question id');
103 // Object has been linked
104 $new_question_id = $question_qst_id;
105 } else {
106 $new_question_info = $mappings[$question_ref_id . '_question_' . $question_qst_id];
107 $new_question_arr = explode('_', $new_question_info);
108 if (!isset($new_question_arr[2]) || !$new_question_arr[2]) {
109 $this->logger->debug('found invalid format of question id mapping: ' . print_r(
110 $new_question_arr,
111 true
112 ));
113 continue;
114 }
115 $new_question_id = $new_question_arr[2];
116 $this->logger->info('New question id is: ' . $new_question_id);
117 }
118
119 ilLoggerFactory::getLogger('crs')->debug('Copying question assignments');
120 $new_question = new ilCourseObjectiveQuestion($a_new_objective);
121 $new_question->setTestRefId($new_ref_id);
122 $new_question->setTestObjId($new_obj_id);
123 $new_question->setQuestionId($new_question_id);
124 $new_question->add();
125 }
126
127 // Copy tests
128 foreach ($this->getTests() as $test) {
129 if (!isset($mappings["$test[ref_id]"])) {
130 continue;
131 }
132 $new_test_id = $mappings["$test[ref_id]"];
133
134 $query = "UPDATE crs_objective_tst " .
135 "SET tst_status = " . $this->db->quote($test['tst_status'], 'integer') . ", " .
136 "tst_limit_p = " . $this->db->quote($test['tst_limit'], 'integer') . " " .
137 "WHERE objective_id = " . $this->db->quote($a_new_objective, 'integer') . " " .
138 "AND ref_id = " . $this->db->quote($new_test_id, 'integer');
139 $res = $this->db->manipulate($query);
140 }
141 }
static _getInstance(int $a_copy_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.

References $res, ilCopyWizardOptions\_getInstance(), ilLoggerFactory\getLogger(), getQuestions(), getTests(), ILIAS\Repository\int(), ILIAS\Repository\logger(), and ILIAS\Repository\objectDataCache().

+ Here is the call graph for this function:

◆ delete()

ilCourseObjectiveQuestion::delete ( int  $qst_id)

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

551 : void
552 {
553 if (!$qst_id) {
554 return;
555 }
556
557 $query = "SELECT * FROM crs_objective_qst " .
558 "WHERE qst_ass_id = " . $this->db->quote($qst_id, 'integer') . " ";
559
560 $test_rid = $test_oid = 0;
561 $res = $this->db->query($query);
562 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
563 $test_rid = (int) $row->ref_id;
564 $test_oid = (int) $row->obj_id;
565 }
566
567 $query = "DELETE FROM crs_objective_qst " .
568 "WHERE qst_ass_id = " . $this->db->quote($qst_id, 'integer') . " ";
569 $res = $this->db->manipulate($query);
570
571 // delete test if it was the last question
572 $query = "SELECT * FROM crs_objective_qst " .
573 "WHERE ref_id = " . $this->db->quote($test_rid, 'integer') . " " .
574 "AND obj_id = " . $this->db->quote($test_oid, 'integer') . " " .
575 "AND objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " ";
576
577 $res = $this->db->query($query);
578 if ($res->numRows() === 0) {
579 $this->__deleteTest($test_rid);
580 }
581 }

References $res, __deleteTest(), ilDBConstants\FETCHMODE_OBJECT, getObjectiveId(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ deleteAll()

ilCourseObjectiveQuestion::deleteAll ( )

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

619 : void
620 {
621 $query = "DELETE FROM crs_objective_qst " .
622 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " ";
623 $res = $this->db->manipulate($query);
624
625 $query = "DELETE FROM crs_objective_tst " .
626 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " ";
627 $res = $this->db->manipulate($query);
628 }

References $res, and getObjectiveId().

+ Here is the call graph for this function:

◆ deleteByTestType()

ilCourseObjectiveQuestion::deleteByTestType ( int  $a_type)

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

598 : void
599 {
600 // Read tests by type
601 $deletable_refs = array();
602 foreach ($this->tests as $tst_data) {
603 if ($tst_data['status'] == $a_type) {
604 $deletable_refs[] = $tst_data['ref_id'];
605 }
606 }
607
608 $query = 'DELETE from crs_objective_tst ' .
609 'WHERE objective_id = ' . $this->db->quote($this->getObjectiveId(), 'integer') . ' ' .
610 'AND tst_status = ' . $this->db->quote($a_type, 'integer');
611 $this->db->manipulate($query);
612
613 $query = 'DELETE from crs_objective_tst ' .
614 'WHERE objective_id = ' . $this->db->quote($this->getObjectiveId(), 'integer') . ' ' .
615 'AND ' . $this->db->in('ref_id', $deletable_refs, false, 'integer');
616 $this->db->manipulate($query);
617 }

References getObjectiveId().

+ Here is the call graph for this function:

◆ deleteTest()

static ilCourseObjectiveQuestion::deleteTest ( int  $a_tst_ref_id)
static

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

584 : void
585 {
586 global $DIC;
587
588 $ilDB = $DIC->database();
589 $query = 'DELETE FROM crs_objective_tst ' .
590 'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id, 'integer');
591 $ilDB->manipulate($query);
592
593 $query = 'DELETE FROM crs_objective_qst ' .
594 'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id, 'integer');
595 $ilDB->manipulate($query);
596 }

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ getFinalTestPoints()

ilCourseObjectiveQuestion::getFinalTestPoints ( )

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

351 : int
352 {
353 $points = 0;
354 foreach ($this->getFinalTestQuestions() as $question) {
355 $points += $question['points'];
356 }
357 return $points;
358 }

References getFinalTestQuestions().

Referenced by updateLimits().

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

◆ getFinalTestQuestions()

ilCourseObjectiveQuestion::getFinalTestQuestions ( )

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

380 : array
381 {
382 $final = [];
383 foreach ($this->questions as $question) {
384 if ($question['test_type'] == self::TYPE_FINAL_TEST) {
385 $final[] = $question;
386 }
387 }
388 return $final;
389 }

Referenced by getFinalTestPoints().

+ Here is the caller graph for this function:

◆ getFinalTests()

ilCourseObjectiveQuestion::getFinalTests ( )

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

293 : array
294 {
295 $final = [];
296 foreach ($this->tests as $test) {
297 if ($test['status'] == self::TYPE_FINAL_TEST) {
298 $final[] = $test;
299 }
300 }
301 return $final;
302 }

◆ getMaxPointsByObjective()

ilCourseObjectiveQuestion::getMaxPointsByObjective ( )

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

446 : int
447 {
448 $points = 0;
449 foreach ($this->getQuestions() as $question) {
450 $tmp_test = ilObjectFactory::getInstanceByRefId($question['ref_id']);
451 $tmp_question = ilObjTest::_instanciateQuestion($question['question_id']);
452 $points += $tmp_question->getMaximumPoints();
453 }
454 return $points;
455 }
static getInstanceByRefId(int $ref_id, bool $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 ( int  $a_test_ref_id)

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

457 : int
458 {
459 $points = 0;
460 $tmp_test = ilObjectFactory::getInstanceByRefId($a_test_ref_id);
461 foreach ($this->getQuestions() as $question) {
462 if ($question['ref_id'] == $a_test_ref_id) {
463 $tmp_question = ilObjTest::_instanciateQuestion($question['question_id']);
464 $points += $tmp_question->getMaximumPoints();
465 }
466 }
467 return $points;
468 }

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

+ Here is the call graph for this function:

◆ getNumberOfQuestionsByTest()

ilCourseObjectiveQuestion::getNumberOfQuestionsByTest ( int  $a_test_ref_id)

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

476 : int
477 {
478 $counter = 0;
479 foreach ($this->getQuestions() as $question) {
480 if ($question['ref_id'] == $a_test_ref_id) {
481 ++$counter;
482 }
483 }
484 return $counter;
485 }
$counter

References $counter, and getQuestions().

+ Here is the call graph for this function:

◆ getObjectiveId()

ilCourseObjectiveQuestion::getObjectiveId ( )

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

411 : int
412 {
413 return $this->objective_id;
414 }

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 ( int  $question_id)

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

402 : array
403 {
404 if ($this->questions[$question_id]) {
405 return $this->questions[$question_id];
406 } else {
407 return array();
408 }
409 }

References $question_id.

◆ getQuestionId()

ilCourseObjectiveQuestion::getQuestionId ( )

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

441 : int
442 {
443 return $this->question_id;
444 }

References $question_id.

Referenced by add().

+ Here is the caller graph for this function:

◆ getQuestions()

ilCourseObjectiveQuestion::getQuestions ( )

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

326 : array
327 {
328 return $this->questions;
329 }

References $questions.

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

+ Here is the caller graph for this function:

◆ getQuestionsByTest()

ilCourseObjectiveQuestion::getQuestionsByTest ( int  $a_test_ref_id)

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

487 : array
488 {
489 $qst = [];
490 foreach ($this->getQuestions() as $question) {
491 if ($question['ref_id'] == $a_test_ref_id) {
492 $qst[] = $question['question_id'];
493 }
494 }
495 return $qst;
496 }

References getQuestions().

Referenced by toXml().

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

◆ getQuestionsOfTest()

ilCourseObjectiveQuestion::getQuestionsOfTest ( int  $a_test_id)

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

391 : array
392 {
393 $questions = [];
394 foreach ($this->getQuestions() as $qst) {
395 if ($a_test_id == $qst['obj_id']) {
396 $questions[] = $qst;
397 }
398 }
399 return $questions;
400 }

References $questions, and getQuestions().

+ Here is the call graph for this function:

◆ getSelfAssessmentPoints()

ilCourseObjectiveQuestion::getSelfAssessmentPoints ( )

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

342 : int
343 {
344 $points = 0;
345 foreach ($this->getSelfAssessmentQuestions() as $question) {
346 $points += $question['points'];
347 }
348 return $points;
349 }

References getSelfAssessmentQuestions().

Referenced by updateLimits().

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

◆ getSelfAssessmentQuestions()

ilCourseObjectiveQuestion::getSelfAssessmentQuestions ( )

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

331 : array
332 {
333 $self = [];
334 foreach ($this->questions as $question) {
335 if ($question['test_type'] == self::TYPE_SELF_ASSESSMENT) {
336 $self[] = $question;
337 }
338 }
339 return $self;
340 }

Referenced by getSelfAssessmentPoints().

+ Here is the caller graph for this function:

◆ getSelfAssessmentTests()

ilCourseObjectiveQuestion::getSelfAssessmentTests ( )

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

282 : array
283 {
284 $self = [];
285 foreach ($this->tests as $test) {
286 if ($test['status'] == self::TYPE_SELF_ASSESSMENT) {
287 $self[] = $test;
288 }
289 }
290 return $self;
291 }

◆ getTestObjId()

ilCourseObjectiveQuestion::getTestObjId ( )

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

431 : int
432 {
433 return $this->tst_obj_id;
434 }

References $tst_obj_id.

Referenced by add().

+ Here is the caller graph for this function:

◆ getTestRefId()

ilCourseObjectiveQuestion::getTestRefId ( )

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

421 : int
422 {
423 return $this->tst_ref_id;
424 }

References $tst_ref_id.

Referenced by __addTest(), and add().

+ Here is the caller graph for this function:

◆ getTests()

ilCourseObjectiveQuestion::getTests ( )

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

259 : array
260 {
261 $query = "SELECT * FROM crs_objective_tst cot " .
262 "JOIN object_data obd ON cot.obj_id = obd.obj_id " .
263 "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
264 "ORDER BY title ";
265
266 $res = $this->db->query($query);
267 $tests = [];
268 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
269 $test['test_objective_id'] = (int) $row->test_objective_id;
270 $test['objective_id'] = (int) $row->objective_id;
271 $test['ref_id'] = (int) $row->ref_id;
272 $test['obj_id'] = (int) $row->obj_id;
273 $test['tst_status'] = (int) $row->tst_status;
274 $test['tst_limit'] = (int) $row->tst_limit_p;
275 $test['title'] = (string) $row->title;
276
277 $tests[] = $test;
278 }
279 return $tests;
280 }

References $res, $tests, ilDBConstants\FETCHMODE_OBJECT, getObjectiveId(), and ILIAS\Repository\int().

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

157 : int
158 {
159 return $this->tst_status;
160 }

References $tst_status.

Referenced by __addTest(), and updateTest().

+ Here is the caller graph for this function:

◆ getTestSuggestedLimit()

ilCourseObjectiveQuestion::getTestSuggestedLimit ( )

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

167 : int
168 {
169 return $this->tst_limit;
170 }

References $tst_limit.

Referenced by updateTest().

+ Here is the caller graph for this function:

◆ isFinalTestQuestion()

ilCourseObjectiveQuestion::isFinalTestQuestion ( int  $a_question_id)

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

370 : bool
371 {
372 foreach ($this->questions as $question) {
373 if ($question['question_id'] == $a_question_id) {
374 return $question['test_type'] === self::TYPE_FINAL_TEST;
375 }
376 }
377 return false;
378 }

References TYPE_FINAL_TEST.

◆ isSelfAssessmentQuestion()

ilCourseObjectiveQuestion::isSelfAssessmentQuestion ( int  $a_question_id)

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

360 : bool
361 {
362 foreach ($this->questions as $question) {
363 if ($question['question_id'] == $a_question_id) {
364 return $question['test_type'] === self::TYPE_SELF_ASSESSMENT;
365 }
366 }
367 return false;
368 }

References TYPE_SELF_ASSESSMENT.

◆ lookupObjectivesOfQuestion()

static ilCourseObjectiveQuestion::lookupObjectivesOfQuestion ( int  $a_qid)
static
Returns
int[]

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

58 : array
59 {
60 global $DIC;
61
62 $ilDB = $DIC->database();
63 $query = 'SELECT objective_id FROM crs_objective_qst ' .
64 'WHERE question_id = ' . $ilDB->quote($a_qid, 'integer');
65 $res = $ilDB->query($query);
66 $objectiveIds = array();
67 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
68 $objectiveIds[] = (int) $row->objective_id;
69 }
70 return $objectiveIds;
71 }

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilLOTestQuestionAdapter\lookupObjectiveIdByFixedQuestionId().

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

◆ lookupQuestionsByObjective()

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

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

715 : array
716 {
717 global $DIC;
718
719 $ilDB = $DIC->database();
720 $query = 'SELECT question_id FROM crs_objective_qst ' .
721 'WHERE objective_id = ' . $ilDB->quote($a_objective, 'integer') . ' ' .
722 'AND obj_id = ' . $ilDB->quote($a_test_id, 'integer');
723 $res = $ilDB->query($query);
724
725 $questions = array();
726 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
727 $questions[] = $row->question_id;
728 }
729 return $questions;
730 }

References $DIC, $ilDB, $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 ( int  $a_test_id,
int  $a_objective_id 
)
static

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

732 : int
733 {
734 global $DIC;
735
736 $ilDB = $DIC['ilDB'];
737 $query = 'SELECT tst_limit_p FROM crs_objective_tst ' .
738 'WHERE objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
739 'AND obj_id = ' . $ilDB->quote($a_test_id, 'integer');
740 $res = $ilDB->query($query);
741 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
742 return (int) $row->tst_limit_p;
743 }
744 return 0;
745 }

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

◆ setQuestionId()

ilCourseObjectiveQuestion::setQuestionId ( int  $a_question_id)

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

436 : void
437 {
438 $this->question_id = $a_question_id;
439 }

◆ setTestObjId()

ilCourseObjectiveQuestion::setTestObjId ( int  $a_obj_id)

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

426 : void
427 {
428 $this->tst_obj_id = $a_obj_id;
429 }

◆ setTestRefId()

ilCourseObjectiveQuestion::setTestRefId ( int  $a_ref_id)

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

416 : void
417 {
418 $this->tst_ref_id = $a_ref_id;
419 }

◆ setTestStatus()

ilCourseObjectiveQuestion::setTestStatus ( int  $a_status)

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

152 : void
153 {
154 $this->tst_status = $a_status;
155 }

◆ setTestSuggestedLimit()

ilCourseObjectiveQuestion::setTestSuggestedLimit ( int  $a_limit)

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

162 : void
163 {
164 $this->tst_limit = $a_limit;
165 }

◆ toXml()

ilCourseObjectiveQuestion::toXml ( ilXmlWriter  $writer)

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

747 : void
748 {
749 foreach ($this->getTests() as $test) {
750 $writer->xmlStartTag(
751 'Test',
752 array(
754 'refId' => $test['ref_id'],
755 'testType' => $test['tst_status'],
756 'limit' => $test['tst_limit']
757 )
758 );
759
760 // questions
761 foreach ($this->getQuestionsByTest($test['ref_id']) as $question_id) {
762 $writer->xmlElement('Question', array('id' => $question_id));
763 }
764 $writer->xmlEndTag('Test');
765 }
766 }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.

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

+ Here is the call graph for this function:

◆ updateLimits()

ilCourseObjectiveQuestion::updateLimits ( )

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

498 : void
499 {
500 $points = 0;
501 foreach ($this->tests as $test_data) {
502 switch ($test_data['status']) {
504 $points = $this->getSelfAssessmentPoints();
505 break;
506
508 $points = $this->getFinalTestPoints();
509 break;
510 }
511 if ($test_data['limit'] == -1 || $test_data['limit'] > $points) {
512 switch ($test_data['status']) {
514 $points = $this->getSelfAssessmentPoints();
515 break;
516
518 $points = $this->getFinalTestPoints();
519 break;
520 }
521 $query = "UPDATE crs_objective_tst " .
522 "SET tst_limit = " . $this->db->quote($points, 'integer') . " " .
523 "WHERE test_objective_id = " . $this->db->quote($test_data['test_objective_id'], 'integer') . " ";
524 $res = $this->db->manipulate($query);
525 }
526 }
527 }

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

+ Here is the call graph for this function:

◆ updateTest()

ilCourseObjectiveQuestion::updateTest ( int  $a_objective_id)

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

250 : void
251 {
252 $query = "UPDATE crs_objective_tst " .
253 "SET tst_status = " . $this->db->quote($this->getTestStatus(), 'integer') . ", " .
254 "tst_limit_p = " . $this->db->quote($this->getTestSuggestedLimit(), 'integer') . " " .
255 "WHERE test_objective_id = " . $this->db->quote($a_objective_id, 'integer') . "";
256 $res = $this->db->manipulate($query);
257 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilCourseObjectiveQuestion::$db
protected

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

◆ $logger

ilLogger ilCourseObjectiveQuestion::$logger
protected

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

◆ $objectDataCache

ilObjectDataCache ilCourseObjectiveQuestion::$objectDataCache
protected

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

◆ $objective_id

int ilCourseObjectiveQuestion::$objective_id = 0
private

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

Referenced by _isAssigned(), and getObjectiveId().

◆ $question_id

int ilCourseObjectiveQuestion::$question_id = 0
private

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

Referenced by getQuestion(), getQuestionId(), and toXml().

◆ $questions

array ilCourseObjectiveQuestion::$questions = []
private

◆ $tests

array ilCourseObjectiveQuestion::$tests = []
private

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

Referenced by getTests().

◆ $tree

ilTree ilCourseObjectiveQuestion::$tree
protected

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

Referenced by _getAssignableTests().

◆ $tst_limit

int ilCourseObjectiveQuestion::$tst_limit = 0
private

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

Referenced by __addTest(), and getTestSuggestedLimit().

◆ $tst_obj_id

int ilCourseObjectiveQuestion::$tst_obj_id = 0
private

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

Referenced by getTestObjId().

◆ $tst_ref_id

int ilCourseObjectiveQuestion::$tst_ref_id = 0
private

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

Referenced by getTestRefId().

◆ $tst_status

int ilCourseObjectiveQuestion::$tst_status = 0
private

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

Referenced by getTestStatus().

◆ TYPE_FINAL_TEST

◆ TYPE_SELF_ASSESSMENT


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