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)
45 $query =
'SELECT * FROM loc_user_results ' .
46 'WHERE user_id = ' .
$ilDB->quote($a_user_id,
'integer') .
' ' .
47 'AND course_id = ' .
$ilDB->quote($a_course_obj_id,
'integer') .
' ' .
48 'AND objective_id = ' .
$ilDB->quote($a_objective_id,
'integer') .
' ' .
49 'AND type = ' .
$ilDB->quote($a_tst_type,
'integer');
52 'status' => self::STATUS_FAILED,
60 $ur[
'status'] =
$row->status;
61 $ur[
'result_perc'] =
$row->result_perc;
62 $ur[
'limit_perc'] =
$row->limit_perc;
63 $ur[
'tries'] =
$row->tries;
64 $ur[
'is_final'] =
$row->is_final;
65 $ur[
'has_result'] =
true;
72 $query =
'UPDATE loc_user_results ' .
73 'SET is_final = ' .
$GLOBALS[
'DIC'][
'ilDB']->quote(0,
'integer') .
' ' .
74 'WHERE objective_id = ' .
$GLOBALS[
'DIC'][
'ilDB']->quote($a_objective_id,
'integer');
87 return in_array((
int)
$a_type, array(self::TYPE_INITIAL, self::TYPE_QUALIFIED));
98 return in_array((
int) $a_status, array(self::STATUS_COMPLETED, self::STATUS_FAILED));
111 $ilDB = $DIC[
'ilDB'];
113 if (!(
int) $a_user_id) {
117 $ilDB->manipulate(
"DELETE FROM loc_user_results" .
118 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer"));
133 $ilDB = $DIC[
'ilDB'];
135 if (!(
int) $a_course_id) {
139 $ilDB->manipulate(
"DELETE FROM loc_user_results" .
140 " WHERE course_id = " .
$ilDB->quote($a_course_id,
"integer"));
148 public function delete()
152 $ilDB = $DIC[
'ilDB'];
154 $query =
'DELETE FROM loc_user_results ' .
155 'WHERE course_id = ' .
$ilDB->quote($this->course_obj_id) .
' ' .
156 'AND user_id = ' .
$ilDB->quote($this->user_id);
170 public static function deleteResultsFromLP($a_course_id, array $a_user_ids, $a_remove_initial, $a_remove_qualified, array $a_objective_ids)
174 $ilDB = $DIC[
'ilDB'];
176 if (!(
int) $a_course_id ||
177 !
sizeof($a_user_ids)) {
181 $base_sql =
"DELETE FROM loc_user_results" .
182 " WHERE course_id = " .
$ilDB->quote($a_course_id,
"integer") .
183 " AND " .
$ilDB->in(
"user_id", $a_user_ids,
"",
"integer");
185 if ((
bool) $a_remove_initial) {
187 " AND type = " .
$ilDB->quote(self::TYPE_INITIAL,
"integer");
188 $ilDB->manipulate($sql);
191 if ((
bool) $a_remove_qualified) {
193 " AND type = " .
$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
194 $ilDB->manipulate($sql);
197 if (is_array($a_objective_ids)) {
199 " AND " .
$ilDB->in(
"objective_id", $a_objective_ids,
"",
"integer");
200 $ilDB->manipulate($sql);
203 $ilDB->manipulate($sql);
224 $ilDB = $DIC[
'ilDB'];
226 if (!self::isValidType(
$a_type) ||
227 !self::isValidStatus($a_status)) {
233 "course_id" => array(
"integer", $this->course_obj_id),
234 "user_id" => array(
"integer", $this->user_id),
235 "objective_id" => array(
"integer", $a_objective_id),
236 "type" => array(
"integer",
$a_type)
239 "status" => array(
"integer", $a_status),
240 "result_perc" => array(
"integer", $a_result_percentage),
241 "limit_perc" => array(
"integer", $a_limit_percentage),
242 "tries" => array(
"integer", $a_tries),
243 "is_final" => array(
"integer", $a_is_final),
244 "tstamp" => array(
"integer", time()),
262 $ilDB = $DIC[
'ilDB'];
266 $sql =
"SELECT objective_id" .
267 " FROM loc_user_results" .
268 " WHERE course_id = " .
$ilDB->quote($this->course_obj_id,
"integer") .
269 " AND user_id = " .
$ilDB->quote($this->user_id,
"integer");
272 $sql .=
" AND type = " .
$ilDB->quote(
$a_type,
"integer");
275 $sql .=
" AND status = " .
$ilDB->quote($a_status,
"integer");
277 if ($a_is_final !== null) {
278 $sql .=
" AND is_final = " .
$ilDB->quote($a_is_final,
"integer");
281 $set =
$ilDB->query($sql);
316 include_once
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
319 if (!$settings->isInitialTestQualifying()
or !$settings->worksWithInitialTest()) {
320 return $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED);
325 $settings->isInitialTestQualifying() &&
326 $settings->worksWithInitialTest()
328 $completed = array();
329 $completed_candidates = array_unique(
335 $failed_final = (array) $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED);
337 foreach ($completed_candidates as $objective_completed) {
338 if (!in_array($objective_completed, $failed_final)) {
339 $completed[] = $objective_completed;
354 return $this->
findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED, $a_is_final);
366 $ilDB = $DIC[
'ilDB'];
370 include_once(
"./Modules/Course/classes/Objectives/class.ilLOSettings.php");
373 $set =
$ilDB->query(
"SELECT *" .
374 " FROM loc_user_results" .
375 " WHERE course_id = " .
$ilDB->quote($this->course_obj_id,
"integer") .
376 " AND user_id = " .
$ilDB->quote($this->user_id,
"integer"));
380 $row[
'type'] == self::TYPE_INITIAL &&
381 !$settings->worksWithInitialTest()
386 $objective_id =
$row[
"objective_id"];
388 unset(
$row[
"objective_id"]);
400 $ilDB = $DIC[
'ilDB'];
403 include_once
"Modules/Course/classes/Objectives/class.ilLOSettings.php";
405 $initial_qualifying = $lo_set->isInitialTestQualifying();
408 include_once
"Services/Tracking/classes/class.ilLPStatus.php";
412 $sql =
"SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final" .
413 " FROM loc_user_results lor" .
414 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)" .
415 " WHERE " .
$ilDB->in(
"lor.objective_id", $a_objective_ids,
"",
"integer");
416 if (!(
bool) $initial_qualifying) {
417 $sql .=
" AND lor.type = " .
$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
419 $sql .=
" AND lor.user_id = " .
$ilDB->quote($a_user_id,
"integer") .
420 " AND cobj.active = " .
$ilDB->quote(1,
"integer") .
421 " ORDER BY lor.type";
422 $set =
$ilDB->query($sql);
424 switch (
$row[
"status"]) {
425 case self::STATUS_FAILED:
426 if ((
bool)
$row[
"is_final"]) {
434 case self::STATUS_COMPLETED:
447 $res[
$row[
"objective_id"]] = $status;
457 $ilDB = $DIC[
'ilDB'];
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";
471 $res = $tmp_completed = array();
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) {
479 $sql .=
" AND lor.type = " .
$ilDB->quote(self::TYPE_QUALIFIED,
"integer");
482 $sql .=
" AND lor.user_id = " .
$ilDB->quote($a_user_id,
"integer");
484 $sql .=
" ORDER BY lor.type DESC";
485 $set =
$ilDB->query($sql);
487 $has_final_result = array();
489 if (
$row[
'type'] == self::TYPE_QUALIFIED) {
490 $has_final_result[
$row[
'objective_id']] = $row[
'user_id'];
494 $status = (int)
$row[
"status"];
498 $row[
"type"] == self::TYPE_INITIAL &&
499 in_array(
$row[
'user_id'], (array) $has_final_result[
$row[
'objective_id']])
508 case self::STATUS_COMPLETED:
512 case self::STATUS_FAILED:
513 if ((
bool)
$row[
"is_final"]) {
521 $all_nr =
sizeof($a_objective_ids);
522 foreach ($tmp_completed as
$user_id => $counter) {
524 if ($counter == $all_nr) {
531 return $res[$a_user_id];
537 public static function hasResults($a_container_id, $a_user_id)
541 $ilDB = $DIC[
'ilDB'];
543 $query =
'SELECT objective_id FROM loc_user_results ' .
544 'WHERE course_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
545 'AND user_id = ' .
$ilDB->quote($a_user_id,
'integer');
565 $ilDB = $DIC[
'ilDB'];
569 $sql =
"SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final, lor.tstamp, lor.course_id, cobj.title" .
570 " FROM loc_user_results lor" .
571 " JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)" .
572 " WHERE lor.user_id = " .
$ilDB->quote($a_user_id,
"integer") .
573 " AND lor.type = " .
$ilDB->quote(self::TYPE_QUALIFIED,
"integer") .
574 " AND lor.tstamp >= " .
$ilDB->quote($a_from_ts,
"integer") .
575 " AND lor.tstamp <= " .
$ilDB->quote($a_to_ts,
"integer") .
576 " AND lor.status = " .
$ilDB->quote(self::STATUS_COMPLETED,
"integer");
578 $set =
$ilDB->query($sql);
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.
const LP_STATUS_IN_PROGRESS_NUM
static getCompletionsOfUser($a_user_id, $a_from_ts, $a_to_ts)
Get completed learning objectives for user and time frame.
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.
foreach($_POST as $key=> $value) $res
static deleteResultsForCourse($a_course_id)
Delete all result entries for course.
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.
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)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
const LP_STATUS_FAILED_NUM
__construct($a_course_obj_id, $a_user_id)
Constructor.