31 $this->course_obj_id = (int) $a_course_obj_id;
32 $this->user_id = (int) $a_user_id;
39 public static function lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
43 $query =
'SELECT * FROM loc_user_results ' .
44 'WHERE user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
45 'AND course_id = ' .
$ilDB->quote($a_course_obj_id,
'integer') .
' ' .
46 'AND objective_id = ' .
$ilDB->quote($a_objective_id,
'integer') .
' ' .
47 'AND type = ' .
$ilDB->quote($a_tst_type,
'integer');
50 'status' => self::STATUS_FAILED,
58 $ur[
'status'] =
$row->status;
59 $ur[
'result_perc'] =
$row->result_perc;
60 $ur[
'limit_perc'] =
$row->limit_perc;
61 $ur[
'tries'] =
$row->tries;
62 $ur[
'is_final'] =
$row->is_final;
63 $ur[
'has_result'] =
true;
70 $query =
'UPDATE loc_user_results ' .
71 'SET is_final = ' .
$GLOBALS[
'ilDB']->quote(0,
'integer') .
' ' .
72 'WHERE objective_id = ' .
$GLOBALS[
'ilDB']->quote($a_objective_id,
'integer');
85 return in_array((
int)
$a_type, array(self::TYPE_INITIAL, self::TYPE_QUALIFIED));
96 return in_array((
int) $a_status, array(self::STATUS_COMPLETED, self::STATUS_FAILED));
109 if (!(
int) $a_user_id) {
113 $ilDB->manipulate(
"DELETE FROM loc_user_results" .
114 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer"));
129 if (!(
int) $a_course_id) {
133 $ilDB->manipulate(
"DELETE FROM loc_user_results" .
134 " WHERE course_id = " .
$ilDB->quote($a_course_id,
"integer"));
142 public function delete()
146 $query =
'DELETE FROM loc_user_results ' .
147 'WHERE course_id = ' .
$ilDB->quote($this->course_obj_id) .
' ' .
148 'AND user_id = ' .
$ilDB->quote($this->user_id);
162 public static function deleteResultsFromLP($a_course_id, array $a_user_ids, $a_remove_initial, $a_remove_qualified, array $a_objective_ids)
166 if (!(
int) $a_course_id ||
167 !
sizeof($a_user_ids)) {
171 $base_sql =
"DELETE FROM loc_user_results" .
172 " WHERE course_id = " .
$ilDB->quote($a_course_id,
"integer") .
173 " AND " .
$ilDB->in(
"user_id", $a_user_ids,
"",
"integer");
175 if ((
bool) $a_remove_initial) {
177 " AND type = " .
$ilDB->quote(self::TYPE_INITIAL,
"integer");
178 $ilDB->manipulate($sql);
181 if ((
bool) $a_remove_qualified) {
183 " AND type = " .
$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
184 $ilDB->manipulate($sql);
187 if (is_array($a_objective_ids)) {
189 " AND " .
$ilDB->in(
"objective_id", $a_objective_ids,
"",
"integer");
190 $ilDB->manipulate($sql);
193 $ilDB->manipulate($sql);
214 if (!self::isValidType(
$a_type) ||
215 !self::isValidStatus($a_status)) {
221 "course_id" => array(
"integer", $this->course_obj_id),
222 "user_id" => array(
"integer", $this->user_id),
223 "objective_id" => array(
"integer", $a_objective_id),
224 "type" => array(
"integer",
$a_type)
227 "status" => array(
"integer", $a_status),
228 "result_perc" => array(
"integer", $a_result_percentage),
229 "limit_perc" => array(
"integer", $a_limit_percentage),
230 "tries" => array(
"integer", $a_tries),
231 "is_final" => array(
"integer", $a_is_final),
232 "tstamp" => array(
"integer", time()),
252 $sql =
"SELECT objective_id" .
253 " FROM loc_user_results" .
254 " WHERE course_id = " .
$ilDB->quote($this->course_obj_id,
"integer") .
255 " AND user_id = " .
$ilDB->quote($this->user_id,
"integer");
258 $sql .=
" AND type = " .
$ilDB->quote(
$a_type,
"integer");
261 $sql .=
" AND status = " .
$ilDB->quote($a_status,
"integer");
263 if ($a_is_final !==
null) {
264 $sql .=
" AND is_final = " .
$ilDB->quote($a_is_final,
"integer");
267 $set =
$ilDB->query($sql);
302 include_once
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
305 if (!$settings->isInitialTestQualifying() or !$settings->worksWithInitialTest()) {
306 return $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED);
311 $settings->isInitialTestQualifying() &&
312 $settings->worksWithInitialTest()
314 $completed = array();
315 $completed_candidates = array_unique(
321 $failed_final = (array) $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED);
323 foreach ($completed_candidates as $objective_completed) {
324 if (!in_array($objective_completed, $failed_final)) {
325 $completed[] = $objective_completed;
340 return $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED, $a_is_final);
354 include_once(
"./Modules/Course/classes/Objectives/class.ilLOSettings.php");
357 $set =
$ilDB->query(
"SELECT *" .
358 " FROM loc_user_results" .
359 " WHERE course_id = " .
$ilDB->quote($this->course_obj_id,
"integer") .
360 " AND user_id = " .
$ilDB->quote($this->user_id,
"integer"));
364 $row[
'type'] == self::TYPE_INITIAL &&
365 !$settings->worksWithInitialTest()
370 $objective_id =
$row[
"objective_id"];
372 unset(
$row[
"objective_id"]);
385 include_once
"Modules/Course/classes/Objectives/class.ilLOSettings.php";
387 $initial_qualifying = $lo_set->isInitialTestQualifying();
390 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
394 $sql =
"SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final" .
395 " FROM loc_user_results lor" .
396 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)" .
397 " WHERE " .
$ilDB->in(
"lor.objective_id", $a_objective_ids,
"",
"integer");
398 if (!(
bool) $initial_qualifying) {
399 $sql .=
" AND lor.type = " .
$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
401 $sql .=
" AND lor.user_id = " .
$ilDB->quote($a_user_id,
"integer") .
402 " AND cobj.active = " .
$ilDB->quote(1,
"integer") .
403 " ORDER BY lor.type";
404 $set =
$ilDB->query($sql);
406 switch (
$row[
"status"]) {
408 if ((
bool)
$row[
"is_final"]) {
429 $res[
$row[
"objective_id"]] = $status;
439 $GLOBALS[
'DIC']->logger()->trac()->debug(
'Get summorized objective status');
444 include_once
"Modules/Course/classes/Objectives/class.ilLOSettings.php";
446 $initial_qualifying = $lo_set->isInitialTestQualifying();
449 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
451 $res = $tmp_completed = array();
453 $sql =
"SELECT lor.objective_id, lor.user_id, lor.status, lor.type, lor.is_final" .
454 " FROM loc_user_results lor" .
455 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)" .
456 " WHERE " .
$ilDB->in(
"lor.objective_id", $a_objective_ids,
"",
"integer") .
457 " AND cobj.active = " .
$ilDB->quote(1,
"integer");
458 if (!(
bool) $initial_qualifying) {
459 $sql .=
" AND lor.type = " .
$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
462 $sql .=
" AND lor.user_id = " .
$ilDB->quote($a_user_id,
"integer");
464 $sql .=
" ORDER BY lor.type DESC";
465 $set =
$ilDB->query($sql);
467 $has_final_result = array();
469 if (
$row[
'type'] == self::TYPE_QUALIFIED) {
470 $has_final_result[
$row[
'objective_id']] =
$row[
'user_id'];
474 $status = (int)
$row[
"status"];
478 $row[
"type"] == self::TYPE_INITIAL &&
479 in_array(
$row[
'user_id'], (array) $has_final_result[
$row[
'objective_id']])
493 if ((
bool)
$row[
"is_final"]) {
501 $all_nr =
sizeof($a_objective_ids);
511 return $res[$a_user_id];
517 public static function hasResults($a_container_id, $a_user_id)
521 $query =
'SELECT objective_id FROM loc_user_results ' .
522 'WHERE course_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
523 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer');
An exception for terminatinating execution or to throw for unit testing.
static getInstanceByObjId($a_obj_id)
get singleton instance
getSuggestedObjectiveIds()
Get all objectives where the user failed the initial test.
static isValidType($a_type)
Is given type valid?
findObjectiveIds($a_type=null, $a_status=null, $a_is_final=null)
Find objective ids by type and/or status.
getFailedObjectiveIds($a_is_final=true)
Get all objectives where the user failed the qualified test.
saveObjectiveResult($a_objective_id, $a_type, $a_status, $a_result_percentage, $a_limit_percentage, $a_tries, $a_is_final)
Save objective result.
static deleteResultsForUser($a_user_id)
Delete all result entries for user.
static getSummarizedObjectiveStatusForLP($a_obj_id, array $a_objective_ids, $a_user_id=null)
static deleteResultsFromLP($a_course_id, array $a_user_ids, $a_remove_initial, $a_remove_qualified, array $a_objective_ids)
Delete all (qualified) result entries for course members.
getCourseResultsForUserPresentation()
Get all results for course and user.
getCompletedObjectiveIds()
Get all objectives where the user completed the qualified test.
static isValidStatus($a_status)
Is given status valid?
__construct($a_course_obj_id, $a_user_id)
Constructor.
static getObjectiveStatusForLP($a_user_id, $a_obj_id, array $a_objective_ids)
static resetFinalByObjective($a_objective_id)
static hasResults($a_container_id, $a_user_id)
static lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
Lookup user result.
getCompletedObjectiveIdsByType($a_type)
All completed objectives by type.
static deleteResultsForCourse($a_course_id)
Delete all result entries for course.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_FAILED_NUM
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res