ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestEvaluationGUI.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 
24 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
25 include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
26 
27 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
28 
43 {
53  function ilTestEvaluationGUI($a_object)
54  {
55  global $ilAccess;
56 
57  parent::ilTestServiceGUI($a_object);
58  }
59 
63  function &executeCommand()
64  {
65  global $ilUser;
66  $cmd = $this->ctrl->getCmd();
67  $next_class = $this->ctrl->getNextClass($this);
68  $this->ctrl->saveParameter($this, "sequence");
69  $this->ctrl->saveParameter($this, "active_id");
70  $cmd = $this->getCommand($cmd);
71  switch($next_class)
72  {
73  default:
74  $ret =& $this->$cmd();
75  break;
76  }
77  return $ret;
78  }
79 
80  function &getHeaderNames()
81  {
82  $headernames = array();
83  if ($this->object->getAnonymity())
84  {
85  array_push($headernames, $this->lng->txt("counter"));
86  }
87  else
88  {
89  array_push($headernames, $this->lng->txt("name"));
90  array_push($headernames, $this->lng->txt("login"));
91  }
92  $additionalFields = $this->object->getEvaluationAdditionalFields();
93  if (count($additionalFields))
94  {
95  foreach ($additionalFields as $fieldname)
96  {
97  array_push($headernames, $this->lng->txt($fieldname));
98  }
99  }
100  array_push($headernames, $this->lng->txt("tst_reached_points"));
101  array_push($headernames, $this->lng->txt("tst_mark"));
102  if ($this->object->ects_output)
103  {
104  array_push($headernames, $this->lng->txt("ects_grade"));
105  }
106  array_push($headernames, $this->lng->txt("tst_answered_questions"));
107  array_push($headernames, $this->lng->txt("working_time"));
108  array_push($headernames, $this->lng->txt("detailed_evaluation"));
109  return $headernames;
110  }
111 
112  function &getHeaderVars()
113  {
114  $headervars = array();
115  if ($this->object->getAnonymity())
116  {
117  array_push($headervars, "counter");
118  }
119  else
120  {
121  array_push($headervars, "name");
122  array_push($headervars, "login");
123  }
124  array_push($headervars, "resultspoints");
125  array_push($headervars, "resultsmarks");
126  if ($this->object->ects_output)
127  {
128  array_push($headervars, "ects_grade");
129  }
130  array_push($headervars, "qworkedthrough");
131  array_push($headervars, "timeofwork");
132  array_push($headervars, "");
133  return $headervars;
134  }
135 
136  public function filterEvaluation()
137  {
138  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
139  $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
140  $table_gui->writeFilterToSession();
141  $this->ctrl->redirect($this, "outEvaluation");
142  }
143 
144  public function resetfilterEvaluation()
145  {
146  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
147  $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
148  $table_gui->resetFilter();
149  $this->ctrl->redirect($this, "outEvaluation");
150  }
151 
157  function outEvaluation()
158  {
159  global $ilAccess;
160 
161  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
162  {
163  // allow only evaluation access
164  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
165  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
166  }
167 
168  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
169 
170  $table_gui = new ilEvaluationAllTableGUI(
171  $this, 'outEvaluation', $this->object->getAnonymity(), $this->object->isOfferingQuestionHintsEnabled()
172  );
173 
174  $data = array();
175  $arrFilter = array();
176 
177  foreach ($table_gui->getFilterItems() as $item)
178  {
179  if ($item->getValue() !== false)
180  {
181  switch ($item->getPostVar())
182  {
183  case 'group':
184  case 'name':
185  case 'course':
186  $arrFilter[$item->getPostVar()] = $item->getValue();
187  break;
188  case 'passed_only':
189  $passedonly = $item->getChecked();
190  break;
191  }
192  }
193  }
194  include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
195  $eval = new ilTestEvaluationData($this->object);
196  $eval->setFilterArray($arrFilter);
197  $foundParticipants =& $eval->getParticipants();
198  $counter = 1;
199  if (count($foundParticipants) > 0)
200  {
201  if ($this->object->ects_output)
202  {
203  $passed_array =& $this->object->getTotalPointsPassedArray();
204  }
205  foreach ($foundParticipants as $active_id => $userdata)
206  {
207  /* @var $userdata ilTestEvaluationUserData */
208 
209  $remove = FALSE;
210  if ($passedonly)
211  {
212  $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent());
213 
214  if( $mark_obj->getPassed() == FALSE || !$userdata->areObligationsAnswered() )
215  {
216  $remove = TRUE;
217  }
218  }
219  if (!$remove)
220  {
221  // build the evaluation row
222  $evaluationrow = array();
223  if ($this->object->getAnonymity())
224  {
225  $evaluationrow['name'] = $counter;
226  $evaluationrow['login'] = '';
227  }
228  else
229  {
230  $evaluationrow['name'] = $userdata->getName();
231  if (strlen($userdata->getLogin()))
232  {
233  $evaluationrow['login'] = "[" . $userdata->getLogin() . "]";
234  }
235  else
236  {
237  $evaluationrow['login'] = '';
238  }
239  }
240 
241  $evaluationrow['reached'] = $userdata->getReached();
242  $evaluationrow['max'] = $userdata->getMaxpoints();
243  $evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass();
244  $percentage = $userdata->getReachedPointsInPercent();
245  $mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
246  if (is_object($mark))
247  {
248  $evaluationrow['mark'] = $mark->getShortName();
249  }
250  if ($this->object->ects_output)
251  {
252  $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints());
253  $evaluationrow['ects_grade'] = $ects_mark;
254  }
255  $evaluationrow['answered'] = $userdata->getQuestionsWorkedThroughInPercent();
256  $evaluationrow['questions_worked_through'] = $userdata->getQuestionsWorkedThrough();
257  $evaluationrow['number_of_questions'] = $userdata->getNumberOfQuestions();
258  $time_seconds = $userdata->getTimeOfWork();
259  $time_hours = floor($time_seconds/3600);
260  $time_seconds -= $time_hours * 3600;
261  $time_minutes = floor($time_seconds/60);
262  $time_seconds -= $time_minutes * 60;
263  $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
264  $this->ctrl->setParameter($this, "active_id", $active_id);
265  $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
266  $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
267  $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>";
268  $userfields = ilObjUser::_lookupFields($userdata->getUserID());
269  $evaluationrow['gender'] = $userfields['gender'];
270  $evaluationrow['email'] = $userfields['email'];
271  $evaluationrow['institution'] = $userfields['institution'];
272  $evaluationrow['street'] = $userfields['street'];
273  $evaluationrow['city'] = $userfields['city'];
274  $evaluationrow['zipcode'] = $userfields['zipcode'];
275  $evaluationrow['country'] = $userfields['country'];
276  $evaluationrow['department'] = $userfields['department'];
277  $evaluationrow['matriculation'] = $userfields['matriculation'];
278  $counter++;
279  $data[] = $evaluationrow;
280  }
281  }
282  }
283 
284  $table_gui->setData($data);
285  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation.html", "Modules/Test");
286  $this->tpl->setVariable('EVALUATION_DATA', $table_gui->getHTML());
287  if (count($foundParticipants) > 0)
288  {
289  $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
290  $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
291  if (!$this->object->getAnonymity())
292  {
293  include_once "./Services/Certificate/classes/class.ilCertificate.php";
294  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
296  {
297  $template->setVariable("TEXT_CERTIFICATE", $this->lng->txt("exp_type_certificate"));
298  }
299  }
300  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
301  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
302  $template->setVariable("CMD_EXPORT", "exportEvaluation");
303  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
304  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
305  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
306  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportEvaluation"));
307  $exportoutput = $template->get();
308  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
309  }
310 
311  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
312  if ($this->object->getShowSolutionAnswersOnly())
313  {
314  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
315  }
316  }
317 
326  {
327  global $ilAccess;
328 
329  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
330  {
331  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), TRUE);
332  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
333  }
334 
335  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation_details.html", "Modules/Test");
336 
337  $active_id = $_GET["active_id"];
338  if (strlen($active_id) == 0)
339  {
340  ilUtil::sendInfo($this->lng->txt("detailed_evaluation_missing_active_id"), TRUE);
341  $this->ctrl->redirect($this, "outEvaluation");
342  }
343 
344  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
345 
346  $data =& $this->object->getCompleteEvaluationData();
347  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
348  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outEvaluation"));
349  $this->tpl->setVariable("HEADING_DETAILED_EVALUATION", sprintf($this->lng->txt("detailed_evaluation_for"),
350  $data->getParticipant($active_id)->getName())
351  );
352  $this->tpl->setVariable("STATISTICAL_DATA", $this->lng->txt("statistical_data"));
353  $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
354  $this->tpl->setVariable("VALUE_RESULTSPOINTS", $data->getParticipant($active_id)->getReached() . " " . strtolower($this->lng->txt("of")) . " " . $data->getParticipant($active_id)->getMaxpoints() . " (" . sprintf("%2.2f", $data->getParticipant($active_id)->getReachedPointsInPercent()) . " %" . ")");
355  if (strlen($data->getParticipant($active_id)->getMark()))
356  {
357  $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
358  $this->tpl->setVariable("VALUE_RESULTSMARKS", $data->getParticipant($active_id)->getMark());
359  if (strlen($data->getParticipant($active_id)->getECTSMark()))
360  {
361  $this->tpl->setVariable("TXT_ECTS", $this->lng->txt("ects_grade"));
362  $this->tpl->setVariable("VALUE_ECTS", $data->getParticipant($active_id)->getECTSMark());
363  }
364  }
365 
366  if( $this->object->isOfferingQuestionHintsEnabled() )
367  {
368  $this->tpl->setVariable("TXT_REQUESTED_HINTS_COUNT", $this->lng->txt("tst_question_hints_requested_hint_count_header"));
369  $this->tpl->setVariable("VALUE_REQUESTED_HINTS_COUNT", $data->getParticipant($active_id)->getRequestedHintsCountFromScoredPass());
370  }
371 
372  $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
373  $this->tpl->setVariable("VALUE_QWORKEDTHROUGH", $data->getParticipant($active_id)->getQuestionsWorkedThrough() . " " . strtolower($this->lng->txt("of")) . " " . $data->getParticipant($active_id)->getNumberOfQuestions() . " (" . sprintf("%2.2f", $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent()) . " %" . ")");
374 
375  $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
376  $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
377  $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
378  $time_hours = floor($time_seconds/3600);
379  $time_seconds -= $time_hours * 3600;
380  $time_minutes = floor($time_seconds/60);
381  $time_seconds -= $time_minutes * 60;
382  $this->tpl->setVariable("VALUE_TIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
383  $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
384  $time_hours = floor($atime_seconds/3600);
385  $atime_seconds -= $time_hours * 3600;
386  $time_minutes = floor($atime_seconds/60);
387  $atime_seconds -= $time_minutes * 60;
388  $this->tpl->setVariable("VALUE_ATIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
389  $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
390  #$this->tpl->setVariable("VALUE_FIRSTVISIT",
391  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getFirstVisit())
392  #);
393  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
394  new ilDateTime($data->getParticipant($active_id)->getFirstVisit(),IL_CAL_UNIX)));
395  $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
396  #$this->tpl->setVariable("VALUE_LASTVISIT",
397  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getLastVisit())
398  #);
399  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
400  new ilDateTime($data->getParticipant($active_id)->getLastVisit(),IL_CAL_UNIX)));
401 
402  $this->tpl->setVariable("TXT_NROFPASSES", $this->lng->txt("tst_nr_of_passes"));
403  $this->tpl->setVariable("VALUE_NROFPASSES", $data->getParticipant($active_id)->getLastPass() + 1);
404  $this->tpl->setVariable("TXT_SCOREDPASS", $this->lng->txt("scored_pass"));
405  if ($this->object->getPassScoring() == SCORE_BEST_PASS)
406  {
407  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getBestPass() + 1);
408  }
409  else
410  {
411  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getLastPass() + 1);
412  }
413 
414  $median = $data->getStatistics()->getStatistics()->median();
415  $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
416  $mark = $this->object->mark_schema->getMatchingMark($pct);
417  if (is_object($mark))
418  {
419  $this->tpl->setVariable("TXT_MARK_MEDIAN", $this->lng->txt("tst_stat_result_mark_median"));
420  $this->tpl->setVariable("VALUE_MARK_MEDIAN", $mark->getShortName());
421  }
422 
423  $this->tpl->setVariable("TXT_RANK_PARTICIPANT", $this->lng->txt("tst_stat_result_rank_participant"));
424  $this->tpl->setVariable("VALUE_RANK_PARTICIPANT", $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
425  $this->tpl->setVariable("TXT_RANK_MEDIAN", $this->lng->txt("tst_stat_result_rank_median"));
426  $this->tpl->setVariable("VALUE_RANK_MEDIAN", $data->getStatistics()->getStatistics()->rank_median());
427  $this->tpl->setVariable("TXT_TOTAL_PARTICIPANTS", $this->lng->txt("tst_stat_result_total_participants"));
428  $this->tpl->setVariable("VALUE_TOTAL_PARTICIPANTS", $data->getStatistics()->getStatistics()->count());
429  $this->tpl->setVariable("TXT_RESULT_MEDIAN", $this->lng->txt("tst_stat_result_median"));
430  $this->tpl->setVariable("VALUE_RESULT_MEDIAN", $median);
431 
432  for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
433  {
434  $finishdate = $this->object->getPassFinishDate($active_id, $pass);
435  if ($finishdate > 0)
436  {
437  $this->tpl->setCurrentBlock("question_header");
438  $this->tpl->setVariable("TXT_QUESTION_DATA", sprintf($this->lng->txt("tst_eval_question_points"), $pass+1));
439  $this->tpl->parseCurrentBlock();
440  global $ilAccess;
441  if (($ilAccess->checkAccess("write", "", $_GET["ref_id"])))
442  {
443  $this->tpl->setCurrentBlock("question_footer");
444  $this->tpl->setVariable("TEXT_TO_DETAILED_RESULTS", $this->lng->txt("tst_show_answer_sheet"));
445  $this->ctrl->setParameter($this, "statistics", "1");
446  $this->ctrl->setParameter($this, "active_id", $active_id);
447  $this->ctrl->setParameter($this, "pass", $pass);
448  $this->tpl->setVariable("URL_TO_DETAILED_RESULTS", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
449  $this->tpl->parseCurrentBlock();
450  }
451  $questions = $data->getParticipant($active_id)->getQuestions($pass);
452  if (!is_array($questions))
453  {
454  $questions = $data->getParticipant($active_id)->getQuestions(0);
455  }
456  $counter = 1;
457  foreach ($questions as $question)
458  {
459  $this->tpl->setCurrentBlock("question_row");
460  $this->tpl->setVariable("QUESTION_COUNTER", $counter);
461  $this->tpl->setVariable("QUESTION_TITLE", $data->getQuestionTitle($question["id"]));
462  $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
463  if (is_array($answeredquestion))
464  {
465  $percent = $answeredquestion["points"] ? $answeredquestion["reached"] / $answeredquestion["points"] * 100.0 : 0;
466  $this->tpl->setVariable("QUESTION_POINTS", $answeredquestion["reached"] . " " . strtolower($this->lng->txt("of")) . " " . $answeredquestion["points"] . " (" . sprintf("%.2f", $percent) . " %)");
467  }
468  else
469  {
470  $this->tpl->setVariable("QUESTION_POINTS", "0 " . strtolower($this->lng->txt("of")) . " " . $question["points"] . " (" . sprintf("%.2f", 0) . " %) - " . $this->lng->txt("question_not_answered"));
471  }
472  $this->tpl->parseCurrentBlock();
473  $counter++;
474  }
475  $this->tpl->touchBlock("question_stats");
476  }
477  }
478  }
479 
486  {
487  $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
488  }
489 
496  {
497  $question_object =& ilObjTest::_instanciateQuestion($_GET["qid"]);
498  $download = "";
499  if (method_exists($question_object, "getFileUploadZIPFile"))
500  {
501  $question_object->getFileUploadZIPFile($this->object->getTestId());
502  }
503  else
504  {
505  $this->ctrl->redirect($this, "singleResults");
506  }
507  }
508 
516  function eval_a()
517  {
518  global $ilAccess;
519 
520  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
521  {
522  // allow only evaluation access
523  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
524  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
525  }
526 
527  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
528  $eval =& $this->object->getCompleteEvaluationData();
529  $data = array();
530  $foundParticipants =& $eval->getParticipants();
531  if (count($foundParticipants))
532  {
533  $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
534  $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
535  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
536  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
537  $template->setVariable("CMD_EXPORT", "exportAggregatedResults");
538  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
539  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
540  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
541  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportAggregatedResults"));
542  $exportoutput = $template->get();
543  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
544 
545  array_push($data, array(
546  'result' => $this->lng->txt("tst_eval_total_persons"),
547  'value' => count($foundParticipants)
548  ));
549  $total_finished = $this->object->evalTotalFinished();
550  array_push($data, array(
551  'result' => $this->lng->txt("tst_eval_total_finished"),
552  'value' => $total_finished
553  ));
554  $average_time = $this->object->evalTotalStartedAverageTime();
555  $diff_seconds = $average_time;
556  $diff_hours = floor($diff_seconds/3600);
557  $diff_seconds -= $diff_hours * 3600;
558  $diff_minutes = floor($diff_seconds/60);
559  $diff_seconds -= $diff_minutes * 60;
560  array_push($data, array(
561  'result' => $this->lng->txt("tst_eval_total_finished_average_time"),
562  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
563  ));
564  $total_passed = 0;
565  $total_passed_reached = 0;
566  $total_passed_max = 0;
567  $total_passed_time = 0;
568  foreach ($foundParticipants as $userdata)
569  {
570  if ($userdata->getPassed())
571  {
572  $total_passed++;
573  $total_passed_reached += $userdata->getReached();
574  $total_passed_max += $userdata->getMaxpoints();
575  $total_passed_time += $userdata->getTimeOfWork();
576  }
577  }
578  $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
579  $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
580  $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
581  array_push($data, array(
582  'result' => $this->lng->txt("tst_eval_total_passed"),
583  'value' => $total_passed
584  ));
585  array_push($data, array(
586  'result' => $this->lng->txt("tst_eval_total_passed_average_points"),
587  'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)
588  ));
589  $average_time = $average_passed_time;
590  $diff_seconds = $average_time;
591  $diff_hours = floor($diff_seconds/3600);
592  $diff_seconds -= $diff_hours * 3600;
593  $diff_minutes = floor($diff_seconds/60);
594  $diff_seconds -= $diff_minutes * 60;
595  array_push($data, array(
596  'result' => $this->lng->txt("tst_eval_total_passed_average_time"),
597  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
598  ));
599  }
600 
601  include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
602  $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
603  $table_gui->setData($data);
604  $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
605 
606  $rows = array();
607  foreach ($eval->getQuestionTitles() as $question_id => $question_title)
608  {
609  $answered = 0;
610  $reached = 0;
611  $max = 0;
612  foreach ($foundParticipants as $userdata)
613  {
614  for ($i = 0; $i <= $userdata->getLastPass(); $i++)
615  {
616  if (is_object($userdata->getPass($i)))
617  {
618  $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
619  if (is_array($question))
620  {
621  $answered++;
622  $reached += $question["reached"];
623  $max += $question["points"];
624  }
625  }
626  }
627  }
628  $percent = $max ? $reached/$max * 100.0 : 0;
629  $counter++;
630  $this->ctrl->setParameter($this, "qid", $question_id);
631  array_push($rows,
632  array(
633  'title' => $question_title,
634  'points' => sprintf("%.2f", $answered ? $reached / $answered : 0) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $answered ? $max / $answered : 0),
635  'percentage' => (float)$percent,
636  'answers' => $answered
637  )
638  );
639  }
640  include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
641  $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
642  $table_gui->setData($rows);
643  $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
644  }
645 
651  function exportEvaluation()
652  {
653  $filterby = "";
654  if (array_key_exists("g_filterby", $_GET))
655  {
656  $filterby = $_GET["g_filterby"];
657  }
658  $filtertext = "";
659  if (array_key_exists("g_userfilter", $_GET))
660  {
661  $filtertext = $_GET["g_userfilter"];
662  }
663  $passedonly = FALSE;
664  if (array_key_exists("g_passedonly", $_GET))
665  {
666  if ($_GET["g_passedonly"] == 1)
667  {
668  $passedonly = TRUE;
669  }
670  }
671  switch ($_POST["export_type"])
672  {
673  case "excel":
674  include_once "./Modules/Test/classes/class.ilTestExport.php";
675  $exportObj = new ilTestExport($this->object, "results");
676  $exportObj->exportToExcel($deliver = TRUE, $filterby, $filtertext, $passedonly);
677  break;
678  case "csv":
679  include_once "./Modules/Test/classes/class.ilTestExport.php";
680  $exportObj = new ilTestExport($this->object, "results");
681  $exportObj->exportToCSV($deliver = TRUE, $filterby, $filtertext, $passedonly);
682  break;
683  case "certificate":
684  if ($passedonly)
685  {
686  $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
687  }
688  if (strlen($filtertext))
689  {
690  $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
691  }
692  $this->ctrl->redirect($this, "exportCertificate");
693  break;
694  }
695  }
696 
703  {
704  switch ($_POST["export_type"])
705  {
706  case "excel":
707  include_once "./Modules/Test/classes/class.ilTestExport.php";
708  $exportObj = new ilTestExport($this->object, "aggregated");
709  $exportObj->exportToExcel($deliver = TRUE);
710  break;
711  case "csv":
712  include_once "./Modules/Test/classes/class.ilTestExport.php";
713  $exportObj = new ilTestExport($this->object, "aggregated");
714  $exportObj->exportToCSV($deliver = TRUE);
715  break;
716  }
717  }
718 
725  public function exportCertificate()
726  {
727  global $ilUser;
728 
729  include_once "./Services/Utilities/classes/class.ilUtil.php";
730  include_once "./Services/Certificate/classes/class.ilCertificate.php";
731  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
732  $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
733  $archive_dir = $certificate->createArchiveDirectory();
734  $total_users = array();
735  $total_users =& $this->object->evalTotalPersonsArray();
736  if (count($total_users))
737  {
738  foreach ($total_users as $active_id => $name)
739  {
740  $user_id = $this->object->_getUserIdFromActiveId($active_id);
741  $pdf = $certificate->outCertificate(
742  array(
743  "active_id" => $active_id,
744  "userfilter" => $userfilter,
745  "passedonly" => $passedonly
746  ),
747  FALSE
748  );
749  if (strlen($pdf))
750  {
751  $certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
752  }
753  }
754  $zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, TRUE);
755  }
756 
757  }
758 
765  function getEvaluationQuestionId($question_id, $original_id = "")
766  {
767  if ($original_id > 0)
768  {
769  return $original_id;
770  }
771  else
772  {
773  return $question_id;
774  }
775  }
776 
785  {
786  global $ilias, $ilAccess;
787 
788  $this->ctrl->saveParameter($this, "pass");
789 
790  if (!$ilAccess->checkAccess('write', '', $this->ref_id))
791  {
792  // allow only write access
793  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
794  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
795  }
796 
797  $this->ctrl->saveParameter($this, "active_id");
798  $active_id = $_GET["active_id"];
799 
800  $testSession = $this->object->getTestSession($active_id);
801 
802  // protect actives from other tests
803  if( $testSession->getTestId() != $this->object->getTestId() )
804  {
805  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
806  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
807  }
808 
809  $this->ctrl->saveParameter($this, "pass");
810  $pass = (int)$_GET["pass"];
811 
812  $result_array =& $this->object->getTestResult($active_id, $pass);
813 
814  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outParticipantsPassDetails");
815  $user_data = $this->getResultsUserdata($active_id, FALSE);
816  $user_id = $this->object->_getUserIdFromActiveId($active_id);
817 
818  $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", TRUE, TRUE, "Modules/Test");
819 
820  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
821  if(ilRPCServerSettings::getInstance()->isEnabled())
822  {
823  $this->ctrl->setParameter($this, "pdf", "1");
824  $template->setCurrentBlock("pdf_export");
825  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
826  $this->ctrl->setParameter($this, "pdf", "");
827  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
828  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
829  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
830  $template->parseCurrentBlock();
831  }
832 
833  if (array_key_exists("statistics", $_GET) && ($_GET["statistics"] == 1))
834  {
835  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
836  $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
837  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilTestEvaluationGUI", "detailedEvaluation"));
838  }
839  else
840  {
841  if ($this->object->getNrOfTries() == 1)
842  {
843  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
844  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
845  }
846  else
847  {
848  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outParticipantsResultsOverview"));
849  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
850  }
851  }
852  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
853  $template->setVariable("PRINT_URL", "javascript:window.print();");
854 
855  if ($this->object->getNrOfTries() == 1)
856  {
857  $statement = $this->getFinalStatement($active_id);
858  $template->setVariable("USER_MARK", $statement["mark"]);
859  if (strlen($statement["markects"]))
860  {
861  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
862  }
863  }
864 
865  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, TRUE);
866  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
867  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
868  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
869  $template->setVariable("PASS_DETAILS", $overview);
870  $template->setVariable("USER_DETAILS", $user_data);
871  $uname = $this->object->userLookupFullName($user_id);
872  $template->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
873 
874  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
875  if ($this->object->getShowSolutionAnswersOnly())
876  {
877  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
878  }
879 
880  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
881  {
882  $this->object->deliverPDFfromHTML($template->get());
883  }
884  else
885  {
886  $this->tpl->setVariable("ADM_CONTENT", $template->get());
887  }
888  }
889 
896  {
897  global $ilias, $ilAccess;
898 
899  if (!$ilAccess->checkAccess('write', '', $this->ref_id))
900  {
901  // allow only write access
902  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
903  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
904  }
905 
906  $active_id = (int)$_GET["active_id"];
907  $testSession = $this->object->getTestSession($active_id);
908 
909  // protect actives from other tests
910  if( $testSession->getTestId() != $this->object->getTestId() )
911  {
912  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
913  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
914  }
915 
916  if ($this->object->getNrOfTries() == 1)
917  {
918  $this->ctrl->setParameter($this, "active_id", $active_id);
919  $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
920  $this->ctrl->redirect($this, "outParticipantsPassDetails");
921  }
922 
923  $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", TRUE, TRUE, "Modules/Test");
924 
925  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
926  if(ilRPCServerSettings::getInstance()->isEnabled())
927  {
928  $this->ctrl->setParameter($this, "pdf", "1");
929  $template->setCurrentBlock("pdf_export");
930  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsResultsOverview"));
931  $this->ctrl->setParameter($this, "pdf", "");
932  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
933  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
934  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
935  $template->parseCurrentBlock();
936  }
937 
938  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outParticipantsPassDetails");
939  $template->setVariable("PASS_OVERVIEW", $overview);
940  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
941  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
942  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
943  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
944  $template->setVariable("PRINT_URL", "javascript:window.print();");
945 
946  $statement = $this->getFinalStatement($active_id);
947  $user_id = $this->object->_getUserIdFromActiveId($active_id);
948  $user_data = $this->getResultsUserdata($active_id);
949  $template->setVariable("USER_DATA", $user_data);
950  $template->setVariable("TEXT_OVERVIEW", $this->lng->txt("tst_results_overview"));
951  $template->setVariable("USER_MARK", $statement["mark"]);
952  if (strlen($statement["markects"]))
953  {
954  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
955  }
956  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
957  $template->parseCurrentBlock();
958 
959  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
960  if ($this->object->getShowSolutionAnswersOnly())
961  {
962  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
963  }
964 
965  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
966  {
967  $this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
968  }
969  else
970  {
971  $this->tpl->setVariable("ADM_CONTENT", $template->get());
972  }
973  }
974 
983  {
984  $testSession = $this->object->getTestSession();
985 
986  $active_id = $testSession->getActiveId();
987  $user_id = $testSession->getUserId();
988 
989  $this->ctrl->saveParameter($this, "pass");
990  $pass = $_GET["pass"];
991  $result_array =& $this->object->getTestResult($active_id, $pass);
992 
993  $command_solution_details = "";
994  if ($this->object->getShowSolutionDetails())
995  {
996  $command_solution_details = "outCorrectSolution";
997  }
998  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserPassDetails", $command_solution_details);
999 
1000  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_pass_details_overview_participants.html", "Modules/Test");
1001 
1002  if ($this->object->getNrOfTries() == 1)
1003  {
1004  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1005  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1006  }
1007  else
1008  {
1009  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outUserResultsOverview"));
1010  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
1011  }
1012 
1013  $this->tpl->parseCurrentBlock();
1014 
1015  if ($this->object->getNrOfTries() == 1)
1016  {
1017  $statement = $this->getFinalStatement($active_id);
1018  $this->tpl->setVariable("USER_MARK", $statement["mark"]);
1019  if (strlen($statement["markects"]))
1020  {
1021  $this->tpl->setVariable("USER_MARK_ECTS", $statement["markects"]);
1022  }
1023  }
1024 
1025  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
1026 
1027  $this->tpl->setCurrentBlock("adm_content");
1028  $this->tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1029  $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
1030  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1031  $this->tpl->setVariable("PASS_DETAILS", $overview);
1032  $uname = $this->object->userLookupFullName($user_id, TRUE);
1033  $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1034  $this->tpl->parseCurrentBlock();
1035 
1036  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1037  if ($this->object->getShowSolutionAnswersOnly())
1038  {
1039  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1040  }
1041  }
1042 
1051  {
1052  global $ilUser, $ilias, $ilLog;
1053 
1054  if (!$this->object->canShowTestResults($ilUser->getId())) $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1055  include_once("./Services/UICore/classes/class.ilTemplate.php");
1056  $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test");
1057  $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
1058 
1059  $pass = null;
1060  $user_id = $ilUser->getId();
1061  $uname = $this->object->userLookupFullName($user_id, TRUE);
1062  $active_id = $this->object->getTestSession()->getActiveId();
1063  $hide_details = !$this->object->getShowPassDetails();
1064  if ($hide_details)
1065  {
1066  $executable = $this->object->isExecutable($ilUser->getId());
1067  if (!$executable["executable"]) $hide_details = FALSE;
1068  }
1069  $begin = microtime(true);
1070  if (($this->object->getNrOfTries() == 1) && (!$hide_details))
1071  {
1072  $pass = 0;
1073  }
1074  else
1075  {
1076  $template->setCurrentBlock("pass_overview");
1077  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserResultsOverview", FALSE, $hide_details);
1078  $template->setVariable("PASS_OVERVIEW", $overview);
1079  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results_overview"));
1080  $template->parseCurrentBlock();
1081  }
1082 
1083  if (((array_key_exists("pass", $_GET)) && (strlen($_GET["pass"]) > 0)) || (!is_null($pass)))
1084  {
1085  if (is_null($pass)) $pass = $_GET["pass"];
1086  }
1087 
1088  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1089  if(ilRPCServerSettings::getInstance()->isEnabled())
1090  {
1091  $this->ctrl->setParameter($this, "pass", $pass);
1092  $this->ctrl->setParameter($this, "pdf", "1");
1093  $templatehead->setCurrentBlock("pdf_export");
1094  $templatehead->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1095  $this->ctrl->setParameter($this, "pass", "");
1096  $this->ctrl->setParameter($this, "pdf", "");
1097  $templatehead->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
1098  $templatehead->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
1099  $templatehead->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
1100  $templatehead->parseCurrentBlock();
1101  if ($this->object->canShowCertificate($user_id, $active_id))
1102  {
1103  $templatehead->setVariable("CERTIFICATE_URL", $this->ctrl->getLinkTarget($this, "outCertificate"));
1104  $templatehead->setVariable("CERTIFICATE_TEXT", $this->lng->txt("certificate"));
1105  }
1106  }
1107  $templatehead->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1108  $templatehead->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1109  $templatehead->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1110  $templatehead->setVariable("PRINT_URL", "javascript:window.print();");
1111 
1112  $statement = $this->getFinalStatement($active_id);
1113  $user_data = $this->getResultsUserdata($active_id, TRUE);
1114 
1115  // output of the details of a selected pass
1116  $this->ctrl->saveParameter($this, "pass");
1117  $this->ctrl->saveParameter($this, "active_id");
1118  if (!is_null($pass))
1119  {
1120  $result_array =& $this->object->getTestResult($active_id, $pass);
1121  $command_solution_details = "";
1122  if ($this->object->getShowSolutionDetails())
1123  {
1124  $command_solution_details = "outCorrectSolution";
1125  }
1126  $detailsoverview = (!$hide_details) ? $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserResultsOverview", $command_solution_details) : '';
1127 
1128  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1129 
1130  if (!$hide_details && $this->object->canShowSolutionPrintview())
1131  {
1132  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
1133  }
1134  else if ($this->object->getShowSolutionDetails())
1135  {
1136  // if this is not commented out, all questions with checkmarks/crosses will be shown
1137  // $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, true);
1138  }
1139 
1140  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1141  $template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1));
1142  $template->setVariable("PASS_DETAILS", $detailsoverview);
1143 
1144  $signature = $this->getResultsSignature();
1145  $template->setVariable("SIGNATURE", $signature);
1146  }
1147  if ($this->object->getAnonymity()) {
1148  $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1149  }
1150  else {
1151  $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1152  $template->setVariable("USER_DATA", $user_data);
1153  }
1154  $template->setVariable("USER_MARK", $statement["mark"]);
1155  if (strlen($statement["markects"]))
1156  {
1157  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
1158  }
1159  $template->parseCurrentBlock();
1160 
1161  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1162  if ($this->object->getShowSolutionAnswersOnly())
1163  {
1164  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1165  }
1166  $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1167 
1168  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1169  {
1170  $this->object->deliverPDFfromHTML($template->get(), sprintf($this->lng->txt("tst_result_user_name"), $uname));
1171  }
1172  else
1173  {
1174  $this->tpl->setVariable("PRINT_CONTENT", $templatehead->get());
1175  }
1176  }
1177 
1186  {
1187  global $ilUser;
1188 
1189  if (!$this->object->getShowSolutionPrintview())
1190  {
1191  ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1192  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1193  }
1194 
1195  $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", TRUE, TRUE, "Modules/Test");
1196 
1197  $pass = null;
1198  if (array_key_exists("pass", $_GET))
1199  {
1200  if (strlen($_GET["pass"])) $pass = $_GET["pass"];
1201  }
1202  $user_id = $ilUser->getId();
1203  $active_id = $this->object->getTestSession()->getActiveId();
1204  $overview = "";
1205  if ($this->object->getNrOfTries() == 1)
1206  {
1207  $pass = 0;
1208  }
1209  else
1210  {
1211  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserListOfAnswerPasses", TRUE);
1212  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1213  $template->setVariable("PASS_OVERVIEW", $overview);
1214  }
1215 
1216  $signature = "";
1217  if (strlen($pass))
1218  {
1219  $signature = $this->getResultsSignature();
1220  $result_array =& $this->object->getTestResult($active_id, $pass);
1221  $user_id =& $this->object->_getUserIdFromActiveId($active_id);
1222  $showAllAnswers = TRUE;
1223  if ($this->object->isExecutable($user_id))
1224  {
1225  $showAllAnswers = FALSE;
1226  }
1227  $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers);
1228  $template->setVariable("PASS_DETAILS", $answers);
1229  }
1230  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1231  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1232  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1233  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1234  $template->setVariable("PRINT_URL", "javascript:window.print();");
1235 
1236  $user_data = $this->getResultsUserdata($active_id, TRUE);
1237  $template->setVariable("USER_DATA", $user_data);
1238  $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1239  if (strlen($signature))
1240  {
1241  $template->setVariable("SIGNATURE", $signature);
1242  }
1243  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1244 
1245  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1246  if ($this->object->getShowSolutionAnswersOnly())
1247  {
1248  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1249  }
1250  }
1251 
1259  function passDetails()
1260  {
1261  if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
1262  {
1263  $this->ctrl->saveParameter($this, "pass");
1264  $this->ctrl->saveParameter($this, "active_id");
1265  $this->outTestResults(false, $_GET["pass"]);
1266  }
1267  else
1268  {
1269  $this->outTestResults(false);
1270  }
1271  }
1272 
1279  {
1280  if( !$this->object->getShowSolutionDetails() )
1281  {
1282  ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1283  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1284  }
1285 
1286  $testSession = $this->object->getTestSession();
1287  $activeId = $testSession->getActiveId();
1288 
1289  if( !($activeId > 0) )
1290  {
1291  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1292  }
1293 
1294  if( !$this->object->canShowTestResults($testSession, $testSession->getUserId()) )
1295  {
1296  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1297  }
1298 
1299  $this->ctrl->saveParameter($this, "pass");
1300  $pass = (int)$_GET['pass'];
1301 
1302  $questionId = (int)$_GET['evaluation'];
1303 
1304  $testSequence = $this->object->getTestSequence($activeId, $pass);
1305 
1306  if( !$testSequence->questionExists($questionId) )
1307  {
1308  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1309  }
1310 
1311  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_correct_solution.html", "Modules/Test");
1312 
1313  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1314  $this->tpl->setCurrentBlock("ContentStyle");
1315  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
1316  $this->tpl->parseCurrentBlock();
1317 
1318  $this->tpl->setCurrentBlock("SyntaxStyle");
1319  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
1320  $this->tpl->parseCurrentBlock();
1321 
1322  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1323  if ($this->object->getShowSolutionAnswersOnly())
1324  {
1325  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1326  }
1327 
1328  $this->tpl->setCurrentBlock("adm_content");
1329  $solution = $this->getCorrectSolutionOutput($questionId, $activeId, $pass);
1330  $this->tpl->setVariable("OUTPUT_SOLUTION", $solution);
1331  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
1332  $this->ctrl->saveParameter($this, "pass");
1333  $this->ctrl->saveParameter($this, "active_id");
1334  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1335  $this->tpl->parseCurrentBlock();
1336  }
1337 
1343  function singleResults()
1344  {
1345  global $ilAccess;
1346 
1347  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
1348  {
1349  // allow only evaluation access
1350  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1351  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1352  }
1353 
1354  $data =& $this->object->getCompleteEvaluationData();
1355  $color_class = array("tblrow1", "tblrow2");
1356  $counter = 0;
1357  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1358  $foundParticipants =& $data->getParticipants();
1359  if (count($foundParticipants) == 0)
1360  {
1361  ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
1362  return;
1363  }
1364  else
1365  {
1366  $rows = array();
1367  foreach ($data->getQuestionTitles() as $question_id => $question_title)
1368  {
1369  $answered = 0;
1370  $reached = 0;
1371  $max = 0;
1372  foreach ($foundParticipants as $userdata)
1373  {
1374  $pass = $userdata->getScoredPass();
1375  if (is_object($userdata->getPass($pass)))
1376  {
1377  $question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1378  if (is_array($question))
1379  {
1380  $answered++;
1381  }
1382  }
1383  }
1384  $counter++;
1385  $this->ctrl->setParameter($this, "qid", $question_id);
1386  $question_object =& ilObjTest::_instanciateQuestion($question_id);
1387  $download = "";
1388  if (method_exists($question_object, "hasFileUploads"))
1389  {
1390  if ($question_object->hasFileUploads($this->object->getTestId()))
1391  {
1392  $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants"). "\">" . $this->lng->txt("download") . "</a>";
1393  }
1394  }
1395  array_push($rows,
1396  array(
1397  $question_title,
1398  $answered,
1399  "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants"). "\">" . $this->lng->txt("pdf_export") . "</a>",
1400  $download
1401  )
1402  );
1403  }
1404  if (count($rows))
1405  {
1406  include_once("./Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php");
1407  $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults", $this->object->hasPDFProcessing());
1408 
1409  $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
1410  $table_gui->setData($rows);
1411 
1412  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
1413  }
1414  else
1415  {
1416  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
1417  }
1418  }
1419  }
1420 
1424  public function outCertificate()
1425  {
1426  global $ilUser;
1427 
1428  $active_id = $this->object->getTestSession()->getActiveId();
1429  $counted_pass = ilObjTest::_getResultPass($active_id);
1430  include_once "./Services/Certificate/classes/class.ilCertificate.php";
1431  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
1432  $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
1433  $certificate->outCertificate(array("active_id" => $active_id, "pass" => $counted_pass));
1434  }
1435 
1436  public function confirmDeletePass()
1437  {
1438  if( !$this->object->isPassDeletionAllowed() )
1439  {
1440  $this->ctrl->redirect($this, 'outUserResultsOverview');
1441  }
1442 
1443  global $tpl;
1444  require_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
1445  $confirm = new ilConfirmationGUI();
1446  $confirm->addHiddenItem('active_id', $_GET['active_id']);
1447  $confirm->addHiddenItem('pass', $_GET['pass']);
1448  $confirm->setHeaderText($this->lng->txt('conf_delete_pass'));
1449  $confirm->setFormAction($this->ctrl->getFormAction($this, 'post'));
1450  $confirm->setHeaderText($this->lng->txt('conf_delete_pass'));
1451  $confirm->setCancel($this->lng->txt('cancel'), 'outUserResultsOverview');
1452  $confirm->setConfirm($this->lng->txt('delete'), 'performDeletePass');
1453 
1454  $tpl->setContent($confirm->getHTML());
1455  }
1456 
1457  public function performDeletePass()
1458  {
1459  if( !$this->object->isPassDeletionAllowed() )
1460  {
1461  $this->ctrl->redirect($this, 'outUserResultsOverview');
1462  }
1463 
1464  global $ilDB;
1465 
1466  $active_fi = $_GET['active_id'];
1467  $pass = (int) $_GET['pass'];
1468 
1469  if( !$this->object->isDynamicTest() && $pass == $this->object->_getResultPass($active_fi) )
1470  {
1471  $this->ctrl->redirect($this, 'outUserResultsOverview');
1472  }
1473 
1474  // Get information
1475  $result = $ilDB->query("
1476  SELECT tst_active.tries, tst_active.last_finished_pass, tst_sequence.pass
1477  FROM tst_active
1478  LEFT JOIN tst_sequence
1479  ON tst_sequence.active_fi = tst_active.active_id
1480  AND tst_sequence.pass = tst_active.tries
1481  WHERE tst_active.active_id = {$ilDB->quote($active_fi, 'integer')}
1482  ");
1483 
1484  $row = $ilDB->fetchAssoc($result);
1485 
1486  $tries = $row['tries'];
1487  $lastFinishedPass = is_numeric($row['last_finished_pass']) ? $row['last_finished_pass'] : -1;
1488 
1489  if( $pass < $lastFinishedPass )
1490  {
1491  $isActivePass = false;
1492  $must_renumber = true;
1493  }
1494  elseif( $pass == $lastFinishedPass )
1495  {
1496  $isActivePass = false;
1497 
1498  if( $tries == $row['pass'] )
1499  {
1500  $must_renumber = true;
1501  }
1502  else
1503  {
1504  $must_renumber = false;
1505  }
1506  }
1507  elseif( $pass == $row['pass'] )
1508  {
1509  $isActivePass = true;
1510  $must_renumber = false;
1511  }
1512 
1513  if( !$this->object->isDynamicTest() && $isActivePass )
1514  {
1515  $this->ctrl->redirect($this, 'outUserResultsOverview');
1516  }
1517 
1518  if( $pass == 0 && (
1519  ($lastFinishedPass == 0 && $tries == 1 && $tries != $row['pass'])
1520  || ($isActivePass == true) // should be equal to || ($lastFinishedPass == -1 && $tries == 0)
1521  ))
1522  {
1523  $last_pass = true;
1524  }
1525  else
1526  {
1527  $last_pass = false;
1528  }
1529 
1530  // Work on tables:
1531  // tst_active
1532  if ($last_pass)
1533  {
1534  $ilDB->manipulate(
1535  'DELETE
1536  FROM tst_active
1537  WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1538  );
1539  }
1540  elseif( !$isActivePass )
1541  {
1542  $ilDB->manipulate(
1543  'UPDATE tst_active
1544  SET tries = ' . $ilDB->quote($tries-1, 'integer') . ',
1545  last_finished_pass = ' . $ilDB->quote($lastFinishedPass-1, 'integer') . '
1546  WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1547  );
1548  }
1549 
1550  // tst_manual_fb
1551  $ilDB->manipulate(
1552  'DELETE
1553  FROM tst_manual_fb
1554  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1555  AND pass = ' . $ilDB->quote($pass, 'integer')
1556  );
1557 
1558  if ($must_renumber)
1559  {
1560  $ilDB->manipulate(
1561  'UPDATE tst_manual_fb
1562  SET pass = pass - 1
1563  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1564  AND pass > ' . $ilDB->quote($pass, 'integer')
1565  );
1566  }
1567 
1568  // tst_mark -> nothing to do
1569  //
1570  // tst_pass_result
1571  $ilDB->manipulate(
1572  'DELETE
1573  FROM tst_pass_result
1574  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1575  AND pass = ' . $ilDB->quote($pass, 'integer')
1576  );
1577 
1578  if ($must_renumber)
1579  {
1580  $ilDB->manipulate(
1581  'UPDATE tst_pass_result
1582  SET pass = pass - 1
1583  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1584  AND pass > ' . $ilDB->quote($pass, 'integer')
1585  );
1586  }
1587 
1588  // tst_qst_solved -> nothing to do
1589 
1590  // tst_rnd_copy -> nothing to do
1591  // tst_rnd_qpl_title -> nothing to do
1592 
1593  // tst_sequence
1594  $ilDB->manipulate(
1595  'DELETE
1596  FROM tst_sequence
1597  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1598  AND pass = ' . $ilDB->quote($pass, 'integer')
1599  );
1600 
1601  if ($must_renumber)
1602  {
1603  $ilDB->manipulate(
1604  'UPDATE tst_sequence
1605  SET pass = pass - 1
1606  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1607  AND pass > ' . $ilDB->quote($pass, 'integer')
1608  );
1609  }
1610 
1611  // tst_solutions
1612  $ilDB->manipulate(
1613  'DELETE
1614  FROM tst_solutions
1615  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1616  AND pass = ' . $ilDB->quote($pass, 'integer')
1617  );
1618 
1619  if ($must_renumber)
1620  {
1621  $ilDB->manipulate(
1622  'UPDATE tst_solutions
1623  SET pass = pass - 1
1624  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1625  AND pass > ' . $ilDB->quote($pass, 'integer')
1626  );
1627  }
1628 
1629  // tst_tests -> nothing to do
1630 
1631  // tst_test_defaults -> nothing to do
1632 
1633  // tst_test_question -> nothing to do
1634 
1635  // tst_test_random -> nothing to do
1636 
1637  // tst_test_result
1638  $ilDB->manipulate(
1639  'DELETE
1640  FROM tst_test_result
1641  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1642  AND pass = ' . $ilDB->quote($pass, 'integer')
1643  );
1644 
1645  if ($must_renumber)
1646  {
1647  $ilDB->manipulate(
1648  'UPDATE tst_test_result
1649  SET pass = pass - 1
1650  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1651  AND pass > ' . $ilDB->quote($pass, 'integer')
1652  );
1653  }
1654 
1655  // tst_test_rnd_qst -> nothing to do
1656 
1657  // tst_times
1658  $ilDB->manipulate(
1659  'DELETE
1660  FROM tst_times
1661  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1662  AND pass = ' . $ilDB->quote($pass, 'integer')
1663  );
1664 
1665  if ($must_renumber)
1666  {
1667  $ilDB->manipulate(
1668  'UPDATE tst_times
1669  SET pass = pass - 1
1670  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1671  AND pass > ' . $ilDB->quote($pass, 'integer')
1672  );
1673  }
1674 
1675  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
1677  {
1678  $this->object->logAction($this->lng->txtlng("assessment", "log_deleted_pass", ilObjAssessmentFolder::_getLogLanguage()));
1679  }
1680  // tst_result_cache
1681  // Ggfls. nur renumbern.
1682  require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
1684 
1685  $this->ctrl->redirectByClass('iltestoutputgui', 'outuserresultsoverview');
1686  }
1687 }