ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLPStatusTestFinished.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=0);
4 
5 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
6 
12 {
13  public static function _getInProgress(int $a_obj_id): array
14  {
15  global $DIC;
16 
17  $ilDB = $DIC['ilDB'];
18 
19  $query = "
20  SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
21  FROM tst_active
22  LEFT JOIN tst_sequence
23  ON tst_sequence.active_fi = tst_active.active_id
24  WHERE tries = {$ilDB->quote(0, "integer")}
25  AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id), "integer")}
26  GROUP BY active_id, user_fi
27  HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
28  ";
29 
30  $res = $ilDB->query($query);
31 
32  $user_ids = array();
33 
34  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
35  $user_ids[$row->user_fi] = (int) $row->user_fi;
36  }
37  return array_values($user_ids);
38  }
39 
40  public static function _getCompleted(int $a_obj_id): array
41  {
42  global $DIC;
43 
44  $ilDB = $DIC['ilDB'];
45  $query = "
46  SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
47  FROM tst_active
48  LEFT JOIN tst_sequence
49  ON tst_sequence.active_fi = tst_active.active_id
50  WHERE tries > {$ilDB->quote(0, "integer")}
51  AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
52  GROUP BY active_id, user_fi
53  HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
54  ";
55 
56  $res = $ilDB->query($query);
57 
58  $user_ids = array();
59 
60  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
61  $user_ids[$row->user_fi] = (int) $row->user_fi;
62  }
63  return array_values($user_ids);
64  }
65 
66  public static function _getNotAttempted(int $a_obj_id): array
67  {
68  global $DIC;
69 
70  $ilDB = $DIC['ilDB'];
71 
72  $query = "
73  SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
74  FROM tst_active
75  LEFT JOIN tst_sequence
76  ON tst_sequence.active_fi = tst_active.active_id
77  WHERE test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
78  GROUP BY active_id, user_fi
79  HAVING COUNT(tst_sequence.active_fi) = {$ilDB->quote(0, "integer")}
80  ";
81 
82  $res = $ilDB->query($query);
83 
84  $user_ids = array();
85 
86  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87  $user_ids[$row->user_fi] = (int) $row->user_fi;
88  }
89 
90  return array_values($user_ids);
91  }
92 
93  public static function getParticipants($a_obj_id)
94  {
95  global $DIC;
96 
97  $ilDB = $DIC['ilDB'];
98 
99  $res = $ilDB->query(
100  "SELECT DISTINCT user_fi FROM tst_active" .
101  " WHERE test_fi = " . $ilDB->quote(
103  )
104  );
105  $user_ids = array();
106 
107  while ($rec = $ilDB->fetchAssoc($res)) {
108  $user_ids[] = (int) $rec["user_fi"];
109  }
110  return $user_ids;
111  }
112 
113  public function determineStatus(
114  int $a_obj_id,
115  int $a_usr_id,
116  object $a_obj = null
117  ): int {
118  $res = $this->db->query(
119  "
120  SELECT active_id, user_fi, tries, COUNT(tst_sequence.active_fi) sequences
121  FROM tst_active
122  LEFT JOIN tst_sequence
123  ON tst_sequence.active_fi = tst_active.active_id
124  WHERE user_fi = {$this->db->quote($a_usr_id, "integer")}
125  AND test_fi = {$this->db->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id), ilDBConstants::T_INTEGER)}
126  GROUP BY active_id, user_fi, tries
127  "
128  );
129 
130  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
131 
132  if ($rec = $this->db->fetchAssoc($res)) {
133  if ($rec['sequences'] > 0) {
134  $status = self::LP_STATUS_IN_PROGRESS_NUM;
135 
136  if ($rec['tries'] > 0) {
137  $status = self::LP_STATUS_COMPLETED_NUM;
138  }
139  }
140  }
141  return $status;
142  }
143 }
$res
Definition: ltiservices.php:69
determineStatus(int $a_obj_id, int $a_usr_id, object $a_obj=null)
static _getNotAttempted(int $a_obj_id)
static _getInProgress(int $a_obj_id)
global $DIC
Definition: feed.php:28
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
$query