ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestEvaluationData.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
36 {
43 
49  private $test;
50 
57 
64 
71 
76  var $datasets;
77 
78  public function __sleep()
79  {
80  return array('questionTitles', 'participants', 'statistics', 'arrFilter', 'datasets', 'test');
81  }
82 
89  {
90  $this->participants = array();
91  $this->questionTitles = array();
92  if( $test !== null )
93  {
94  $this->test = $test;
95  $this->generateOverview();
96  }
97  }
98 
99  function generateOverview()
100  {
101  global $ilDB;
102 
103  include_once "./Modules/Test/classes/class.ilTestEvaluationPassData.php";
104  include_once "./Modules/Test/classes/class.ilTestEvaluationUserData.php";
105 
106  $this->participants = array();
107 
108  $query = "
109  SELECT usr_data.usr_id,
110  usr_data.firstname,
111  usr_data.lastname,
112  usr_data.title,
113  usr_data.login,
114  tst_pass_result.*
115  FROM tst_pass_result, tst_active
116  LEFT JOIN usr_data
117  ON tst_active.user_fi = usr_data.usr_id
118  WHERE tst_active.active_id = tst_pass_result.active_fi
119  AND tst_active.test_fi = %s
120  ORDER BY usr_data.lastname,
121  usr_data.firstname,
122  tst_pass_result.active_fi,
123  tst_pass_result.pass,
124  tst_pass_result.tstamp
125  ";
126 
127  $result = $ilDB->queryF(
128  $query, array('integer'), array($this->getTest()->getTestId())
129  );
130 
131  $pass = NULL;
132  $checked = array();
133  $thissets = 0;
134 
135  while( $row = $ilDB->fetchAssoc($result) )
136  {
137  $thissets++;
138 
139  $remove = FALSE;
140 
141  if( !$this->participantExists($row["active_fi"]) )
142  {
143  $this->addParticipant($row["active_fi"], new ilTestEvaluationUserData($this->getTest()->getPassScoring()));
144 
145  $this->getParticipant($row["active_fi"])->setName(
146  $this->getTest()->buildName($row["usr_id"], $row["firstname"], $row["lastname"], $row["title"])
147  );
148 
149  $this->getParticipant($row["active_fi"])->setLogin($row["login"]);
150 
151  $this->getParticipant($row["active_fi"])->setUserID($row["usr_id"]);
152  }
153 
154  if( !is_object($this->getParticipant($row["active_fi"])->getPass($row["pass"])) )
155  {
157  $pass->setPass($row["pass"]);
158  $this->getParticipant($row["active_fi"])->addPass($row["pass"], $pass);
159  }
160 
161  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setReachedPoints($row["points"]);
162  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setObligationsAnswered($row["obligations_answered"]);
163 
164  if( $row["questioncount"] == 0 )
165  {
167  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setMaxPoints($data['points']);
168  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setQuestionCount($data['count']);
169  }
170  else
171  {
172  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setMaxPoints($row["maxpoints"]);
173  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setQuestionCount($row["questioncount"]);
174  }
175 
176  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setNrOfAnsweredQuestions($row["answeredquestions"]);
177  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setWorkingTime($row["workingtime"]);
178 
179  $this->getParticipant($row['active_fi'])->getPass($row['pass'])->setRequestedHintsCount($row['hint_count']);
180  $this->getParticipant($row['active_fi'])->getPass($row['pass'])->setDeductedHintPoints($row['hint_points']);
181  }
182  }
183 
184  function getTest()
185  {
186  return $this->test;
187  }
188 
189  function setTest($test)
190  {
191  $this->test =& $test;
192  }
193 
195  {
196  $this->datasets = $datasets;
197  }
198 
199  function getDatasets()
200  {
201  return $this->datasets;
202  }
203 
204  function addQuestionTitle($question_id, $question_title)
205  {
206  $this->questionTitles[$question_id] = $question_title;
207  }
208 
209  function getQuestionTitles()
210  {
211  return $this->questionTitles;
212  }
213 
214  function getQuestionTitle($question_id)
215  {
216  if (array_key_exists($question_id, $this->questionTitles))
217  {
218  return $this->questionTitles[$question_id];
219  }
220  else
221  {
222  return "";
223  }
224  }
225 
227  {
228  include_once "./Modules/Test/classes/class.ilTestStatistics.php";
229  $this->statistics = new ilTestStatistics($this);
230  }
231 
232  function getParticipants()
233  {
234  if (count($this->arrFilter))
235  {
236  $filteredParticipants = array();
237  $courseids = array();
238  $groupids = array();
239  global $ilDB;
240  if (array_key_exists('group', $this->arrFilter))
241  {
242  $ids = ilObject::_getIdsForTitle($this->arrFilter['group'], 'grp', true);
243  $groupids = array_merge($groupids, $ids);
244  }
245  if (array_key_exists('course', $this->arrFilter))
246  {
247  $ids = ilObject::_getIdsForTitle($this->arrFilter['course'], 'crs', true);
248  $courseids = array_merge($courseids, $ids);
249  }
250  foreach ($this->participants as $active_id => $participant)
251  {
252  $remove = FALSE;
253  if (array_key_exists('name', $this->arrFilter))
254  {
255  if (!(strpos(strtolower($participant->getName()), strtolower($this->arrFilter['name'])) !== FALSE)) $remove = TRUE;
256  }
257  if (!$remove)
258  {
259  if (array_key_exists('group', $this->arrFilter))
260  {
261  include_once "./Services/Membership/classes/class.ilParticipants.php";
262  $groups = ilParticipants::_getMembershipByType($participant->getUserID(), "grp");
263  $foundfilter = FALSE;
264  if (count(array_intersect($groupids, $groups))) $foundfilter = TRUE;
265  if (!$foundfilter) $remove = TRUE;
266  }
267  }
268  if (!$remove)
269  {
270  if (array_key_exists('course', $this->arrFilter))
271  {
272  include_once "./Services/Membership/classes/class.ilParticipants.php";
273  $courses = ilParticipants::_getMembershipByType($participant->getUserID(), "crs");
274  $foundfilter = FALSE;
275  if (count(array_intersect($courseids, $courses))) $foundfilter = TRUE;
276  if (!$foundfilter) $remove = TRUE;
277  }
278  }
279  if (!$remove)
280  {
281  if (array_key_exists('active_id', $this->arrFilter))
282  {
283  if ($active_id != $this->arrFilter['active_id']) $remove = TRUE;
284  }
285  }
286  if (!$remove) $filteredParticipants[$active_id] = $participant;
287  }
288  return $filteredParticipants;
289  }
290  else
291  {
292  return $this->participants;
293  }
294  }
295 
296  function resetFilter()
297  {
298  $this->arrFilter = array();
299  }
300 
301  /*
302  * Set an output filter for getParticipants
303  *
304  * @param string $by name, course, group
305  * @param string $text Filter text
306  */
307  function setFilter($by, $text)
308  {
309  $this->arrFilter = array($by => $text);
310  }
311 
312  /*
313  * Set an output filter for getParticipants
314  *
315  * @param array $arrFilter filter values
316  */
318  {
319  $this->arrFilter = $arrFilter;
320  }
321 
322  function addParticipant($active_id, $participant)
323  {
324  $this->participants[$active_id] = $participant;
325  }
326 
331  function &getParticipant($active_id)
332  {
333  return $this->participants[$active_id];
334  }
335 
336  function participantExists($active_id)
337  {
338  return array_key_exists($active_id, $this->participants);
339  }
340 
341  function removeParticipant($active_id)
342  {
343  unset($this->participants[$active_id]);
344  }
345 
346  function &getStatistics()
347  {
348  return $this->statistics;
349  }
350 
351  function getParticipantIds()
352  {
353  return array_keys($this->participants);
354  }
355 } // END ilTestEvaluationData