ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAssQuestionSkillAssignment.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/TestQuestionPool/classes/class.ilAssQuestionSolutionComparisonExpressionList.php';
5
13{
15
18
19
23 private $db;
24
28 private $parentObjId;
29
33 private $questionId;
34
38 private $skillBaseId;
39
43 private $skillTrefId;
44
48 private $skillPoints;
49
53 private $skillTitle;
54
58 private $skillPath;
59
63 private $evalMode;
64
69
70 public function __construct(ilDB $db)
71 {
72 $this->db = $db;
73
74 $this->solutionComparisonExpressionList = new ilAssQuestionSolutionComparisonExpressionList($this->db);
75 }
76
77 public function loadFromDb()
78 {
79 $query = "
80 SELECT obj_fi, question_fi, skill_base_fi, skill_tref_fi, skill_points, eval_mode
81 FROM qpl_qst_skl_assigns
82 WHERE obj_fi = %s
83 AND question_fi = %s
84 AND skill_base_fi = %s
85 AND skill_tref_fi = %s
86 ";
87
88 $res = $this->db->queryF(
89 $query, array('integer', 'integer', 'integer', 'integer'),
90 array($this->getParentObjId(), $this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId())
91 );
92
93 $row = $this->db->fetchAssoc($res);
94
95 if( is_array($row) )
96 {
97 $this->setSkillPoints($row['skill_points']);
98 $this->setEvalMode($row['eval_mode']);
99 }
100
101 if( $this->getEvalMode() == self::EVAL_MODE_BY_QUESTION_SOLUTION )
102 {
104 }
105 }
106
108 {
110 $this->solutionComparisonExpressionList->load();
111 }
112
113 public function saveToDb()
114 {
115 if( $this->dbRecordExists() )
116 {
117 $this->db->update('qpl_qst_skl_assigns', array(
118 'skill_points' => array('integer', $this->getSkillPoints()),
119 'eval_mode' => array('text', $this->getEvalMode())
120 ),
121 array(
122 'obj_fi' => array('integer', $this->getParentObjId()),
123 'question_fi' => array('integer', $this->getQuestionId()),
124 'skill_base_fi' => array('integer', $this->getSkillBaseId()),
125 'skill_tref_fi' => array('integer', $this->getSkillTrefId())
126 )
127 );
128 }
129 else
130 {
131 $this->db->insert('qpl_qst_skl_assigns', array(
132 'obj_fi' => array('integer', $this->getParentObjId()),
133 'question_fi' => array('integer', $this->getQuestionId()),
134 'skill_base_fi' => array('integer', $this->getSkillBaseId()),
135 'skill_tref_fi' => array('integer', $this->getSkillTrefId()),
136 'skill_points' => array('integer', $this->getSkillPoints()),
137 'eval_mode' => array('text', $this->getEvalMode())
138 ));
139 }
140
141 if( $this->getEvalMode() == self::EVAL_MODE_BY_QUESTION_SOLUTION )
142 {
144 }
145 }
146
148 {
150 $this->solutionComparisonExpressionList->save();
151 }
152
153 public function deleteFromDb()
154 {
155 $query = "
156 DELETE FROM qpl_qst_skl_assigns
157 WHERE obj_fi = %s
158 AND question_fi = %s
159 AND skill_base_fi = %s
160 AND skill_tref_fi = %s
161 ";
162
163 $this->db->manipulateF(
164 $query, array('integer', 'integer', 'integer', 'integer'),
165 array($this->getParentObjId(), $this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId())
166 );
167
169 }
170
172 {
174 $this->solutionComparisonExpressionList->delete();
175 }
176
177 public function dbRecordExists()
178 {
179 $query = "
180 SELECT COUNT(*) cnt
181 FROM qpl_qst_skl_assigns
182 WHERE obj_fi = %s
183 AND question_fi = %s
184 AND skill_base_fi = %s
185 AND skill_tref_fi = %s
186 ";
187
188 $res = $this->db->queryF(
189 $query, array('integer', 'integer', 'integer', 'integer'),
190 array($this->getParentObjId(), $this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId())
191 );
192
193 $row = $this->db->fetchAssoc($res);
194
195 return $row['cnt'] > 0;
196 }
197
202 {
203 $this->skillPoints = $skillPoints;
204 }
205
209 public function getSkillPoints()
210 {
211 return $this->skillPoints;
212 }
213
217 public function setQuestionId($questionId)
218 {
219 $this->questionId = $questionId;
220 }
221
225 public function getQuestionId()
226 {
227 return $this->questionId;
228 }
229
234 {
235 $this->skillBaseId = $skillBaseId;
236 }
237
241 public function getSkillBaseId()
242 {
243 return $this->skillBaseId;
244 }
245
250 {
251 $this->skillTrefId = $skillTrefId;
252 }
253
257 public function getSkillTrefId()
258 {
259 return $this->skillTrefId;
260 }
261
266 {
267 $this->parentObjId = $parentObjId;
268 }
269
273 public function getParentObjId()
274 {
275 return $this->parentObjId;
276 }
277
278 public function loadAdditionalSkillData()
279 {
280 require_once 'Services/Skill/classes/class.ilBasicSkill.php';
281 require_once 'Services/Skill/classes/class.ilSkillTree.php';
282
283 $this->setSkillTitle(
285 );
286
287 $tree = new ilSkillTree();
288
289 $path = $tree->getSkillTreePath(
290 $this->getSkillBaseId(), $this->getSkillTrefId()
291 );
292
293 $nodes = array();
294 foreach ($path as $node)
295 {
296 if( $node['child'] > 1 && $node['skill_id'] != $this->getSkillBaseId() )
297 {
298 $nodes[] = $node['title'];
299 }
300 }
301
302 $this->setSkillPath(implode(' > ', $nodes));
303 }
304
305 public function setSkillTitle($skillTitle)
306 {
307 $this->skillTitle = $skillTitle;
308 }
309
310 public function getSkillTitle()
311 {
312 return $this->skillTitle;
313 }
314
315 public function setSkillPath($skillPath)
316 {
317 $this->skillPath = $skillPath;
318 }
319
320 public function getSkillPath()
321 {
322 return $this->skillPath;
323 }
324
325 public function getEvalMode()
326 {
327 return $this->evalMode;
328 }
329
330 public function setEvalMode($evalMode)
331 {
332 $this->evalMode = $evalMode;
333 }
334
335 public function hasEvalModeBySolution()
336 {
338 }
339
341 {
342 $this->solutionComparisonExpressionList->setQuestionId($this->getQuestionId());
343 $this->solutionComparisonExpressionList->setSkillBaseId($this->getSkillBaseId());
344 $this->solutionComparisonExpressionList->setSkillTrefId($this->getSkillTrefId());
345 }
346
348 {
350 }
351
352 public function getMaxSkillPoints()
353 {
354 if( $this->hasEvalModeBySolution() )
355 {
356 $maxPoints = 0;
357
358 foreach($this->solutionComparisonExpressionList->get() as $expression)
359 {
360 if( $expression->getPoints() > $maxPoints )
361 {
362 $maxPoints = $expression->getPoints();
363 }
364 }
365
366 return $maxPoints;
367 }
368
369 return $this->getSkillPoints();
370 }
371}
Database Wrapper.
Definition: class.ilDB.php:29
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
$path
Definition: index.php:22