ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilLPStatusManual.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=0);
4 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
5 
11 {
12  public static function _getInProgress(int $a_obj_id): array
13  {
14  $users = ilChangeEvent::lookupUsersInProgress($a_obj_id);
15 
16  // Exclude all users with status completed.
17  return array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
18  }
19 
20  public static function _getCompleted(int $a_obj_id): array
21  {
22  global $DIC;
23 
24  $ilDB = $DIC['ilDB'];
25 
26  $usr_ids = array();
27 
28  $query = "SELECT DISTINCT(usr_id) user_id FROM ut_lp_marks " .
29  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
30  "AND completed = '1' ";
31 
32  $res = $ilDB->query($query);
33  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
34  $usr_ids[] = (int) $row->user_id;
35  }
36  return $usr_ids;
37  }
38 
42  public function determineStatus(
43  int $a_obj_id,
44  int $a_usr_id,
45  object $a_obj = null
46  ): int {
47  global $DIC;
48 
49  $ilObjDataCache = $DIC['ilObjDataCache'];
50  $ilDB = $DIC['ilDB'];
51 
52  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
53  switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
54  case 'lm':
55  case 'copa':
56  case 'file':
57  case 'htlm':
58  if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
59  $status = self::LP_STATUS_IN_PROGRESS_NUM;
60 
61  // completed?
62  $set = $this->db->query(
63  $q = "SELECT usr_id FROM ut_lp_marks " .
64  "WHERE obj_id = " . $this->db->quote(
65  $a_obj_id,
66  'integer'
67  ) . " " .
68  "AND usr_id = " . $this->db->quote(
69  $a_usr_id,
70  'integer'
71  ) . " " .
72  "AND completed = '1' "
73  );
74  if ($rec = $this->db->fetchAssoc($set)) {
75  $status = self::LP_STATUS_COMPLETED_NUM;
76  }
77  }
78  break;
79  }
80  return $status;
81  }
82 
89  public static function _lookupFailedForObject(
90  int $a_obj_id,
91  ?array $a_user_ids = null
92  ): array {
93  return array();
94  }
95 }
$res
Definition: ltiservices.php:69
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.
determineStatus(int $a_obj_id, int $a_usr_id, object $a_obj=null)
Determine status.
global $DIC
Definition: feed.php:28
static lookupUsersInProgress(int $a_obj_id)
ilObjectDataCache $ilObjDataCache
static _getCompleted(int $a_obj_id)
$q
Definition: shib_logout.php:21