ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLPStatusSurveyFinished.php
Go to the documentation of this file.
1<?php
2
3// patch-begin svy_lp
4
5/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
6
7include_once './Services/Tracking/classes/class.ilLPStatus.php';
8
18{
19 public static function _getInProgress($a_obj_id)
20 {
21 return self::getParticipants($a_obj_id);
22 }
23
24 public static function _getCompleted($a_obj_id)
25 {
26 return self::getParticipants($a_obj_id, true);
27 }
28
37 public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
38 {
39 $survey_id = self::getSurveyId($a_obj_id);
40 if (!$survey_id) {
41 return;
42 }
43
45
46 if (ilObjSurveyAccess::_isSurveyParticipant($a_user_id, $survey_id)) {
48
49 if (ilObjSurveyAccess::_lookupFinished($a_obj_id, $a_user_id)) {
51 }
52 }
53
54 return $status;
55 }
56
57 protected static function getSurveyId($a_obj_id)
58 {
59 global $DIC;
60
61 $ilDB = $DIC['ilDB'];
62
63 $set = $ilDB->query("SELECT survey_id FROM svy_svy" .
64 " WHERE obj_fi = " . $ilDB->quote($a_obj_id));
65 $row = $ilDB->fetchAssoc($set);
66 return (int) $row["survey_id"];
67 }
68
69 public static function getParticipants($a_obj_id, $a_only_finished = false)
70 {
71 global $DIC;
72
73 $ilDB = $DIC['ilDB'];
74
75 $res = array();
76
77 $survey_id = self::getSurveyId($a_obj_id);
78 if (!$survey_id) {
79 return $res;
80 }
81
82 $sql = "SELECT user_fi FROM svy_finished fin" .
83 " WHERE fin.survey_fi = " . $ilDB->quote($survey_id, "integer");
84
85 if ($a_only_finished) {
86 $sql .= " AND fin.state = " . $ilDB->quote(1, "integer");
87 }
88
89 $set = $ilDB->query($sql);
90 while ($row = $ilDB->fetchAssoc($set)) {
91 $res[] = $row["user_fi"];
92 }
93
94 return $res;
95 }
96}
97
98// patch-end svy_lp
An exception for terminatinating execution or to throw for unit testing.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
static getParticipants($a_obj_id, $a_only_finished=false)
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static _isSurveyParticipant($user_id, $survey_id)
static _lookupFinished($a_obj_id, $a_user_id="")
get finished status
global $DIC
Definition: goto.php:24
foreach($_POST as $key=> $value) $res
global $ilDB