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