26 public function __construct($a_crs_id, $a_user_id, $a_test_id, $a_objective_id)
30 $this->logger = $DIC->logger()->crs();
32 $this->container_id = $a_crs_id;
33 $this->user_id = $a_user_id;
34 $this->test_id = $a_test_id;
35 $this->objective_id = $a_objective_id;
52 $query =
'SELECT * FROM loc_tst_run ' .
53 'WHERE test_id = ' . $ilDB->quote($a_test_id,
'integer') .
' ' .
54 'AND objective_id = ' . $ilDB->quote($a_objective_id,
'integer') .
' ' .
55 'AND user_id = ' . $ilDB->quote($a_user_id,
'integer');
70 public static function deleteRuns($a_container_id, $a_user_id)
74 $query =
'DELETE FROM loc_tst_run ' .
75 'WHERE container_id = ' . $ilDB->quote($a_container_id,
'integer') .
' ' .
76 'AND user_id = ' . $ilDB->quote($a_user_id,
'integer') .
' ';
80 public static function deleteRun($a_container_id, $a_user_id, $a_test_id)
84 $query =
'DELETE FROM loc_tst_run ' .
85 'WHERE container_id = ' . $ilDB->quote($a_container_id,
'integer') .
' ' .
86 'AND user_id = ' . $ilDB->quote($a_user_id,
'integer') .
' ' .
87 'AND test_id = ' . $ilDB->quote($a_test_id,
'integer') .
' ';
95 $query =
'SELECT objective_id FROM loc_tst_run ' .
96 'WHERE container_id = ' . $ilDB->quote($a_container_id,
'integer') .
' ' .
97 'AND user_id = ' . $ilDB->quote($a_user_id,
'integer') .
' ' .
98 'AND test_id = ' . $ilDB->quote($a_test_id,
'integer');
100 $res = $ilDB->query($query);
101 $objectives =
array();
103 $objectives[] =
$row->objective_id;
112 public static function getRun($a_container_id, $a_user_id, $a_test_id)
116 $query =
'SELECT objective_id FROM loc_tst_run ' .
117 'WHERE container_id = ' . $ilDB->quote($a_container_id,
'integer') .
' ' .
118 'AND user_id = ' . $ilDB->quote($a_user_id,
'integer') .
' ' .
119 'AND test_id = ' . $ilDB->quote($a_test_id,
'integer') .
' ';
124 $run[] =
new ilLOTestRun($a_container_id, $a_user_id, $a_test_id,
$row->objective_id);
156 $this->max_points = $a_points;
166 $this->questions =
array();
171 $this->questions[$a_id] = 0;
176 return array_key_exists($a_question_id, (
array) $this->questions);
185 $this->logger->debug($a_qst_id .
' ' . $a_points);
186 $this->questions[$a_qst_id] = $a_points;
196 foreach ($this->questions as $qid => $points) {
197 $sum_points += $points;
207 'reached' => $sum_points,
208 'percentage' => $percentage
217 public function delete()
221 $query =
'DELETE FROM loc_tst_run ' .
222 'WHERE container_id = ' . $ilDB->quote($this->
getContainerId(),
'integer') .
' ' .
223 'AND user_id = ' . $ilDB->quote($this->
getUserId(),
'integer') .
' ' .
224 'AND test_id = ' . $ilDB->quote($this->
getTestId(),
'integer') .
' ' .
225 'AND objective_id = ' . $ilDB->quote($this->
getObjectiveId(),
'integer');
226 $ilDB->manipulate(
$query);
233 $query =
'INSERT INTO loc_tst_run ' .
234 '(container_id, user_id, test_id, objective_id,max_points,questions) ' .
237 $ilDB->quote($this->
getUserId(),
'integer') .
', ' .
238 $ilDB->quote($this->
getTestId(),
'integer') .
', ' .
241 $ilDB->quote(serialize($this->
getQuestions()),
'text') .
' ' .
243 $ilDB->manipulate(
$query);
250 $query =
'UPDATE loc_tst_run SET ' .
251 'max_points = ' . $ilDB->quote($this->
getMaxPoints(),
'integer') .
', ' .
252 'questions = ' . $ilDB->quote(serialize($this->
getQuestions()),
'text') .
' ' .
253 'WHERE container_id = ' . $ilDB->quote($this->container_id,
'integer') .
' ' .
254 'AND user_id = ' . $ilDB->quote($this->
getUserId(),
'integer') .
' ' .
255 'AND test_id = ' . $ilDB->quote($this->
getTestId(),
'integer') .
' ' .
256 'AND objective_id = ' . $ilDB->quote($this->
getObjectiveId(),
'integer') .
' ';
257 $ilDB->manipulate(
$query);
268 $query =
'SELECT * FROM loc_tst_run ' .
269 'WHERE container_id = ' . $ilDB->quote($this->
getContainerId(),
'integer') .
' ' .
270 'AND user_id = ' . $ilDB->quote($this->
getUserId(),
'integer') .
' ' .
271 'AND test_id = ' . $ilDB->quote($this->
getTestId(),
'integer') .
' ' .
272 'AND objective_id = ' . $ilDB->quote($this->
getObjectiveId(),
'integer');
275 $this->max_points =
$row->max_points;
276 if (
$row->questions) {
277 $this->questions = unserialize(
$row->questions);
__construct($a_crs_id, $a_user_id, $a_test_id, $a_objective_id)
static lookupRunExistsForObjective($a_test_id, $a_objective_id, $a_user_id)
type $ilDB
getResult()
Get result for objective run.
questionExists($a_question_id)
setQuestionResult($a_qst_id, $a_points)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static getRun($a_container_id, $a_user_id, $a_test_id)
static deleteRuns($a_container_id, $a_user_id)
Delete runs type $ilDB.
static lookupObjectives($a_container_id, $a_user_id, $a_test_id)
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
static deleteRun($a_container_id, $a_user_id, $a_test_id)
Stores current objective, questions and max points.