21 public function __construct($a_crs_id, $a_user_id, $a_test_id, $a_objective_id)
23 $this->container_id = $a_crs_id;
24 $this->user_id = $a_user_id;
25 $this->test_id = $a_test_id;
26 $this->objective_id = $a_objective_id;
43 $query =
'SELECT * FROM loc_tst_run '.
44 'WHERE test_id = '.$ilDB->quote($a_test_id,
'integer').
' '.
45 'AND objective_id = '.$ilDB->quote($a_objective_id,
'integer').
' '.
46 'AND user_id = '.$ilDB->quote($a_user_id,
'integer');
62 public static function deleteRuns($a_container_id, $a_user_id)
66 $query =
'DELETE FROM loc_tst_run '.
67 'WHERE container_id = ' . $ilDB->quote($a_container_id,
'integer').
' '.
68 'AND user_id = '.$ilDB->quote($a_user_id,
'integer').
' ';
73 public static function deleteRun($a_container_id, $a_user_id, $a_test_id)
77 $query =
'DELETE FROM loc_tst_run '.
78 'WHERE container_id = ' . $ilDB->quote($a_container_id,
'integer').
' '.
79 'AND user_id = '.$ilDB->quote($a_user_id,
'integer').
' '.
80 'AND test_id = '.$ilDB->quote($a_test_id,
'integer').
' ';
88 $query =
'SELECT objective_id FROM loc_tst_run '.
89 'WHERE container_id = '.$ilDB->quote($a_container_id,
'integer').
' '.
90 'AND user_id = '.$ilDB->quote($a_user_id,
'integer').
' '.
91 'AND test_id = '.$ilDB->quote($a_test_id,
'integer');
94 $objectives =
array();
97 $objectives[] =
$row->objective_id;
106 public static function getRun($a_container_id, $a_user_id, $a_test_id)
110 $query =
'SELECT objective_id FROM loc_tst_run '.
111 'WHERE container_id = ' . $ilDB->quote($a_container_id,
'integer').
' '.
112 'AND user_id = '.$ilDB->quote($a_user_id,
'integer').
' '.
113 'AND test_id = '.$ilDB->quote($a_test_id,
'integer').
' ';
119 $run[] =
new ilLOTestRun($a_container_id, $a_user_id, $a_test_id,
$row->objective_id);
151 $this->max_points = $a_points;
161 $this->questions =
array();
166 $this->questions[$a_id] = 0;
171 return array_key_exists($a_question_id,(
array) $this->questions);
176 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.$a_qst_id.
' '.$a_points);
179 if($this->questions[$a_qst_id] < $a_points)
181 $this->questions[$a_qst_id] = $a_points;
183 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.print_r($this->questions,
true));
192 foreach($this->questions as $qid => $points)
194 $sum_points += $points;
204 'reached' => $sum_points,
205 'percentage' => $percentage
214 public function delete()
218 $query =
'DELETE FROM loc_tst_run '.
219 'WHERE container_id = ' . $ilDB->quote($this->
getContainerId(),
'integer').
' '.
220 'AND user_id = '.$ilDB->quote($this->
getUserId(),
'integer').
' '.
221 'AND test_id = '.$ilDB->quote($this->
getTestId(),
'integer').
' '.
222 'AND objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer');
223 $ilDB->manipulate(
$query);
230 $query =
'INSERT INTO loc_tst_run '.
231 '(container_id, user_id, test_id, objective_id,max_points,questions) '.
234 $ilDB->quote($this->
getUserId(),
'integer').
', '.
235 $ilDB->quote($this->
getTestId(),
'integer').
', '.
238 $ilDB->quote(serialize($this->
getQuestions()),
'text').
' '.
240 $ilDB->manipulate(
$query);
247 $query =
'UPDATE loc_tst_run SET '.
248 'max_points = '.$ilDB->quote($this->
getMaxPoints(),
'integer').
', '.
249 'questions = '.$ilDB->quote(serialize($this->
getQuestions()),
'text').
' '.
250 'WHERE container_id = '.$ilDB->quote($this->container_id,
'integer').
' '.
251 'AND user_id = '.$ilDB->quote($this->
getUserId(),
'integer').
' '.
252 'AND test_id = '.$ilDB->quote($this->
getTestId(),
'integer').
' '.
253 'AND objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer').
' ';
254 $ilDB->manipulate(
$query);
265 $query =
'SELECT * FROM loc_tst_run '.
266 'WHERE container_id = ' . $ilDB->quote($this->
getContainerId(),
'integer').
' '.
267 'AND user_id = '.$ilDB->quote($this->
getUserId(),
'integer').
' '.
268 'AND test_id = '.$ilDB->quote($this->
getTestId(),
'integer').
' '.
269 'AND objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer');
273 $this->max_points =
$row->max_points;
276 $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)
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.