ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPStatusTestFinished.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Tracking/classes/class.ilLPStatus.php';
6 
16 {
17 
18  function ilLPStatusTestFinished($a_obj_id)
19  {
20  global $ilDB;
21 
22  parent::ilLPStatus($a_obj_id);
23  $this->db =& $ilDB;
24  }
25 
26  function _getInProgress($a_obj_id)
27  {
28  global $ilDB;
29 
30  include_once './Modules/Test/classes/class.ilObjTestAccess.php';
31 
32  $query = "
33  SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
34  FROM tst_active
35  LEFT JOIN tst_sequence
36  ON tst_sequence.active_fi = tst_active.active_id
37  WHERE tries = {$ilDB->quote(0, "integer")}
38  AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id), "integer")}
39  GROUP BY active_id, user_fi
40  HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
41  ";
42 
43  $res = $ilDB->query($query);
44 
45  $user_ids = array();
46 
47  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
48  {
49  $user_ids[$row->user_fi] = $row->user_fi;
50  }
51 
52  return array_values($user_ids);
53  }
54 
55 
56  function _getCompleted($a_obj_id)
57  {
58  global $ilDB;
59 
60  include_once './Modules/Test/classes/class.ilObjTestAccess.php';
61 
62  $query = "
63  SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
64  FROM tst_active
65  LEFT JOIN tst_sequence
66  ON tst_sequence.active_fi = tst_active.active_id
67  WHERE tries > {$ilDB->quote(0, "integer")}
68  AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
69  GROUP BY active_id, user_fi
70  HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
71  ";
72 
73  $res = $ilDB->query($query);
74 
75  $user_ids = array();
76 
77  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
78  {
79  $user_ids[$row->user_fi] = $row->user_fi;
80  }
81 
82  return array_values($user_ids);
83  }
84 
85  function _getNotAttempted($a_obj_id)
86  {
87  global $ilDB;
88 
89  include_once './Modules/Test/classes/class.ilObjTestAccess.php';
90 
91  $query = "
92  SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
93  FROM tst_active
94  LEFT JOIN tst_sequence
95  ON tst_sequence.active_fi = tst_active.active_id
96  WHERE test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
97  GROUP BY active_id, user_fi
98  HAVING COUNT(tst_sequence.active_fi) = {$ilDB->quote(0, "integer")}
99  ";
100 
101  $res = $ilDB->query($query);
102 
103  $user_ids = array();
104 
105  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
106  {
107  $user_ids[$row->user_fi] = $row->user_fi;
108  }
109 
110  return array_values($user_ids);
111  }
112 
119  function getParticipants($a_obj_id)
120  {
121  global $ilDB;
122 
123  include_once './Modules/Test/classes/class.ilObjTestAccess.php';
124 
125  $res = $ilDB->query("SELECT DISTINCT user_fi FROM tst_active".
126  " WHERE test_fi = ".$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id)));
127  $user_ids = array();
128 
129  while($rec = $ilDB->fetchAssoc($res))
130  {
131  $user_ids[] = $rec["user_fi"];
132  }
133  return $user_ids;
134  }
135 
136 
145  function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
146  {
147  global $ilDB;
148 
149  include_once './Modules/Test/classes/class.ilObjTestAccess.php';
150 
151  $res = $ilDB->query("
152  SELECT active_id, user_fi, tries, COUNT(tst_sequence.active_fi) sequences
153  FROM tst_active
154  LEFT JOIN tst_sequence
155  ON tst_sequence.active_fi = tst_active.active_id
156  WHERE user_fi = {$ilDB->quote($a_user_id, "integer")}
157  AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
158  GROUP BY active_id, user_fi, tries
159  ");
160 
162 
163  if ($rec = $ilDB->fetchAssoc($res))
164  {
165  if ($rec['sequences'] > 0)
166  {
168 
169  if ($rec['tries'] > 0)
170  {
172  }
173  }
174  }
175 
176  return $status;
177  }
178 
179 }
180 ?>