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;
69 $query =
'UPDATE loc_user_results '.
70 'SET is_final = '.$GLOBALS[
'ilDB']->quote(0,
'integer').
' '.
71 'WHERE objective_id = '.$GLOBALS[
'ilDB']->quote($a_objective_id,
'integer');
84 return in_array((
int)
$a_type,
array(self::TYPE_INITIAL, self::TYPE_QUALIFIED));
95 return in_array((
int)$a_status,
array(self::STATUS_COMPLETED, self::STATUS_FAILED));
113 $ilDB->manipulate(
"DELETE FROM loc_user_results".
114 " WHERE user_id = ".$ilDB->quote($a_user_id,
"integer"));
129 if(!(
int)$a_course_id)
134 $ilDB->manipulate(
"DELETE FROM loc_user_results".
135 " WHERE course_id = ".$ilDB->quote($a_course_id,
"integer"));
143 public function delete()
147 $query =
'DELETE FROM loc_user_results '.
148 'WHERE course_id = '.$ilDB->quote($this->course_obj_id).
' '.
149 'AND user_id = '.$ilDB->quote($this->user_id);
150 $ilDB->manipulate(
$query);
167 if(!(
int)$a_course_id ||
168 !
sizeof($a_user_ids))
173 $base_sql =
"DELETE FROM loc_user_results".
174 " WHERE course_id = ".$ilDB->quote($a_course_id,
"integer").
175 " AND ".$ilDB->in(
"user_id", $a_user_ids,
"",
"integer");
177 if((
bool)$a_remove_initial)
180 " AND type = ".$ilDB->quote(self::TYPE_INITIAL,
"integer");
181 $ilDB->manipulate($sql);
184 if((
bool)$a_remove_qualified)
187 " AND type = ".$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
188 $ilDB->manipulate($sql);
191 if(is_array($a_objective_ids))
194 " AND ".$ilDB->in(
"objective_id", $a_objective_ids,
"",
"integer");
195 $ilDB->manipulate($sql);
198 $ilDB->manipulate($sql);
219 if(!self::isValidType(
$a_type) ||
220 !self::isValidStatus($a_status))
224 $ilDB->replace(
"loc_user_results",
226 "course_id" =>
array(
"integer", $this->course_obj_id),
227 "user_id" =>
array(
"integer", $this->user_id),
228 "objective_id" =>
array(
"integer", $a_objective_id),
232 "status" =>
array(
"integer", $a_status),
233 "result_perc" =>
array(
"integer", $a_result_percentage),
234 "limit_perc" =>
array(
"integer", $a_limit_percentage),
235 "tries" =>
array(
"integer", $a_tries),
236 "is_final" =>
array(
"integer", $a_is_final),
257 $sql =
"SELECT objective_id".
258 " FROM loc_user_results".
259 " WHERE course_id = ".$ilDB->quote($this->course_obj_id,
"integer").
260 " AND user_id = ".$ilDB->quote($this->user_id,
"integer");
264 $sql .=
" AND type = ".$ilDB->quote(
$a_type,
"integer");
268 $sql .=
" AND status = ".$ilDB->quote($a_status,
"integer");
270 if($a_is_final !== null)
272 $sql .=
" AND is_final = ".$ilDB->quote($a_is_final,
"integer");
275 $set = $ilDB->query($sql);
276 while(
$row = $ilDB->fetchAssoc($set))
311 include_once
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
314 if(!$settings->isInitialTestQualifying()
or !$settings->worksWithInitialTest())
316 return $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED);
321 $settings->isInitialTestQualifying() &&
322 $settings->worksWithInitialTest()
325 $completed =
array();
326 $completed_candidates = array_unique(
333 foreach($completed_candidates as $objective_completed)
335 if(!in_array($objective_completed, $failed_final))
337 $completed[] = $objective_completed;
352 return $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED, $a_is_final);
366 include_once(
"./Modules/Course/classes/Objectives/class.ilLOSettings.php");
369 $set = $ilDB->query(
"SELECT *".
370 " FROM loc_user_results".
371 " WHERE course_id = ".$ilDB->quote($this->course_obj_id,
"integer").
372 " AND user_id = ".$ilDB->quote($this->user_id,
"integer"));
373 while(
$row = $ilDB->fetchAssoc($set))
377 $row[
'type'] == self::TYPE_INITIAL &&
378 !$settings->worksWithInitialTest()
384 $objective_id =
$row[
"objective_id"];
385 $type =
$row[
"type"];
386 unset(
$row[
"objective_id"]);
399 include_once
"Modules/Course/classes/Objectives/class.ilLOSettings.php";
401 $initial_qualifying = $lo_set->isInitialTestQualifying();
404 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
408 $sql =
"SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final".
409 " FROM loc_user_results lor".
410 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
411 " WHERE ".$ilDB->in(
"lor.objective_id", $a_objective_ids,
"",
"integer");
412 if(!(
bool)$initial_qualifying)
414 $sql .=
" AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
416 $sql .=
" AND lor.user_id = ".$ilDB->quote($a_user_id,
"integer").
417 " AND cobj.active = ".$ilDB->quote(1,
"integer").
418 " ORDER BY lor.type";
419 $set = $ilDB->query($sql);
420 while(
$row = $ilDB->fetchAssoc($set))
422 switch(
$row[
"status"])
424 case self::STATUS_FAILED:
425 if((
bool)
$row[
"is_final"])
436 case self::STATUS_COMPLETED:
449 $res[
$row[
"objective_id"]] = $status;
459 $GLOBALS[
'DIC']->logger()->trac()->debug(
'Get summorized objective status');
464 include_once
"Modules/Course/classes/Objectives/class.ilLOSettings.php";
466 $initial_qualifying = $lo_set->isInitialTestQualifying();
469 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
473 $sql =
"SELECT lor.objective_id, lor.user_id, lor.status, lor.type, lor.is_final".
474 " FROM loc_user_results lor".
475 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
476 " WHERE ".$ilDB->in(
"lor.objective_id", $a_objective_ids,
"",
"integer").
477 " AND cobj.active = ".$ilDB->quote(1,
"integer");
478 if(!(
bool)$initial_qualifying)
480 $sql .=
" AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
484 $sql .=
" AND lor.user_id = ".$ilDB->quote($a_user_id,
"integer");
486 $sql .=
" ORDER BY lor.type DESC";
487 $set = $ilDB->query($sql);
489 $has_final_result =
array();
490 while(
$row = $ilDB->fetchAssoc($set))
492 if(
$row[
'type'] == self::TYPE_QUALIFIED)
494 $has_final_result[
$row[
'objective_id']] = $row[
'user_id'];
498 $status = (int)
$row[
"status"];
502 $row[
"type"] == self::TYPE_INITIAL &&
503 in_array(
$row[
'user_id'], (
array) $has_final_result[
$row[
'objective_id']])
515 case self::STATUS_COMPLETED:
519 case self::STATUS_FAILED:
520 if((
bool)
$row[
"is_final"])
529 $all_nr =
sizeof($a_objective_ids);
542 return $res[$a_user_id];
550 public static function hasResults($a_container_id, $a_user_id)
554 $query =
'SELECT objective_id FROM loc_user_results '.
555 'WHERE course_id = '.$ilDB->quote($a_container_id,
'integer').
' '.
556 'AND user_id = '.$ilDB->quote($a_user_id,
'integer');
const LP_STATUS_COMPLETED_NUM
static getObjectiveStatusForLP($a_user_id, $a_obj_id, array $a_objective_ids)
static getInstanceByObjId($a_obj_id)
get singleton instance
static resetFinalByObjective($a_objective_id)
getCompletedObjectiveIdsByType($a_type)
All completed objectives by type.
static getSummarizedObjectiveStatusForLP($a_obj_id, array $a_objective_ids, $a_user_id=null)
static lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
Lookup user result.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const LP_STATUS_IN_PROGRESS_NUM
static deleteResultsForUser($a_user_id)
Delete all result entries for user.
getSuggestedObjectiveIds()
Get all objectives where the user failed the initial test.
getCompletedObjectiveIds()
Get all objectives where the user completed 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 deleteResultsForCourse($a_course_id)
Delete all result entries for course.
Create styles array
The data for the language used.
getFailedObjectiveIds($a_is_final=true)
Get all objectives where the user failed the qualified test.
findObjectiveIds($a_type=null, $a_status=null, $a_is_final=null)
Find objective ids by type and/or status.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static isValidStatus($a_status)
Is given status valid?
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.
static isValidType($a_type)
Is given type valid?
getCourseResultsForUserPresentation()
Get all results for course and user.
static hasResults($a_container_id, $a_user_id)
const LP_STATUS_FAILED_NUM
__construct($a_course_obj_id, $a_user_id)
Constructor.