ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLPStatusManual.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=0);
25 {
26  public static function _getInProgress(int $a_obj_id): array
27  {
28  $users = ilChangeEvent::lookupUsersInProgress($a_obj_id);
29 
30  // Exclude all users with status completed.
31  return array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
32  }
33 
34  public static function _getCompleted(int $a_obj_id): array
35  {
36  global $DIC;
37 
38  $ilDB = $DIC['ilDB'];
39 
40  $usr_ids = array();
41 
42  $query = "SELECT DISTINCT(usr_id) user_id FROM ut_lp_marks " .
43  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
44  "AND completed = '1' ";
45 
46  $res = $ilDB->query($query);
47  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
48  $usr_ids[] = (int) $row->user_id;
49  }
50  return $usr_ids;
51  }
52 
56  public function determineStatus(
57  int $a_obj_id,
58  int $a_usr_id,
59  ?object $a_obj = null
60  ): int {
61  global $DIC;
62 
63  $ilObjDataCache = $DIC['ilObjDataCache'];
64  $ilDB = $DIC['ilDB'];
65 
66  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
67  switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
68  case 'lm':
69  case 'copa':
70  case 'file':
71  case 'htlm':
72  if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
73  $status = self::LP_STATUS_IN_PROGRESS_NUM;
74 
75  // completed?
76  $set = $this->db->query(
77  $q = "SELECT usr_id FROM ut_lp_marks " .
78  "WHERE obj_id = " . $this->db->quote(
79  $a_obj_id,
80  'integer'
81  ) . " " .
82  "AND usr_id = " . $this->db->quote(
83  $a_usr_id,
84  'integer'
85  ) . " " .
86  "AND completed = '1' "
87  );
88  if ($rec = $this->db->fetchAssoc($set)) {
89  $status = self::LP_STATUS_COMPLETED_NUM;
90  }
91  }
92  break;
93  }
94  return $status;
95  }
96 
103  public static function _lookupFailedForObject(
104  int $a_obj_id,
105  ?array $a_user_ids = null
106  ): array {
107  return array();
108  }
109 }
$res
Definition: ltiservices.php:66
static _getInProgress(int $a_obj_id)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get failed users for object.
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static lookupUsersInProgress(int $a_obj_id)
global $DIC
Definition: shib_login.php:22
ilObjectDataCache $ilObjDataCache
static _getCompleted(int $a_obj_id)
$q
Definition: shib_logout.php:21
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
Determine status.