ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestSequenceRandomQuestionSet.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
30
31 public function loadQuestions(): void
32 {
33 $this->questions = [];
34
35 $result = $this->db->queryF(
36 "SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = %s ORDER BY sequence",
37 ['integer','integer'],
38 [$this->active_id, $this->pass]
39 );
40 // The following is a fix for random tests prior to ILIAS 3.8. If someone started a random test in ILIAS < 3.8, there
41 // is only one test pass (pass = 0) in tst_test_rnd_qst while with ILIAS 3.8 there are questions for every test pass.
42 // To prevent problems with tests started in an older version and continued in ILIAS 3.8, the first pass should be taken if
43 // no questions are present for a newer pass.
44 if ($result->numRows() == 0) {
45 $result = $this->db->queryF(
46 "SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = 0 ORDER BY sequence",
47 ['integer'],
48 [$this->active_id]
49 );
50 }
51
52 $index = 1;
53
54 while ($data = $this->db->fetchAssoc($result)) {
55 $this->questions[$index++] = $data["question_fi"];
56
57 $this->responsibleSourcePoolDefinitionByQuestion[$data['question_fi']] = $data['src_pool_def_fi'];
58 }
59 }
60
71 public function hasRandomQuestionsForPass(int $active_id, int $pass): bool
72 {
73 $result = $this->db->queryF(
74 "SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
75 ['integer','integer'],
76 [$active_id, $pass]
77 );
78 return ($result->numRows() > 0) ? true : false;
79 }
80
81 public function getResponsibleSourcePoolDefinitionId(int $question_id): ?int
82 {
83 if (isset($this->responsibleSourcePoolDefinitionByQuestion[$question_id])) {
84 return $this->responsibleSourcePoolDefinitionByQuestion[$question_id];
85 }
86
87 return null;
88 }
89}
return true
hasRandomQuestionsForPass(int $active_id, int $pass)
!!! LEGACY CODE !!!
Test sequence handler.