34 public function __construct(
int $a_crs_id,
int $a_user_id,
int $a_test_id,
int $a_objective_id)
38 $this->db = $DIC->database();
40 $this->container_id = $a_crs_id;
41 $this->user_id = $a_user_id;
42 $this->test_id = $a_test_id;
43 $this->objective_id = $a_objective_id;
52 $ilDB = $DIC->database();
53 $query =
'SELECT * FROM loc_tst_run ' .
54 'WHERE test_id = ' .
$ilDB->quote($a_test_id,
'integer') .
' ' .
55 'AND objective_id = ' .
$ilDB->quote($a_objective_id,
'integer') .
' ' .
56 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer');
64 public static function deleteRuns(
int $a_container_id,
int $a_user_id): void
69 $query =
'DELETE FROM loc_tst_run ' .
70 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
71 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ';
72 $ilDB->manipulate($query);
75 public static function deleteRun(
int $a_container_id,
int $a_user_id,
int $a_test_id): void
79 $ilDB = $DIC->database();
80 $query =
'DELETE FROM loc_tst_run ' .
81 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
82 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
83 'AND test_id = ' .
$ilDB->quote($a_test_id,
'integer') .
' ';
84 $ilDB->manipulate($query);
87 public static function lookupObjectives(
int $a_container_id,
int $a_user_id,
int $a_test_id): array
91 $ilDB = $DIC->database();
92 $query =
'SELECT objective_id FROM loc_tst_run ' .
93 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
94 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
95 'AND test_id = ' .
$ilDB->quote($a_test_id,
'integer');
107 public static function getRun(
int $a_container_id,
int $a_user_id,
int $a_test_id): array
111 $ilDB = $DIC->database();
112 $query =
'SELECT objective_id FROM loc_tst_run ' .
113 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
114 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
115 'AND test_id = ' .
$ilDB->quote($a_test_id,
'integer') .
' ';
120 $run[] =
new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
152 $this->max_points = $a_points;
162 $this->questions = array();
167 $this->questions[$a_id] = 0;
172 return array_key_exists($a_question_id, $this->questions);
177 $this->questions[$a_qst_id] = $a_points;
183 foreach ($this->questions as $points) {
184 $sum_points += $points;
194 'reached' => $sum_points,
195 'percentage' => $percentage
199 public function delete():
void 201 $query =
'DELETE FROM loc_tst_run ' .
202 'WHERE container_id = ' . $this->db->quote($this->
getContainerId(),
'integer') .
' ' .
203 'AND user_id = ' . $this->db->quote($this->
getUserId(),
'integer') .
' ' .
204 'AND test_id = ' . $this->db->quote($this->
getTestId(),
'integer') .
' ' .
205 'AND objective_id = ' . $this->db->quote($this->
getObjectiveId(),
'integer');
206 $this->db->manipulate($query);
211 $query =
'INSERT INTO loc_tst_run ' .
212 '(container_id, user_id, test_id, objective_id,max_points,questions) ' .
215 $this->db->quote($this->
getUserId(),
'integer') .
', ' .
216 $this->db->quote($this->
getTestId(),
'integer') .
', ' .
218 $this->db->quote($this->
getMaxPoints(),
'integer') .
', ' .
219 $this->db->quote(serialize($this->
getQuestions()),
'text') .
' ' .
221 $this->db->manipulate($query);
226 $query =
'UPDATE loc_tst_run SET ' .
227 'max_points = ' . $this->db->quote($this->
getMaxPoints(),
'integer') .
', ' .
228 'questions = ' . $this->db->quote(serialize($this->
getQuestions()),
'text') .
' ' .
229 'WHERE container_id = ' . $this->db->quote($this->container_id,
'integer') .
' ' .
230 'AND user_id = ' . $this->db->quote($this->
getUserId(),
'integer') .
' ' .
231 'AND test_id = ' . $this->db->quote($this->
getTestId(),
'integer') .
' ' .
232 'AND objective_id = ' . $this->db->quote($this->
getObjectiveId(),
'integer') .
' ';
233 $this->db->manipulate($query);
238 $query =
'SELECT * FROM loc_tst_run ' .
239 'WHERE container_id = ' . $this->db->quote($this->
getContainerId(),
'integer') .
' ' .
240 'AND user_id = ' . $this->db->quote($this->
getUserId(),
'integer') .
' ' .
241 'AND test_id = ' . $this->db->quote($this->
getTestId(),
'integer') .
' ' .
242 'AND objective_id = ' . $this->db->quote($this->
getObjectiveId(),
'integer');
243 $res = $this->db->query($query);
245 $this->max_points = $row->max_points;
246 if ($row->questions) {
247 $this->questions = unserialize($row->questions);
__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)
setQuestionResult(int $a_qst_id, float $a_points)
static lookupObjectives(int $a_container_id, int $a_user_id, int $a_test_id)
setMaxPoints(int $a_points)
static lookupRunExistsForObjective(int $a_test_id, int $a_objective_id, int $a_user_id)
static getRun(int $a_container_id, int $a_user_id, int $a_test_id)
questionExists(int $a_question_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deleteRuns(int $a_container_id, int $a_user_id)