ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
5include_once './Services/Tracking/classes/class.ilLPStatus.php';
6
16{
17 public function __construct($a_obj_id)
18 {
19 global $DIC;
20
21 $ilDB = $DIC['ilDB'];
22
23 parent::__construct($a_obj_id);
24 $this->db = $ilDB;
25 }
26
27 public static function _getInProgress($a_obj_id)
28 {
29 global $DIC;
30
31 $ilDB = $DIC['ilDB'];
32
33 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
34
35 $query = "
36 SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
37 FROM tst_active
38 LEFT JOIN tst_sequence
39 ON tst_sequence.active_fi = tst_active.active_id
40 WHERE tries = {$ilDB->quote(0, "integer")}
41 AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id), "integer")}
42 GROUP BY active_id, user_fi
43 HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
44 ";
45
46 $res = $ilDB->query($query);
47
48 $user_ids = array();
49
50 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
51 $user_ids[$row->user_fi] = $row->user_fi;
52 }
53
54 return array_values($user_ids);
55 }
56
57
58 public static function _getCompleted($a_obj_id)
59 {
60 global $DIC;
61
62 $ilDB = $DIC['ilDB'];
63
64 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
65
66 $query = "
67 SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
68 FROM tst_active
69 LEFT JOIN tst_sequence
70 ON tst_sequence.active_fi = tst_active.active_id
71 WHERE tries > {$ilDB->quote(0, "integer")}
72 AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
73 GROUP BY active_id, user_fi
74 HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
75 ";
76
77 $res = $ilDB->query($query);
78
79 $user_ids = array();
80
81 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
82 $user_ids[$row->user_fi] = $row->user_fi;
83 }
84
85 return array_values($user_ids);
86 }
87
88 public static function _getNotAttempted($a_obj_id)
89 {
90 global $DIC;
91
92 $ilDB = $DIC['ilDB'];
93
94 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
95
96 $query = "
97 SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
98 FROM tst_active
99 LEFT JOIN tst_sequence
100 ON tst_sequence.active_fi = tst_active.active_id
101 WHERE test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
102 GROUP BY active_id, user_fi
103 HAVING COUNT(tst_sequence.active_fi) = {$ilDB->quote(0, "integer")}
104 ";
105
106 $res = $ilDB->query($query);
107
108 $user_ids = array();
109
110 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
111 $user_ids[$row->user_fi] = $row->user_fi;
112 }
113
114 return array_values($user_ids);
115 }
116
123 public static function getParticipants($a_obj_id)
124 {
125 global $DIC;
126
127 $ilDB = $DIC['ilDB'];
128
129 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
130
131 $res = $ilDB->query("SELECT DISTINCT user_fi FROM tst_active" .
132 " WHERE test_fi = " . $ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id)));
133 $user_ids = array();
134
135 while ($rec = $ilDB->fetchAssoc($res)) {
136 $user_ids[] = $rec["user_fi"];
137 }
138 return $user_ids;
139 }
140
141
150 public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
151 {
152 global $DIC;
153
154 $ilDB = $DIC['ilDB'];
155
156 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
157
158 $res = $ilDB->query("
159 SELECT active_id, user_fi, tries, COUNT(tst_sequence.active_fi) sequences
160 FROM tst_active
161 LEFT JOIN tst_sequence
162 ON tst_sequence.active_fi = tst_active.active_id
163 WHERE user_fi = {$ilDB->quote($a_user_id, "integer")}
164 AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
165 GROUP BY active_id, user_fi, tries
166 ");
167
169
170 if ($rec = $ilDB->fetchAssoc($res)) {
171 if ($rec['sequences'] > 0) {
173
174 if ($rec['tries'] > 0) {
176 }
177 }
178 }
179
180 return $status;
181 }
182}
An exception for terminatinating execution or to throw for unit testing.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
static getParticipants($a_obj_id)
Get participants.
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
$row
$query
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB