ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilLORandomTestQuestionPools.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
5include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
6
16{
17 protected $container_id = 0;
18 protected $objective_id = 0;
19 protected $test_type = 0;
20 protected $test_id = 0;
21 protected $qpl_seq = 0;
22 protected $limit = 50;
23
24
30 public function __construct($a_container_id, $a_objective_id, $a_test_type)
31 {
32 $this->container_id = $a_container_id;
33 $this->objective_id = $a_objective_id;
34 $this->test_type = $a_test_type;
35
36 $this->read();
37 }
38
39 public static function lookupLimit($a_container_id, $a_objective_id, $a_test_type)
40 {
41 global $ilDB;
42
43 $query = 'SELECT * FROM loc_rnd_qpl '.
44 'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
45 'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
46 'AND tst_type = '.$ilDB->quote($a_test_type,'integer');
47 $res = $ilDB->query($query);
48 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
49 {
50 return $row->percentage;
51 }
52 return 0;
53 }
54
55 public static function lookupSequence($a_container_id, $a_objective_id, $a_test_id)
56 {
57 global $ilDB;
58
59 $query = 'SELECT * FROM loc_rnd_qpl '.
60 'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
61 'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
62 'AND tst_id = '.$ilDB->quote($a_test_id,'integer');
63 $res = $ilDB->query($query);
64 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
65 {
66 return $row->qp_seq;
67 }
68 return 0;
69
70 }
71
72
73 public function setContainerId($a_id)
74 {
75 $this->container_id = $a_id;
76 }
77
78 public function getContainerId()
79 {
81 }
82
83 public function setObjectiveId($a_id)
84 {
85 $this->objective_id = $a_id;
86 }
87
88 public function getObjectiveId()
89 {
91 }
92
93 public function setTestType($a_type)
94 {
95 $this->test_type = $a_type;
96 }
97
98 public function getTestType()
99 {
100 return $this->test_type;
101 }
102
103 public function setTestId($a_id)
104 {
105 $this->test_id = $a_id;
106 }
107
108 public function getTestId()
109 {
110 return $this->test_id;
111 }
112
113 public function setQplSequence($a_id)
114 {
115 $this->qpl_seq = $a_id;
116 }
117
118 public function getQplSequence()
119 {
120 return $this->qpl_seq;
121 }
122
123 public function setLimit($a_id)
124 {
125 $this->limit = $a_id;
126 }
127
128 public function getLimit()
129 {
130 return $this->limit;
131 }
132
133
134 public function read()
135 {
136 global $ilDB;
137
138 $query = 'SELECT * FROM loc_rnd_qpl '.
139 'WHERE container_id = '.$ilDB->quote($this->getContainerId(),'integer').' '.
140 'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
141 'AND tst_type = '.$ilDB->quote($this->getTestType(),'integer');
142
143 $res = $ilDB->query($query);
144 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
145 {
146 $this->setLimit($row->percentage);
147 $this->setTestId($row->tst_id);
148 $this->setQplSequence($row->qp_seq);
149 }
150 return true;
151 }
152
153 public function delete()
154 {
155 global $ilDB;
156
157 $query = 'DELETE FROM loc_rnd_qpl '.
158 'WHERE container_id = '.$ilDB->quote($this->getContainerId(),'integer').' '.
159 'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
160 'AND tst_type = '.$ilDB->quote($this->getTestType(),'integer');
161 $ilDB->manipulate($query);
162 }
163
164 public function create()
165 {
166 global $ilDB;
167
168 $query = 'INSERT INTO loc_rnd_qpl ' .
169 '(container_id, objective_id, tst_type, tst_id, qp_seq, percentage) '.
170 'VALUES ( '.
171 $ilDB->quote($this->getContainerId(),'integer').', '.
172 $ilDB->quote($this->getObjectiveId(),'integer').', '.
173 $ilDB->quote($this->getTestType(),'integer').', '.
174 $ilDB->quote($this->getTestId(),'integer').', '.
175 $ilDB->quote($this->getQplSequence(),'integer').', '.
176 $ilDB->quote($this->getLimit()).' '.
177 ')';
178 $ilDB->manipulate($query);
179 }
180}
181?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static lookupLimit($a_container_id, $a_objective_id, $a_test_type)
__construct($a_container_id, $a_objective_id, $a_test_type)
Constructor.
static lookupSequence($a_container_id, $a_objective_id, $a_test_id)
global $ilDB