ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestRandomQuestionSetSourcePoolDefinition.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
17  protected $db = null;
18 
24  protected $testOBJ = null;
25 
26  private $id = null;
27 
28  private $poolId = null;
29 
30  private $poolTitle = null;
31 
32  private $poolPath = null;
33 
34  private $poolQuestionCount = null;
35 
36  private $originalFilterTaxId = null;
37 
38  private $originalFilterTaxNodeId = null;
39 
40  private $mappedFilterTaxId = null;
41 
42  private $mappedFilterTaxNodeId = null;
43 
44  private $questionAmount = null;
45 
46  private $sequencePosition = null;
47 
49  {
50  $this->db = $db;
51  $this->testOBJ = $testOBJ;
52  }
53 
54  public function setId($id)
55  {
56  $this->id = $id;
57  }
58 
59  public function getId()
60  {
61  return $this->id;
62  }
63 
64  public function setPoolId($poolId)
65  {
66  $this->poolId = $poolId;
67  }
68 
69  public function getPoolId()
70  {
71  return $this->poolId;
72  }
73 
74  public function setPoolTitle($poolTitle)
75  {
76  $this->poolTitle = $poolTitle;
77  }
78 
79  public function getPoolTitle()
80  {
81  return $this->poolTitle;
82  }
83 
84  public function setPoolPath($poolPath)
85  {
86  $this->poolPath = $poolPath;
87  }
88 
89  public function getPoolPath()
90  {
91  return $this->poolPath;
92  }
93 
95  {
96  $this->poolQuestionCount = $poolQuestionCount;
97  }
98 
99  public function getPoolQuestionCount()
100  {
102  }
103 
105  {
106  $this->originalFilterTaxId = $originalFilterTaxId;
107  }
108 
109  public function getOriginalFilterTaxId()
110  {
112  }
113 
114  public function setOriginalFilterTaxNodeId($originalFilterNodeId)
115  {
116  $this->originalFilterTaxNodeId = $originalFilterNodeId;
117  }
118 
119  public function getOriginalFilterTaxNodeId()
120  {
122  }
123 
125  {
126  $this->mappedFilterTaxId = $mappedFilterTaxId;
127  }
128 
129  public function getMappedFilterTaxId()
130  {
132  }
133 
135  {
136  $this->mappedFilterTaxNodeId = $mappedFilterTaxNodeId;
137  }
138 
139  public function getMappedFilterTaxNodeId()
140  {
142  }
143 
145  {
146  $this->questionAmount = $questionAmount;
147  }
148 
149  public function getQuestionAmount()
150  {
151  return $this->questionAmount;
152  }
153 
155  {
156  $this->sequencePosition = $sequencePosition;
157  }
158 
159  public function getSequencePosition()
160  {
162  }
163 
164  // -----------------------------------------------------------------------------------------------------------------
165 
169  public function initFromArray($dataArray)
170  {
171  foreach($dataArray as $field => $value)
172  {
173  switch($field)
174  {
175  case 'def_id': $this->setId($value); break;
176  case 'pool_fi': $this->setPoolId($value); break;
177  case 'pool_title': $this->setPoolTitle($value); break;
178  case 'pool_path': $this->setPoolPath($value); break;
179  case 'pool_quest_count': $this->setPoolQuestionCount($value); break;
180  case 'origin_tax_fi': $this->setOriginalFilterTaxId($value); break;
181  case 'origin_node_fi': $this->setOriginalFilterTaxNodeId($value); break;
182  case 'mapped_tax_fi': $this->setMappedFilterTaxId($value); break;
183  case 'mapped_node_fi': $this->setMappedFilterTaxNodeId($value); break;
184  case 'quest_amount': $this->setQuestionAmount($value); break;
185  case 'sequence_pos': $this->setSequencePosition($value); break;
186  }
187  }
188  }
189 
194  public function loadFromDb($id)
195  {
196  $res = $this->db->queryF(
197  "SELECT * FROM tst_rnd_quest_set_qpls WHERE def_id = %s", array('integer'), array($id)
198  );
199 
200  while( $row = $this->db->fetchAssoc($res) )
201  {
202  $this->initFromArray($row);
203 
204  return true;
205  }
206 
207  return false;
208  }
209 
210  public function saveToDb()
211  {
212  if( $this->getId() )
213  {
214  $this->updateDbRecord($this->testOBJ->getTestId());
215  }
216  else
217  {
218  $this->insertDbRecord($this->testOBJ->getTestId());
219  }
220  }
221 
222  public function cloneToDbForTestId($testId)
223  {
224  $this->insertDbRecord($testId);
225  }
226 
227  public function deleteFromDb()
228  {
229  $this->db->manipulateF(
230  "DELETE FROM tst_rnd_quest_set_qpls WHERE def_id = %s", array('integer'), array($this->getId())
231  );
232  }
233 
237  private function updateDbRecord($testId)
238  {
239  $this->db->update('tst_rnd_quest_set_qpls',
240  array(
241  'test_fi' => array('integer', $testId),
242  'pool_fi' => array('integer', $this->getPoolId()),
243  'pool_title' => array('text', $this->getPoolTitle()),
244  'pool_path' => array('text', $this->getPoolPath()),
245  'pool_quest_count' => array('integer', $this->getPoolQuestionCount()),
246  'origin_tax_fi' => array('integer', $this->getOriginalFilterTaxId()),
247  'origin_node_fi' => array('integer', $this->getOriginalFilterTaxNodeId()),
248  'mapped_tax_fi' => array('integer', $this->getMappedFilterTaxId()),
249  'mapped_node_fi' => array('integer', $this->getMappedFilterTaxNodeId()),
250  'quest_amount' => array('integer', $this->getQuestionAmount()),
251  'sequence_pos' => array('integer', $this->getSequencePosition())
252  ),
253  array(
254  'def_id' => array('integer', $this->getId())
255  )
256  );
257  }
258 
262  private function insertDbRecord($testId)
263  {
264  $nextId = $this->db->nextId('tst_rnd_quest_set_qpls');
265 
266  $this->db->insert('tst_rnd_quest_set_qpls', array(
267  'def_id' => array('integer', $nextId),
268  'test_fi' => array('integer', $testId),
269  'pool_fi' => array('integer', $this->getPoolId()),
270  'pool_title' => array('text', $this->getPoolTitle()),
271  'pool_path' => array('text', $this->getPoolPath()),
272  'pool_quest_count' => array('integer', $this->getPoolQuestionCount()),
273  'origin_tax_fi' => array('integer', $this->getOriginalFilterTaxId()),
274  'origin_node_fi' => array('integer', $this->getOriginalFilterTaxNodeId()),
275  'mapped_tax_fi' => array('integer', $this->getMappedFilterTaxId()),
276  'mapped_node_fi' => array('integer', $this->getMappedFilterTaxNodeId()),
277  'quest_amount' => array('integer', $this->getQuestionAmount()),
278  'sequence_pos' => array('integer', $this->getSequencePosition())
279  ));
280 
281  $this->setId($nextId);
282  }
283 
284  // -----------------------------------------------------------------------------------------------------------------
285 
287  {
288  $poolInfoLabel = sprintf(
289  $lng->txt('tst_dynamic_question_set_source_questionpool_summary_string'),
290  $this->getPoolTitle(),
291  $this->getPoolPath(),
292  $this->getPoolQuestionCount()
293  );
294 
295  return $poolInfoLabel;
296  }
297 
298  // -----------------------------------------------------------------------------------------------------------------
299 }