ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestEvaluationData.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
23
29 private $test;
30
37
44
50 public $arrFilter;
51
56 public $datasets;
57
58 public function __sleep()
59 {
60 return array('questionTitles', 'participants', 'statistics', 'arrFilter', 'datasets', 'test');
61 }
62
68 public function __construct(ilObjTest $test = null)
69 {
70 $this->participants = array();
71 $this->questionTitles = array();
72 if ($test !== null) {
73 $this->test = $test;
74 $this->generateOverview();
75 }
76 }
77
78 public function generateOverview()
79 {
80 global $ilDB;
81
82 include_once "./Modules/Test/classes/class.ilTestEvaluationPassData.php";
83 include_once "./Modules/Test/classes/class.ilTestEvaluationUserData.php";
84
85 $this->participants = array();
86
87 $query = "
88 SELECT usr_data.usr_id,
89 usr_data.firstname,
90 usr_data.lastname,
91 usr_data.title,
92 usr_data.login,
93 tst_pass_result.*
94 FROM tst_pass_result, tst_active
95 LEFT JOIN usr_data
96 ON tst_active.user_fi = usr_data.usr_id
97 WHERE tst_active.active_id = tst_pass_result.active_fi
98 AND tst_active.test_fi = %s
99 ORDER BY usr_data.lastname,
100 usr_data.firstname,
101 tst_pass_result.active_fi,
102 tst_pass_result.pass,
103 tst_pass_result.tstamp
104 ";
105
106 $result = $ilDB->queryF(
107 $query,
108 array('integer'),
109 array($this->getTest()->getTestId())
110 );
111
112 $pass = null;
113 $checked = array();
114 $thissets = 0;
115
116 while ($row = $ilDB->fetchAssoc($result)) {
117 $thissets++;
118
119 $remove = false;
120
121 if (!$this->participantExists($row["active_fi"])) {
122 $this->addParticipant($row["active_fi"], new ilTestEvaluationUserData($this->getTest()->getPassScoring()));
123
124 $this->getParticipant($row["active_fi"])->setName(
125 $this->getTest()->buildName($row["usr_id"], $row["firstname"], $row["lastname"], $row["title"])
126 );
127
128 $this->getParticipant($row["active_fi"])->setLogin($row["login"]);
129
130 $this->getParticipant($row["active_fi"])->setUserID($row["usr_id"]);
131 }
132
133 if (!is_object($this->getParticipant($row["active_fi"])->getPass($row["pass"]))) {
135 $pass->setPass($row["pass"]);
136 $this->getParticipant($row["active_fi"])->addPass($row["pass"], $pass);
137 }
138
139 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setReachedPoints($row["points"]);
140 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setObligationsAnswered($row["obligations_answered"]);
141
142 if ($row["questioncount"] == 0) {
144 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setMaxPoints($data['points']);
145 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setQuestionCount($data['count']);
146 } else {
147 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setMaxPoints($row["maxpoints"]);
148 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setQuestionCount($row["questioncount"]);
149 }
150
151 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setNrOfAnsweredQuestions($row["answeredquestions"]);
152 $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setWorkingTime($row["workingtime"]);
153
154 $this->getParticipant($row['active_fi'])->getPass($row['pass'])->setRequestedHintsCount($row['hint_count']);
155 $this->getParticipant($row['active_fi'])->getPass($row['pass'])->setDeductedHintPoints($row['hint_points']);
156 }
157 }
158
159 public function getTest()
160 {
161 return $this->test;
162 }
163
164 public function setTest($test)
165 {
166 $this->test =&$test;
167 }
168
169 public function setDatasets($datasets)
170 {
171 $this->datasets = $datasets;
172 }
173
174 public function getDatasets()
175 {
176 return $this->datasets;
177 }
178
179 public function addQuestionTitle($question_id, $question_title)
180 {
181 $this->questionTitles[$question_id] = $question_title;
182 }
183
184 public function getQuestionTitles()
185 {
187 }
188
189 public function getQuestionTitle($question_id)
190 {
191 if (array_key_exists($question_id, $this->questionTitles)) {
192 return $this->questionTitles[$question_id];
193 } else {
194 return "";
195 }
196 }
197
198 public function calculateStatistics()
199 {
200 include_once "./Modules/Test/classes/class.ilTestStatistics.php";
201 $this->statistics = new ilTestStatistics($this);
202 }
203
204 public function getParticipants()
205 {
206 if (is_array($this->arrFilter) && count($this->arrFilter) > 0) {
207 $filteredParticipants = array();
208 $courseids = array();
209 $groupids = array();
210 global $ilDB;
211 if (array_key_exists('group', $this->arrFilter)) {
212 $ids = ilObject::_getIdsForTitle($this->arrFilter['group'], 'grp', true);
213 $groupids = array_merge($groupids, $ids);
214 }
215 if (array_key_exists('course', $this->arrFilter)) {
216 $ids = ilObject::_getIdsForTitle($this->arrFilter['course'], 'crs', true);
217 $courseids = array_merge($courseids, $ids);
218 }
219 foreach ($this->participants as $active_id => $participant) {
220 $remove = false;
221 if (array_key_exists('name', $this->arrFilter)) {
222 if (!(strpos(strtolower($participant->getName()), strtolower($this->arrFilter['name'])) !== false)) {
223 $remove = true;
224 }
225 }
226 if (!$remove) {
227 if (array_key_exists('group', $this->arrFilter)) {
228 include_once "./Services/Membership/classes/class.ilParticipants.php";
229 $groups = ilParticipants::_getMembershipByType($participant->getUserID(), "grp");
230 $foundfilter = false;
231 if (count(array_intersect($groupids, $groups))) {
232 $foundfilter = true;
233 }
234 if (!$foundfilter) {
235 $remove = true;
236 }
237 }
238 }
239 if (!$remove) {
240 if (array_key_exists('course', $this->arrFilter)) {
241 include_once "./Services/Membership/classes/class.ilParticipants.php";
242 $courses = ilParticipants::_getMembershipByType($participant->getUserID(), "crs");
243 $foundfilter = false;
244 if (count(array_intersect($courseids, $courses))) {
245 $foundfilter = true;
246 }
247 if (!$foundfilter) {
248 $remove = true;
249 }
250 }
251 }
252 if (!$remove) {
253 if (array_key_exists('active_id', $this->arrFilter)) {
254 if ($active_id != $this->arrFilter['active_id']) {
255 $remove = true;
256 }
257 }
258 }
259 if (!$remove) {
260 $filteredParticipants[$active_id] = $participant;
261 }
262 }
263 return $filteredParticipants;
264 } else {
265 return $this->participants;
266 }
267 }
268
269 public function resetFilter()
270 {
271 $this->arrFilter = array();
272 }
273
274 /*
275 * Set an output filter for getParticipants
276 *
277 * @param string $by name, course, group
278 * @param string $text Filter text
279 */
280 public function setFilter($by, $text)
281 {
282 $this->arrFilter = array($by => $text);
283 }
284
285 /*
286 * Set an output filter for getParticipants
287 *
288 * @param array $arrFilter filter values
289 */
290 public function setFilterArray($arrFilter)
291 {
292 $this->arrFilter = $arrFilter;
293 }
294
295 public function addParticipant($active_id, $participant)
296 {
297 $this->participants[$active_id] = $participant;
298 }
299
304 public function getParticipant($active_id)
305 {
306 return $this->participants[$active_id];
307 }
308
309 public function participantExists($active_id)
310 {
311 return array_key_exists($active_id, $this->participants);
312 }
313
314 public function removeParticipant($active_id)
315 {
316 unset($this->participants[$active_id]);
317 }
318
319 public function getStatistics()
320 {
321 return $this->statistics;
322 }
323
324 public function getParticipantIds()
325 {
326 return array_keys($this->participants);
327 }
328} // END ilTestEvaluationData
$result
An exception for terminatinating execution or to throw for unit testing.
static _getQuestionCountAndPointsForPassOfParticipant($active_id, $pass)
static _getIdsForTitle($title, $type='', $partialmatch=false)
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
addQuestionTitle($question_id, $question_title)
addParticipant($active_id, $participant)
__construct(ilObjTest $test=null)
Constructor.
This class calculates statistical data for a test which has to be calculated using all participant da...
$query
global $ilDB
$text
Definition: errorreport.php:18