ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once './Modules/Test/classes/class.ilTestServiceGUI.php';
5require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
6
27{
32
41 public function __construct(ilObjTest $a_object)
42 {
43 parent::__construct($a_object);
44
45 global $DIC; /* @var ILIAS\DI\Container $DIC */
46
47 require_once 'Modules/Test/classes/class.ilTestProcessLockerFactory.php';
48 $this->processLockerFactory = new ilTestProcessLockerFactory(
49 new ilSetting('assessment'), $DIC->database()
50 );
51 }
52
56 public function executeCommand()
57 {
58 $cmd = $this->ctrl->getCmd();
59 $next_class = $this->ctrl->getNextClass($this);
60 $this->ctrl->saveParameter($this, "sequence");
61 $this->ctrl->saveParameter($this, "active_id");
62 $cmd = $this->getCommand($cmd);
63 switch($next_class)
64 {
65 case 'iltestpassdetailsoverviewtablegui':
66 require_once 'Modules/Test/classes/tables/class.ilTestPassDetailsOverviewTableGUI.php';
67 $tableGUI = new ilTestPassDetailsOverviewTableGUI($this->ctrl, $this, 'outUserPassDetails');
68 $tableGUI->setIsPdfGenerationRequest($this->isPdfDeliveryRequest());
69 $tableGUI->initFilter();
70 $this->ctrl->forwardCommand($tableGUI);
71 break;
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->getECTSOutput())
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->getECTSOutput())
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 {
163 global $ilAccess, $ilToolbar;
164
165 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
166 {
167 // allow only evaluation access
168 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
169 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
170 }
171
172 include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
173
174 $table_gui = new ilEvaluationAllTableGUI(
175 $this, 'outEvaluation', $this->object->getAnonymity(), $this->object->isOfferingQuestionHintsEnabled()
176 );
177
178 $data = array();
179 $arrFilter = array();
180
181 foreach ($table_gui->getFilterItems() as $item)
182 {
183 if ($item->getValue() !== false)
184 {
185 switch ($item->getPostVar())
186 {
187 case 'group':
188 case 'name':
189 case 'course':
190 $arrFilter[$item->getPostVar()] = $item->getValue();
191 break;
192 case 'passed_only':
193 $passedonly = $item->getChecked();
194 break;
195 }
196 }
197 }
198 include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
199 $eval = new ilTestEvaluationData($this->object);
200 $eval->setFilterArray($arrFilter);
201 $foundParticipants =& $eval->getParticipants();
202 $counter = 1;
203 if (count($foundParticipants) > 0)
204 {
205 if ($this->object->getECTSOutput())
206 {
207 $passed_array =& $this->object->getTotalPointsPassedArray();
208 }
209 foreach ($foundParticipants as $active_id => $userdata)
210 {
211 /* @var $userdata ilTestEvaluationUserData */
212
213 $remove = FALSE;
214 if ($passedonly)
215 {
216 $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent());
217
218 if( $mark_obj->getPassed() == FALSE || !$userdata->areObligationsAnswered() )
219 {
220 $remove = TRUE;
221 }
222 }
223 if (!$remove)
224 {
225 // build the evaluation row
226 $evaluationrow = array();
227 if ($this->object->getAnonymity())
228 {
229 $evaluationrow['name'] = $counter;
230 $evaluationrow['login'] = '';
231 }
232 else
233 {
234 $evaluationrow['name'] = $userdata->getName();
235 if (strlen($userdata->getLogin()))
236 {
237 $evaluationrow['login'] = "[" . $userdata->getLogin() . "]";
238 }
239 else
240 {
241 $evaluationrow['login'] = '';
242 }
243 }
244
245 $evaluationrow['reached'] = $userdata->getReached();
246 $evaluationrow['max'] = $userdata->getMaxpoints();
247 $evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass();
248 $percentage = $userdata->getReachedPointsInPercent();
249 $mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
250 if (is_object($mark))
251 {
252 $evaluationrow['mark'] = $mark->getShortName();
253 }
254 if ($this->object->getECTSOutput())
255 {
256 $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints());
257 $evaluationrow['ects_grade'] = $ects_mark;
258 }
259 $evaluationrow['answered'] = $userdata->getQuestionsWorkedThroughInPercent();
260 $evaluationrow['questions_worked_through'] = $userdata->getQuestionsWorkedThrough();
261 $evaluationrow['number_of_questions'] = $userdata->getNumberOfQuestions();
262 $time_seconds = $userdata->getTimeOfWork();
263 $time_hours = floor($time_seconds/3600);
264 $time_seconds -= $time_hours * 3600;
265 $time_minutes = floor($time_seconds/60);
266 $time_seconds -= $time_minutes * 60;
267 $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
268 $this->ctrl->setParameter($this, "active_id", $active_id);
269 $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
270 $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
271 $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>";
272 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
273 $evaluationrow['gender'] = $userfields['gender'];
274 $evaluationrow['email'] = $userfields['email'];
275 $evaluationrow['institution'] = $userfields['institution'];
276 $evaluationrow['street'] = $userfields['street'];
277 $evaluationrow['city'] = $userfields['city'];
278 $evaluationrow['zipcode'] = $userfields['zipcode'];
279 $evaluationrow['country'] = $userfields['country'];
280 $evaluationrow['sel_country'] = $userfields['sel_country'];
281 $evaluationrow['department'] = $userfields['department'];
282 $evaluationrow['matriculation'] = $userfields['matriculation'];
283 $counter++;
284 $data[] = $evaluationrow;
285 }
286 }
287 }
288
289 $table_gui->setData($data);
290 if(count($foundParticipants) > 0)
291 {
292 $ilToolbar->setFormName('form_output_eval');
293 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportEvaluation'));
294 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
295 $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
296 $options = array(
297 'excel' => $this->lng->txt('exp_type_excel'),
298 'csv' => $this->lng->txt('exp_type_spss')
299 );
300
301 if(!$this->object->getAnonymity())
302 {
303 include_once 'Services/Certificate/classes/class.ilCertificate.php';
304 include_once 'Modules/Test/classes/class.ilTestCertificateAdapter.php';
306 {
307 $options['certificate'] = $this->lng->txt('exp_type_certificate');
308 }
309 }
310
311 $export_type->setOptions($options);
312
313 $ilToolbar->addInputItem($export_type, true);
314 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
315 $button = ilSubmitButton::getInstance();
316 $button->setCommand('exportEvaluation');
317 $button->setCaption('export');
318 $button->getOmitPreventDoubleSubmission();
319 $ilToolbar->addButtonInstance($button);
320 }
321
322 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
323 if ($this->object->getShowSolutionAnswersOnly())
324 {
325 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
326 }
327
328 $this->tpl->setContent($table_gui->getHTML());
329 }
330
339 {
340 global $DIC;
341
342 if((!$DIC->access()->checkAccess('tst_statistics', '', $this->ref_id)) && (!$DIC->access()->checkAccess('write', '', $this->ref_id)))
343 {
344 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), TRUE);
345 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
346 }
347
348 $active_id = $_GET['active_id'];
349 if(strlen($active_id) == 0)
350 {
351 ilUtil::sendInfo($this->lng->txt('detailed_evaluation_missing_active_id'), TRUE);
352 $this->ctrl->redirect($this, 'outEvaluation');
353 }
354
355 $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print');
356
357 $toolbar = $DIC['ilToolbar'];
358
359 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
360 $backBtn = ilLinkButton::getInstance();
361 $backBtn->setCaption('back');
362 $backBtn->setUrl($this->ctrl->getLinkTarget($this, 'outEvaluation'));
363 $toolbar->addInputItem($backBtn);
364
365 $data =& $this->object->getCompleteEvaluationData();
366
367 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
368 $form = new ilPropertyFormGUI();
369 $form->setTitle(sprintf(
370 $this->lng->txt('detailed_evaluation_for'), $data->getParticipant($active_id)->getName()
371 ));
372
373 $resultPoints = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_resultspoints'));
374 $resultPoints->setValue($data->getParticipant($active_id)->getReached() . " " . strtolower($this->lng->txt("of")) . " " . $data->getParticipant($active_id)->getMaxpoints() . " (" . sprintf("%2.2f", $data->getParticipant($active_id)->getReachedPointsInPercent()) . " %" . ")");
375 $form->addItem($resultPoints);
376
377 if(strlen($data->getParticipant($active_id)->getMark()))
378 {
379 $resultMarks = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_resultsmarks'));
380 $resultMarks->setValue($data->getParticipant($active_id)->getMark());
381 $form->addItem($resultMarks);
382 if(strlen($data->getParticipant($active_id)->getECTSMark()))
383 {
384 $ectsGrade = new ilNonEditableValueGUI($this->lng->txt('ects_grade'));
385 $ectsGrade->setValue($data->getParticipant($active_id)->getECTSMark());
386 $form->addItem($ectsGrade);
387 }
388 }
389
390 if($this->object->isOfferingQuestionHintsEnabled() )
391 {
392 $requestHints = new ilNonEditableValueGUI($this->lng->txt('tst_question_hints_requested_hint_count_header'));
393 $requestHints->setValue($data->getParticipant($active_id)->getRequestedHintsCountFromScoredPass());
394 $form->addItem($requestHints);
395 }
396
397 $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
398 $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
399 $time_hours = floor($time_seconds/3600);
400 $time_seconds -= $time_hours * 3600;
401 $time_minutes = floor($time_seconds/60);
402 $time_seconds -= $time_minutes * 60;
403 $timeOfWork = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_timeofwork'));
404 $timeOfWork->setValue(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
405 $form->addItem($timeOfWork);
406
407 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt(""));
408 $time_hours = floor($atime_seconds/3600);
409 $atime_seconds -= $time_hours * 3600;
410 $time_minutes = floor($atime_seconds/60);
411 $atime_seconds -= $time_minutes * 60;
412 $avgTimeOfWork = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_atimeofwork'));
413 $avgTimeOfWork->setValue(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
414 $form->addItem($avgTimeOfWork);
415
416 $firstVisit = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_firstvisit'));
417 $firstVisit->setValue(ilDatePresentation::formatDate(new ilDateTime($data->getParticipant($active_id)->getFirstVisit(),IL_CAL_UNIX)));
418 $form->addItem($firstVisit);
419
420 $lastVisit = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_lastvisit'));
421 $lastVisit->setValue(ilDatePresentation::formatDate(new ilDateTime($data->getParticipant($active_id)->getLastVisit(),IL_CAL_UNIX)));
422 $form->addItem($lastVisit);
423
424 $nrPasses = new ilNonEditableValueGUI($this->lng->txt('tst_nr_of_passes'));
425 $nrPasses->setValue($data->getParticipant($active_id)->getLastPass() + 1);
426 $form->addItem($nrPasses);
427
428 $scoredPass = new ilNonEditableValueGUI($this->lng->txt('scored_pass'));
429 if($this->object->getPassScoring() == SCORE_BEST_PASS)
430 {
431 $scoredPass->setValue($data->getParticipant($active_id)->getBestPass() + 1);
432 }
433 else
434 {
435 $scoredPass->setValue($data->getParticipant($active_id)->getLastPass() + 1);
436 }
437 $form->addItem($scoredPass);
438
439 $median = $data->getStatistics()->getStatistics()->median();
440 $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
441 $mark = $this->object->mark_schema->getMatchingMark($pct);
442 if(is_object($mark))
443 {
444 $markMedian = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_mark_median'));
445 $markMedian->setValue($mark->getShortName());
446 $form->addItem($markMedian);
447 }
448
449 $rankParticipant = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_rank_participant'));
450 $rankParticipant->setValue($data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
451 $form->addItem($rankParticipant);
452
453 $rankMedian = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_rank_median'));
454 $rankMedian->setValue($data->getStatistics()->getStatistics()->rank_median());
455 $form->addItem($rankMedian);
456
457 $totalParticipants = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_total_participants'));
458 $totalParticipants->setValue($data->getStatistics()->getStatistics()->count());
459 $form->addItem($totalParticipants);
460
461 $medianField = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_median'));
462 $medianField->setValue($median);
463 $form->addItem($medianField);
464
465 $this->tpl->setContent($form->getHTML());
466
467 $tables = array();
468
469 for($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
470 {
471 $finishdate = $this->object->getPassFinishDate($active_id, $pass);
472 if($finishdate > 0)
473 {
474 if(($DIC->access()->checkAccess('write', '', (int)$_GET['ref_id'])))
475 {
476 $this->ctrl->setParameter($this, 'statistics', '1');
477 $this->ctrl->setParameter($this, 'active_id', $active_id);
478 $this->ctrl->setParameter($this, 'pass', $pass);
479 }
480 else
481 {
482 $this->ctrl->setParameter($this, 'statistics', '');
483 $this->ctrl->setParameter($this, 'active_id', '');
484 $this->ctrl->setParameter($this, 'pass', '');
485 }
486
487 require_once 'Modules/Test/classes/tables/class.ilTestDetailedEvaluationStatisticsTableGUI.php';
488 $table = new ilTestDetailedEvaluationStatisticsTableGUI($this, 'detailedEvaluation', ($pass + 1). '_' . $this->object->getId());
489 $table->setTitle(sprintf($this->lng->txt("tst_eval_question_points"), $pass + 1));
490 if(($DIC->access()->checkAccess('write', '', (int)$_GET['ref_id'])))
491 {
492 $table->addCommandButton('outParticipantsPassDetails', $this->lng->txt('tst_show_answer_sheet'));
493 }
494
495 $questions = $data->getParticipant($active_id)->getQuestions($pass);
496 if(!is_array($questions))
497 {
498 $questions = $data->getParticipant($active_id)->getQuestions(0);
499 }
500
501 $tableData = array();
502
503 $counter = 0;
504 foreach((array)$questions as $question)
505 {
506 $userDataData = array(
507 'counter' => ++$counter,
508 'id' => $question['id'],
509 'id_txt' => $this->lng->txt('question_id_short'),
510 'title' => $data->getQuestionTitle($question['id'])
511 );
512
513 $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
514 if(is_array($answeredquestion))
515 {
516 $percent = $answeredquestion['points'] ? $answeredquestion['reached'] / $answeredquestion['points'] * 100.0 : 0;
517 $userDataData['points'] = $answeredquestion['reached'] . ' ' . strtolower($this->lng->txt('of')) . " " . $answeredquestion['points'] . ' (' . sprintf("%.2f", $percent) . ' %)';
518 }
519 else
520 {
521 $userDataData['points'] = '0 ' . strtolower($this->lng->txt('of')) . ' ' . $question['points'] . ' (' . sprintf("%.2f", 0) . ' %) - ' . $this->lng->txt('question_not_answered');
522 }
523
524 $tableData[] = $userDataData;
525 }
526 $table->setData($tableData);
527
528 $tables[] = $table->getHTML();
529 }
530 }
531
532 $GLOBALS['tpl']->setContent($form->getHTML() . implode('', $tables));
533 }
534
540 {
541 $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
542 }
543
549 {
550 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
551 $question_object = assQuestion::_instanciateQuestion($_GET["qid"]);
552 if ( $question_object instanceof ilObjFileHandlingQuestionType )
553 {
554 $question_object->deliverFileUploadZIPFile($this->object->getTestId(), $this->object->getTitle());
555 }
556 else
557 {
558 $this->ctrl->redirect($this, "singleResults");
559 }
560 }
561
569 function eval_a()
570 {
575 global $ilAccess, $ilToolbar;
576
577 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
578 {
579 // allow only evaluation access
580 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
581 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
582 }
583
584 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
585 $eval =& $this->object->getCompleteEvaluationData();
586 $data = array();
587 $foundParticipants =& $eval->getParticipants();
588 if (count($foundParticipants))
589 {
590 $ilToolbar->setFormName('form_output_eval');
591 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportAggregatedResults'));
592 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
593 $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
594 $export_type->setOptions(array(
595 'excel' => $this->lng->txt('exp_type_excel'),
596 'csv' => $this->lng->txt('exp_type_spss')
597 ));
598 $ilToolbar->addInputItem($export_type, true);
599 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
600 $button = ilSubmitButton::getInstance();
601 $button->setCommand('exportAggregatedResults');
602 $button->setCaption('export');
603 $button->getOmitPreventDoubleSubmission();
604 $ilToolbar->addButtonInstance($button);
605
606 array_push($data, array(
607 'result' => $this->lng->txt("tst_eval_total_persons"),
608 'value' => count($foundParticipants)
609 ));
610 $total_finished = $this->object->evalTotalFinished();
611 array_push($data, array(
612 'result' => $this->lng->txt("tst_eval_total_finished"),
613 'value' => $total_finished
614 ));
615 $average_time = $this->object->evalTotalStartedAverageTime();
616 $diff_seconds = $average_time;
617 $diff_hours = floor($diff_seconds/3600);
618 $diff_seconds -= $diff_hours * 3600;
619 $diff_minutes = floor($diff_seconds/60);
620 $diff_seconds -= $diff_minutes * 60;
621 array_push($data, array(
622 'result' => $this->lng->txt("tst_eval_total_finished_average_time"),
623 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
624 ));
625 $total_passed = 0;
626 $total_passed_reached = 0;
627 $total_passed_max = 0;
628 $total_passed_time = 0;
629 foreach ($foundParticipants as $userdata)
630 {
631 if ($userdata->getPassed())
632 {
633 $total_passed++;
634 $total_passed_reached += $userdata->getReached();
635 $total_passed_max += $userdata->getMaxpoints();
636 $total_passed_time += $userdata->getTimeOfWork();
637 }
638 }
639 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
640 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
641 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
642 array_push($data, array(
643 'result' => $this->lng->txt("tst_eval_total_passed"),
644 'value' => $total_passed
645 ));
646 array_push($data, array(
647 'result' => $this->lng->txt("tst_eval_total_passed_average_points"),
648 'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)
649 ));
650 $average_time = $average_passed_time;
651 $diff_seconds = $average_time;
652 $diff_hours = floor($diff_seconds/3600);
653 $diff_seconds -= $diff_hours * 3600;
654 $diff_minutes = floor($diff_seconds/60);
655 $diff_seconds -= $diff_minutes * 60;
656 array_push($data, array(
657 'result' => $this->lng->txt("tst_eval_total_passed_average_time"),
658 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
659 ));
660 }
661
662 include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
663 $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
664 $table_gui->setData($data);
665 $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
666
667 $rows = array();
668 foreach ($eval->getQuestionTitles() as $question_id => $question_title)
669 {
670 $answered = 0;
671 $reached = 0;
672 $max = 0;
673 foreach ($foundParticipants as $userdata)
674 {
675 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
676 {
677 if (is_object($userdata->getPass($i)))
678 {
679 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
680 if (is_array($question))
681 {
682 $answered++;
683 $reached += $question["reached"];
684 $max += $question["points"];
685 }
686 }
687 }
688 }
689 $percent = $max ? $reached/$max * 100.0 : 0;
690 $counter++;
691 $this->ctrl->setParameter($this, "qid", $question_id);
692
693 $points_reached = ($answered ? $reached / $answered : 0);
694 $points_max = ($answered ? $max / $answered : 0);
695 array_push($rows,
696 array(
697 'qid' => $question_id,
698 'title' => $question_title,
699 'points' => $points_reached,
700 'points_reached' => $points_reached,
701 'points_max' => $points_max,
702 'percentage' => (float)$percent,
703 'answers' => $answered
704 )
705 );
706 }
707 include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
708 $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
709 $table_gui->setData($rows);
710 $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
711 }
712
716 public function exportEvaluation()
717 {
718 $filterby = "";
719 if (array_key_exists("g_filterby", $_GET))
720 {
721 $filterby = $_GET["g_filterby"];
722 }
723
724 $filtertext = "";
725 if (array_key_exists("g_userfilter", $_GET))
726 {
727 $filtertext = $_GET["g_userfilter"];
728 }
729
730 $passedonly = FALSE;
731 if (array_key_exists("g_passedonly", $_GET))
732 {
733 if ($_GET["g_passedonly"] == 1)
734 {
735 $passedonly = TRUE;
736 }
737 }
738
739 require_once 'Modules/Test/classes/class.ilTestExportFactory.php';
740 $expFactory = new ilTestExportFactory($this->object);
741
742 switch ($_POST["export_type"])
743 {
744 case "excel":
745 $expFactory->getExporter('results')->exportToExcel(
746 $deliver = TRUE, $filterby, $filtertext, $passedonly
747 );
748 break;
749
750 case "csv":
751 $expFactory->getExporter('results')->exportToCSV(
752 $deliver = TRUE, $filterby, $filtertext, $passedonly
753 );
754 break;
755
756 case "certificate":
757 if ($passedonly)
758 {
759 $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
760 }
761 if (strlen($filtertext))
762 {
763 $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
764 }
765 $this->ctrl->redirect($this, "exportCertificate");
766 break;
767 }
768 }
769
776 {
777 require_once 'Modules/Test/classes/class.ilTestExportFactory.php';
778 $expFactory = new ilTestExportFactory($this->object);
779 $exportObj = $expFactory->getExporter('aggregated');
780
781 switch ($_POST["export_type"])
782 {
783 case "excel":
784 $exportObj->exportToExcel($deliver = TRUE);
785 break;
786 case "csv":
787 $exportObj->exportToCSV($deliver = TRUE);
788 break;
789 }
790 }
791
798 public function exportCertificate()
799 {
800 global $ilUser;
801
802 include_once "./Services/Utilities/classes/class.ilUtil.php";
803 include_once "./Services/Certificate/classes/class.ilCertificate.php";
804 include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
805 $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
806 $archive_dir = $certificate->createArchiveDirectory();
807 $total_users = array();
808 $total_users =& $this->object->evalTotalPersonsArray();
809 if (count($total_users))
810 {
811 foreach ($total_users as $active_id => $name)
812 {
813 $user_id = $this->object->_getUserIdFromActiveId($active_id);
814 $pdf = $certificate->outCertificate(
815 array(
816 "active_id" => $active_id,
817 "userfilter" => $userfilter,
818 "passedonly" => $passedonly
819 ),
820 FALSE
821 );
822 if (strlen($pdf))
823 {
824 $certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
825 }
826 }
827 $zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, TRUE);
828 }
829
830 }
831
838 function getEvaluationQuestionId($question_id, $original_id = "")
839 {
840 if ($original_id > 0)
841 {
842 return $original_id;
843 }
844 else
845 {
846 return $question_id;
847 }
848 }
849
858 {
859 global $ilTabs, $ilAccess, $ilObjDataCache;
860
861 if (!$ilAccess->checkAccess('write', '', $this->ref_id))
862 {
863 // allow only write access
864 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
865 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
866 }
867
868 $this->ctrl->saveParameter($this, "active_id");
869 $active_id = (int)$_GET["active_id"];
870 $testSession = $this->testSessionFactory->getSession($active_id);
871
872 // protect actives from other tests
873 if( $testSession->getTestId() != $this->object->getTestId() )
874 {
875 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
876 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
877 }
878
879 $this->ctrl->saveParameter($this, "pass");
880 $pass = (int)$_GET["pass"];
881
882 if ( isset($_GET['statistics']) && $_GET['statistics'] == 1)
883 {
884 $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
885 $this->ctrl->saveParameter($this, 'statistics');
886
887 $ilTabs->setBackTarget(
888 $this->lng->txt('back'), $this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'detailedEvaluation')
889 );
890 }
891 elseif ($this->object->getNrOfTries() == 1)
892 {
893 $ilTabs->setBackTarget(
894 $this->lng->txt('back'), $this->ctrl->getLinkTargetByClass('ilobjtestgui', 'participants')
895 );
896 }
897 else
898 {
899 $ilTabs->setBackTarget(
900 $this->lng->txt('tst_results_back_overview'), $this->ctrl->getLinkTarget($this, 'outParticipantsResultsOverview')
901 );
902 }
903
904 // prepare generation before contents are processed (for mathjax)
905 if ($this->isPdfDeliveryRequest())
906 {
907 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
909 }
910
911 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
912 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
913
914 $objectivesList = null;
915
916 if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
917 {
918 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
919 $testSequence->loadFromDb();
920 $testSequence->loadQuestions();
921
922 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
923 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
924
925 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
926 $objectivesList->loadObjectivesTitles();
927
928 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
929 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
930 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
931 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
932 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
933 }
934
935 $result_array = $this->object->getTestResult(
936 $active_id, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
937 );
938
939 $overviewTableGUI = $this->getPassDetailsOverviewTableGUI($result_array, $active_id, $pass, $this, "outParticipantsPassDetails", '', true, $objectivesList);
940 $overviewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
941 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, FALSE);
942 $user_id = $this->object->_getUserIdFromActiveId($active_id);
943
944 $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", TRUE, TRUE, "Modules/Test");
945
946 $toolbar = $this->buildUserTestResultsToolbarGUI();
947
948 $this->ctrl->setParameter($this, 'pdf', '1');
949 $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails') );
950 $this->ctrl->setParameter($this, 'pdf', '');
951
952 if( isset($_GET['show_best_solutions']) )
953 {
954 $_SESSION['tst_results_show_best_solutions'] = true;
955 }
956 elseif( isset($_GET['hide_best_solutions']) )
957 {
958 $_SESSION['tst_results_show_best_solutions'] = false;
959 }
960 elseif( !isset($_SESSION['tst_results_show_best_solutions']) )
961 {
962 $_SESSION['tst_results_show_best_solutions'] = false;
963 }
964
965 if( $_SESSION['tst_results_show_best_solutions'] )
966 {
967 $this->ctrl->setParameter($this, 'hide_best_solutions', '1');
968 $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
969 $this->ctrl->setParameter($this, 'hide_best_solutions', '');
970 }
971 else
972 {
973 $this->ctrl->setParameter($this, 'show_best_solutions', '1');
974 $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
975 $this->ctrl->setParameter($this, 'show_best_solutions', '');
976 }
977
978 $toolbar->build();
979 $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
980
981 if( $this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1 )
982 {
983 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
984 $gradingMessageBuilder->buildList();
985
986 $template->setCurrentBlock('grading_message');
987 $template->setVariable('GRADING_MESSAGE', $gradingMessageBuilder->getList());
988 $template->parseCurrentBlock();
989 }
990
991 $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, $_SESSION['tst_results_show_best_solutions'], false, false, false, true, $objectivesList, $testResultHeaderLabelBuilder);
992 $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
993 $template->setVariable("PASS_DETAILS", $this->ctrl->getHTML($overviewTableGUI));
994
995 if( !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
996 {
997 $template->setVariable("USER_DATA", $user_data);
998
999 $uname = $this->object->userLookupFullName($user_id);
1000 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1001
1002 $template->setVariable("TEXT_RESULTS", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
1003 }
1004
1005 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1006
1007 $this->populatePassFinishDate($template, $this->object->getPassFinishDate($active_id, $pass));
1008
1009 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1010 if ($this->object->getShowSolutionAnswersOnly())
1011 {
1012 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1013 }
1014
1015 if( $this->isPdfDeliveryRequest() )
1016 {
1017 //$this->object->deliverPDFfromHTML($template->get());
1018 require_once 'class.ilTestPDFGenerator.php';
1019 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant());
1020 }
1021 else
1022 {
1023 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1024 }
1025 }
1026
1033 {
1034 global $ilTabs, $ilAccess, $ilObjDataCache;
1035
1036 if (!$ilAccess->checkAccess('write', '', $this->ref_id))
1037 {
1038 // allow only write access
1039 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
1040 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
1041 }
1042
1043 $active_id = (int)$_GET["active_id"];
1044 $testSession = $this->testSessionFactory->getSession($active_id);
1045
1046 // protect actives from other tests
1047 if( $testSession->getTestId() != $this->object->getTestId() )
1048 {
1049 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
1050 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
1051 }
1052
1053 if ($this->object->getNrOfTries() == 1)
1054 {
1055 $this->ctrl->setParameter($this, "active_id", $active_id);
1056 $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
1057 $this->ctrl->redirect($this, "outParticipantsPassDetails");
1058 }
1059
1060 $ilTabs->setBackTarget(
1061 $this->lng->txt('back'), $this->ctrl->getLinkTargetByClass('ilobjtestgui', 'participants')
1062 );
1063
1064 // prepare generation before contents are processed (for mathjax)
1065 if ($this->isPdfDeliveryRequest())
1066 {
1067 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
1069 }
1070
1071 $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", TRUE, TRUE, "Modules/Test");
1072
1073 $toolbar = $this->buildUserTestResultsToolbarGUI();
1074
1075 $this->ctrl->setParameter($this, 'pdf', '1');
1076 $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, __FUNCTION__) );
1077 $this->ctrl->setParameter($this, 'pdf', '');
1078
1079 $toolbar->build();
1080 $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1081
1082 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1083 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1084 if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1085 {
1086 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1087 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1088 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1089 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1090 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1091 }
1092
1093 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1094 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
1095 $testPassesSelector->setActiveId($testSession->getActiveId());
1096 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1097
1098 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this, 'outParticipantsResultsOverview');
1099 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1100 $passOverViewTableGUI->setResultPresentationEnabled(true);
1101 $passOverViewTableGUI->setPassDetailsCommand('outParticipantsPassDetails');
1102 $passOverViewTableGUI->init();
1103 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getExistingPasses(), true, true));
1104 $passOverViewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassOverviewHeaderLabel());
1105 $template->setVariable("PASS_OVERVIEW", $passOverViewTableGUI->getHTML());
1106
1107 if( $this->isGradingMessageRequired() )
1108 {
1109 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1110 $gradingMessageBuilder->buildList();
1111
1112 $template->setCurrentBlock('grading_message');
1113 $template->setVariable('GRADING_MESSAGE', $gradingMessageBuilder->getList());
1114 $template->parseCurrentBlock();
1115 }
1116
1117 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, TRUE);
1118 $user_id = $this->object->_getUserIdFromActiveId($active_id);
1119
1120 if( !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1121 {
1122 if ($this->object->getAnonymity())
1123 {
1124 $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1125 }
1126 else
1127 {
1128 $uname = $this->object->userLookupFullName($user_id, TRUE);
1129 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1130 $template->setVariable("USER_DATA", $user_data);
1131 }
1132 }
1133
1134 $template->parseCurrentBlock();
1135
1136
1137 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1138 if ($this->object->getShowSolutionAnswersOnly())
1139 {
1140 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1141 }
1142
1143 if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1144 {
1145 //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1146
1147 $name = ilObjUser::_lookupName($user_id);
1148 $filename = $name['lastname'] . '_' . $name['firstname'] . '_' . $name['login'] . '__'. $this->object->getTitleFilenameCompliant();
1149 require_once 'class.ilTestPDFGenerator.php';
1151 //ilUtil::deliverData($file, ilUtil::getASCIIFilename($this->object->getTitle()) . ".pdf", "application/pdf", false, true);
1152 //$template->setVariable("PDF_FILE_LOCATION", $filename);
1153 }
1154 else
1155 {
1156 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1157 }
1158 }
1159
1161 {
1162 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1163 $tableGUI->initFilter();
1164 $tableGUI->resetOffset();
1165 $tableGUI->writeFilterToSession();
1166 $this->outUserPassDetails();
1167 }
1168
1170 {
1171 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1172 $tableGUI->initFilter();
1173 $tableGUI->resetOffset();
1174 $tableGUI->resetFilter();
1175 $this->outUserPassDetails();
1176 }
1177
1184 {
1185 global $ilTabs, $ilUser, $ilObjDataCache;
1186
1187 $this->handleTabs('results_pass_oriented');
1188
1189 if ($this->object->getNrOfTries() == 1)
1190 {
1191 $ilTabs->setBackTarget($this->lng->txt('tst_results_back_introduction'), $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen'));
1192 }
1193 else
1194 {
1195 $ilTabs->setBackTarget($this->lng->txt('tst_results_back_overview'), $this->ctrl->getLinkTarget($this, 'outUserResultsOverview'));
1196 }
1197
1198 $testSession = $this->testSessionFactory->getSession();
1199
1200 if( !$this->object->getShowPassDetails() )
1201 {
1202 #$executable = $this->object->isExecutable($testSession, $ilUser->getId());
1203
1204 #if($executable["executable"])
1205 #{
1206 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1207 #}
1208 }
1209
1210 $active_id = $testSession->getActiveId();
1211 $user_id = $testSession->getUserId();
1212
1213 $this->ctrl->saveParameter($this, "pass");
1214 $pass = $_GET["pass"];
1215
1216 // prepare generation before contents are processed (for mathjax)
1217 if ($this->isPdfDeliveryRequest())
1218 {
1219 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
1221 }
1222
1223 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1224 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1225
1226 $objectivesList = null;
1227
1228 $considerHiddenQuestions = true;
1229 $considerOptionalQuestions = true;
1230
1231 if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1232 {
1233 $considerHiddenQuestions = false;
1234
1235 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
1236 $testSequence->loadFromDb();
1237 $testSequence->loadQuestions();
1238
1239 if( $this->object->isRandomTest() && !$testSequence->isAnsweringOptionalQuestionsConfirmed() )
1240 {
1241 $considerOptionalQuestions = false;
1242 }
1243
1244 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
1245 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
1246
1247 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
1248 $objectivesList->loadObjectivesTitles();
1249
1250 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1251 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1252 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1253 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1254 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1255 }
1256
1257 $result_array = $this->getFilteredTestResult($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions);
1258
1259 $command_solution_details = "";
1260 if ($this->object->getShowSolutionDetails())
1261 {
1262 $command_solution_details = "outCorrectSolution";
1263 }
1264 $questionAnchorNav = $this->object->canShowSolutionPrintview();
1265
1266 $tpl = new ilTemplate('tpl.il_as_tst_pass_details_overview_participants.html', true, true, "Modules/Test");
1267
1268 if( !$this->isPdfDeliveryRequest() )
1269 {
1270 $toolbar = $this->buildUserTestResultsToolbarGUI();
1271
1272 $this->ctrl->setParameter($this, 'pdf', '1');
1273 $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, 'outUserPassDetails') );
1274 $this->ctrl->setParameter($this, 'pdf', '');
1275
1276 include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1277 if( $this->object->canShowCertificate($testSession, $user_id, $active_id) )
1278 {
1279 $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1280 }
1281
1282 $toolbar->build();
1283
1284 $tpl->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1285
1286 $tpl->setCurrentBlock('signature');
1287 $tpl->setVariable("SIGNATURE", $this->getResultsSignature());
1288 $tpl->parseCurrentBlock();
1289
1290 if ($this->object->isShowExamIdInTestResultsEnabled())
1291 {
1292 $tpl->setCurrentBlock('exam_id');
1293 $tpl->setVariable('EXAM_ID', ilObjTest::lookupExamId(
1294 $testSession->getActiveId(), $pass
1295 ));
1296 $tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1297 $tpl->parseCurrentBlock();
1298 }
1299 }
1300
1301 if( !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() &&
1302 $this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1 )
1303 {
1304 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1305 $gradingMessageBuilder->buildMessage();
1306 $gradingMessageBuilder->sendMessage();
1307
1308 #$template->setCurrentBlock('grading_message');
1309 #$template->setVariable('GRADING_MESSAGE', );
1310 #$template->parseCurrentBlock();
1311 }
1312
1313 $overviewTableGUI = $this->getPassDetailsOverviewTableGUI(
1314 $result_array, $active_id, $pass, $this, "outUserPassDetails",
1315 $command_solution_details, $questionAnchorNav, $objectivesList
1316 );
1317 $overviewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
1318 $tpl->setVariable("PASS_DETAILS", $this->ctrl->getHTML($overviewTableGUI));
1319
1320 if( $this->object->canShowSolutionPrintview() )
1321 {
1322 $list_of_answers = $this->getPassListOfAnswers(
1323 $result_array, $active_id, $pass, $this->object->getShowSolutionListComparison(),
1324 false, false, false, true, $objectivesList, $testResultHeaderLabelBuilder
1325 );
1326 $tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1327 }
1328
1329 $tpl->setVariable("TEXT_RESULTS", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass+1));
1330 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1331
1332 $uname = $this->object->userLookupFullName($user_id, TRUE);
1333 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, TRUE);
1334 if( !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1335 {
1336 if($this->object->getAnonymity())
1337 {
1338 $tpl->setVariable("TEXT_HEADING", $this->lng->txt("tst_result_pass"));
1339 } else
1340 {
1341 $tpl->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1342 $tpl->setVariable("USER_DATA", $user_data);
1343 }
1344 }
1345
1346 $this->populatePassFinishDate($tpl, $this->object->getPassFinishDate($active_id, $pass));
1347
1348 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1349 if ($this->object->getShowSolutionAnswersOnly())
1350 {
1351 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1352 }
1353
1354 if( $this->isPdfDeliveryRequest() )
1355 {
1356 require_once 'class.ilTestPDFGenerator.php';
1357 ilTestPDFGenerator::generatePDF($tpl->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant());
1358 }
1359 else
1360 {
1361 $this->tpl->setContent($tpl->get());
1362 }
1363 }
1364
1371 {
1372 global $ilUser, $ilTabs, $ilObjDataCache;
1373
1374 $this->handleTabs('results_pass_oriented');
1375
1376 $ilTabs->setBackTarget(
1377 $this->lng->txt('tst_results_back_introduction'),
1378 $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen')
1379 );
1380
1381 $testSession = $this->testSessionFactory->getSession();
1382 $active_id = $testSession->getActiveId();
1383 $user_id = $ilUser->getId();
1384 $uname = $this->object->userLookupFullName($user_id, TRUE);
1385
1386 if( !$this->object->canShowTestResults($testSession) )
1387 {
1388 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1389 }
1390
1391 // prepare generation before contents are processed (for mathjax)
1392 if ($this->isPdfDeliveryRequest())
1393 {
1394 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
1396 }
1397
1398 $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test");
1399 $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
1400
1401 $toolbar = $this->buildUserTestResultsToolbarGUI();
1402
1403 $this->ctrl->setParameter($this, 'pdf', '1');
1404 $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, 'outUserResultsOverview') );
1405 $this->ctrl->setParameter($this, 'pdf', '');
1406
1407 include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1408 if( $this->object->canShowCertificate($testSession, $user_id, $active_id) )
1409 {
1410 $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1411 }
1412
1413 $toolbar->build();
1414
1415 $templatehead->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1416
1417 $passDetailsEnabled = $this->object->getShowPassDetails();
1418 #if (!$passDetailsEnabled)
1419 #{
1420 # $executable = $this->object->isExecutable($testSession, $ilUser->getId());
1421 # if (!$executable["executable"]) $passDetailsEnabled = true;
1422 #}
1423
1424 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1425 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1426 if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1427 {
1428 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1429 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1430 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1431 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1432 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1433 }
1434
1435 $template->setCurrentBlock("pass_overview");
1436
1437 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1438 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
1439 $testPassesSelector->setActiveId($testSession->getActiveId());
1440 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1441
1442 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this, 'outUserResultsOverview');
1443 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1444 $passOverViewTableGUI->setResultPresentationEnabled(true);
1445 if($passDetailsEnabled)
1446 {
1447 $passOverViewTableGUI->setPassDetailsCommand('outUserPassDetails');
1448 }
1449 if( $this->object->isPassDeletionAllowed() )
1450 {
1451 $passOverViewTableGUI->setPassDeletionCommand('confirmDeletePass');
1452 }
1453 $passOverViewTableGUI->init();
1454 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getReportablePasses(), true));
1455 $passOverViewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassOverviewHeaderLabel());
1456 $overview = $passOverViewTableGUI->getHTML();
1457 if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1458 {
1459 require_once 'Modules/Test/classes/class.ilTestLearningObjectivesStatusGUI.php';
1460 $loStatus = new ilTestLearningObjectivesStatusGUI($this->lng);
1461 $loStatus->setCrsObjId($this->getObjectiveOrientedContainer()->getObjId());
1462 $loStatus->setUsrId($testSession->getUserId());
1463 $overview .= "<br />".$loStatus->getHTML();
1464 }
1465 $template->setVariable("PASS_OVERVIEW", $overview);
1466 $template->parseCurrentBlock();
1467
1468 if( $this->isGradingMessageRequired() )
1469 {
1470 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1471 $gradingMessageBuilder->buildMessage();
1472 $gradingMessageBuilder->sendMessage();
1473
1474 #$template->setCurrentBlock('grading_message');
1475 #$template->setVariable('GRADING_MESSAGE', );
1476 #$template->parseCurrentBlock();
1477 }
1478
1479 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, TRUE);
1480
1481 if( !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1482 {
1483 if ($this->object->getAnonymity())
1484 {
1485 $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1486 }
1487 else
1488 {
1489 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1490 $template->setVariable("USER_DATA", $user_data);
1491 }
1492 }
1493
1494 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1495 if ($this->object->getShowSolutionAnswersOnly())
1496 {
1497 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1498 }
1499 $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1500
1501 if( $this->isPdfDeliveryRequest() )
1502 {
1503 //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1504 require_once 'class.ilTestPDFGenerator.php';
1505 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant());
1506 }
1507 else
1508 {
1509 $this->tpl->setContent($templatehead->get());
1510 }
1511 }
1512
1521 {
1522 global $ilUser, $ilObjDataCache;
1523
1524 if (!$this->object->getShowSolutionPrintview())
1525 {
1526 ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1527 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1528 }
1529
1530 $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", TRUE, TRUE, "Modules/Test");
1531
1532 $pass = null;
1533 if (array_key_exists("pass", $_GET))
1534 {
1535 if (strlen($_GET["pass"])) $pass = $_GET["pass"];
1536 }
1537 $user_id = $ilUser->getId();
1538
1539 $testSession = $this->testSessionFactory->getSession();
1540 $active_id = $testSession->getActiveId();
1541
1542 $overview = "";
1543 if ($this->object->getNrOfTries() == 1)
1544 {
1545 $pass = 0;
1546 }
1547 else
1548 {
1549 $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1550
1551 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1552 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
1553 $testPassesSelector->setActiveId($testSession->getActiveId());
1554 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1555
1556 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this, 'outUserListOfAnswerPasses');
1557 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1558 $passOverViewTableGUI->setResultPresentationEnabled(false);
1559 $passOverViewTableGUI->setPassDetailsCommand('outUserListOfAnswerPasses');
1560 $passOverViewTableGUI->init();
1561 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getClosedPasses(), false));
1562 $template->setVariable("PASS_OVERVIEW", $passOverViewTableGUI->getHTML());
1563 }
1564
1565 $signature = "";
1566 if (strlen($pass))
1567 {
1568 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1569 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1570
1571 $objectivesList = null;
1572
1573 if( $this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() )
1574 {
1575 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
1576 $testSequence->loadFromDb();
1577 $testSequence->loadQuestions();
1578
1579 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
1580 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
1581
1582 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
1583 $objectivesList->loadObjectivesTitles();
1584
1585 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1586 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1587 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1588 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1589 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1590 }
1591
1592 $result_array = $this->object->getTestResult(
1593 $active_id, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
1594 );
1595
1596 $signature = $this->getResultsSignature();
1597 $user_id =& $this->object->_getUserIdFromActiveId($active_id);
1598 $showAllAnswers = TRUE;
1599 if ($this->object->isExecutable($testSession, $user_id))
1600 {
1601 $showAllAnswers = FALSE;
1602 }
1603 $this->setContextResultPresentation(false);
1604 $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers, false, false, false, $objectivesList, $testResultHeaderLabelBuilder);
1605 $template->setVariable("PASS_DETAILS", $answers);
1606 }
1607 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1608 $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1609 $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1610 $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1611 $template->setVariable("PRINT_URL", "javascript:window.print();");
1612
1613 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, TRUE);
1614 $template->setVariable("USER_DATA", $user_data);
1615 $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1616 if (strlen($signature))
1617 {
1618 $template->setVariable("SIGNATURE", $signature);
1619 }
1620 if (!is_null($pass) && $this->object->isShowExamIdInTestResultsEnabled())
1621 {
1622 $template->setCurrentBlock('exam_id_footer');
1623 $template->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
1624 $testSession->getActiveId(), $pass
1625 ));
1626 $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1627 $template->parseCurrentBlock();
1628 }
1629 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1630
1631 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1632 if ($this->object->getShowSolutionAnswersOnly())
1633 {
1634 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1635 }
1636 }
1637
1645 function passDetails()
1646 {
1647 if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
1648 {
1649 $this->ctrl->saveParameter($this, "pass");
1650 $this->ctrl->saveParameter($this, "active_id");
1651 $this->outTestResults(false, $_GET["pass"]);
1652 }
1653 else
1654 {
1655 $this->outTestResults(false);
1656 }
1657 }
1658
1663 public function singleResults()
1664 {
1665 global $ilAccess;
1666
1667 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
1668 {
1669 // allow only evaluation access
1670 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1671 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1672 }
1673
1674 $data =& $this->object->getCompleteEvaluationData();
1675 $color_class = array("tblrow1", "tblrow2");
1676 $counter = 0;
1677 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1678 $foundParticipants =& $data->getParticipants();
1679 if (count($foundParticipants) == 0)
1680 {
1681 ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
1682 return;
1683 }
1684 else
1685 {
1686 $rows = array();
1687 foreach ($data->getQuestionTitles() as $question_id => $question_title)
1688 {
1689 $answered = 0;
1690 $reached = 0;
1691 $max = 0;
1692 foreach ($foundParticipants as $userdata)
1693 {
1694 $pass = $userdata->getScoredPass();
1695 if (is_object($userdata->getPass($pass)))
1696 {
1697 $question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1698 if (is_array($question))
1699 {
1700 $answered++;
1701 }
1702 }
1703 }
1704 $counter++;
1705 $this->ctrl->setParameter($this, "qid", $question_id);
1706 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
1707 $question_object = assQuestion::_instanciateQuestion($question_id);
1708 $download = "";
1709 if ( $question_object instanceof ilObjFileHandlingQuestionType )
1710 {
1711 if ($question_object->hasFileUploads($this->object->getTestId()))
1712 {
1713 $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants"). "\">" . $this->lng->txt("download") . "</a>";
1714 }
1715 }
1716 array_push($rows,
1717 array(
1718 'qid' => $question_id,
1719 'question_title' => $question_title,
1720 'number_of_answers' => $answered,
1721 'output' => "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants") . "\">" . $this->lng->txt("pdf_export") . "</a>",
1722 'file_uploads' => $download
1723 )
1724 );
1725 }
1726 if (count($rows))
1727 {
1728 require_once './Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php';
1729 $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults");
1730 $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
1731 $table_gui->setData($rows);
1732
1733 $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
1734 }
1735 else
1736 {
1737 $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
1738 }
1739 }
1740 }
1741
1745 public function outCertificate()
1746 {
1747 $testSession = $this->testSessionFactory->getSession();
1748
1749 require_once './Services/Certificate/classes/class.ilCertificate.php';
1750 require_once './Modules/Test/classes/class.ilTestCertificateAdapter.php';
1751 $certificate = new ilCertificate(new ilTestCertificateAdapter( $this->object ) );
1752 $certificate->outCertificate(
1753 array(
1754 "active_id" => $testSession->getActiveId(),
1755 "pass" => ilObjTest::_getResultPass( $testSession->getActiveId() )
1756 )
1757 );
1758 }
1759
1760 public function confirmDeletePass()
1761 {
1762 if( isset($_GET['context']) && strlen($_GET['context']) )
1763 {
1764 $context = $_GET['context'];
1765 }
1766 else
1767 {
1769 }
1770
1771 if( !$this->object->isPassDeletionAllowed() && !$this->object->isDynamicTest() )
1772 {
1773 $this->redirectToPassDeletionContext($context);
1774 }
1775
1776 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1777
1778 $confirm = new ilTestPassDeletionConfirmationGUI($this->ctrl, $this->lng, $this);
1779 $confirm->build((int)$_GET['active_id'], (int)$_GET['pass'], $context);
1780
1781 global $tpl;
1782 $tpl->setContent($this->ctrl->getHTML($confirm));
1783 }
1784
1785 public function cancelDeletePass()
1786 {
1787 $this->redirectToPassDeletionContext($_POST['context']);
1788 }
1789
1790 private function redirectToPassDeletionContext($context)
1791 {
1792 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1793
1794 switch($context)
1795 {
1797
1798 $this->ctrl->redirect($this, 'outUserResultsOverview');
1799
1801
1802 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
1803
1805
1806 $this->ctrl->redirectByClass('ilTestPlayerDynamicQuestionSetGUI', 'startTest');
1807 }
1808 }
1809
1810 public function performDeletePass()
1811 {
1812 if( isset($_POST['context']) && strlen($_POST['context']) )
1813 {
1814 $context = $_POST['context'];
1815 }
1816 else
1817 {
1819 }
1820
1821 if( !$this->object->isPassDeletionAllowed() && !$this->object->isDynamicTest() )
1822 {
1823 $this->redirectToPassDeletionContext($context);
1824 }
1826 global $ilDB;
1827
1828 $active_fi = null;
1829 $pass = null;
1830
1831 if( isset($_POST['active_id']) && (int)$_POST['active_id'] )
1832 {
1833 $active_fi = $_POST['active_id'];
1834 }
1835
1836 if( isset($_POST['pass']) && is_numeric($_POST['pass']) )
1837 {
1838 $pass = $_POST['pass'];
1839 }
1840
1841 if( is_null($active_fi) || is_null($pass) )
1842 {
1843 $this->ctrl->redirect($this, 'outUserResultsOverview');
1844 }
1845
1846 if( !$this->object->isDynamicTest() && $pass == $this->object->_getResultPass($active_fi) )
1847 {
1848 $this->ctrl->redirect($this, 'outUserResultsOverview');
1849 }
1850
1851 // Get information
1852 $result = $ilDB->query("
1853 SELECT tst_active.tries, tst_active.last_finished_pass, tst_sequence.pass
1854 FROM tst_active
1855 LEFT JOIN tst_sequence
1856 ON tst_sequence.active_fi = tst_active.active_id
1857 AND tst_sequence.pass = tst_active.tries
1858 WHERE tst_active.active_id = {$ilDB->quote($active_fi, 'integer')}
1859 ");
1860
1861 $row = $ilDB->fetchAssoc($result);
1862
1863 $tries = $row['tries'];
1864 $lastFinishedPass = is_numeric($row['last_finished_pass']) ? $row['last_finished_pass'] : -1;
1865
1866 if( $pass < $lastFinishedPass )
1867 {
1868 $isActivePass = false;
1869 $must_renumber = true;
1870 }
1871 elseif( $pass == $lastFinishedPass )
1872 {
1873 $isActivePass = false;
1874
1875 if( $tries == $row['pass'] )
1876 {
1877 $must_renumber = true;
1878 }
1879 else
1880 {
1881 $must_renumber = false;
1882 }
1883 }
1884 elseif( $pass == $row['pass'] )
1885 {
1886 $isActivePass = true;
1887 $must_renumber = false;
1888 }
1889 else
1890 {
1891 throw new ilTestException ('This should not happen, please contact Bjoern Heyser to clean up this pass salad!');
1892 }
1893
1894 if( !$this->object->isDynamicTest() && $isActivePass )
1895 {
1896 $this->ctrl->redirect($this, 'outUserResultsOverview');
1897 }
1898
1899 if( $pass == 0 && (
1900 ($lastFinishedPass == 0 && $tries == 1 && $tries != $row['pass'])
1901 || ($isActivePass == true) // should be equal to || ($lastFinishedPass == -1 && $tries == 0)
1902 ))
1903 {
1904 $last_pass = true;
1905 }
1906 else
1907 {
1908 $last_pass = false;
1909 }
1910
1911 // Work on tables:
1912 // tst_active
1913 if ($last_pass)
1914 {
1915 $ilDB->manipulate(
1916 'DELETE
1917 FROM tst_active
1918 WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1919 );
1920 }
1921 elseif( !$isActivePass )
1922 {
1923 $ilDB->manipulate(
1924 'UPDATE tst_active
1925 SET tries = ' . $ilDB->quote($tries-1, 'integer') . ',
1926 last_finished_pass = ' . $ilDB->quote($lastFinishedPass-1, 'integer') . '
1927 WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1928 );
1929 }
1930 // tst_manual_fb
1931 $ilDB->manipulate(
1932 'DELETE
1933 FROM tst_manual_fb
1934 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1935 AND pass = ' . $ilDB->quote($pass, 'integer')
1936 );
1937
1938 if ($must_renumber)
1939 {
1940 $ilDB->manipulate(
1941 'UPDATE tst_manual_fb
1942 SET pass = pass - 1
1943 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1944 AND pass > ' . $ilDB->quote($pass, 'integer')
1945 );
1946 }
1947
1948 // tst_mark -> nothing to do
1949 //
1950 // tst_pass_result
1951 $ilDB->manipulate(
1952 'DELETE
1953 FROM tst_pass_result
1954 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1955 AND pass = ' . $ilDB->quote($pass, 'integer')
1956 );
1957
1958 if ($must_renumber)
1959 {
1960 $ilDB->manipulate(
1961 'UPDATE tst_pass_result
1962 SET pass = pass - 1
1963 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1964 AND pass > ' . $ilDB->quote($pass, 'integer')
1965 );
1966 }
1967
1968 // tst_qst_solved -> nothing to do
1969
1970 // tst_rnd_copy -> nothing to do
1971 // tst_rnd_qpl_title -> nothing to do
1972
1973 // tst_sequence
1974 $ilDB->manipulate(
1975 'DELETE
1976 FROM tst_sequence
1977 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1978 AND pass = ' . $ilDB->quote($pass, 'integer')
1979 );
1980
1981 if ($must_renumber)
1982 {
1983 $ilDB->manipulate(
1984 'UPDATE tst_sequence
1985 SET pass = pass - 1
1986 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
1987 AND pass > ' . $ilDB->quote($pass, 'integer')
1988 );
1989 }
1990
1991 if( $this->object->isDynamicTest() )
1992 {
1993 $tables = array(
1994 'tst_seq_qst_tracking', 'tst_seq_qst_answstatus', 'tst_seq_qst_postponed', 'tst_seq_qst_checked'
1995 );
1996
1997 foreach($tables as $table)
1998 {
1999 $ilDB->manipulate("
2000 DELETE FROM $table
2001 WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
2002 AND pass = {$ilDB->quote($pass, 'integer')}
2003 ");
2004
2005 if( $must_renumber )
2006 {
2007 $ilDB->manipulate("
2008 UPDATE $table
2009 SET pass = pass - 1
2010 WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
2011 AND pass > {$ilDB->quote($pass, 'integer')}
2012 ");
2013 }
2014 }
2015 }
2016
2017 // tst_solutions
2018 $ilDB->manipulate(
2019 'DELETE
2020 FROM tst_solutions
2021 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
2022 AND pass = ' . $ilDB->quote($pass, 'integer')
2023 );
2024
2025 if ($must_renumber)
2026 {
2027 $ilDB->manipulate(
2028 'UPDATE tst_solutions
2029 SET pass = pass - 1
2030 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
2031 AND pass > ' . $ilDB->quote($pass, 'integer')
2032 );
2033 }
2034
2035 // tst_test_result
2036 $ilDB->manipulate(
2037 'DELETE
2038 FROM tst_test_result
2039 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
2040 AND pass = ' . $ilDB->quote($pass, 'integer')
2041 );
2042
2043 if ($must_renumber)
2044 {
2045 $ilDB->manipulate(
2046 'UPDATE tst_test_result
2047 SET pass = pass - 1
2048 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
2049 AND pass > ' . $ilDB->quote($pass, 'integer')
2050 );
2051 }
2052
2053 // tst_test_rnd_qst -> nothing to do
2054
2055 // tst_times
2056 $ilDB->manipulate(
2057 'DELETE
2058 FROM tst_times
2059 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
2060 AND pass = ' . $ilDB->quote($pass, 'integer')
2061 );
2062
2063 if ($must_renumber)
2064 {
2065 $ilDB->manipulate(
2066 'UPDATE tst_times
2067 SET pass = pass - 1
2068 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer'). '
2069 AND pass > ' . $ilDB->quote($pass, 'integer')
2070 );
2071 }
2072
2073 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
2075 {
2076 $this->object->logAction($this->lng->txtlng("assessment", "log_deleted_pass", ilObjAssessmentFolder::_getLogLanguage()));
2077 }
2078 // tst_result_cache
2079 // Ggfls. nur renumbern.
2080 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
2082
2083 if( $this->object->isDynamicTest() )
2084 {
2085 require_once 'Modules/Test/classes/tables/class.ilTestDynamicQuestionSetStatisticTableGUI.php';
2087 }
2088
2089 $this->redirectToPassDeletionContext($context);
2090 }
2091
2092 protected function getFilteredTestResult($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions)
2093 {
2094 global $ilDB, $ilPluginAdmin;
2095
2096 $resultData = $this->object->getTestResult($active_id, $pass, false, $considerHiddenQuestions);
2097 $questionIds = array();
2098 foreach($resultData as $resultItemKey => $resultItemValue)
2099 {
2100 if($resultItemKey === 'test' || $resultItemKey === 'pass')
2101 {
2102 continue;
2103 }
2104
2105 $questionIds[] = $resultItemValue['qid'];
2106 }
2107
2108 $table_gui = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
2109 $table_gui->initFilter();
2110
2111 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
2112 $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin);
2113
2114 $questionList->setIncludeQuestionIdsFilter($questionIds);
2115 $questionList->setQuestionInstanceTypeFilter(null);
2116
2117 foreach ($table_gui->getFilterItems() as $item)
2118 {
2119 if( substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_' )
2120 {
2121 $v = $item->getValue();
2122
2123 if( is_array($v) && count($v) && !(int)$v[0] )
2124 {
2125 continue;
2126 }
2127
2128 $taxId = substr($item->getPostVar(), strlen('tax_'));
2129 $questionList->addTaxonomyFilter($taxId, $item->getValue(), $this->object->getId(), 'tst');
2130 }
2131 elseif( $item->getValue() !== false )
2132 {
2133 $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
2134 }
2135 }
2136
2137 $questionList->load();
2138
2139 $filteredTestResult = array();
2140
2141 foreach($resultData as $resultItemKey => $resultItemValue)
2142 {
2143 if($resultItemKey === 'test' || $resultItemKey === 'pass')
2144 {
2145 continue;
2146 }
2147
2148 if( !$questionList->isInList($resultItemValue['qid']) )
2149 {
2150 continue;
2151 }
2152
2153 $filteredTestResult[] = $resultItemValue;
2154 }
2155
2156 return $filteredTestResult;
2157 }
2158
2160 {
2161 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
2162 $cgui = new ilConfirmationGUI();
2163 $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2164 $cgui->setHeaderText($this->lng->txt("finish_pass_for_user_confirmation"));
2165 $cgui->setCancel($this->lng->txt("cancel"), "redirectBackToParticipantsScreen");
2166 $cgui->setConfirm($this->lng->txt("proceed"), "confirmFinishTestPassForUser");
2167 $this->tpl->setContent($cgui->getHTML());
2168 }
2169
2171 {
2172 require_once 'Modules/Test/classes/class.ilTestPassFinishTasks.php';
2173 $active_id = (int) $_GET["active_id"];
2174 $this->finishTestPass($active_id, $this->object->getId());
2176 }
2177
2178 public function finishAllUserPasses()
2179 {
2180 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
2181 $cgui = new ilConfirmationGUI();
2182 $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2183 $cgui->setHeaderText($this->lng->txt("finish_pass_for_all_users"));
2184 $cgui->setCancel($this->lng->txt("cancel"), "redirectBackToParticipantsScreen");
2185 $cgui->setConfirm($this->lng->txt("proceed"), "confirmFinishTestPassForAllUser");
2186 $this->tpl->setContent($cgui->getHTML());
2187 }
2188
2190 {
2191 require_once 'Modules/Test/classes/class.ilTestPassFinishTasks.php';
2192 $participants = $this->object->getTestParticipants();
2193 foreach($participants as $participant)
2194 {
2195 if(array_key_exists('unfinished_passes', $participant) && $participant['unfinished_passes'] == 1)
2196 {
2197 $this->finishTestPass($participant['active_id'], $this->object->getId());
2198 }
2199 }
2201 }
2202
2203 protected function finishTestPass($active_id, $obj_id)
2204 {
2205 $this->processLockerFactory->setActiveId($active_id);
2206 $processLocker = $this->processLockerFactory->getLocker();
2207
2208 $test_pass_finisher = new ilTestPassFinishTasks($active_id, $obj_id);
2209 $test_pass_finisher->performFinishTasks($processLocker);
2210 }
2211
2213 {
2214 $this->ctrl->redirectByClass("ilobjtestgui", "participants");
2215 }
2216}
sprintf('%.4f', $callTime)
$result
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Create PDF certificates.
static _isComplete($adapter)
Checks the status of the certificate.
Confirmation screen class.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
TableGUI class for evaluation of all users.
static getInstance(ilTestSession $a_test_session)
static getInstance()
Factory.
This class represents a non editable value in a property form.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
static lookupExamId($active_id, $pass)
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
static _lookupName($a_user_id)
lookup user name
static prepareGeneration()
Prepare the PDF generation This initializes the purpose for MathJax rendering It has to be called bef...
This class represents a property form user interface.
TableGUI class for results by question.
This class represents a selection list property in a property form.
ILIAS Setting Class.
static getInstance()
Factory.
special template class to simplify handling of ITX/PEAR
Output class for assessment test evaluation.
exportFileUploadsForAllParticipants()
Creates a ZIP file containing all file uploads for a given question in a test.
outCertificate()
Output of a test certificate.
singleResults()
Creates user results for single questions.
outUserPassDetails()
Output of the pass details of an existing test pass for the active test participant.
passDetails()
Output of the learners view of an existing test pass.
__construct(ilObjTest $a_object)
ilTestEvaluationGUI constructor
exportCertificate()
Exports the user results as PDF certificates using XSL-FO via XML:RPC calls.
exportAggregatedResults()
Exports the aggregated results.
detailedEvaluation()
Creates the detailed evaluation output for a selected participant.
outUserListOfAnswerPasses()
Output of the pass overview for a user when he/she wants to see his/her list of answers.
exportQuestionForAllParticipants()
Creates a PDF representation of the answers for a given question in a test.
outParticipantsPassDetails()
Output of the pass details of an existing test pass for the test statistics.
getEvaluationQuestionId($question_id, $original_id="")
Returns the ID of a question for evaluation purposes.
outUserResultsOverview()
Output of the pass overview for a test called by a test participant.
exportEvaluation()
Exports the evaluation data to a selected file format.
getFilteredTestResult($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions)
outParticipantsResultsOverview()
Output of the pass overview for a test called from the statistics.
finishTestPass($active_id, $obj_id)
Base Exception for all Exceptions relating to Modules/Test.
static generatePDF($pdf_output, $output_mode, $filename=null)
Class ilTestPassFinishTasks.
Service GUI class for tests.
buildPassOverviewTableGUI($targetGUI, $targetCmd='')
populatePassFinishDate($tpl, $passFinishDate)
getResultsSignature()
Returns HTML code for a signature field.
getCommand($cmd)
Retrieves the ilCtrl command.
getQuestionResultForTestUsers($question_id, $test_id)
Creates a HTML representation for the results of a given question in a test.
getPassListOfAnswers(&$result_array, $active_id, $pass, $show_solutions=FALSE, $only_answered_questions=FALSE, $show_question_only=FALSE, $show_reached_points=FALSE, $anchorNav=false, ilTestQuestionRelatedObjectivesList $objectivesList=null, ilTestResultHeaderLabelBuilder $testResultHeaderLabelBuilder=null)
Returns the list of answers of a users test pass.
getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, $overwrite_anonymity=FALSE)
Returns the user data for a test results output.
setContextResultPresentation($contextResultPresentation)
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectivesAdapter, ilTestQuestionSequence $testSequence)
getPassOverviewTableData(ilTestSession $testSession, $passes, $withResults)
getPassDetailsOverviewTableGUI($result_array, $active_id, $pass, $targetGUI, $targetCMD, $questionDetailsCMD, $questionAnchorNav, ilTestQuestionRelatedObjectivesList $objectivesList=null, $multipleObjectivesInvolved=true)
buildPassDetailsOverviewTableGUI($targetGUI, $targetCMD)
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$counter
$pdf
Definition: example_001.php:31
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const SCORE_BEST_PASS
Interface ilObjFileHandlingQuestionType.
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35
global $ilDB
if(!is_array($argv)) $options
global $DIC
$ilUser
Definition: imgupload.php:18