ILIAS  Release_4_0_x_branch Revision 61816
 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 
35 {
42 
48  private $test;
49 
56 
63 
70 
75  var $datasets;
76 
77  public function __sleep()
78  {
79  return array('questionTitles', 'participants', 'statistics', 'arrFilter', 'datasets', 'test');
80  }
81 
87  function ilTestEvaluationData($test = "")
88  {
89  $this->participants = array();
90  $this->questionTitles = array();
91  if (is_object($test)) $this->test =& $test;
92  if (is_object($test))
93  {
94  $this->generateOverview();
95  }
96  }
97 
98  function generateOverview()
99  {
100  $this->participants = array();
101  global $ilDB;
102  include_once "./Modules/Test/classes/class.ilTestEvaluationPassData.php";
103  include_once "./Modules/Test/classes/class.ilTestEvaluationUserData.php";
104  $result = $ilDB->queryF("SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
105  "tst_pass_result.* FROM tst_pass_result, tst_active " .
106  "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
107  "WHERE tst_active.active_id = tst_pass_result.active_fi " .
108  "AND tst_active.test_fi = %s " .
109  "ORDER BY usr_data.lastname, usr_data.firstname, tst_pass_result.active_fi, tst_pass_result.pass, tst_pass_result.tstamp",
110  array('integer'),
111  array($this->getTest()->getTestId())
112  );
113  $pass = NULL;
114  $checked = array();
115  $thissets = 0;
116  while ($row = $ilDB->fetchAssoc($result))
117  {
118  $thissets++;
119  $remove = FALSE;
120  if (!$this->participantExists($row["active_fi"]))
121  {
122  $this->addParticipant($row["active_fi"], new ilTestEvaluationUserData($this->getTest()->getPassScoring()));
123  $this->getParticipant($row["active_fi"])->setName($this->getTest()->buildName($row["usr_id"], $row["firstname"], $row["lastname"], $row["title"]));
124  $this->getParticipant($row["active_fi"])->setLogin($row["login"]);
125  $this->getParticipant($row["active_fi"])->setUserID($row["usr_id"]);
126  }
127  if (!is_object($this->getParticipant($row["active_fi"])->getPass($row["pass"])))
128  {
130  $pass->setPass($row["pass"]);
131  $this->getParticipant($row["active_fi"])->addPass($row["pass"], $pass);
132  }
133  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setReachedPoints($row["points"]);
134  if ($row["questioncount"] == 0)
135  {
137  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setMaxPoints($data['points']);
138  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setQuestionCount($data['count']);
139  }
140  else
141  {
142  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setMaxPoints($row["maxpoints"]);
143  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setQuestionCount($row["questioncount"]);
144  }
145  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setNrOfAnsweredQuestions($row["answeredquestions"]);
146  $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setWorkingTime($row["workingtime"]);
147  }
148  }
149 
150  function getTest()
151  {
152  return $this->test;
153  }
154 
155  function setTest($test)
156  {
157  $this->test =& $test;
158  }
159 
161  {
162  $this->datasets = $datasets;
163  }
164 
165  function getDatasets()
166  {
167  return $this->datasets;
168  }
169 
170  function addQuestionTitle($question_id, $question_title)
171  {
172  $this->questionTitles[$question_id] = $question_title;
173  }
174 
175  function getQuestionTitles()
176  {
177  return $this->questionTitles;
178  }
179 
180  function getQuestionTitle($question_id)
181  {
182  if (array_key_exists($question_id, $this->questionTitles))
183  {
184  return $this->questionTitles[$question_id];
185  }
186  else
187  {
188  return "";
189  }
190  }
191 
193  {
194  include_once "./Modules/Test/classes/class.ilTestStatistics.php";
195  $this->statistics = new ilTestStatistics($this);
196  }
197 
198  function getParticipants()
199  {
200  if (count($this->arrFilter))
201  {
202  $filteredParticipants = array();
203  $courseids = array();
204  $groupids = array();
205  global $ilDB;
206  if (array_key_exists('group', $this->arrFilter))
207  {
208  $ids = ilObject::_getIdsForTitle($this->arrFilter['group'], 'grp', true);
209  $groupids = array_merge($groupids, $ids);
210  }
211  if (array_key_exists('course', $this->arrFilter))
212  {
213  $ids = ilObject::_getIdsForTitle($this->arrFilter['course'], 'crs', true);
214  $courseids = array_merge($courseids, $ids);
215  }
216  foreach ($this->participants as $active_id => $participant)
217  {
218  $remove = FALSE;
219  if (array_key_exists('name', $this->arrFilter))
220  {
221  if (!(strpos(strtolower($participant->getName()), strtolower($this->arrFilter['name'])) !== FALSE)) $remove = TRUE;
222  }
223  if (!$remove)
224  {
225  if (array_key_exists('group', $this->arrFilter))
226  {
227  include_once "./Services/Membership/classes/class.ilParticipants.php";
228  $groups = ilParticipants::_getMembershipByType($participant->getUserID(), "grp");
229  $foundfilter = FALSE;
230  if (count(array_intersect($groupids, $groups))) $foundfilter = TRUE;
231  if (!$foundfilter) $remove = TRUE;
232  }
233  }
234  if (!$remove)
235  {
236  if (array_key_exists('course', $this->arrFilter))
237  {
238  include_once "./Services/Membership/classes/class.ilParticipants.php";
239  $courses = ilParticipants::_getMembershipByType($participant->getUserID(), "crs");
240  $foundfilter = FALSE;
241  if (count(array_intersect($courseids, $courses))) $foundfilter = TRUE;
242  if (!$foundfilter) $remove = TRUE;
243  }
244  }
245  if (!$remove)
246  {
247  if (array_key_exists('active_id', $this->arrFilter))
248  {
249  if ($active_id != $this->arrFilter['active_id']) $remove = TRUE;
250  }
251  }
252  if (!$remove) $filteredParticipants[$active_id] = $participant;
253  }
254  return $filteredParticipants;
255  }
256  else
257  {
258  return $this->participants;
259  }
260  }
261 
262  function resetFilter()
263  {
264  $this->arrFilter = array();
265  }
266 
267  /*
268  * Set an output filter for getParticipants
269  *
270  * @param string $by name, course, group
271  * @param string $text Filter text
272  */
273  function setFilter($by, $text)
274  {
275  $this->arrFilter = array($by => $text);
276  }
277 
278  /*
279  * Set an output filter for getParticipants
280  *
281  * @param array $arrFilter filter values
282  */
284  {
285  $this->arrFilter = $arrFilter;
286  }
287 
288  function addParticipant($active_id, $participant)
289  {
290  $this->participants[$active_id] = $participant;
291  }
292 
293  function &getParticipant($active_id)
294  {
295  return $this->participants[$active_id];
296  }
297 
298  function participantExists($active_id)
299  {
300  return array_key_exists($active_id, $this->participants);
301  }
302 
303  function removeParticipant($active_id)
304  {
305  unset($this->participants[$active_id]);
306  }
307 
308  function &getStatistics()
309  {
310  return $this->statistics;
311  }
312 
313  function getParticipantIds()
314  {
315  return array_keys($this->participants);
316  }
317 } // END ilTestEvaluationData
318 
319 ?>