ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 require_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(ilDBInterface $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(
62  $query,
63  array('integer', 'integer', 'integer'),
64  array($this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId())
65  );
66 
67  while ($row = $this->db->fetchAssoc($res)) {
69  $expression->setDb($this->db);
70  $expression->initInstanceFromArray($row);
71 
72  $this->add($expression);
73  }
74  }
75 
76  public function save()
77  {
78  $this->delete();
79 
80  foreach ($this->expressions as $orderIndex => $expression) {
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(
96  $query,
97  array('integer', 'integer', 'integer'),
98  array($this->getQuestionId(), $this->getSkillBaseId(), $this->getSkillTrefId())
99  );
100  }
101 
102  public function add(ilAssQuestionSolutionComparisonExpression $expression)
103  {
104  $expression->setDb($this->db);
105  $expression->setQuestionId($this->getQuestionId());
106  $expression->setSkillBaseId($this->getSkillBaseId());
107  $expression->setSkillTrefId($this->getSkillTrefId());
108 
109  $this->expressions[$expression->getOrderIndex()] = $expression;
110  }
111 
112  public function get()
113  {
114  return $this->expressions;
115  }
116 
117  public function reset()
118  {
119  $this->expressions = array();
120  }
121 
125  public function getQuestionId()
126  {
127  return $this->questionId;
128  }
129 
133  public function setQuestionId($questionId)
134  {
135  $this->questionId = $questionId;
136  }
137 
141  public function getSkillBaseId()
142  {
143  return $this->skillBaseId;
144  }
145 
149  public function setSkillBaseId($skillBaseId)
150  {
151  $this->skillBaseId = $skillBaseId;
152  }
153 
157  public function getSkillTrefId()
158  {
159  return $this->skillTrefId;
160  }
161 
165  public function setSkillTrefId($skillTrefId)
166  {
167  $this->skillTrefId = $skillTrefId;
168  }
169 }
Interface ilDBInterface.
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.