ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionSolutionComparisonExpressionList.php
Go to the documentation of this file.
1<?php
2
26{
30 protected $db;
31
35 private $questionId;
36
40 private $skillBaseId;
41
45 private $skillTrefId;
46
50 private $expressions;
51
55 public function __construct(ilDBInterface $db)
56 {
57 $this->db = $db;
58
59 $this->questionId = null;
60 $this->skillBaseId = null;
61 $this->skillTrefId = null;
62
63 $this->expressions = [];
64 }
65
66 public function load(): void
67 {
68 $query = "
69 SELECT *
70 FROM qpl_qst_skl_sol_expr
71 WHERE question_fi = %s AND skill_base_fi = %s AND skill_tref_fi = %s
72 ";
73
74 $res = $this->db->queryF(
75 $query,
76 ['integer', 'integer', 'integer'],
77 [$this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId()]
78 );
79
80 while ($row = $this->db->fetchAssoc($res)) {
82 $expression->setDb($this->db);
83 $expression->initInstanceFromArray($row);
84
85 $this->add($expression);
86 }
87 }
88
89 public function save(): void
90 {
91 $this->delete();
92
93 foreach ($this->expressions as $orderIndex => $expression) {
94 /* @var ilAssQuestionSolutionComparisonExpression $expression */
95
96 $expression->setQuestionId($this->getQuestionId());
97 $expression->save();
98 }
99 }
100
101 public function delete(): void
102 {
103 $query = "
104 DELETE FROM qpl_qst_skl_sol_expr
105 WHERE question_fi = %s AND skill_base_fi = %s AND skill_tref_fi = %s
106 ";
107
108 $this->db->manipulateF(
109 $query,
110 ['integer', 'integer', 'integer'],
111 [$this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId()]
112 );
113 }
114
115 public function add(ilAssQuestionSolutionComparisonExpression $expression): void
116 {
117 $expression->setDb($this->db);
118 $expression->setQuestionId($this->getQuestionId());
119 $expression->setSkillBaseId($this->getSkillBaseId());
120 $expression->setSkillTrefId($this->getSkillTrefId());
121
122 $this->expressions[$expression->getOrderIndex()] = $expression;
123 }
124
125 public function get(): array
126 {
127 return $this->expressions;
128 }
129
130 public function reset(): void
131 {
132 $this->expressions = [];
133 }
134
138 public function getQuestionId(): ?int
139 {
140 return $this->questionId;
141 }
142
146 public function setQuestionId($questionId): void
147 {
148 $this->questionId = $questionId;
149 }
150
154 public function getSkillBaseId(): ?int
155 {
156 return $this->skillBaseId;
157 }
158
162 public function setSkillBaseId($skillBaseId): void
163 {
164 $this->skillBaseId = $skillBaseId;
165 }
166
170 public function getSkillTrefId(): ?int
171 {
172 return $this->skillTrefId;
173 }
174
178 public function setSkillTrefId($skillTrefId): void
179 {
180 $this->skillTrefId = $skillTrefId;
181 }
182}
Interface ilDBInterface.
$res
Definition: ltiservices.php:69