ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestSequenceRandomQuestionSet.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Test/classes/class.ilTestSequence.php';
5require_once 'Modules/Test/interfaces/interface.ilTestRandomQuestionSequence.php';
6
7
15{
17
18 public function loadQuestions(ilTestQuestionSetConfig $testQuestionSetConfig = null, $taxonomyFilterSelection = array())
19 {
20 global $ilDB;
21
22 $this->questions = array();
23
24 $result = $ilDB->queryF(
25 "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",
26 array('integer','integer'),
27 array($this->active_id, $this->pass)
28 );
29 // The following is a fix for random tests prior to ILIAS 3.8. If someone started a random test in ILIAS < 3.8, there
30 // is only one test pass (pass = 0) in tst_test_rnd_qst while with ILIAS 3.8 there are questions for every test pass.
31 // To prevent problems with tests started in an older version and continued in ILIAS 3.8, the first pass should be taken if
32 // no questions are present for a newer pass.
33 if ($result->numRows() == 0) {
34 $result = $ilDB->queryF(
35 "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",
36 array('integer'),
37 array($this->active_id)
38 );
39 }
40
41 $index = 1;
42
43 while ($data = $ilDB->fetchAssoc($result)) {
44 $this->questions[$index++] = $data["question_fi"];
45
46 $this->responsibleSourcePoolDefinitionByQuestion[$data['question_fi']] = $data['src_pool_def_fi'];
47 }
48 }
49
61 {
62 global $ilDB;
63 $result = $ilDB->queryF(
64 "SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
65 array('integer','integer'),
66 array($active_id, $pass)
67 );
68 return ($result->numRows() > 0) ? true : false;
69 }
70
71 public function getResponsibleSourcePoolDefinitionId($questionId)
72 {
73 if (isset($this->responsibleSourcePoolDefinitionByQuestion[$questionId])) {
74 return $this->responsibleSourcePoolDefinitionByQuestion[$questionId];
75 }
76
77 return null;
78 }
79}
$result
An exception for terminatinating execution or to throw for unit testing.
hasRandomQuestionsForPass($active_id, $pass)
!!! LEGACY CODE !!!
loadQuestions(ilTestQuestionSetConfig $testQuestionSetConfig=null, $taxonomyFilterSelection=array())
Loads the question mapping.
Test sequence handler.
$index
Definition: metadata.php:60
global $ilDB