ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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';
5
13{
15
16 public function loadQuestions()
17 {
18 global $ilDB;
19
20 $this->questions = array();
21
22 $result = $ilDB->queryF("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",
23 array('integer','integer'),
24 array($this->active_id, $this->pass)
25 );
26 // The following is a fix for random tests prior to ILIAS 3.8. If someone started a random test in ILIAS < 3.8, there
27 // is only one test pass (pass = 0) in tst_test_rnd_qst while with ILIAS 3.8 there are questions for every test pass.
28 // To prevent problems with tests started in an older version and continued in ILIAS 3.8, the first pass should be taken if
29 // no questions are present for a newer pass.
30 if ($result->numRows() == 0)
31 {
32 $result = $ilDB->queryF("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",
33 array('integer'),
34 array($this->active_id)
35 );
36 }
37
38 $index = 1;
39
40 while ($data = $ilDB->fetchAssoc($result))
41 {
42 $this->questions[$index++] = $data["question_fi"];
43
44 $this->responsibleSourcePoolDefinitionByQuestion[$data['question_fi']] = $data['src_pool_def_fi'];
45 }
46 }
47
59 {
60 global $ilDB;
61 $result = $ilDB->queryF("SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
62 array('integer','integer'),
63 array($active_id, $pass)
64 );
65 return ($result->numRows() > 0) ? true : false;
66 }
67
68 public function getResponsibleSourcePoolDefinitionId($questionId)
69 {
70 if( isset($this->responsibleSourcePoolDefinitionByQuestion[$questionId]) )
71 {
72 return $this->responsibleSourcePoolDefinitionByQuestion[$questionId];
73 }
74
75 return null;
76 }
77}
$result
hasRandomQuestionsForPass($active_id, $pass)
!!! LEGACY CODE !!!
Test sequence handler.
global $ilDB