ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 'htlm':
57  if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
58  $status = self::LP_STATUS_IN_PROGRESS_NUM;
59 
60  // completed?
61  $set = $this->db->query(
62  $q = "SELECT usr_id FROM ut_lp_marks " .
63  "WHERE obj_id = " . $this->db->quote(
64  $a_obj_id,
65  'integer'
66  ) . " " .
67  "AND usr_id = " . $this->db->quote(
68  $a_usr_id,
69  'integer'
70  ) . " " .
71  "AND completed = '1' "
72  );
73  if ($rec = $this->db->fetchAssoc($set)) {
74  $status = self::LP_STATUS_COMPLETED_NUM;
75  }
76  }
77  break;
78  }
79  return $status;
80  }
81 
88  public static function _lookupFailedForObject(
89  int $a_obj_id,
90  ?array $a_user_ids = null
91  ): array {
92  return array();
93  }
94 }
$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)
$query
ilObjectDataCache $ilObjDataCache
static _getCompleted(int $a_obj_id)