ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
7 include_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  include_once './Modules/Survey/classes/class.ilObjSurveyAccess.php';
47  if (ilObjSurveyAccess::_isSurveyParticipant($a_user_id, $survey_id)) {
49 
50  if (ilObjSurveyAccess::_lookupFinished($a_obj_id, $a_user_id)) {
52  }
53  }
54 
55  return $status;
56  }
57 
58  protected static function getSurveyId($a_obj_id)
59  {
60  global $DIC;
61 
62  $ilDB = $DIC['ilDB'];
63 
64  $set = $ilDB->query("SELECT survey_id FROM svy_svy" .
65  " WHERE obj_fi = " . $ilDB->quote($a_obj_id));
66  $row = $ilDB->fetchAssoc($set);
67  return (int) $row["survey_id"];
68  }
69 
70  public static function getParticipants($a_obj_id, $a_only_finished = false)
71  {
72  global $DIC;
73 
74  $ilDB = $DIC['ilDB'];
75 
76  $res = array();
77 
78  $survey_id = self::getSurveyId($a_obj_id);
79  if (!$survey_id) {
80  return $res;
81  }
82 
83  $sql = "SELECT user_fi FROM svy_finished fin" .
84  " WHERE fin.survey_fi = " . $ilDB->quote($survey_id, "integer");
85 
86  if ($a_only_finished) {
87  $sql .= " AND fin.state = " . $ilDB->quote(1, "integer");
88  }
89 
90  $set = $ilDB->query($sql);
91  while ($row = $ilDB->fetchAssoc($set)) {
92  $res[] = $row["user_fi"];
93  }
94 
95  return $res;
96  }
97 }
98 
99 // patch-end svy_lp
const LP_STATUS_COMPLETED_NUM
static _isSurveyParticipant($user_id, $survey_id)
global $DIC
Definition: saml.php:7
const LP_STATUS_IN_PROGRESS_NUM
static getParticipants($a_obj_id, $a_only_finished=false)
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
foreach($_POST as $key=> $value) $res
static _lookupFinished($a_obj_id, $a_user_id="")
get finished status
$row
const LP_STATUS_NOT_ATTEMPTED_NUM
global $ilDB
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...