35 public function __construct(
int $a_crs_id,
int $a_user_id,
int $a_test_id,
int $a_objective_id)
39 $this->db =
$DIC->database();
41 $this->container_id = $a_crs_id;
42 $this->user_id = $a_user_id;
43 $this->test_id = $a_test_id;
44 $this->objective_id = $a_objective_id;
54 $query =
'SELECT * FROM loc_tst_run ' .
55 'WHERE test_id = ' .
$ilDB->quote($a_test_id,
'integer') .
' ' .
56 'AND objective_id = ' .
$ilDB->quote($a_objective_id,
'integer') .
' ' .
57 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer');
65 public static function deleteRuns(
int $a_container_id,
int $a_user_id): void
70 $query =
'DELETE FROM loc_tst_run ' .
71 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
72 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ';
73 $ilDB->manipulate($query);
76 public static function deleteRun(
int $a_container_id,
int $a_user_id,
int $a_test_id): void
81 $query =
'DELETE FROM loc_tst_run ' .
82 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
83 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
84 'AND test_id = ' .
$ilDB->quote($a_test_id,
'integer') .
' ';
85 $ilDB->manipulate($query);
88 public static function lookupObjectives(
int $a_container_id,
int $a_user_id,
int $a_test_id): array
93 $query =
'SELECT objective_id FROM loc_tst_run ' .
94 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
95 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
96 'AND test_id = ' .
$ilDB->quote($a_test_id,
'integer');
108 public static function getRun(
int $a_container_id,
int $a_user_id,
int $a_test_id): array
113 $query =
'SELECT objective_id FROM loc_tst_run ' .
114 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
115 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
116 'AND test_id = ' .
$ilDB->quote($a_test_id,
'integer') .
' ';
121 $run[] =
new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
153 $this->max_points = $a_points;
163 $this->questions = array();
168 $this->questions[$a_id] = 0;
173 return array_key_exists($a_question_id, $this->questions);
178 $this->questions[$a_qst_id] = $a_points;
184 foreach ($this->questions as $points) {
185 $sum_points += $points;
195 'reached' => $sum_points,
196 'percentage' => $percentage
200 public function delete():
void
202 $query =
'DELETE FROM loc_tst_run ' .
203 'WHERE container_id = ' . $this->db->quote($this->
getContainerId(),
'integer') .
' ' .
204 'AND user_id = ' . $this->db->quote($this->getUserId(),
'integer') .
' ' .
205 'AND test_id = ' . $this->db->quote($this->getTestId(),
'integer') .
' ' .
206 'AND objective_id = ' . $this->db->quote($this->getObjectiveId(),
'integer');
207 $this->db->manipulate($query);
212 $query =
'INSERT INTO loc_tst_run ' .
213 '(container_id, user_id, test_id, objective_id,max_points,questions) ' .
216 $this->db->quote($this->
getUserId(),
'integer') .
', ' .
217 $this->db->quote($this->
getTestId(),
'integer') .
', ' .
219 $this->db->quote($this->
getMaxPoints(),
'float') .
', ' .
220 $this->db->quote(serialize($this->
getQuestions()),
'text') .
' ' .
222 $this->db->manipulate($query);
227 $query =
'UPDATE loc_tst_run SET ' .
228 'max_points = ' . $this->db->quote($this->
getMaxPoints(),
'float') .
', ' .
229 'questions = ' . $this->db->quote(serialize($this->
getQuestions()),
'text') .
' ' .
230 'WHERE container_id = ' . $this->db->quote($this->container_id,
'integer') .
' ' .
231 'AND user_id = ' . $this->db->quote($this->
getUserId(),
'integer') .
' ' .
232 'AND test_id = ' . $this->db->quote($this->
getTestId(),
'integer') .
' ' .
233 'AND objective_id = ' . $this->db->quote($this->
getObjectiveId(),
'integer') .
' ';
234 $this->db->manipulate($query);
239 $query =
'SELECT * FROM loc_tst_run ' .
240 'WHERE container_id = ' . $this->db->quote($this->
getContainerId(),
'integer') .
' ' .
241 'AND user_id = ' . $this->db->quote($this->
getUserId(),
'integer') .
' ' .
242 'AND test_id = ' . $this->db->quote($this->
getTestId(),
'integer') .
' ' .
243 'AND objective_id = ' . $this->db->quote($this->
getObjectiveId(),
'integer');
244 $res = $this->db->query($query);
246 $this->max_points = $row->max_points;
247 if ($row->questions) {
248 $this->questions = unserialize($row->questions);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setQuestionResult(int $a_qst_id, float $a_points)
static deleteRuns(int $a_container_id, int $a_user_id)
setMaxPoints(float $a_points)
__construct(int $a_crs_id, int $a_user_id, int $a_test_id, int $a_objective_id)
static deleteRun(int $a_container_id, int $a_user_id, int $a_test_id)
static lookupRunExistsForObjective(int $a_test_id, int $a_objective_id, int $a_user_id)
questionExists(int $a_question_id)
static lookupObjectives(int $a_container_id, int $a_user_id, int $a_test_id)
static getRun(int $a_container_id, int $a_user_id, int $a_test_id)