ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAssQuestionSolutionComparisonExpressionList.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.ilAssQuestionSolutionComparisonExpression.php';
5
13{
17 protected $db;
18
22 private $questionId;
23
27 private $skillBaseId;
28
32 private $skillTrefId;
33
37 private $expressions;
38
42 public function __construct(ilDB $db)
43 {
44 $this->db = $db;
45
46 $this->questionId = null;
47 $this->skillBaseId = null;
48 $this->skillTrefId = null;
49
50 $this->expressions = array();
51 }
52
53 public function load()
54 {
55 $query = "
56 SELECT *
57 FROM qpl_qst_skl_sol_expr
58 WHERE question_fi = %s AND skill_base_fi = %s AND skill_tref_fi = %s
59 ";
60
61 $res = $this->db->queryF( $query, array('integer', 'integer', 'integer'),
62 array($this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId())
63 );
64
65 while($row = $this->db->fetchAssoc($res) )
66 {
68 $expression->setDb($this->db);
69 $expression->initInstanceFromArray($row);
70
71 $this->add($expression);
72 }
73 }
74
75 public function save()
76 {
77 $this->delete();
78
79 foreach($this->expressions as $orderIndex => $expression)
80 {
81 /* @var ilAssQuestionSolutionComparisonExpression $expression */
82
83 $expression->setQuestionId($this->getQuestionId());
84 $expression->save();
85 }
86 }
87
88 public function delete()
89 {
90 $query = "
91 DELETE FROM qpl_qst_skl_sol_expr
92 WHERE question_fi = %s AND skill_base_fi = %s AND skill_tref_fi = %s
93 ";
94
95 $this->db->manipulateF($query, array('integer', 'integer', 'integer'),
96 array($this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId())
97 );
98 }
99
101 {
102 $expression->setDb($this->db);
103 $expression->setQuestionId($this->getQuestionId());
104 $expression->setSkillBaseId($this->getSkillBaseId());
105 $expression->setSkillTrefId($this->getSkillTrefId());
106
107 $this->expressions[$expression->getOrderIndex()] = $expression;
108 }
109
110 public function get()
111 {
112 return $this->expressions;
113 }
114
115 public function reset()
116 {
117 $this->expressions = array();
118 }
119
123 public function getQuestionId()
124 {
125 return $this->questionId;
126 }
127
131 public function setQuestionId($questionId)
132 {
133 $this->questionId = $questionId;
134 }
135
139 public function getSkillBaseId()
140 {
141 return $this->skillBaseId;
142 }
143
148 {
149 $this->skillBaseId = $skillBaseId;
150 }
151
155 public function getSkillTrefId()
156 {
157 return $this->skillTrefId;
158 }
159
164 {
165 $this->skillTrefId = $skillTrefId;
166 }
167}
Database Wrapper.
Definition: class.ilDB.php:29