ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestEvaluationGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
5 require_once './Modules/Test/classes/class.ilTestServiceGUI.php';
6 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
7 
28 {
37  public function __construct(ilObjTest $a_object)
38  {
39  parent::ilTestServiceGUI($a_object);
40  }
41 
45  public function &executeCommand()
46  {
47  $cmd = $this->ctrl->getCmd();
48  $next_class = $this->ctrl->getNextClass($this);
49  $this->ctrl->saveParameter($this, "sequence");
50  $this->ctrl->saveParameter($this, "active_id");
51  $cmd = $this->getCommand($cmd);
52  switch($next_class)
53  {
54  case 'iltestpassdetailsoverviewtablegui':
55  require_once 'Modules/Test/classes/tables/class.ilTestPassDetailsOverviewTableGUI.php';
56  $tableGUI = new ilTestPassDetailsOverviewTableGUI($this->ctrl, $this, 'outUserPassDetails');
57  $tableGUI->setIsPdfGenerationRequest($this->isPdfDeliveryRequest());
58  $tableGUI->initFilter();
59  $this->ctrl->forwardCommand($tableGUI);
60  break;
61 
62  default:
63  $ret =& $this->$cmd();
64  break;
65  }
66  return $ret;
67  }
68 
69  function &getHeaderNames()
70  {
71  $headernames = array();
72  if ($this->object->getAnonymity())
73  {
74  array_push($headernames, $this->lng->txt("counter"));
75  }
76  else
77  {
78  array_push($headernames, $this->lng->txt("name"));
79  array_push($headernames, $this->lng->txt("login"));
80  }
81  $additionalFields = $this->object->getEvaluationAdditionalFields();
82  if (count($additionalFields))
83  {
84  foreach ($additionalFields as $fieldname)
85  {
86  array_push($headernames, $this->lng->txt($fieldname));
87  }
88  }
89  array_push($headernames, $this->lng->txt("tst_reached_points"));
90  array_push($headernames, $this->lng->txt("tst_mark"));
91  if ($this->object->getECTSOutput())
92  {
93  array_push($headernames, $this->lng->txt("ects_grade"));
94  }
95  array_push($headernames, $this->lng->txt("tst_answered_questions"));
96  array_push($headernames, $this->lng->txt("working_time"));
97  array_push($headernames, $this->lng->txt("detailed_evaluation"));
98  return $headernames;
99  }
100 
101  function &getHeaderVars()
102  {
103  $headervars = array();
104  if ($this->object->getAnonymity())
105  {
106  array_push($headervars, "counter");
107  }
108  else
109  {
110  array_push($headervars, "name");
111  array_push($headervars, "login");
112  }
113  array_push($headervars, "resultspoints");
114  array_push($headervars, "resultsmarks");
115  if ($this->object->getECTSOutput())
116  {
117  array_push($headervars, "ects_grade");
118  }
119  array_push($headervars, "qworkedthrough");
120  array_push($headervars, "timeofwork");
121  array_push($headervars, "");
122  return $headervars;
123  }
124 
125  public function filterEvaluation()
126  {
127  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
128  $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
129  $table_gui->writeFilterToSession();
130  $this->ctrl->redirect($this, "outEvaluation");
131  }
132 
133  public function resetfilterEvaluation()
134  {
135  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
136  $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
137  $table_gui->resetFilter();
138  $this->ctrl->redirect($this, "outEvaluation");
139  }
140 
146  function outEvaluation()
147  {
152  global $ilAccess, $ilToolbar;
153 
154  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
155  {
156  // allow only evaluation access
157  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
158  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
159  }
160 
161  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
162 
163  $table_gui = new ilEvaluationAllTableGUI(
164  $this, 'outEvaluation', $this->object->getAnonymity(), $this->object->isOfferingQuestionHintsEnabled()
165  );
166 
167  $data = array();
168  $arrFilter = array();
169 
170  foreach ($table_gui->getFilterItems() as $item)
171  {
172  if ($item->getValue() !== false)
173  {
174  switch ($item->getPostVar())
175  {
176  case 'group':
177  case 'name':
178  case 'course':
179  $arrFilter[$item->getPostVar()] = $item->getValue();
180  break;
181  case 'passed_only':
182  $passedonly = $item->getChecked();
183  break;
184  }
185  }
186  }
187  include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
188  $eval = new ilTestEvaluationData($this->object);
189  $eval->setFilterArray($arrFilter);
190  $foundParticipants =& $eval->getParticipants();
191  $counter = 1;
192  if (count($foundParticipants) > 0)
193  {
194  if ($this->object->getECTSOutput())
195  {
196  $passed_array =& $this->object->getTotalPointsPassedArray();
197  }
198  foreach ($foundParticipants as $active_id => $userdata)
199  {
200  /* @var $userdata ilTestEvaluationUserData */
201 
202  $remove = FALSE;
203  if ($passedonly)
204  {
205  $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent());
206 
207  if( $mark_obj->getPassed() == FALSE || !$userdata->areObligationsAnswered() )
208  {
209  $remove = TRUE;
210  }
211  }
212  if (!$remove)
213  {
214  // build the evaluation row
215  $evaluationrow = array();
216  if ($this->object->getAnonymity())
217  {
218  $evaluationrow['name'] = $counter;
219  $evaluationrow['login'] = '';
220  }
221  else
222  {
223  $evaluationrow['name'] = $userdata->getName();
224  if (strlen($userdata->getLogin()))
225  {
226  $evaluationrow['login'] = "[" . $userdata->getLogin() . "]";
227  }
228  else
229  {
230  $evaluationrow['login'] = '';
231  }
232  }
233 
234  $evaluationrow['reached'] = $userdata->getReached();
235  $evaluationrow['max'] = $userdata->getMaxpoints();
236  $evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass();
237  $percentage = $userdata->getReachedPointsInPercent();
238  $mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
239  if (is_object($mark))
240  {
241  $evaluationrow['mark'] = $mark->getShortName();
242  }
243  if ($this->object->getECTSOutput())
244  {
245  $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints());
246  $evaluationrow['ects_grade'] = $ects_mark;
247  }
248  $evaluationrow['answered'] = $userdata->getQuestionsWorkedThroughInPercent();
249  $evaluationrow['questions_worked_through'] = $userdata->getQuestionsWorkedThrough();
250  $evaluationrow['number_of_questions'] = $userdata->getNumberOfQuestions();
251  $time_seconds = $userdata->getTimeOfWork();
252  $time_hours = floor($time_seconds/3600);
253  $time_seconds -= $time_hours * 3600;
254  $time_minutes = floor($time_seconds/60);
255  $time_seconds -= $time_minutes * 60;
256  $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
257  $this->ctrl->setParameter($this, "active_id", $active_id);
258  $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
259  $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
260  $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>";
261  $userfields = ilObjUser::_lookupFields($userdata->getUserID());
262  $evaluationrow['gender'] = $userfields['gender'];
263  $evaluationrow['email'] = $userfields['email'];
264  $evaluationrow['institution'] = $userfields['institution'];
265  $evaluationrow['street'] = $userfields['street'];
266  $evaluationrow['city'] = $userfields['city'];
267  $evaluationrow['zipcode'] = $userfields['zipcode'];
268  $evaluationrow['country'] = $userfields['country'];
269  $evaluationrow['sel_country'] = $userfields['sel_country'];
270  $evaluationrow['department'] = $userfields['department'];
271  $evaluationrow['matriculation'] = $userfields['matriculation'];
272  $counter++;
273  $data[] = $evaluationrow;
274  }
275  }
276  }
277 
278  $table_gui->setData($data);
279  if(count($foundParticipants) > 0)
280  {
281  $ilToolbar->setFormName('form_output_eval');
282  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportEvaluation'));
283  require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
284  $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
285  $options = array(
286  'excel' => $this->lng->txt('exp_type_excel'),
287  'csv' => $this->lng->txt('exp_type_spss')
288  );
289 
290  if(!$this->object->getAnonymity())
291  {
292  include_once 'Services/Certificate/classes/class.ilCertificate.php';
293  include_once 'Modules/Test/classes/class.ilTestCertificateAdapter.php';
295  {
296  $options['certificate'] = $this->lng->txt('exp_type_certificate');
297  }
298  }
299 
300  $export_type->setOptions($options);
301 
302  $ilToolbar->addInputItem($export_type, true);
303  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
304  $button = ilSubmitButton::getInstance();
305  $button->setCommand('exportEvaluation');
306  $button->setCaption('export');
307  $button->getOmitPreventDoubleSubmission();
308  $ilToolbar->addButtonInstance($button);
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  $this->tpl->setContent($table_gui->getHTML());
318  }
319 
328  {
329  global $ilAccess;
330 
331  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
332  {
333  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), TRUE);
334  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
335  }
336 
337  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation_details.html", "Modules/Test");
338 
339  $active_id = $_GET["active_id"];
340  if (strlen($active_id) == 0)
341  {
342  ilUtil::sendInfo($this->lng->txt("detailed_evaluation_missing_active_id"), TRUE);
343  $this->ctrl->redirect($this, "outEvaluation");
344  }
345 
346  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
347 
348  $data =& $this->object->getCompleteEvaluationData();
349  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
350  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outEvaluation"));
351  $this->tpl->setVariable("HEADING_DETAILED_EVALUATION", sprintf($this->lng->txt("detailed_evaluation_for"),
352  $data->getParticipant($active_id)->getName())
353  );
354  $this->tpl->setVariable("STATISTICAL_DATA", $this->lng->txt("statistical_data"));
355  $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
356  $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()) . " %" . ")");
357  if (strlen($data->getParticipant($active_id)->getMark()))
358  {
359  $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
360  $this->tpl->setVariable("VALUE_RESULTSMARKS", $data->getParticipant($active_id)->getMark());
361  if (strlen($data->getParticipant($active_id)->getECTSMark()))
362  {
363  $this->tpl->setVariable("TXT_ECTS", $this->lng->txt("ects_grade"));
364  $this->tpl->setVariable("VALUE_ECTS", $data->getParticipant($active_id)->getECTSMark());
365  }
366  }
367 
368  if( $this->object->isOfferingQuestionHintsEnabled() )
369  {
370  $this->tpl->setVariable("TXT_REQUESTED_HINTS_COUNT", $this->lng->txt("tst_question_hints_requested_hint_count_header"));
371  $this->tpl->setVariable("VALUE_REQUESTED_HINTS_COUNT", $data->getParticipant($active_id)->getRequestedHintsCountFromScoredPass());
372  }
373 
374  $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
375  $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()) . " %" . ")");
376 
377  $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
378  $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
379  $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
380  $time_hours = floor($time_seconds/3600);
381  $time_seconds -= $time_hours * 3600;
382  $time_minutes = floor($time_seconds/60);
383  $time_seconds -= $time_minutes * 60;
384  $this->tpl->setVariable("VALUE_TIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
385  $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
386  $time_hours = floor($atime_seconds/3600);
387  $atime_seconds -= $time_hours * 3600;
388  $time_minutes = floor($atime_seconds/60);
389  $atime_seconds -= $time_minutes * 60;
390  $this->tpl->setVariable("VALUE_ATIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
391  $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
392  #$this->tpl->setVariable("VALUE_FIRSTVISIT",
393  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getFirstVisit())
394  #);
395  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
396  new ilDateTime($data->getParticipant($active_id)->getFirstVisit(),IL_CAL_UNIX)));
397  $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
398  #$this->tpl->setVariable("VALUE_LASTVISIT",
399  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getLastVisit())
400  #);
401  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
402  new ilDateTime($data->getParticipant($active_id)->getLastVisit(),IL_CAL_UNIX)));
403 
404  $this->tpl->setVariable("TXT_NROFPASSES", $this->lng->txt("tst_nr_of_passes"));
405  $this->tpl->setVariable("VALUE_NROFPASSES", $data->getParticipant($active_id)->getLastPass() + 1);
406  $this->tpl->setVariable("TXT_SCOREDPASS", $this->lng->txt("scored_pass"));
407  if ($this->object->getPassScoring() == SCORE_BEST_PASS)
408  {
409  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getBestPass() + 1);
410  }
411  else
412  {
413  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getLastPass() + 1);
414  }
415 
416  $median = $data->getStatistics()->getStatistics()->median();
417  $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
418  $mark = $this->object->mark_schema->getMatchingMark($pct);
419  if (is_object($mark))
420  {
421  $this->tpl->setVariable("TXT_MARK_MEDIAN", $this->lng->txt("tst_stat_result_mark_median"));
422  $this->tpl->setVariable("VALUE_MARK_MEDIAN", $mark->getShortName());
423  }
424 
425  $this->tpl->setVariable("TXT_RANK_PARTICIPANT", $this->lng->txt("tst_stat_result_rank_participant"));
426  $this->tpl->setVariable("VALUE_RANK_PARTICIPANT", $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
427  $this->tpl->setVariable("TXT_RANK_MEDIAN", $this->lng->txt("tst_stat_result_rank_median"));
428  $this->tpl->setVariable("VALUE_RANK_MEDIAN", $data->getStatistics()->getStatistics()->rank_median());
429  $this->tpl->setVariable("TXT_TOTAL_PARTICIPANTS", $this->lng->txt("tst_stat_result_total_participants"));
430  $this->tpl->setVariable("VALUE_TOTAL_PARTICIPANTS", $data->getStatistics()->getStatistics()->count());
431  $this->tpl->setVariable("TXT_RESULT_MEDIAN", $this->lng->txt("tst_stat_result_median"));
432  $this->tpl->setVariable("VALUE_RESULT_MEDIAN", $median);
433 
434  for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
435  {
436  $finishdate = $this->object->getPassFinishDate($active_id, $pass);
437  if ($finishdate > 0)
438  {
439  $this->tpl->setCurrentBlock("question_header");
440  $this->tpl->setVariable("TXT_QUESTION_DATA", sprintf($this->lng->txt("tst_eval_question_points"), $pass+1));
441  $this->tpl->parseCurrentBlock();
442  global $ilAccess;
443  if (($ilAccess->checkAccess("write", "", $_GET["ref_id"])))
444  {
445  $this->tpl->setCurrentBlock("question_footer");
446  $this->tpl->setVariable("TEXT_TO_DETAILED_RESULTS", $this->lng->txt("tst_show_answer_sheet"));
447  $this->ctrl->setParameter($this, "statistics", "1");
448  $this->ctrl->setParameter($this, "active_id", $active_id);
449  $this->ctrl->setParameter($this, "pass", $pass);
450  $this->tpl->setVariable("URL_TO_DETAILED_RESULTS", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
451  $this->tpl->parseCurrentBlock();
452  }
453  $questions = $data->getParticipant($active_id)->getQuestions($pass);
454  if (!is_array($questions))
455  {
456  $questions = $data->getParticipant($active_id)->getQuestions(0);
457  }
458  $counter = 1;
459  foreach ($questions as $question)
460  {
461  $this->tpl->setCurrentBlock("question_row");
462  $this->tpl->setVariable("QUESTION_COUNTER", $counter);
463  $this->tpl->setVariable("QUESTION_ID", $question["id"]);
464  $this->tpl->setVariable("QUESTION_ID_TXT", $this->lng->txt('question_id_short'));
465  $this->tpl->setVariable("QUESTION_TITLE", $data->getQuestionTitle($question["id"]));
466  $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
467  if (is_array($answeredquestion))
468  {
469  $percent = $answeredquestion["points"] ? $answeredquestion["reached"] / $answeredquestion["points"] * 100.0 : 0;
470  $this->tpl->setVariable("QUESTION_POINTS", $answeredquestion["reached"] . " " . strtolower($this->lng->txt("of")) . " " . $answeredquestion["points"] . " (" . sprintf("%.2f", $percent) . " %)");
471  }
472  else
473  {
474  $this->tpl->setVariable("QUESTION_POINTS", "0 " . strtolower($this->lng->txt("of")) . " " . $question["points"] . " (" . sprintf("%.2f", 0) . " %) - " . $this->lng->txt("question_not_answered"));
475  }
476  $this->tpl->parseCurrentBlock();
477  $counter++;
478  }
479  $this->tpl->touchBlock("question_stats");
480  }
481  }
482  }
483 
489  {
490  $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
491  }
492 
498  {
499  require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
500  $question_object = assQuestion::_instanciateQuestion($_GET["qid"]);
501  if ( $question_object instanceof ilObjFileHandlingQuestionType )
502  {
503  $question_object->getFileUploadZIPFile($this->object->getTestId());
504  }
505  else
506  {
507  $this->ctrl->redirect($this, "singleResults");
508  }
509  }
510 
518  function eval_a()
519  {
524  global $ilAccess, $ilToolbar;
525 
526  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
527  {
528  // allow only evaluation access
529  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
530  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
531  }
532 
533  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
534  $eval =& $this->object->getCompleteEvaluationData();
535  $data = array();
536  $foundParticipants =& $eval->getParticipants();
537  if (count($foundParticipants))
538  {
539  $ilToolbar->setFormName('form_output_eval');
540  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportAggregatedResults'));
541  require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
542  $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
543  $export_type->setOptions(array(
544  'excel' => $this->lng->txt('exp_type_excel'),
545  'csv' => $this->lng->txt('exp_type_spss')
546  ));
547  $ilToolbar->addInputItem($export_type, true);
548  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
549  $button = ilSubmitButton::getInstance();
550  $button->setCommand('exportAggregatedResults');
551  $button->setCaption('export');
552  $button->getOmitPreventDoubleSubmission();
553  $ilToolbar->addButtonInstance($button);
554 
555  array_push($data, array(
556  'result' => $this->lng->txt("tst_eval_total_persons"),
557  'value' => count($foundParticipants)
558  ));
559  $total_finished = $this->object->evalTotalFinished();
560  array_push($data, array(
561  'result' => $this->lng->txt("tst_eval_total_finished"),
562  'value' => $total_finished
563  ));
564  $average_time = $this->object->evalTotalStartedAverageTime();
565  $diff_seconds = $average_time;
566  $diff_hours = floor($diff_seconds/3600);
567  $diff_seconds -= $diff_hours * 3600;
568  $diff_minutes = floor($diff_seconds/60);
569  $diff_seconds -= $diff_minutes * 60;
570  array_push($data, array(
571  'result' => $this->lng->txt("tst_eval_total_finished_average_time"),
572  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
573  ));
574  $total_passed = 0;
575  $total_passed_reached = 0;
576  $total_passed_max = 0;
577  $total_passed_time = 0;
578  foreach ($foundParticipants as $userdata)
579  {
580  if ($userdata->getPassed())
581  {
582  $total_passed++;
583  $total_passed_reached += $userdata->getReached();
584  $total_passed_max += $userdata->getMaxpoints();
585  $total_passed_time += $userdata->getTimeOfWork();
586  }
587  }
588  $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
589  $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
590  $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
591  array_push($data, array(
592  'result' => $this->lng->txt("tst_eval_total_passed"),
593  'value' => $total_passed
594  ));
595  array_push($data, array(
596  'result' => $this->lng->txt("tst_eval_total_passed_average_points"),
597  'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)
598  ));
599  $average_time = $average_passed_time;
600  $diff_seconds = $average_time;
601  $diff_hours = floor($diff_seconds/3600);
602  $diff_seconds -= $diff_hours * 3600;
603  $diff_minutes = floor($diff_seconds/60);
604  $diff_seconds -= $diff_minutes * 60;
605  array_push($data, array(
606  'result' => $this->lng->txt("tst_eval_total_passed_average_time"),
607  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
608  ));
609  }
610 
611  include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
612  $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
613  $table_gui->setData($data);
614  $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
615 
616  $rows = array();
617  foreach ($eval->getQuestionTitles() as $question_id => $question_title)
618  {
619  $answered = 0;
620  $reached = 0;
621  $max = 0;
622  foreach ($foundParticipants as $userdata)
623  {
624  for ($i = 0; $i <= $userdata->getLastPass(); $i++)
625  {
626  if (is_object($userdata->getPass($i)))
627  {
628  $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
629  if (is_array($question))
630  {
631  $answered++;
632  $reached += $question["reached"];
633  $max += $question["points"];
634  }
635  }
636  }
637  }
638  $percent = $max ? $reached/$max * 100.0 : 0;
639  $counter++;
640  $this->ctrl->setParameter($this, "qid", $question_id);
641 
642  $points_reached = ($answered ? $reached / $answered : 0);
643  $points_max = ($answered ? $max / $answered : 0);
644  array_push($rows,
645  array(
646  'qid' => $question_id,
647  'title' => $question_title,
648  'points' => $points_reached,
649  'points_reached' => $points_reached,
650  'points_max' => $points_max,
651  'percentage' => (float)$percent,
652  'answers' => $answered
653  )
654  );
655  }
656  include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
657  $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
658  $table_gui->setData($rows);
659  $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
660  }
661 
665  public function exportEvaluation()
666  {
667  $filterby = "";
668  if (array_key_exists("g_filterby", $_GET))
669  {
670  $filterby = $_GET["g_filterby"];
671  }
672 
673  $filtertext = "";
674  if (array_key_exists("g_userfilter", $_GET))
675  {
676  $filtertext = $_GET["g_userfilter"];
677  }
678 
679  $passedonly = FALSE;
680  if (array_key_exists("g_passedonly", $_GET))
681  {
682  if ($_GET["g_passedonly"] == 1)
683  {
684  $passedonly = TRUE;
685  }
686  }
687 
688  switch ($_POST["export_type"])
689  {
690  case "excel":
691  require_once './Modules/Test/classes/class.ilTestExport.php';
692  $exportObj = new ilTestExport($this->object, "results");
693  $exportObj->exportToExcel($deliver = TRUE, $filterby, $filtertext, $passedonly);
694  break;
695 
696  case "csv":
697  require_once './Modules/Test/classes/class.ilTestExport.php';
698  $exportObj = new ilTestExport($this->object, "results");
699  $exportObj->exportToCSV($deliver = TRUE, $filterby, $filtertext, $passedonly);
700  break;
701 
702  case "certificate":
703  if ($passedonly)
704  {
705  $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
706  }
707  if (strlen($filtertext))
708  {
709  $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
710  }
711  $this->ctrl->redirect($this, "exportCertificate");
712  break;
713  }
714  }
715 
722  {
723  switch ($_POST["export_type"])
724  {
725  case "excel":
726  include_once "./Modules/Test/classes/class.ilTestExport.php";
727  $exportObj = new ilTestExport($this->object, "aggregated");
728  $exportObj->exportToExcel($deliver = TRUE);
729  break;
730  case "csv":
731  include_once "./Modules/Test/classes/class.ilTestExport.php";
732  $exportObj = new ilTestExport($this->object, "aggregated");
733  $exportObj->exportToCSV($deliver = TRUE);
734  break;
735  }
736  }
737 
744  public function exportCertificate()
745  {
746  global $ilUser;
747 
748  include_once "./Services/Utilities/classes/class.ilUtil.php";
749  include_once "./Services/Certificate/classes/class.ilCertificate.php";
750  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
751  $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
752  $archive_dir = $certificate->createArchiveDirectory();
753  $total_users = array();
754  $total_users =& $this->object->evalTotalPersonsArray();
755  if (count($total_users))
756  {
757  foreach ($total_users as $active_id => $name)
758  {
759  $user_id = $this->object->_getUserIdFromActiveId($active_id);
760  $pdf = $certificate->outCertificate(
761  array(
762  "active_id" => $active_id,
763  "userfilter" => $userfilter,
764  "passedonly" => $passedonly
765  ),
766  FALSE
767  );
768  if (strlen($pdf))
769  {
770  $certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
771  }
772  }
773  $zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, TRUE);
774  }
775 
776  }
777 
784  function getEvaluationQuestionId($question_id, $original_id = "")
785  {
786  if ($original_id > 0)
787  {
788  return $original_id;
789  }
790  else
791  {
792  return $question_id;
793  }
794  }
795 
804  {
805  global $ilTabs, $ilAccess;
806 
807  if (!$ilAccess->checkAccess('write', '', $this->ref_id))
808  {
809  // allow only write access
810  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
811  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
812  }
813 
814  $this->ctrl->saveParameter($this, "active_id");
815  $active_id = (int)$_GET["active_id"];
816  $testSession = $this->testSessionFactory->getSession($active_id);
817 
818  // protect actives from other tests
819  if( $testSession->getTestId() != $this->object->getTestId() )
820  {
821  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
822  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
823  }
824 
825  $this->ctrl->saveParameter($this, "pass");
826  $pass = (int)$_GET["pass"];
827 
828  if ( isset($_GET['statistics']) && $_GET['statistics'] == 1)
829  {
830  $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
831 
832  $ilTabs->setBackTarget(
833  $this->lng->txt('back'), $this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'detailedEvaluation')
834  );
835  }
836  elseif ($this->object->getNrOfTries() == 1)
837  {
838  $ilTabs->setBackTarget(
839  $this->lng->txt('back'), $this->ctrl->getLinkTargetByClass('ilobjtestgui', 'participants')
840  );
841  }
842  else
843  {
844  $ilTabs->setBackTarget(
845  $this->lng->txt('tst_results_back_overview'), $this->ctrl->getLinkTarget($this, 'outParticipantsResultsOverview')
846  );
847  }
848 
849  $result_array =& $this->object->getTestResult($active_id, $pass);
850 
851  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, $this, "outParticipantsPassDetails", '', true);
852  $user_data = $this->getResultsUserdata($testSession, $active_id, FALSE);
853  $user_id = $this->object->_getUserIdFromActiveId($active_id);
854 
855  $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", TRUE, TRUE, "Modules/Test");
856 
857  require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php';
858  $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng);
859 
860  $this->ctrl->setParameter($this, 'pdf', '1');
861  $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails') );
862  $this->ctrl->setParameter($this, 'pdf', '');
863 
864  if( isset($_GET['show_best_solutions']) )
865  {
866  $_SESSION['tst_results_show_best_solutions'] = true;
867  }
868  elseif( isset($_GET['hide_best_solutions']) )
869  {
870  $_SESSION['tst_results_show_best_solutions'] = false;
871  }
872  elseif( !isset($_SESSION['tst_results_show_best_solutions']) )
873  {
874  $_SESSION['tst_results_show_best_solutions'] = false;
875  }
876 
877  if( $_SESSION['tst_results_show_best_solutions'] )
878  {
879  $this->ctrl->setParameter($this, 'hide_best_solutions', '1');
880  $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
881  $this->ctrl->setParameter($this, 'hide_best_solutions', '');
882  }
883  else
884  {
885  $this->ctrl->setParameter($this, 'show_best_solutions', '1');
886  $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
887  $this->ctrl->setParameter($this, 'show_best_solutions', '');
888  }
889 
890  $toolbar->build();
891  $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
892 
893  if( $this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1 )
894  {
895  $template->setCurrentBlock('grading_message');
896  $template->setVariable('GRADING_MESSAGE', $this->getGradingMessage($active_id));
897  $template->parseCurrentBlock();
898  }
899 
900  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, $_SESSION['tst_results_show_best_solutions'], false, false, false, true);
901  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
902  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
903  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
904  $template->setVariable("PASS_DETAILS", $overview);
905  $template->setVariable("USER_DATA", $user_data);
906  $uname = $this->object->userLookupFullName($user_id);
907  $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
908 
909  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
910  if ($this->object->getShowSolutionAnswersOnly())
911  {
912  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
913  }
914 
915  if( $this->isPdfDeliveryRequest() )
916  {
917  //$this->object->deliverPDFfromHTML($template->get());
918  require_once 'class.ilTestPDFGenerator.php';
919  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle());
920  }
921  else
922  {
923  $this->tpl->setVariable("ADM_CONTENT", $template->get());
924  }
925  }
926 
933  {
934  global $ilTabs, $ilAccess;
935 
936  if (!$ilAccess->checkAccess('write', '', $this->ref_id))
937  {
938  // allow only write access
939  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
940  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
941  }
942 
943  $active_id = (int)$_GET["active_id"];
944  $testSession = $this->testSessionFactory->getSession($active_id);
945 
946  // protect actives from other tests
947  if( $testSession->getTestId() != $this->object->getTestId() )
948  {
949  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
950  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
951  }
952 
953  if ($this->object->getNrOfTries() == 1)
954  {
955  $this->ctrl->setParameter($this, "active_id", $active_id);
956  $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
957  $this->ctrl->redirect($this, "outParticipantsPassDetails");
958  }
959 
960  $ilTabs->setBackTarget(
961  $this->lng->txt('back'), $this->ctrl->getLinkTargetByClass('ilobjtestgui', 'participants')
962  );
963 
964  $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", TRUE, TRUE, "Modules/Test");
965 
966  require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php';
967  $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng);
968 
969  $this->ctrl->setParameter($this, 'pdf', '1');
970  $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, __FUNCTION__) );
971  $this->ctrl->setParameter($this, 'pdf', '');
972 
973  $toolbar->build();
974  $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
975 
976  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outParticipantsPassDetails", false, false, true);
977  $template->setVariable("PASS_OVERVIEW", $overview);
978 
979  $user_id = $this->object->_getUserIdFromActiveId($active_id);
980  $user_data = $this->getResultsUserdata($testSession, $active_id);
981  $template->setVariable("USER_DATA", $user_data);
982  $template->setVariable("TEXT_OVERVIEW", $this->lng->txt("tst_results_overview"));
983 
984  if( $this->isGradingMessageRequired() )
985  {
986  $template->setCurrentBlock('grading_message');
987  $template->setVariable('GRADING_MESSAGE', $this->getGradingMessage($active_id));
988  $template->parseCurrentBlock();
989  }
990 
991  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
992  $template->parseCurrentBlock();
993 
994  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
995  if ($this->object->getShowSolutionAnswersOnly())
996  {
997  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
998  }
999 
1000  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1001  {
1002  //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1003 
1004  $name = ilObjUser::_lookupName($user_id);
1005  $filename = $name['lastname'] . '_' . $name['firstname'] . '_' . $name['login'] . '__'. $this->object->getTitle();
1006  require_once 'class.ilTestPDFGenerator.php';
1008  //ilUtil::deliverData($file, ilUtil::getASCIIFilename($this->object->getTitle()) . ".pdf", "application/pdf", false, true);
1009  //$template->setVariable("PDF_FILE_LOCATION", $filename);
1010  }
1011  else
1012  {
1013  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1014  }
1015  }
1016 
1018  {
1019  $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1020  $tableGUI->initFilter();
1021  $tableGUI->resetOffset();
1022  $tableGUI->writeFilterToSession();
1023  $this->outUserPassDetails();
1024  }
1025 
1027  {
1028  $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1029  $tableGUI->initFilter();
1030  $tableGUI->resetOffset();
1031  $tableGUI->resetFilter();
1032  $this->outUserPassDetails();
1033  }
1034 
1041  {
1042  global $ilTabs, $ilUser;
1043 
1044  if ($this->object->getNrOfTries() == 1)
1045  {
1046  $ilTabs->setBackTarget($this->lng->txt('tst_results_back_introduction'), $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen'));
1047  }
1048  else
1049  {
1050  $ilTabs->setBackTarget($this->lng->txt('tst_results_back_overview'), $this->ctrl->getLinkTarget($this, 'outUserResultsOverview'));
1051  }
1052 
1053  $testSession = $this->testSessionFactory->getSession();
1054 
1055  if( !$this->object->getShowPassDetails() )
1056  {
1057  #$executable = $this->object->isExecutable($testSession, $ilUser->getId());
1058 
1059  #if($executable["executable"])
1060  #{
1061  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1062  #}
1063  }
1064 
1065  $active_id = $testSession->getActiveId();
1066  $user_id = $testSession->getUserId();
1067 
1068  $this->ctrl->saveParameter($this, "pass");
1069  $pass = $_GET["pass"];
1070 
1071  $result_array = $this->getFilteredTestResult($active_id, $pass);
1072 
1073  $command_solution_details = "";
1074  if ($this->object->getShowSolutionDetails())
1075  {
1076  $command_solution_details = "outCorrectSolution";
1077  }
1078  $questionAnchorNav = $this->object->canShowSolutionPrintview();
1079 
1080  $tpl = new ilTemplate('tpl.il_as_tst_pass_details_overview_participants.html', true, true, "Modules/Test");
1081 
1082  if( !$this->isPdfDeliveryRequest() )
1083  {
1084  require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php';
1085  $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng);
1086 
1087  $this->ctrl->setParameter($this, 'pdf', '1');
1088  $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, 'outUserPassDetails') );
1089  $this->ctrl->setParameter($this, 'pdf', '');
1090 
1091  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1092  if( $this->object->canShowCertificate($testSession, $user_id, $active_id) )
1093  {
1094  $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1095  }
1096 
1097  $toolbar->build();
1098 
1099  $tpl->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1100 
1101  $tpl->setCurrentBlock('signature');
1102  $tpl->setVariable("SIGNATURE", $this->getResultsSignature());
1103  $tpl->parseCurrentBlock();
1104 
1105  if ($this->object->isShowExamIdInTestResultsEnabled())
1106  {
1107  $tpl->setCurrentBlock('exam_id');
1108  $tpl->setVariable('EXAM_ID', $this->object->lookupExamId(
1109  $testSession->getActiveId(), $pass
1110  ));
1111  $tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1112  $tpl->parseCurrentBlock();
1113  }
1114  }
1115 
1116  if( $this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1 )
1117  {
1118  $tpl->setCurrentBlock('grading_message');
1119  $tpl->setVariable('GRADING_MESSAGE', $this->getGradingMessage($active_id));
1120  $tpl->parseCurrentBlock();
1121  }
1122 
1123  $overview = $this->getPassDetailsOverview(
1124  $result_array, $active_id, $pass, $this, "outUserPassDetails", $command_solution_details, $questionAnchorNav
1125  );
1126  $tpl->setVariable("PASS_DETAILS", $overview);
1127 
1128  if( $this->object->canShowSolutionPrintview() )
1129  {
1130  $list_of_answers = $this->getPassListOfAnswers(
1131  $result_array, $active_id, $pass, $this->object->getShowSolutionListComparison(),
1132  false, false, false, true
1133  );
1134  $tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1135  }
1136 
1137  $tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
1138  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1139 
1140  $uname = $this->object->userLookupFullName($user_id, TRUE);
1141  $user_data = $this->getResultsUserdata($testSession, $active_id, TRUE);
1142  if ($this->object->getAnonymity())
1143  {
1144  $tpl->setVariable("TEXT_HEADING", $this->lng->txt("tst_result_pass"));
1145  }
1146  else
1147  {
1148  $tpl->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1149  $tpl->setVariable("USER_DATA", $user_data);
1150  }
1151 
1152  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1153  if ($this->object->getShowSolutionAnswersOnly())
1154  {
1155  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1156  }
1157 
1158  if( $this->isPdfDeliveryRequest() )
1159  {
1160  require_once 'class.ilTestPDFGenerator.php';
1162  }
1163  else
1164  {
1165  $this->tpl->setContent($tpl->get());
1166  }
1167  }
1168 
1175  {
1176  global $ilUser, $ilTabs;
1177 
1178  $ilTabs->setBackTarget(
1179  $this->lng->txt('tst_results_back_introduction'),
1180  $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen')
1181  );
1182 
1183  $testSession = $this->testSessionFactory->getSession();
1184  $active_id = $testSession->getActiveId();
1185  $user_id = $ilUser->getId();
1186  $uname = $this->object->userLookupFullName($user_id, TRUE);
1187 
1188  if( !$this->object->canShowTestResults($testSession, $ilUser->getId()) )
1189  {
1190  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1191  }
1192 
1193  $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test");
1194  $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
1195 
1196  require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php';
1197  $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng);
1198 
1199  $this->ctrl->setParameter($this, 'pdf', '1');
1200  $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, 'outUserResultsOverview') );
1201  $this->ctrl->setParameter($this, 'pdf', '');
1202 
1203  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1204  if( $this->object->canShowCertificate($testSession, $user_id, $active_id) )
1205  {
1206  $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1207  }
1208 
1209  $toolbar->build();
1210 
1211  $templatehead->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1212 
1213  $hide_details = !$this->object->getShowPassDetails();
1214  #if ($hide_details)
1215  #{
1216  # $executable = $this->object->isExecutable($testSession, $ilUser->getId());
1217  # if (!$executable["executable"]) $hide_details = FALSE;
1218  #}
1219 
1220  $template->setCurrentBlock("pass_overview");
1221  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserPassDetails", FALSE, $hide_details);
1222  $template->setVariable("PASS_OVERVIEW", $overview);
1223  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results_overview"));
1224  $template->parseCurrentBlock();
1225 
1226  $user_data = $this->getResultsUserdata($testSession, $active_id, TRUE);
1227 
1228  if ($this->object->getAnonymity()) {
1229  $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1230  }
1231  else {
1232  $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1233  $template->setVariable("USER_DATA", $user_data);
1234  }
1235 
1236  if( $this->isGradingMessageRequired() )
1237  {
1238  $template->setCurrentBlock('grading_message');
1239  $template->setVariable('GRADING_MESSAGE', $this->getGradingMessage($active_id));
1240  $template->parseCurrentBlock();
1241  }
1242 
1243  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1244  if ($this->object->getShowSolutionAnswersOnly())
1245  {
1246  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1247  }
1248  $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1249 
1250  if( $this->isPdfDeliveryRequest() )
1251  {
1252  //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1253  require_once 'class.ilTestPDFGenerator.php';
1254  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle());
1255  //$this->object->deliverPDFfromHTML($template->get(), sprintf($this->lng->txt("tst_result_user_name"), $uname));
1256  }
1257  else
1258  {
1259  $this->tpl->setContent($templatehead->get());
1260  }
1261  }
1262 
1271  {
1272  global $ilUser;
1273 
1274  if (!$this->object->getShowSolutionPrintview())
1275  {
1276  ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1277  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1278  }
1279 
1280  $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", TRUE, TRUE, "Modules/Test");
1281 
1282  $pass = null;
1283  if (array_key_exists("pass", $_GET))
1284  {
1285  if (strlen($_GET["pass"])) $pass = $_GET["pass"];
1286  }
1287  $user_id = $ilUser->getId();
1288 
1289  $testSession = $this->testSessionFactory->getSession();
1290  $active_id = $testSession->getActiveId();
1291 
1292  $overview = "";
1293  if ($this->object->getNrOfTries() == 1)
1294  {
1295  $pass = 0;
1296  }
1297  else
1298  {
1299  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserListOfAnswerPasses", TRUE);
1300  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1301  $template->setVariable("PASS_OVERVIEW", $overview);
1302  }
1303 
1304  $signature = "";
1305  if (strlen($pass))
1306  {
1307  $signature = $this->getResultsSignature();
1308  $result_array =& $this->object->getTestResult($active_id, $pass);
1309  $user_id =& $this->object->_getUserIdFromActiveId($active_id);
1310  $showAllAnswers = TRUE;
1311  if ($this->object->isExecutable($testSession, $user_id))
1312  {
1313  $showAllAnswers = FALSE;
1314  }
1315  $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers);
1316  $template->setVariable("PASS_DETAILS", $answers);
1317  }
1318  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1319  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1320  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1321  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1322  $template->setVariable("PRINT_URL", "javascript:window.print();");
1323 
1324  $user_data = $this->getResultsUserdata($testSession, $active_id, TRUE);
1325  $template->setVariable("USER_DATA", $user_data);
1326  $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1327  if (strlen($signature))
1328  {
1329  $template->setVariable("SIGNATURE", $signature);
1330  }
1331  if (!is_null($pass) && $this->object->isShowExamIdInTestResultsEnabled())
1332  {
1333  $template->setCurrentBlock('exam_id_footer');
1334  $template->setVariable('EXAM_ID_VAL', $this->object->lookupExamId(
1335  $testSession->getActiveId(), $pass
1336  ));
1337  $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1338  $template->parseCurrentBlock();
1339  }
1340  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1341 
1342  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1343  if ($this->object->getShowSolutionAnswersOnly())
1344  {
1345  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1346  }
1347  }
1348 
1356  function passDetails()
1357  {
1358  if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
1359  {
1360  $this->ctrl->saveParameter($this, "pass");
1361  $this->ctrl->saveParameter($this, "active_id");
1362  $this->outTestResults(false, $_GET["pass"]);
1363  }
1364  else
1365  {
1366  $this->outTestResults(false);
1367  }
1368  }
1369 
1376  {
1377  if( !$this->object->getShowSolutionDetails() )
1378  {
1379  ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1380  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1381  }
1382 
1383  $testSession = $this->testSessionFactory->getSession();
1384  $activeId = $testSession->getActiveId();
1385 
1386  if( !($activeId > 0) )
1387  {
1388  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1389  }
1390 
1391  if( !$this->object->canShowTestResults($testSession, $testSession->getUserId()) )
1392  {
1393  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1394  }
1395 
1396  $this->ctrl->saveParameter($this, "pass");
1397  $pass = (int)$_GET['pass'];
1398 
1399  $testSequence = $this->testSequenceFactory->getSequenceByPass($testSession, $pass);
1400  $testSequence->loadFromDb();
1401  $testSequence->loadQuestions();
1402 
1403  $questionId = (int)$_GET['evaluation'];
1404 
1405  if( !$testSequence->questionExists($questionId) )
1406  {
1407  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1408  }
1409 
1410  global $ilTabs;
1411 
1412  $ilTabs->setBackTarget($this->lng->txt("tst_back_to_pass_details"), $this->ctrl->getLinkTarget($this, 'outUserPassDetails'));
1413 
1414  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1415  $this->tpl->setCurrentBlock("ContentStyle");
1416  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
1417  $this->tpl->parseCurrentBlock();
1418 
1419  $this->tpl->setCurrentBlock("SyntaxStyle");
1420  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
1421  $this->tpl->parseCurrentBlock();
1422 
1423  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1424  if ($this->object->getShowSolutionAnswersOnly())
1425  {
1426  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1427  }
1428 
1429  $solution = $this->getCorrectSolutionOutput($questionId, $activeId, $pass);
1430 
1431  $this->tpl->setContent($solution);
1432  }
1433 
1438  public function singleResults()
1439  {
1440  global $ilAccess;
1441 
1442  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
1443  {
1444  // allow only evaluation access
1445  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1446  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1447  }
1448 
1449  $data =& $this->object->getCompleteEvaluationData();
1450  $color_class = array("tblrow1", "tblrow2");
1451  $counter = 0;
1452  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1453  $foundParticipants =& $data->getParticipants();
1454  if (count($foundParticipants) == 0)
1455  {
1456  ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
1457  return;
1458  }
1459  else
1460  {
1461  $rows = array();
1462  foreach ($data->getQuestionTitles() as $question_id => $question_title)
1463  {
1464  $answered = 0;
1465  $reached = 0;
1466  $max = 0;
1467  foreach ($foundParticipants as $userdata)
1468  {
1469  $pass = $userdata->getScoredPass();
1470  if (is_object($userdata->getPass($pass)))
1471  {
1472  $question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1473  if (is_array($question))
1474  {
1475  $answered++;
1476  }
1477  }
1478  }
1479  $counter++;
1480  $this->ctrl->setParameter($this, "qid", $question_id);
1481  require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
1482  $question_object = assQuestion::_instanciateQuestion($question_id);
1483  $download = "";
1484  if ( $question_object instanceof ilObjFileHandlingQuestionType )
1485  {
1486  if ($question_object->hasFileUploads($this->object->getTestId()))
1487  {
1488  $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants"). "\">" . $this->lng->txt("download") . "</a>";
1489  }
1490  }
1491  array_push($rows,
1492  array(
1493  'qid' => $question_id,
1494  'question_title' => $question_title,
1495  'number_of_answers' => $answered,
1496  'output' => "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants") . "\">" . $this->lng->txt("pdf_export") . "</a>",
1497  'file_uploads' => $download
1498  )
1499  );
1500  }
1501  if (count($rows))
1502  {
1503  require_once './Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php';
1504  $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults");
1505  $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
1506  $table_gui->setData($rows);
1507 
1508  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
1509  }
1510  else
1511  {
1512  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
1513  }
1514  }
1515  }
1516 
1520  public function outCertificate()
1521  {
1522  $testSession = $this->testSessionFactory->getSession();
1523 
1524  require_once './Services/Certificate/classes/class.ilCertificate.php';
1525  require_once './Modules/Test/classes/class.ilTestCertificateAdapter.php';
1526  $certificate = new ilCertificate(new ilTestCertificateAdapter( $this->object ) );
1527  $certificate->outCertificate(
1528  array(
1529  "active_id" => $testSession->getActiveId(),
1530  "pass" => ilObjTest::_getResultPass( $testSession->getActiveId() )
1531  )
1532  );
1533  }
1534 
1535  public function confirmDeletePass()
1536  {
1537  if( !$this->object->isPassDeletionAllowed() )
1538  {
1539  $this->ctrl->redirect($this, 'outUserResultsOverview');
1540  }
1541 
1542  require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1543 
1544  if( isset($_GET['context']) && strlen($_GET['context']) )
1545  {
1546  $context = $_GET['context'];
1547  }
1548  else
1549  {
1551  }
1552 
1553  $confirm = new ilTestPassDeletionConfirmationGUI($this->ctrl, $this->lng, $this);
1554  $confirm->build((int)$_GET['active_id'], (int)$_GET['pass'], $context);
1555 
1556  global $tpl;
1557  $tpl->setContent($this->ctrl->getHTML($confirm));
1558  }
1559 
1560  public function cancelDeletePass()
1561  {
1562  $this->redirectToPassDeletionContext($_POST['context']);
1563  }
1564 
1565  private function redirectToPassDeletionContext($context)
1566  {
1567  require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1568 
1569  switch($context)
1570  {
1572 
1573  $this->ctrl->redirect($this, 'outUserResultsOverview');
1574 
1576 
1577  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
1578 
1580 
1581  $this->ctrl->redirectByClass('ilTestPlayerDynamicQuestionSetGUI', 'startTest');
1582  }
1583  }
1584 
1585  public function performDeletePass()
1586  {
1587  if( !$this->object->isPassDeletionAllowed() )
1588  {
1589  $this->ctrl->redirect($this, 'outUserResultsOverview');
1590  }
1592  global $ilDB;
1593 
1594  $active_fi = null;
1595  $pass = null;
1596 
1597  if( isset($_POST['active_id']) && (int)$_POST['active_id'] )
1598  {
1599  $active_fi = $_POST['active_id'];
1600  }
1601 
1602  if( isset($_POST['pass']) && is_numeric($_POST['pass']) )
1603  {
1604  $pass = $_POST['pass'];
1605  }
1606 
1607  if( is_null($active_fi) || is_null($pass) )
1608  {
1609  $this->ctrl->redirect($this, 'outUserResultsOverview');
1610  }
1611 
1612  if( !$this->object->isDynamicTest() && $pass == $this->object->_getResultPass($active_fi) )
1613  {
1614  $this->ctrl->redirect($this, 'outUserResultsOverview');
1615  }
1616 
1617  // Get information
1618  $result = $ilDB->query("
1619  SELECT tst_active.tries, tst_active.last_finished_pass, tst_sequence.pass
1620  FROM tst_active
1621  LEFT JOIN tst_sequence
1622  ON tst_sequence.active_fi = tst_active.active_id
1623  AND tst_sequence.pass = tst_active.tries
1624  WHERE tst_active.active_id = {$ilDB->quote($active_fi, 'integer')}
1625  ");
1626 
1627  $row = $ilDB->fetchAssoc($result);
1628 
1629  $tries = $row['tries'];
1630  $lastFinishedPass = is_numeric($row['last_finished_pass']) ? $row['last_finished_pass'] : -1;
1631 
1632  if( $pass < $lastFinishedPass )
1633  {
1634  $isActivePass = false;
1635  $must_renumber = true;
1636  }
1637  elseif( $pass == $lastFinishedPass )
1638  {
1639  $isActivePass = false;
1640 
1641  if( $tries == $row['pass'] )
1642  {
1643  $must_renumber = true;
1644  }
1645  else
1646  {
1647  $must_renumber = false;
1648  }
1649  }
1650  elseif( $pass == $row['pass'] )
1651  {
1652  $isActivePass = true;
1653  $must_renumber = false;
1654  }
1655  else
1656  {
1657  throw new ilTestException ('This should not happen, please contact Bjoern Heyser to clean up this pass salad!');
1658  }
1659 
1660  if( !$this->object->isDynamicTest() && $isActivePass )
1661  {
1662  $this->ctrl->redirect($this, 'outUserResultsOverview');
1663  }
1664 
1665  if( $pass == 0 && (
1666  ($lastFinishedPass == 0 && $tries == 1 && $tries != $row['pass'])
1667  || ($isActivePass == true) // should be equal to || ($lastFinishedPass == -1 && $tries == 0)
1668  ))
1669  {
1670  $last_pass = true;
1671  }
1672  else
1673  {
1674  $last_pass = false;
1675  }
1676 
1677  // Work on tables:
1678  // tst_active
1679  if ($last_pass)
1680  {
1681  $ilDB->manipulate(
1682  'DELETE
1683  FROM tst_active
1684  WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1685  );
1686  }
1687  elseif( !$isActivePass )
1688  {
1689  $ilDB->manipulate(
1690  'UPDATE tst_active
1691  SET tries = ' . $ilDB->quote($tries-1, 'integer') . ',
1692  last_finished_pass = ' . $ilDB->quote($lastFinishedPass-1, 'integer') . '
1693  WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1694  );
1695  }
1696  // tst_manual_fb
1697  $ilDB->manipulate(
1698  'DELETE
1699  FROM tst_manual_fb
1700  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1701  AND pass = ' . $ilDB->quote($pass, 'integer')
1702  );
1703 
1704  if ($must_renumber)
1705  {
1706  $ilDB->manipulate(
1707  'UPDATE tst_manual_fb
1708  SET pass = pass - 1
1709  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1710  AND pass > ' . $ilDB->quote($pass, 'integer')
1711  );
1712  }
1713 
1714  // tst_mark -> nothing to do
1715  //
1716  // tst_pass_result
1717  $ilDB->manipulate(
1718  'DELETE
1719  FROM tst_pass_result
1720  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1721  AND pass = ' . $ilDB->quote($pass, 'integer')
1722  );
1723 
1724  if ($must_renumber)
1725  {
1726  $ilDB->manipulate(
1727  'UPDATE tst_pass_result
1728  SET pass = pass - 1
1729  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1730  AND pass > ' . $ilDB->quote($pass, 'integer')
1731  );
1732  }
1733 
1734  // tst_qst_solved -> nothing to do
1735 
1736  // tst_rnd_copy -> nothing to do
1737  // tst_rnd_qpl_title -> nothing to do
1738 
1739  // tst_sequence
1740  $ilDB->manipulate(
1741  'DELETE
1742  FROM tst_sequence
1743  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1744  AND pass = ' . $ilDB->quote($pass, 'integer')
1745  );
1746 
1747  if ($must_renumber)
1748  {
1749  $ilDB->manipulate(
1750  'UPDATE tst_sequence
1751  SET pass = pass - 1
1752  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1753  AND pass > ' . $ilDB->quote($pass, 'integer')
1754  );
1755  }
1756 
1757  if( $this->object->isDynamicTest() )
1758  {
1759  $tables = array(
1760  'tst_seq_qst_tracking', 'tst_seq_qst_answstatus', 'tst_seq_qst_postponed', 'tst_seq_qst_checked'
1761  );
1762 
1763  foreach($tables as $table)
1764  {
1765  $ilDB->manipulate("
1766  DELETE FROM $table
1767  WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
1768  AND pass = {$ilDB->quote($pass, 'integer')}
1769  ");
1770 
1771  if( $must_renumber )
1772  {
1773  $ilDB->manipulate("
1774  UPDATE $table
1775  SET pass = pass - 1
1776  WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
1777  AND pass > {$ilDB->quote($pass, 'integer')}
1778  ");
1779  }
1780  }
1781  }
1782 
1783  // tst_solutions
1784  $ilDB->manipulate(
1785  'DELETE
1786  FROM tst_solutions
1787  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1788  AND pass = ' . $ilDB->quote($pass, 'integer')
1789  );
1790 
1791  if ($must_renumber)
1792  {
1793  $ilDB->manipulate(
1794  'UPDATE tst_solutions
1795  SET pass = pass - 1
1796  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1797  AND pass > ' . $ilDB->quote($pass, 'integer')
1798  );
1799  }
1800 
1801  // tst_test_result
1802  $ilDB->manipulate(
1803  'DELETE
1804  FROM tst_test_result
1805  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1806  AND pass = ' . $ilDB->quote($pass, 'integer')
1807  );
1808 
1809  if ($must_renumber)
1810  {
1811  $ilDB->manipulate(
1812  'UPDATE tst_test_result
1813  SET pass = pass - 1
1814  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1815  AND pass > ' . $ilDB->quote($pass, 'integer')
1816  );
1817  }
1818 
1819  // tst_test_rnd_qst -> nothing to do
1820 
1821  // tst_times
1822  $ilDB->manipulate(
1823  'DELETE
1824  FROM tst_times
1825  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1826  AND pass = ' . $ilDB->quote($pass, 'integer')
1827  );
1828 
1829  if ($must_renumber)
1830  {
1831  $ilDB->manipulate(
1832  'UPDATE tst_times
1833  SET pass = pass - 1
1834  WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1835  AND pass > ' . $ilDB->quote($pass, 'integer')
1836  );
1837  }
1838 
1839  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
1841  {
1842  $this->object->logAction($this->lng->txtlng("assessment", "log_deleted_pass", ilObjAssessmentFolder::_getLogLanguage()));
1843  }
1844  // tst_result_cache
1845  // Ggfls. nur renumbern.
1846  require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
1848 
1849  if( $this->object->isDynamicTest() )
1850  {
1851  require_once 'Modules/Test/classes/tables/class.ilTestDynamicQuestionSetStatisticTableGUI.php';
1853  }
1854 
1855  $this->redirectToPassDeletionContext($_POST['context']);
1856  }
1857 
1858  protected function getFilteredTestResult($active_id, $pass)
1859  {
1860  global $ilDB, $ilPluginAdmin;
1861 
1862  $testResults = $this->object->getTestResult($active_id, $pass);
1863  $questionIds = array();
1864  foreach($testResults as $resultItemKey => $resultItemValue)
1865  {
1866  if($resultItemKey === 'test' || $resultItemKey === 'pass')
1867  {
1868  continue;
1869  }
1870 
1871  $questionIds[] = $resultItemValue['qid'];
1872  }
1873 
1874  $table_gui = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1875  $table_gui->initFilter();
1876 
1877  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
1878  $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin, null);
1879  $questionList->setQuestionIdsFilter($questionIds);
1880  $questionList->setQuestionInstanceTypeFilter(null);
1881 
1882  foreach ($table_gui->getFilterItems() as $item)
1883  {
1884  if( substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_' )
1885  {
1886  $v = $item->getValue();
1887 
1888  if( is_array($v) && count($v) && !(int)$v[0] )
1889  {
1890  continue;
1891  }
1892 
1893  $taxId = substr($item->getPostVar(), strlen('tax_'));
1894  $questionList->addTaxonomyFilter($taxId, $item->getValue());
1895  }
1896  elseif( $item->getValue() !== false )
1897  {
1898  $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
1899  }
1900  }
1901 
1902  $questionList->load();
1903 
1904  $filteredTestResult = array();
1905 
1906  foreach($testResults as $resultItemKey => $resultItemValue)
1907  {
1908  if($resultItemKey === 'test' || $resultItemKey === 'pass')
1909  {
1910  continue;
1911  }
1912 
1913  if( !$questionList->isInList($resultItemValue['qid']) )
1914  {
1915  continue;
1916  }
1917 
1918  $filteredTestResult[] = $resultItemValue;
1919  }
1920 
1921  return $filteredTestResult;
1922  }
1923 }