ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
20
21 parent::__construct($a_obj_id);
22 $this->db = $ilDB;
23 }
24
25 public static function _getInProgress($a_obj_id)
26 {
27 global $ilDB;
28
29 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
30
31 $query = "
32 SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
33 FROM tst_active
34 LEFT JOIN tst_sequence
35 ON tst_sequence.active_fi = tst_active.active_id
36 WHERE tries = {$ilDB->quote(0, "integer")}
37 AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id), "integer")}
38 GROUP BY active_id, user_fi
39 HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
40 ";
41
42 $res = $ilDB->query($query);
43
44 $user_ids = array();
45
46 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
47 $user_ids[$row->user_fi] = $row->user_fi;
48 }
49
50 return array_values($user_ids);
51 }
52
53
54 public static function _getCompleted($a_obj_id)
55 {
56 global $ilDB;
57
58 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
59
60 $query = "
61 SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
62 FROM tst_active
63 LEFT JOIN tst_sequence
64 ON tst_sequence.active_fi = tst_active.active_id
65 WHERE tries > {$ilDB->quote(0, "integer")}
66 AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
67 GROUP BY active_id, user_fi
68 HAVING COUNT(tst_sequence.active_fi) > {$ilDB->quote(0, "integer")}
69 ";
70
71 $res = $ilDB->query($query);
72
73 $user_ids = array();
74
75 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
76 $user_ids[$row->user_fi] = $row->user_fi;
77 }
78
79 return array_values($user_ids);
80 }
81
82 public static function _getNotAttempted($a_obj_id)
83 {
84 global $ilDB;
85
86 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
87
88 $query = "
89 SELECT active_id, user_fi, COUNT(tst_sequence.active_fi) sequences
90 FROM tst_active
91 LEFT JOIN tst_sequence
92 ON tst_sequence.active_fi = tst_active.active_id
93 WHERE test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
94 GROUP BY active_id, user_fi
95 HAVING COUNT(tst_sequence.active_fi) = {$ilDB->quote(0, "integer")}
96 ";
97
98 $res = $ilDB->query($query);
99
100 $user_ids = array();
101
102 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
103 $user_ids[$row->user_fi] = $row->user_fi;
104 }
105
106 return array_values($user_ids);
107 }
108
115 public static function getParticipants($a_obj_id)
116 {
117 global $ilDB;
118
119 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
120
121 $res = $ilDB->query("SELECT DISTINCT user_fi FROM tst_active" .
122 " WHERE test_fi = " . $ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id)));
123 $user_ids = array();
124
125 while ($rec = $ilDB->fetchAssoc($res)) {
126 $user_ids[] = $rec["user_fi"];
127 }
128 return $user_ids;
129 }
130
131
140 public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
141 {
142 global $ilDB;
143
144 include_once './Modules/Test/classes/class.ilObjTestAccess.php';
145
146 $res = $ilDB->query("
147 SELECT active_id, user_fi, tries, COUNT(tst_sequence.active_fi) sequences
148 FROM tst_active
149 LEFT JOIN tst_sequence
150 ON tst_sequence.active_fi = tst_active.active_id
151 WHERE user_fi = {$ilDB->quote($a_user_id, "integer")}
152 AND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}
153 GROUP BY active_id, user_fi, tries
154 ");
155
157
158 if ($rec = $ilDB->fetchAssoc($res)) {
159 if ($rec['sequences'] > 0) {
161
162 if ($rec['tries'] > 0) {
164 }
165 }
166 }
167
168 return $status;
169 }
170}
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.
$query
foreach($_POST as $key=> $value) $res
global $ilDB