ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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';
6require_once 'Modules/Test/classes/class.ilTestPassFinishTasks.php';
7
8
29{
33 protected $testAccess;
34
39
48 public function __construct(ilObjTest $a_object)
49 {
50 parent::__construct($a_object);
51
52 global $DIC; /* @var ILIAS\DI\Container $DIC */
53
54 require_once 'Modules/Test/classes/class.ilTestProcessLockerFactory.php';
55 $this->processLockerFactory = new ilTestProcessLockerFactory(
56 new ilSetting('assessment'),
57 $DIC->database()
58 );
59 }
60
64 public function getTestAccess()
65 {
66 return $this->testAccess;
67 }
68
72 public function setTestAccess($testAccess)
73 {
74 $this->testAccess = $testAccess;
75 }
76
80 public function executeCommand()
81 {
82 $cmd = $this->ctrl->getCmd();
83 $next_class = $this->ctrl->getNextClass($this);
84 $this->ctrl->saveParameter($this, "sequence");
85 $this->ctrl->saveParameter($this, "active_id");
86 $cmd = $this->getCommand($cmd);
87 switch ($next_class) {
88 case 'iltestpassdetailsoverviewtablegui':
89 require_once 'Modules/Test/classes/tables/class.ilTestPassDetailsOverviewTableGUI.php';
90 $tableGUI = new ilTestPassDetailsOverviewTableGUI($this->ctrl, $this, 'outUserPassDetails');
91 $tableGUI->setIsPdfGenerationRequest($this->isPdfDeliveryRequest());
92 $tableGUI->initFilter();
93 $this->ctrl->forwardCommand($tableGUI);
94 break;
95
96 default:
97 $ret = &$this->$cmd();
98 break;
99 }
100 return $ret;
101 }
102
103 public function &getHeaderNames()
104 {
105 $headernames = array();
106 if ($this->object->getAnonymity()) {
107 array_push($headernames, $this->lng->txt("counter"));
108 } else {
109 array_push($headernames, $this->lng->txt("name"));
110 array_push($headernames, $this->lng->txt("login"));
111 }
112 $additionalFields = $this->object->getEvaluationAdditionalFields();
113 if (count($additionalFields)) {
114 foreach ($additionalFields as $fieldname) {
115 array_push($headernames, $this->lng->txt($fieldname));
116 }
117 }
118 array_push($headernames, $this->lng->txt("tst_reached_points"));
119 array_push($headernames, $this->lng->txt("tst_mark"));
120 if ($this->object->getECTSOutput()) {
121 array_push($headernames, $this->lng->txt("ects_grade"));
122 }
123 array_push($headernames, $this->lng->txt("tst_answered_questions"));
124 array_push($headernames, $this->lng->txt("working_time"));
125 array_push($headernames, $this->lng->txt("detailed_evaluation"));
126 return $headernames;
127 }
128
129 public function &getHeaderVars()
130 {
131 $headervars = array();
132 if ($this->object->getAnonymity()) {
133 array_push($headervars, "counter");
134 } else {
135 array_push($headervars, "name");
136 array_push($headervars, "login");
137 }
138 array_push($headervars, "resultspoints");
139 array_push($headervars, "resultsmarks");
140 if ($this->object->getECTSOutput()) {
141 array_push($headervars, "ects_grade");
142 }
143 array_push($headervars, "qworkedthrough");
144 array_push($headervars, "timeofwork");
145 array_push($headervars, "");
146 return $headervars;
147 }
148
152 public function filterEvaluation()
153 {
154 if (!$this->getTestAccess()->checkStatisticsAccess()) {
156 }
157
158 include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
159 $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
160 $table_gui->writeFilterToSession();
161 $this->ctrl->redirect($this, "outEvaluation");
162 }
163
167 public function resetfilterEvaluation()
168 {
169 if (!$this->getTestAccess()->checkStatisticsAccess()) {
171 }
172
173 include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
174 $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
175 $table_gui->resetFilter();
176 $this->ctrl->redirect($this, "outEvaluation");
177 }
178
184 public function outEvaluation()
185 {
186 global $DIC; /* @var ILIAS\DI\Container $DIC */
187 $ilToolbar = $DIC->toolbar();
188
189 if (!$this->getTestAccess()->checkStatisticsAccess()) {
191 }
192
193 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_STATISTICS);
194
195 include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
196
197 $table_gui = new ilEvaluationAllTableGUI(
198 $this,
199 'outEvaluation',
200 $this->object->getAnonymity(),
201 $this->object->isOfferingQuestionHintsEnabled()
202 );
203
204 $data = array();
205 $arrFilter = array();
206
207 foreach ($table_gui->getFilterItems() as $item) {
208 if ($item->getValue() !== false) {
209 switch ($item->getPostVar()) {
210 case 'group':
211 case 'name':
212 case 'course':
213 $arrFilter[$item->getPostVar()] = $item->getValue();
214 break;
215 case 'passed_only':
216 $passedonly = $item->getChecked();
217 break;
218 }
219 }
220 }
221 include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
222 $eval = new ilTestEvaluationData($this->object);
223 $eval->setFilterArray($arrFilter);
224 $foundParticipants = $eval->getParticipants();
225
226 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
227 require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
228
229 $participantData = new ilTestParticipantData($DIC->database(), $DIC->language());
230 $participantData->setActiveIdsFilter($eval->getParticipantIds());
231
232 $participantData->setParticipantAccessFilter(
234 );
235
236 $participantData->load($this->object->getTestId());
237
238 $counter = 1;
239 if (count($participantData->getActiveIds()) > 0) {
240 if ($this->object->getECTSOutput()) {
241 $passed_array = &$this->object->getTotalPointsPassedArray();
242 }
243 foreach ($participantData->getActiveIds() as $active_id) {
244 if (!isset($foundParticipants[$active_id]) || !($foundParticipants[$active_id] instanceof ilTestEvaluationUserData)) {
245 continue;
246 }
247
248 /* @var $userdata ilTestEvaluationUserData */
249 $userdata = $foundParticipants[$active_id];
250
251 $remove = false;
252 if ($passedonly) {
253 $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent());
254
255 if ($mark_obj->getPassed() == false || !$userdata->areObligationsAnswered()) {
256 $remove = true;
257 }
258 }
259 if (!$remove) {
260 // build the evaluation row
261 $evaluationrow = array();
262 if ($this->object->getAnonymity()) {
263 $evaluationrow['name'] = $counter;
264 $evaluationrow['login'] = '';
265 } else {
266 $evaluationrow['name'] = $userdata->getName();
267 if (strlen($userdata->getLogin())) {
268 $evaluationrow['login'] = "[" . $userdata->getLogin() . "]";
269 } else {
270 $evaluationrow['login'] = '';
271 }
272 }
273
274 $evaluationrow['reached'] = $userdata->getReached();
275 $evaluationrow['max'] = $userdata->getMaxpoints();
276 $evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass();
277 $evaluationrow['exam_id'] = $userdata->getExamIdFromScoredPass();
278 $percentage = $userdata->getReachedPointsInPercent();
279 $mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
280 if (is_object($mark)) {
281 $evaluationrow['mark'] = $mark->getShortName();
282 }
283 if ($this->object->getECTSOutput()) {
284 $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints());
285 $evaluationrow['ects_grade'] = $ects_mark;
286 }
287 $evaluationrow['answered'] = $userdata->getQuestionsWorkedThroughInPercent();
288 $evaluationrow['questions_worked_through'] = $userdata->getQuestionsWorkedThrough();
289 $evaluationrow['number_of_questions'] = $userdata->getNumberOfQuestions();
290 $time_seconds = $userdata->getTimeOfWork();
291 $time_hours = floor($time_seconds / 3600);
292 $time_seconds -= $time_hours * 3600;
293 $time_minutes = floor($time_seconds / 60);
294 $time_seconds -= $time_minutes * 60;
295 $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
296 $this->ctrl->setParameter($this, "active_id", $active_id);
297 $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
298 $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
299 $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>";
300 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
301 $evaluationrow['gender'] = $userfields['gender'];
302 $evaluationrow['email'] = $userfields['email'];
303 $evaluationrow['institution'] = $userfields['institution'];
304 $evaluationrow['street'] = $userfields['street'];
305 $evaluationrow['city'] = $userfields['city'];
306 $evaluationrow['zipcode'] = $userfields['zipcode'];
307 $evaluationrow['country'] = $userfields['country'];
308 $evaluationrow['sel_country'] = $userfields['sel_country'];
309 $evaluationrow['department'] = $userfields['department'];
310 $evaluationrow['matriculation'] = $userfields['matriculation'];
311 $counter++;
312 $data[] = $evaluationrow;
313 }
314 }
315 }
316
317 $table_gui->setData($data);
318 if (count($participantData->getActiveIds()) > 0) {
319 $ilToolbar->setFormName('form_output_eval');
320 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportEvaluation'));
321 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
322 $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
323 $options = array(
324 'excel' => $this->lng->txt('exp_type_excel'),
325 'csv' => $this->lng->txt('exp_type_spss')
326 );
327
328 if (!$this->object->getAnonymity()) {
329 $globalCertificatePrerequisites = new ilCertificateActiveValidator();
330 if ($globalCertificatePrerequisites->validate()) {
331 $options['certificate'] = $this->lng->txt('exp_type_certificate');
332 }
333 }
334
335 $export_type->setOptions($options);
336
337 $ilToolbar->addInputItem($export_type, true);
338 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
339 $button = ilSubmitButton::getInstance();
340 $button->setCommand('exportEvaluation');
341 $button->setCaption('export');
342 $button->getOmitPreventDoubleSubmission();
343 $ilToolbar->addButtonInstance($button);
344 }
345
346 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
347 if ($this->object->getShowSolutionAnswersOnly()) {
348 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
349 }
350
351 $this->tpl->setContent($table_gui->getHTML());
352 }
353
361 public function detailedEvaluation()
362 {
363 global $DIC; /* @var ILIAS\DI\Container $DIC */
364
365 if (!$this->getTestAccess()->checkStatisticsAccess()) {
367 }
368
369 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_STATISTICS);
370
371 $active_id = $_GET['active_id'];
372
373 if (!$this->getTestAccess()->checkResultsAccessForActiveId($active_id)) {
375 }
376
377 if (strlen($active_id) == 0) {
378 ilUtil::sendInfo($this->lng->txt('detailed_evaluation_missing_active_id'), true);
379 $this->ctrl->redirect($this, 'outEvaluation');
380 }
381
382 $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print');
383
384 $toolbar = $DIC['ilToolbar'];
385
386 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
387 $backBtn = ilLinkButton::getInstance();
388 $backBtn->setCaption('back');
389 $backBtn->setUrl($this->ctrl->getLinkTarget($this, 'outEvaluation'));
390 $toolbar->addInputItem($backBtn);
391
392 $this->object->setAccessFilteredParticipantList(
393 $this->object->buildStatisticsAccessFilteredParticipantList()
394 );
395
396 $data = &$this->object->getCompleteEvaluationData();
397
398 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
399 $form = new ilPropertyFormGUI();
400 $form->setTitle(sprintf(
401 $this->lng->txt('detailed_evaluation_for'),
402 $data->getParticipant($active_id)->getName()
403 ));
404
405 $resultPoints = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_resultspoints'));
406 $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()) . " %" . ")");
407 $form->addItem($resultPoints);
408
409 if (strlen($data->getParticipant($active_id)->getMark())) {
410 $resultMarks = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_resultsmarks'));
411 $resultMarks->setValue($data->getParticipant($active_id)->getMark());
412 $form->addItem($resultMarks);
413 if (strlen($data->getParticipant($active_id)->getECTSMark())) {
414 $ectsGrade = new ilNonEditableValueGUI($this->lng->txt('ects_grade'));
415 $ectsGrade->setValue($data->getParticipant($active_id)->getECTSMark());
416 $form->addItem($ectsGrade);
417 }
418 }
419
420 if ($this->object->isOfferingQuestionHintsEnabled()) {
421 $requestHints = new ilNonEditableValueGUI($this->lng->txt('tst_question_hints_requested_hint_count_header'));
422 $requestHints->setValue($data->getParticipant($active_id)->getRequestedHintsCountFromScoredPass());
423 $form->addItem($requestHints);
424 }
425
426 $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
427 $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
428 $time_hours = floor($time_seconds / 3600);
429 $time_seconds -= $time_hours * 3600;
430 $time_minutes = floor($time_seconds / 60);
431 $time_seconds -= $time_minutes * 60;
432 $timeOfWork = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_timeofwork'));
433 $timeOfWork->setValue(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
434 $form->addItem($timeOfWork);
435
436 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt(""));
437 $time_hours = floor($atime_seconds / 3600);
438 $atime_seconds -= $time_hours * 3600;
439 $time_minutes = floor($atime_seconds / 60);
440 $atime_seconds -= $time_minutes * 60;
441 $avgTimeOfWork = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_atimeofwork'));
442 $avgTimeOfWork->setValue(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
443 $form->addItem($avgTimeOfWork);
444
445 $firstVisit = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_firstvisit'));
446 $firstVisit->setValue(ilDatePresentation::formatDate(new ilDateTime($data->getParticipant($active_id)->getFirstVisit(), IL_CAL_UNIX)));
447 $form->addItem($firstVisit);
448
449 $lastVisit = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_lastvisit'));
450 $lastVisit->setValue(ilDatePresentation::formatDate(new ilDateTime($data->getParticipant($active_id)->getLastVisit(), IL_CAL_UNIX)));
451 $form->addItem($lastVisit);
452
453 $nrPasses = new ilNonEditableValueGUI($this->lng->txt('tst_nr_of_passes'));
454 $nrPasses->setValue($data->getParticipant($active_id)->getLastPass() + 1);
455 $form->addItem($nrPasses);
456
457 $scoredPass = new ilNonEditableValueGUI($this->lng->txt('scored_pass'));
458 if ($this->object->getPassScoring() == SCORE_BEST_PASS) {
459 $scoredPass->setValue($data->getParticipant($active_id)->getBestPass() + 1);
460 } else {
461 $scoredPass->setValue($data->getParticipant($active_id)->getLastPass() + 1);
462 }
463 $form->addItem($scoredPass);
464
465 $median = $data->getStatistics()->getStatistics()->median();
466 $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
467 $mark = $this->object->mark_schema->getMatchingMark($pct);
468 if (is_object($mark)) {
469 $markMedian = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_mark_median'));
470 $markMedian->setValue($mark->getShortName());
471 $form->addItem($markMedian);
472 }
473
474 $rankParticipant = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_rank_participant'));
475 $rankParticipant->setValue($data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
476 $form->addItem($rankParticipant);
477
478 $rankMedian = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_rank_median'));
479 $rankMedian->setValue($data->getStatistics()->getStatistics()->rank_median());
480 $form->addItem($rankMedian);
481
482 $totalParticipants = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_total_participants'));
483 $totalParticipants->setValue($data->getStatistics()->getStatistics()->count());
484 $form->addItem($totalParticipants);
485
486 $medianField = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_median'));
487 $medianField->setValue($median);
488 $form->addItem($medianField);
489
490 $this->tpl->setContent($form->getHTML());
491
492 $tables = array();
493
494 for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++) {
495 $finishdate = ilObjTest::lookupPassResultsUpdateTimestamp($active_id, $pass);
496 if ($finishdate > 0) {
497 if (($DIC->access()->checkAccess('write', '', (int) $_GET['ref_id']))) {
498 $this->ctrl->setParameter($this, 'statistics', '1');
499 $this->ctrl->setParameter($this, 'active_id', $active_id);
500 $this->ctrl->setParameter($this, 'pass', $pass);
501 } else {
502 $this->ctrl->setParameter($this, 'statistics', '');
503 $this->ctrl->setParameter($this, 'active_id', '');
504 $this->ctrl->setParameter($this, 'pass', '');
505 }
506
507 require_once 'Modules/Test/classes/tables/class.ilTestDetailedEvaluationStatisticsTableGUI.php';
508 $table = new ilTestDetailedEvaluationStatisticsTableGUI($this, 'detailedEvaluation', ($pass + 1) . '_' . $this->object->getId());
509 $table->setTitle(sprintf($this->lng->txt("tst_eval_question_points"), $pass + 1));
510 if (($DIC->access()->checkAccess('write', '', (int) $_GET['ref_id']))) {
511 $table->addCommandButton('outParticipantsPassDetails', $this->lng->txt('tst_show_answer_sheet'));
512 }
513
514 $questions = $data->getParticipant($active_id)->getQuestions($pass);
515 if (!is_array($questions)) {
516 $questions = $data->getParticipant($active_id)->getQuestions(0);
517 }
518
519 $tableData = array();
520
521 $counter = 0;
522 foreach ((array) $questions as $question) {
523 $userDataData = array(
524 'counter' => ++$counter,
525 'id' => $question['id'],
526 'id_txt' => $this->lng->txt('question_id_short'),
527 'title' => $data->getQuestionTitle($question['id'])
528 );
529
530 $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
531 if (is_array($answeredquestion)) {
532 $percent = $answeredquestion['points'] ? $answeredquestion['reached'] / $answeredquestion['points'] * 100.0 : 0;
533 $userDataData['points'] = $answeredquestion['reached'] . ' ' . strtolower($this->lng->txt('of')) . " " . $answeredquestion['points'] . ' (' . sprintf("%.2f", $percent) . ' %)';
534 } else {
535 $userDataData['points'] = '0 ' . strtolower($this->lng->txt('of')) . ' ' . $question['points'] . ' (' . sprintf("%.2f", 0) . ' %) - ' . $this->lng->txt('question_not_answered');
536 }
537
538 $tableData[] = $userDataData;
539 }
540 $table->setData($tableData);
541
542 $tables[] = $table->getHTML();
543 }
544 }
545
546 global $DIC; /* @var ILIAS\DI\Container $DIC */
547 $DIC['tpl']->setContent($form->getHTML() . implode('', $tables));
548 }
549
555 {
556 $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
557 }
558
564 {
565 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
566 $question_object = assQuestion::_instanciateQuestion($_GET["qid"]);
567 if ($question_object instanceof ilObjFileHandlingQuestionType) {
568 $question_object->deliverFileUploadZIPFile(
569 $this->ref_id,
570 $this->object->getTestId(),
571 $this->object->getTitle()
572 );
573 } else {
574 $this->ctrl->redirect($this, "singleResults");
575 }
576 }
577
585 public function eval_a()
586 {
587 global $DIC; /* @var ILIAS\DI\Container $DIC */
588 $ilToolbar = $DIC->toolbar();
589
590 if (!$this->getTestAccess()->checkStatisticsAccess()) {
592 }
593
594 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_STATISTICS);
595
596 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
597
598 $this->object->setAccessFilteredParticipantList(
599 $this->object->buildStatisticsAccessFilteredParticipantList()
600 );
601
602 $eval = &$this->object->getCompleteEvaluationData();
603 $data = array();
604 $foundParticipants = &$eval->getParticipants();
605 if (count($foundParticipants)) {
606 $ilToolbar->setFormName('form_output_eval');
607 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportAggregatedResults'));
608 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
609 $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
610 $export_type->setOptions(array(
611 'excel' => $this->lng->txt('exp_type_excel'),
612 'csv' => $this->lng->txt('exp_type_spss')
613 ));
614 $ilToolbar->addInputItem($export_type, true);
615 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
616 $button = ilSubmitButton::getInstance();
617 $button->setCommand('exportAggregatedResults');
618 $button->setCaption('export');
619 $button->getOmitPreventDoubleSubmission();
620 $ilToolbar->addButtonInstance($button);
621
622 array_push($data, array(
623 'result' => $this->lng->txt("tst_eval_total_persons"),
624 'value' => count($foundParticipants)
625 ));
626 $total_finished = $eval->getTotalFinishedParticipants();
627 array_push($data, array(
628 'result' => $this->lng->txt("tst_eval_total_finished"),
629 'value' => $total_finished
630 ));
631 $average_time = $this->object->evalTotalStartedAverageTime(
632 $eval->getParticipantIds()
633 );
634 $diff_seconds = $average_time;
635 $diff_hours = floor($diff_seconds / 3600);
636 $diff_seconds -= $diff_hours * 3600;
637 $diff_minutes = floor($diff_seconds / 60);
638 $diff_seconds -= $diff_minutes * 60;
639 array_push($data, array(
640 'result' => $this->lng->txt("tst_eval_total_finished_average_time"),
641 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
642 ));
643 $total_passed = 0;
644 $total_passed_reached = 0;
645 $total_passed_max = 0;
646 $total_passed_time = 0;
647 foreach ($foundParticipants as $userdata) {
648 if ($userdata->getPassed()) {
649 $total_passed++;
650 $total_passed_reached += $userdata->getReached();
651 $total_passed_max += $userdata->getMaxpoints();
652 $total_passed_time += $userdata->getTimeOfWork();
653 }
654 }
655 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
656 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
657 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
658 array_push($data, array(
659 'result' => $this->lng->txt("tst_eval_total_passed"),
660 'value' => $total_passed
661 ));
662 array_push($data, array(
663 'result' => $this->lng->txt("tst_eval_total_passed_average_points"),
664 'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)
665 ));
666 $average_time = $average_passed_time;
667 $diff_seconds = $average_time;
668 $diff_hours = floor($diff_seconds / 3600);
669 $diff_seconds -= $diff_hours * 3600;
670 $diff_minutes = floor($diff_seconds / 60);
671 $diff_seconds -= $diff_minutes * 60;
672 array_push($data, array(
673 'result' => $this->lng->txt("tst_eval_total_passed_average_time"),
674 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
675 ));
676 }
677
678 include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
679 $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
680 $table_gui->setData($data);
681 $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
682
683 $rows = array();
684 foreach ($eval->getQuestionTitles() as $question_id => $question_title) {
685 $answered = 0;
686 $reached = 0;
687 $max = 0;
688 foreach ($foundParticipants as $userdata) {
689 for ($i = 0; $i <= $userdata->getLastPass(); $i++) {
690 if (is_object($userdata->getPass($i))) {
691 $question = &$userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
692 if (is_array($question)) {
693 $answered++;
694 $reached += $question["reached"];
695 $max += $question["points"];
696 }
697 }
698 }
699 }
700 $percent = $max ? $reached / $max * 100.0 : 0;
701 $counter++;
702 $this->ctrl->setParameter($this, "qid", $question_id);
703
704 $points_reached = ($answered ? $reached / $answered : 0);
705 $points_max = ($answered ? $max / $answered : 0);
706 array_push(
707 $rows,
708 array(
709 'qid' => $question_id,
710 'title' => $question_title,
711 'points' => $points_reached,
712 'points_reached' => $points_reached,
713 'points_max' => $points_max,
714 'percentage' => (float) $percent,
715 'answers' => $answered
716 )
717 );
718 }
719 include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
720 $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
721 $table_gui->setData($rows);
722 $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
723 }
724
728 public function exportEvaluation()
729 {
730 $filterby = "";
731 if (array_key_exists("g_filterby", $_GET)) {
732 $filterby = $_GET["g_filterby"];
733 }
734
735 $filtertext = "";
736 if (array_key_exists("g_userfilter", $_GET)) {
737 $filtertext = $_GET["g_userfilter"];
738 }
739
740 $passedonly = false;
741 if (array_key_exists("g_passedonly", $_GET)) {
742 if ($_GET["g_passedonly"] == 1) {
743 $passedonly = true;
744 }
745 }
746
747 require_once 'Modules/Test/classes/class.ilTestExportFactory.php';
748 $expFactory = new ilTestExportFactory($this->object);
749
750 switch ($_POST["export_type"]) {
751 case "excel":
752 $expFactory->getExporter('results')->exportToExcel(
753 $deliver = true,
754 $filterby,
755 $filtertext,
756 $passedonly
757 );
758 break;
759
760 case "csv":
761 $expFactory->getExporter('results')->exportToCSV(
762 $deliver = true,
763 $filterby,
764 $filtertext,
765 $passedonly
766 );
767 break;
768
769 case "certificate":
770 if ($passedonly) {
771 $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
772 }
773 if (strlen($filtertext)) {
774 $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
775 }
776 $this->ctrl->redirect($this, "exportCertificate");
777 break;
778 }
779 }
780
786 public function exportAggregatedResults()
787 {
788 require_once 'Modules/Test/classes/class.ilTestExportFactory.php';
789 $expFactory = new ilTestExportFactory($this->object);
790 $exportObj = $expFactory->getExporter('aggregated');
791
792 switch ($_POST["export_type"]) {
793 case "excel":
794 $exportObj->exportToExcel($deliver = true);
795 break;
796 case "csv":
797 $exportObj->exportToCSV($deliver = true);
798 break;
799 }
800 }
801
808 public function exportCertificate()
809 {
810 global $DIC;
811
812 $globalCertificatePrerequisites = new ilCertificateActiveValidator();
813 if (!$globalCertificatePrerequisites->validate()) {
814 $DIC['ilErr']->raiseError($this->lng->txt('permission_denied'), $DIC['ilErr']->MESSAGE);
815 }
816
817 $database = $DIC->database();
818 $logger = $DIC->logger()->root();
819
821
822 $certificate = $factory->create($this->object);
823
824 $archive_dir = $certificate->createArchiveDirectory();
825 $total_users = array();
826
827 $this->object->setAccessFilteredParticipantList(
828 $this->object->buildStatisticsAccessFilteredParticipantList()
829 );
830
831 $ilUserCertificateRepository = new ilUserCertificateRepository($database, $logger);
832 $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $logger);
833
834 $total_users = &$this->object->evalTotalPersonsArray();
835 if (count($total_users)) {
836 $certValidator = new ilCertificateDownloadValidator();
837
838 foreach ($total_users as $active_id => $name) {
839 $user_id = $this->object->_getUserIdFromActiveId($active_id);
840
841 if (!$certValidator->isCertificateDownloadable($user_id, $this->object->getId())) {
842 continue;
843 }
844
845 $pdfAction = new ilCertificatePdfAction(
846 $logger,
847 $pdfGenerator,
849 $this->lng->txt('error_creating_certificate_pdf')
850 );
851
852 $pdf = $pdfAction->createPDF($user_id, $this->object->getid());
853 if (strlen($pdf)) {
854 $certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
855 }
856 }
857 $zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, true);
858 }
859 }
860
867 public function getEvaluationQuestionId($question_id, $original_id = "")
868 {
869 if ($original_id > 0) {
870 return $original_id;
871 } else {
872 return $question_id;
873 }
874 }
875
884 {
885 global $DIC;
886 $ilTabs = $DIC['ilTabs'];
887 $ilAccess = $DIC['ilAccess'];
888 $ilObjDataCache = $DIC['ilObjDataCache'];
889
890 $active_id = (int) $_GET["active_id"];
891
892 if (!$this->getTestAccess()->checkResultsAccessForActiveId($active_id)) {
894 }
895
896 $this->ctrl->saveParameter($this, "active_id");
897 $testSession = $this->testSessionFactory->getSession($active_id);
898
899 // protect actives from other tests
900 if ($testSession->getTestId() != $this->object->getTestId()) {
902 }
903
904 $this->ctrl->saveParameter($this, "pass");
905 $pass = (int) $_GET["pass"];
906
907 if (isset($_GET['statistics']) && $_GET['statistics'] == 1) {
908 $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
909 $this->ctrl->saveParameter($this, 'statistics');
910
911 $ilTabs->setBackTarget(
912 $this->lng->txt('back'),
913 $this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'detailedEvaluation')
914 );
915 } elseif ($this->object->getNrOfTries() == 1) {
916 $ilTabs->setBackTarget(
917 $this->lng->txt('back'),
918 $this->ctrl->getLinkTargetByClass('ilParticipantsTestResultsGUI')
919 );
920 } else {
921 $ilTabs->setBackTarget(
922 $this->lng->txt('tst_results_back_overview'),
923 $this->ctrl->getLinkTarget($this, 'outParticipantsResultsOverview')
924 );
925 }
926
927 // prepare generation before contents are processed (for mathjax)
928 if ($this->isPdfDeliveryRequest()) {
930 }
931
932 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
933 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
934
935 $objectivesList = null;
936
937 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
938 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
939 $testSequence->loadFromDb();
940 $testSequence->loadQuestions();
941
942 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
943 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
944
945 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
946 $objectivesList->loadObjectivesTitles();
947
948 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
949 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
950 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
951 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
952 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
953 }
954
955 $result_array = $this->getFilteredTestResult($active_id, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired());
956
957 $overviewTableGUI = $this->getPassDetailsOverviewTableGUI($result_array, $active_id, $pass, $this, "outParticipantsPassDetails", '', true, $objectivesList);
958 $overviewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
959 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, false);
960 $user_id = $this->object->_getUserIdFromActiveId($active_id);
961
962 $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", true, true, "Modules/Test");
963
964 $toolbar = $this->buildUserTestResultsToolbarGUI();
965
966 $this->ctrl->setParameter($this, 'pdf', '1');
967 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
968 $this->ctrl->setParameter($this, 'pdf', '');
969
970 if (isset($_GET['show_best_solutions'])) {
971 $_SESSION['tst_results_show_best_solutions'] = true;
972 } elseif (isset($_GET['hide_best_solutions'])) {
973 $_SESSION['tst_results_show_best_solutions'] = false;
974 } elseif (!isset($_SESSION['tst_results_show_best_solutions'])) {
975 $_SESSION['tst_results_show_best_solutions'] = false;
976 }
977
978 if ($_SESSION['tst_results_show_best_solutions']) {
979 $this->ctrl->setParameter($this, 'hide_best_solutions', '1');
980 $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
981 $this->ctrl->setParameter($this, 'hide_best_solutions', '');
982 } else {
983 $this->ctrl->setParameter($this, 'show_best_solutions', '1');
984 $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
985 $this->ctrl->setParameter($this, 'show_best_solutions', '');
986 }
987
988 $toolbar->build();
989 $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
990
991 if ($this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1) {
992 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
993 $gradingMessageBuilder->buildList();
994
995 $template->setCurrentBlock('grading_message');
996 $template->setVariable('GRADING_MESSAGE', $gradingMessageBuilder->getList());
997 $template->parseCurrentBlock();
998 }
999
1000 $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, $_SESSION['tst_results_show_best_solutions'], false, false, false, true, $objectivesList, $testResultHeaderLabelBuilder);
1001 $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1002 $template->setVariable("PASS_DETAILS", $this->ctrl->getHTML($overviewTableGUI));
1003
1004 $data = &$this->object->getCompleteEvaluationData();
1005 $result = $data->getParticipant($active_id)->getReached() . " " . strtolower($this->lng->txt("of")) . " " . $data->getParticipant($active_id)->getMaxpoints() . " (" . sprintf("%2.2f", $data->getParticipant($active_id)->getReachedPointsInPercent()) . " %" . ")";
1006 $template->setCurrentBlock('total_score');
1007 $template->setVariable("TOTAL_RESULT_TEXT",$this->lng->txt('tst_stat_result_resultspoints'));
1008 $template->setVariable("TOTAL_RESULT",$result);
1009 $template->parseCurrentBlock();
1010
1011 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1012 $template->setVariable("USER_DATA", $user_data);
1013
1014 $uname = $this->object->userLookupFullName($user_id);
1015 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1016
1017 $template->setVariable("TEXT_RESULTS", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
1018 }
1019
1020 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1021
1022 $this->populateExamId($template, (int) $active_id, (int) $pass);
1024
1025 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1026 if ($this->object->getShowSolutionAnswersOnly()) {
1027 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1028 }
1029
1030 if ($this->isPdfDeliveryRequest()) {
1031 //$this->object->deliverPDFfromHTML($template->get());
1032 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
1033 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_USER_RESULT);
1034 } else {
1035 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1036 }
1037 }
1038
1045 {
1046 global $DIC;
1047 $ilTabs = $DIC['ilTabs'];
1048 $ilObjDataCache = $DIC['ilObjDataCache'];
1049
1050 $active_id = (int) $_GET["active_id"];
1051
1052 if (!$this->getTestAccess()->checkResultsAccessForActiveId($active_id)) {
1054 }
1055
1056 $testSession = $this->testSessionFactory->getSession($active_id);
1057
1058 // protect actives from other tests
1059 if ($testSession->getTestId() != $this->object->getTestId()) {
1061 }
1062
1063 if ($this->object->getNrOfTries() == 1) {
1064 $this->ctrl->setParameter($this, "active_id", $active_id);
1065 $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
1066 $this->ctrl->redirect($this, "outParticipantsPassDetails");
1067 }
1068
1069 $ilTabs->setBackTarget(
1070 $this->lng->txt('back'),
1071 $this->ctrl->getLinkTargetByClass('ilParticipantsTestResultsGUI')
1072 );
1073
1074 // prepare generation before contents are processed (for mathjax)
1075 if ($this->isPdfDeliveryRequest()) {
1077 }
1078
1079 $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", true, true, "Modules/Test");
1080
1081 $toolbar = $this->buildUserTestResultsToolbarGUI();
1082
1083 $this->ctrl->setParameter($this, 'pdf', '1');
1084 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, __FUNCTION__));
1085 $this->ctrl->setParameter($this, 'pdf', '');
1086
1087 $toolbar->build();
1088 $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1089
1090 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1091 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1092 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1093 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1094 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1095 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1096 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1097 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1098 }
1099
1100 global $DIC; /* @var ILIAS\DI\Container $DIC */
1101 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1102 $testPassesSelector = new ilTestPassesSelector($DIC['ilDB'], $this->object);
1103 $testPassesSelector->setActiveId($testSession->getActiveId());
1104 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1105
1106 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this);
1107 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1108 $passOverViewTableGUI->setResultPresentationEnabled(true);
1109 $passOverViewTableGUI->setPassDetailsCommand('outParticipantsPassDetails');
1110 $passOverViewTableGUI->init();
1111 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getExistingPasses(), true, true));
1112 $passOverViewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassOverviewHeaderLabel());
1113 $template->setVariable("PASS_OVERVIEW", $passOverViewTableGUI->getHTML());
1114
1115 if ($this->isGradingMessageRequired()) {
1116 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1117 $gradingMessageBuilder->buildList();
1118
1119 $template->setCurrentBlock('grading_message');
1120 $template->setVariable('GRADING_MESSAGE', $gradingMessageBuilder->getList());
1121 $template->parseCurrentBlock();
1122 }
1123
1124 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1125 $user_id = $this->object->_getUserIdFromActiveId($active_id);
1126
1127 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1128 if ($this->object->getAnonymity()) {
1129 $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1130 } else {
1131 $uname = $this->object->userLookupFullName($user_id, true);
1132 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1133 $template->setVariable("USER_DATA", $user_data);
1134 }
1135 }
1136
1137 $template->parseCurrentBlock();
1138
1139
1140 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1141 if ($this->object->getShowSolutionAnswersOnly()) {
1142 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1143 }
1144
1145 if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1)) {
1146 //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1147
1148 $name = ilObjUser::_lookupName($user_id);
1149 $filename = $name['lastname'] . '_' . $name['firstname'] . '_' . $name['login'] . '__' . $this->object->getTitleFilenameCompliant();
1150 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
1152 //ilUtil::deliverData($file, ilUtil::getASCIIFilename($this->object->getTitle()) . ".pdf", "application/pdf", false, true);
1153 //$template->setVariable("PDF_FILE_LOCATION", $filename);
1154 } else {
1155 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1156 }
1157 }
1158
1160 {
1161 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1162 $tableGUI->initFilter();
1163 $tableGUI->resetOffset();
1164 $tableGUI->writeFilterToSession();
1165 $this->outUserPassDetails();
1166 }
1167
1169 {
1170 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1171 $tableGUI->initFilter();
1172 $tableGUI->resetOffset();
1173 $tableGUI->resetFilter();
1174 $this->outUserPassDetails();
1175 }
1176
1178 {
1179 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outParticipantsPassDetails');
1180 $tableGUI->initFilter();
1181 $tableGUI->resetOffset();
1182 $tableGUI->writeFilterToSession();
1184 }
1185
1187 {
1188 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outParticipantsPassDetails');
1189 $tableGUI->initFilter();
1190 $tableGUI->resetOffset();
1191 $tableGUI->resetFilter();
1193 }
1194
1200 public function outUserPassDetails()
1201 {
1202 global $DIC;
1203 $ilTabs = $DIC['ilTabs'];
1204 $ilUser = $DIC['ilUser'];
1205 $ilObjDataCache = $DIC['ilObjDataCache'];
1206
1207 $ilTabs->clearSubTabs();
1208 $ilTabs->setBackTarget($this->lng->txt('tst_results_back_overview'), $this->ctrl->getLinkTarget($this));
1209
1210 $testSession = $this->testSessionFactory->getSession();
1211
1212 if (!$this->object->getShowPassDetails()) {
1213 #$executable = $this->object->isExecutable($testSession, $ilUser->getId());
1214
1215 #if($executable["executable"])
1216 #{
1217 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1218 #}
1219 }
1220
1221 $active_id = $testSession->getActiveId();
1222 $user_id = $testSession->getUserId();
1223
1224 $this->ctrl->saveParameter($this, "pass");
1225 $pass = $_GET["pass"];
1226
1227 // prepare generation before contents are processed (for mathjax)
1228 if ($this->isPdfDeliveryRequest()) {
1230 }
1231
1232 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1233 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1234
1235 $objectivesList = null;
1236
1237 $considerHiddenQuestions = true;
1238 $considerOptionalQuestions = true;
1239
1240 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1241 $considerHiddenQuestions = false;
1242
1243 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
1244 $testSequence->loadFromDb();
1245 $testSequence->loadQuestions();
1246
1247 if ($this->object->isRandomTest() && !$testSequence->isAnsweringOptionalQuestionsConfirmed()) {
1248 $considerOptionalQuestions = false;
1249 }
1250
1251 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
1252 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
1253
1254 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
1255 $objectivesList->loadObjectivesTitles();
1256
1257 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1258 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1259 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1260 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1261 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1262 }
1263
1264 $result_array = $this->getFilteredTestResult($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions);
1265
1266 $command_solution_details = "";
1267 if ($this->object->getShowSolutionDetails()) {
1268 $command_solution_details = "outCorrectSolution";
1269 }
1270 $questionAnchorNav = $this->object->canShowSolutionPrintview();
1271
1272 $tpl = new ilTemplate('tpl.il_as_tst_pass_details_overview_participants.html', true, true, "Modules/Test");
1273
1274 if (!$this->isPdfDeliveryRequest()) {
1275 $toolbar = $this->buildUserTestResultsToolbarGUI();
1276
1277 $this->ctrl->setParameter($this, 'pdf', '1');
1278 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, 'outUserPassDetails'));
1279 $this->ctrl->setParameter($this, 'pdf', '');
1280
1281 $validator = new ilCertificateDownloadValidator();
1282 if ($validator->isCertificateDownloadable($user_id, $this->object->getId())) {
1283 $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1284 }
1285
1286 $toolbar->build();
1287
1288 $tpl->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1289
1290 $tpl->setCurrentBlock('signature');
1291 $tpl->setVariable("SIGNATURE", $this->getResultsSignature());
1292 $tpl->parseCurrentBlock();
1293
1294 if ($this->object->isShowExamIdInTestResultsEnabled()) {
1295 $tpl->setCurrentBlock('exam_id');
1296 $tpl->setVariable('EXAM_ID', ilObjTest::lookupExamId(
1297 $testSession->getActiveId(),
1298 $pass
1299 ));
1300 $tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1301 $tpl->parseCurrentBlock();
1302 }
1303 }
1304
1305 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() &&
1306 $this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1) {
1307 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1308 $gradingMessageBuilder->buildMessage();
1309 $gradingMessageBuilder->sendMessage();
1310
1311 #$template->setCurrentBlock('grading_message');
1312 #$template->setVariable('GRADING_MESSAGE', );
1313 #$template->parseCurrentBlock();
1314 }
1315
1316 $overviewTableGUI = $this->getPassDetailsOverviewTableGUI(
1317 $result_array,
1318 $active_id,
1319 $pass,
1320 $this,
1321 "outUserPassDetails",
1322 $command_solution_details,
1323 $questionAnchorNav,
1324 $objectivesList
1325 );
1326 $overviewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
1327 $tpl->setVariable("PASS_DETAILS", $this->ctrl->getHTML($overviewTableGUI));
1328
1329 $data = &$this->object->getCompleteEvaluationData();
1330 $result = $data->getParticipant($active_id)->getReached() . " " . strtolower($this->lng->txt("of")) . " " . $data->getParticipant($active_id)->getMaxpoints() . " (" . sprintf("%2.2f", $data->getParticipant($active_id)->getReachedPointsInPercent()) . " %" . ")";
1331 $tpl->setCurrentBlock('total_score');
1332 $tpl->setVariable("TOTAL_RESULT_TEXT",$this->lng->txt('tst_stat_result_resultspoints'));
1333 $tpl->setVariable("TOTAL_RESULT",$result);
1334 $tpl->parseCurrentBlock();
1335
1336 if ($this->object->canShowSolutionPrintview()) {
1337 $list_of_answers = $this->getPassListOfAnswers(
1338 $result_array,
1339 $active_id,
1340 $pass,
1341 $this->object->getShowSolutionListComparison(),
1342 false,
1343 false,
1344 false,
1345 true,
1346 $objectivesList,
1347 $testResultHeaderLabelBuilder
1348 );
1349 $tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1350 }
1351
1352 $tpl->setVariable("TEXT_RESULTS", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
1353 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1354
1355 $uname = $this->object->userLookupFullName($user_id, true);
1356 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1357 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1358 if ($this->object->getAnonymity()) {
1359 $tpl->setVariable("TEXT_HEADING", $this->lng->txt("tst_result_pass"));
1360 } else {
1361 $tpl->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1362 $tpl->setVariable("USER_DATA", $user_data);
1363 }
1364 }
1365
1366 $this->populateExamId($tpl, (int) $active_id, (int) $pass);
1368
1369 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1370 if ($this->object->getShowSolutionAnswersOnly()) {
1371 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1372 }
1373
1374 if ($this->isPdfDeliveryRequest()) {
1375 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
1376 ilTestPDFGenerator::generatePDF($tpl->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_USER_RESULT);
1377 } else {
1378 $this->tpl->setContent($tpl->get());
1379 }
1380 }
1381
1387 public function outUserResultsOverview()
1388 {
1389 global $DIC;
1390 $ilUser = $DIC['ilUser'];
1391 $ilObjDataCache = $DIC['ilObjDataCache'];
1392
1393 $testSession = $this->testSessionFactory->getSession();
1394 $active_id = $testSession->getActiveId();
1395 $user_id = $ilUser->getId();
1396 $uname = $this->object->userLookupFullName($user_id, true);
1397
1398 if (!$this->object->canShowTestResults($testSession)) {
1399 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1400 }
1401
1402 // prepare generation before contents are processed (for mathjax)
1403 if ($this->isPdfDeliveryRequest()) {
1405 }
1406
1407 $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", true, true, "Modules/Test");
1408 $template = new ilTemplate("tpl.il_as_tst_results_participant.html", true, true, "Modules/Test");
1409
1410 $toolbar = $this->buildUserTestResultsToolbarGUI();
1411
1412 $this->ctrl->setParameter($this, 'pdf', '1');
1413 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, 'outUserResultsOverview'));
1414 $this->ctrl->setParameter($this, 'pdf', '');
1415
1416 $validator = new ilCertificateDownloadValidator();
1417 if ($validator->isCertificateDownloadable($user_id, $this->object->getId())) {
1418 $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1419 }
1420
1421 $toolbar->build();
1422
1423 $templatehead->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1424
1425 $passDetailsEnabled = $this->object->getShowPassDetails();
1426 #if (!$passDetailsEnabled)
1427 #{
1428 # $executable = $this->object->isExecutable($testSession, $ilUser->getId());
1429 # if (!$executable["executable"]) $passDetailsEnabled = true;
1430 #}
1431
1432 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1433 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1434 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1435 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1436 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1437 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1438 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1439 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1440 }
1441
1442 $template->setCurrentBlock("pass_overview");
1443
1444 global $DIC; /* @var ILIAS\DI\Container $DIC */
1445 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1446 $testPassesSelector = new ilTestPassesSelector($DIC['ilDB'], $this->object);
1447 $testPassesSelector->setActiveId($testSession->getActiveId());
1448 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1449
1450 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this);
1451 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1452 $passOverViewTableGUI->setResultPresentationEnabled(true);
1453 if ($passDetailsEnabled) {
1454 $passOverViewTableGUI->setPassDetailsCommand('outUserPassDetails');
1455 }
1456 if ($this->object->isPassDeletionAllowed()) {
1457 $passOverViewTableGUI->setPassDeletionCommand('confirmDeletePass');
1458 }
1459 $passOverViewTableGUI->init();
1460 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getReportablePasses(), true));
1461 $passOverViewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassOverviewHeaderLabel());
1462 $overview = $passOverViewTableGUI->getHTML();
1463 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1464 require_once 'Modules/Test/classes/class.ilTestLearningObjectivesStatusGUI.php';
1465 $loStatus = new ilTestLearningObjectivesStatusGUI($this->lng);
1466 $loStatus->setCrsObjId($this->getObjectiveOrientedContainer()->getObjId());
1467 $loStatus->setUsrId($testSession->getUserId());
1468 $overview .= "<br />" . $loStatus->getHTML();
1469 }
1470 $template->setVariable("PASS_OVERVIEW", $overview);
1471 $template->parseCurrentBlock();
1472
1473 if ($this->isGradingMessageRequired()) {
1474 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1475 $gradingMessageBuilder->buildMessage();
1476 $gradingMessageBuilder->sendMessage();
1477
1478 #$template->setCurrentBlock('grading_message');
1479 #$template->setVariable('GRADING_MESSAGE', );
1480 #$template->parseCurrentBlock();
1481 }
1482
1483 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1484
1485 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1486 if ($this->object->getAnonymity()) {
1487 $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1488 } else {
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 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1497 }
1498 $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1499
1500 if ($this->isPdfDeliveryRequest()) {
1501 //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1502 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
1503 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_USER_RESULT);
1504 } else {
1505 $this->tpl->setContent($templatehead->get());
1506 }
1507 }
1508
1517 {
1518 global $DIC; /* @var ILIAS\DI\Container $DIC */
1519 $ilUser = $DIC['ilUser'];
1520 $ilObjDataCache = $DIC['ilObjDataCache'];
1521
1522 if (!$this->object->getShowSolutionPrintview()) {
1523 ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1524 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1525 }
1526
1527 $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", true, true, "Modules/Test");
1528
1529 $pass = null;
1530 if (array_key_exists("pass", $_GET)) {
1531 if (strlen($_GET["pass"])) {
1532 $pass = $_GET["pass"];
1533 }
1534 }
1535 $user_id = $ilUser->getId();
1536
1537 $testSession = $this->testSessionFactory->getSession();
1538 $active_id = $testSession->getActiveId();
1539
1540 $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1541
1542 global $DIC; /* @var ILIAS\DI\Container $DIC */
1543 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1544 $testPassesSelector = new ilTestPassesSelector($DIC['ilDB'], $this->object);
1545 $testPassesSelector->setActiveId($testSession->getActiveId());
1546 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1547
1548 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this);
1549 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1550 $passOverViewTableGUI->setResultPresentationEnabled(false);
1551 $passOverViewTableGUI->setPassDetailsCommand('outUserListOfAnswerPasses');
1552 $passOverViewTableGUI->init();
1553 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getClosedPasses(), false));
1554 $template->setVariable("PASS_OVERVIEW", $passOverViewTableGUI->getHTML());
1555
1556 $signature = "";
1557 if (strlen($pass)) {
1558 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1559 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1560
1561 $objectivesList = null;
1562
1563 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1564 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
1565 $testSequence->loadFromDb();
1566 $testSequence->loadQuestions();
1567
1568 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
1569 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
1570
1571 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
1572 $objectivesList->loadObjectivesTitles();
1573
1574 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1575 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1576 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1577 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1578 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1579 }
1580
1581 $result_array = $this->object->getTestResult(
1582 $active_id,
1583 $pass,
1584 false,
1585 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
1586 );
1587
1588 $signature = $this->getResultsSignature();
1589 $user_id = &$this->object->_getUserIdFromActiveId($active_id);
1590 $showAllAnswers = true;
1591 if ($this->object->isExecutable($testSession, $user_id)) {
1592 $showAllAnswers = false;
1593 }
1594 $this->setContextResultPresentation(false);
1595 $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, false, $showAllAnswers, false, false, false, $objectivesList, $testResultHeaderLabelBuilder);
1596 $template->setVariable("PASS_DETAILS", $answers);
1597 }
1598 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1599 $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1600 $template->setVariable("PRINT_URL", "javascript:window.print();");
1601
1602 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1603 $template->setVariable("USER_DATA", $user_data);
1604 $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1605 if (strlen($signature)) {
1606 $template->setVariable("SIGNATURE", $signature);
1607 }
1608 if (!is_null($pass) && $this->object->isShowExamIdInTestResultsEnabled()) {
1609 $template->setCurrentBlock('exam_id_footer');
1610 $template->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
1611 $testSession->getActiveId(),
1612 $pass
1613 ));
1614 $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1615 $template->parseCurrentBlock();
1616 }
1617 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1618
1619 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1620 if ($this->object->getShowSolutionAnswersOnly()) {
1621 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1622 }
1623 }
1624
1632 public function passDetails()
1633 {
1634 if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0)) {
1635 $this->ctrl->saveParameter($this, "pass");
1636 $this->ctrl->saveParameter($this, "active_id");
1637 $this->outTestResults(false, $_GET["pass"]);
1638 } else {
1639 $this->outTestResults(false);
1640 }
1641 }
1642
1647 public function singleResults()
1648 {
1649 global $DIC; /* @var ILIAS\DI\Container $DIC */
1650
1651 if (!$this->getTestAccess()->checkStatisticsAccess()) {
1653 }
1654
1655 $this->object->setAccessFilteredParticipantList(
1656 $this->object->buildStatisticsAccessFilteredParticipantList()
1657 );
1658
1659 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_STATISTICS);
1660
1661 $data = &$this->object->getCompleteEvaluationData();
1662 $color_class = array("tblrow1", "tblrow2");
1663 $counter = 0;
1664 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1665 $foundParticipants = &$data->getParticipants();
1666 if (count($foundParticipants) == 0) {
1667 ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
1668 return;
1669 } else {
1670 $rows = array();
1671 foreach ($data->getQuestionTitles() as $question_id => $question_title) {
1672 $answered = 0;
1673 $reached = 0;
1674 $max = 0;
1675 foreach ($foundParticipants as $userdata) {
1676 $pass = $userdata->getScoredPass();
1677 if (is_object($userdata->getPass($pass))) {
1678 $question = &$userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1679 if (is_array($question)) {
1680 $answered++;
1681 }
1682 }
1683 }
1684 $counter++;
1685 $this->ctrl->setParameter($this, "qid", $question_id);
1686 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
1687 $question_object = assQuestion::_instanciateQuestion($question_id);
1688 $download = "";
1689 if ($question_object instanceof ilObjFileHandlingQuestionType) {
1690 if ($question_object->hasFileUploads($this->object->getTestId())) {
1691 $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants") . "\">" . $this->lng->txt("download") . "</a>";
1692 }
1693 }
1694 array_push(
1695 $rows,
1696 array(
1697 'qid' => $question_id,
1698 'question_title' => $question_title,
1699 'number_of_answers' => $answered,
1700 'output' => "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants") . "\">" . $this->lng->txt("pdf_export") . "</a>",
1701 'file_uploads' => $download
1702 )
1703 );
1704 }
1705 if (count($rows)) {
1706 require_once './Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php';
1707 $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults");
1708 $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
1709 $table_gui->setData($rows);
1710
1711 $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
1712 } else {
1713 $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
1714 }
1715 }
1716 }
1717
1721 public function outCertificate()
1722 {
1723 global $DIC;
1724
1725 $user = $DIC->user();
1726 $database = $DIC->database();
1727 $logger = $DIC->logger()->root();
1728
1729 $ilUserCertificateRepository = new ilUserCertificateRepository($database, $logger);
1730 $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $logger);
1731
1732 $pdfAction = new ilCertificatePdfAction(
1733 $logger,
1734 $pdfGenerator,
1736 $this->lng->txt('error_creating_certificate_pdf')
1737 );
1738
1739 $pdfAction->downloadPdf((int) $user->getId(), (int) $this->object->getId());
1740 }
1741
1742 public function confirmDeletePass()
1743 {
1744 if (isset($_GET['context']) && strlen($_GET['context'])) {
1745 $context = $_GET['context'];
1746 } else {
1748 }
1749
1750 if (!$this->object->isPassDeletionAllowed() && !$this->object->isDynamicTest()) {
1752 }
1753
1754 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1755
1756 $confirm = new ilTestPassDeletionConfirmationGUI($this->ctrl, $this->lng, $this);
1757 $confirm->build((int) $_GET['active_id'], (int) $_GET['pass'], $context);
1758
1759 global $DIC;
1760 $tpl = $DIC['tpl'];
1761 $tpl->setContent($this->ctrl->getHTML($confirm));
1762 }
1763
1764 public function cancelDeletePass()
1765 {
1766 $this->redirectToPassDeletionContext($_POST['context']);
1767 }
1768
1770 {
1771 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1772
1773 switch ($context) {
1775
1776 $this->ctrl->redirect($this, 'outUserResultsOverview');
1777
1778 // no break
1780
1781 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
1782
1783 // no break
1785
1786 $this->ctrl->redirectByClass('ilTestPlayerDynamicQuestionSetGUI', 'startTest');
1787 }
1788 }
1789
1790 public function performDeletePass()
1791 {
1792 if (isset($_POST['context']) && strlen($_POST['context'])) {
1793 $context = $_POST['context'];
1794 } else {
1796 }
1797
1798 if (!$this->object->isPassDeletionAllowed() && !$this->object->isDynamicTest()) {
1800 }
1802 global $DIC;
1803 $ilDB = $DIC['ilDB'];
1804
1805 $active_fi = null;
1806 $pass = null;
1807
1808 if (isset($_POST['active_id']) && (int) $_POST['active_id']) {
1809 $active_fi = $_POST['active_id'];
1810 }
1811
1812 if (isset($_POST['pass']) && is_numeric($_POST['pass'])) {
1813 $pass = $_POST['pass'];
1814 }
1815
1816 if (is_null($active_fi) || is_null($pass)) {
1817 $this->ctrl->redirect($this, 'outUserResultsOverview');
1818 }
1819
1820 if (!$this->object->isDynamicTest() && $pass == $this->object->_getResultPass($active_fi)) {
1821 $this->ctrl->redirect($this, 'outUserResultsOverview');
1822 }
1823
1824 // Get information
1825 $result = $ilDB->query("
1826 SELECT tst_active.tries, tst_active.last_finished_pass, tst_sequence.pass
1827 FROM tst_active
1828 LEFT JOIN tst_sequence
1829 ON tst_sequence.active_fi = tst_active.active_id
1830 AND tst_sequence.pass = tst_active.tries
1831 WHERE tst_active.active_id = {$ilDB->quote($active_fi, 'integer')}
1832 ");
1833
1834 $row = $ilDB->fetchAssoc($result);
1835
1836 $tries = $row['tries'];
1837 $lastFinishedPass = is_numeric($row['last_finished_pass']) ? $row['last_finished_pass'] : -1;
1838
1839 if ($pass < $lastFinishedPass) {
1840 $isActivePass = false;
1841 $must_renumber = true;
1842 } elseif ($pass == $lastFinishedPass) {
1843 $isActivePass = false;
1844
1845 if ($tries == $row['pass']) {
1846 $must_renumber = true;
1847 } else {
1848 $must_renumber = false;
1849 }
1850 } elseif ($pass == $row['pass']) {
1851 $isActivePass = true;
1852 $must_renumber = false;
1853 } else {
1854 throw new ilTestException('This should not happen, please contact Bjoern Heyser to clean up this pass salad!');
1855 }
1856
1857 if (!$this->object->isDynamicTest() && $isActivePass) {
1858 $this->ctrl->redirect($this, 'outUserResultsOverview');
1859 }
1860
1861 if ($pass == 0 && (
1862 ($lastFinishedPass == 0 && $tries == 1 && $tries != $row['pass'])
1863 || ($isActivePass == true) // should be equal to || ($lastFinishedPass == -1 && $tries == 0)
1864 )) {
1865 $last_pass = true;
1866 } else {
1867 $last_pass = false;
1868 }
1869
1870 // Work on tables:
1871 // tst_active
1872 if ($last_pass) {
1873 $ilDB->manipulate(
1874 'DELETE
1875 FROM tst_active
1876 WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1877 );
1878 } elseif (!$isActivePass) {
1879 $ilDB->manipulate(
1880 'UPDATE tst_active
1881 SET tries = ' . $ilDB->quote($tries - 1, 'integer') . ',
1882 last_finished_pass = ' . $ilDB->quote($lastFinishedPass - 1, 'integer') . '
1883 WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1884 );
1885 }
1886 // tst_manual_fb
1887 $ilDB->manipulate(
1888 'DELETE
1889 FROM tst_manual_fb
1890 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1891 AND pass = ' . $ilDB->quote($pass, 'integer')
1892 );
1893
1894 if ($must_renumber) {
1895 $ilDB->manipulate(
1896 'UPDATE tst_manual_fb
1897 SET pass = pass - 1
1898 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1899 AND pass > ' . $ilDB->quote($pass, 'integer')
1900 );
1901 }
1902
1903 // tst_mark -> nothing to do
1904 //
1905 // tst_pass_result
1906 $ilDB->manipulate(
1907 'DELETE
1908 FROM tst_pass_result
1909 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1910 AND pass = ' . $ilDB->quote($pass, 'integer')
1911 );
1912
1913 if ($must_renumber) {
1914 $ilDB->manipulate(
1915 'UPDATE tst_pass_result
1916 SET pass = pass - 1
1917 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1918 AND pass > ' . $ilDB->quote($pass, 'integer')
1919 );
1920 }
1921
1922 // tst_qst_solved -> nothing to do
1923
1924 // tst_rnd_copy -> nothing to do
1925 // tst_rnd_qpl_title -> nothing to do
1926
1927 // tst_sequence
1928 $ilDB->manipulate(
1929 'DELETE
1930 FROM tst_sequence
1931 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1932 AND pass = ' . $ilDB->quote($pass, 'integer')
1933 );
1934
1935 if ($must_renumber) {
1936 $ilDB->manipulate(
1937 'UPDATE tst_sequence
1938 SET pass = pass - 1
1939 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1940 AND pass > ' . $ilDB->quote($pass, 'integer')
1941 );
1942 }
1943
1944 if ($this->object->isDynamicTest()) {
1945 $tables = array(
1946 'tst_seq_qst_tracking', 'tst_seq_qst_answstatus', 'tst_seq_qst_postponed', 'tst_seq_qst_checked'
1947 );
1948
1949 foreach ($tables as $table) {
1950 $ilDB->manipulate("
1951 DELETE FROM $table
1952 WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
1953 AND pass = {$ilDB->quote($pass, 'integer')}
1954 ");
1955
1956 if ($must_renumber) {
1957 $ilDB->manipulate("
1958 UPDATE $table
1959 SET pass = pass - 1
1960 WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
1961 AND pass > {$ilDB->quote($pass, 'integer')}
1962 ");
1963 }
1964 }
1965 }
1966
1967 // tst_solutions
1968 $ilDB->manipulate(
1969 'DELETE
1970 FROM tst_solutions
1971 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1972 AND pass = ' . $ilDB->quote($pass, 'integer')
1973 );
1974
1975 if ($must_renumber) {
1976 $ilDB->manipulate(
1977 'UPDATE tst_solutions
1978 SET pass = pass - 1
1979 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1980 AND pass > ' . $ilDB->quote($pass, 'integer')
1981 );
1982 }
1983
1984 // tst_test_result
1985 $ilDB->manipulate(
1986 'DELETE
1987 FROM tst_test_result
1988 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1989 AND pass = ' . $ilDB->quote($pass, 'integer')
1990 );
1991
1992 if ($must_renumber) {
1993 $ilDB->manipulate(
1994 'UPDATE tst_test_result
1995 SET pass = pass - 1
1996 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1997 AND pass > ' . $ilDB->quote($pass, 'integer')
1998 );
1999 }
2000
2001 // tst_test_rnd_qst -> nothing to do
2002
2003 // tst_times
2004 $ilDB->manipulate(
2005 'DELETE
2006 FROM tst_times
2007 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
2008 AND pass = ' . $ilDB->quote($pass, 'integer')
2009 );
2010
2011 if ($must_renumber) {
2012 $ilDB->manipulate(
2013 'UPDATE tst_times
2014 SET pass = pass - 1
2015 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
2016 AND pass > ' . $ilDB->quote($pass, 'integer')
2017 );
2018 }
2019
2020 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
2022 $this->object->logAction($this->lng->txtlng("assessment", "log_deleted_pass", ilObjAssessmentFolder::_getLogLanguage()));
2023 }
2024 // tst_result_cache
2025 // Ggfls. nur renumbern.
2026 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
2028
2029 if ($this->object->isDynamicTest()) {
2030 require_once 'Modules/Test/classes/tables/class.ilTestDynamicQuestionSetStatisticTableGUI.php';
2032 }
2033
2035 }
2036
2037 protected function getFilteredTestResult($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions)
2038 {
2039 global $DIC;
2040 $ilDB = $DIC['ilDB'];
2041 $ilPluginAdmin = $DIC['ilPluginAdmin'];
2042
2043 $resultData = $this->object->getTestResult($active_id, $pass, false, $considerHiddenQuestions);
2044 $questionIds = array();
2045 foreach ($resultData as $resultItemKey => $resultItemValue) {
2046 if ($resultItemKey === 'test' || $resultItemKey === 'pass') {
2047 continue;
2048 }
2049
2050 $questionIds[] = $resultItemValue['qid'];
2051 }
2052
2053 $table_gui = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
2054 $table_gui->initFilter();
2055
2056 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
2057 $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin);
2058
2059 $questionList->setIncludeQuestionIdsFilter($questionIds);
2060 $questionList->setQuestionInstanceTypeFilter(null);
2061
2062 foreach ($table_gui->getFilterItems() as $item) {
2063 if (substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_') {
2064 $v = $item->getValue();
2065
2066 if (is_array($v) && count($v) && !(int) $v[0]) {
2067 continue;
2068 }
2069
2070 $taxId = substr($item->getPostVar(), strlen('tax_'));
2071 $questionList->addTaxonomyFilter($taxId, $item->getValue(), $this->object->getId(), 'tst');
2072 } elseif ($item->getValue() !== false) {
2073 $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
2074 }
2075 }
2076
2077 $questionList->load();
2078
2079 $filteredTestResult = array();
2080
2081 foreach ($resultData as $resultItemKey => $resultItemValue) {
2082 if ($resultItemKey === 'test' || $resultItemKey === 'pass') {
2083 continue;
2084 }
2085
2086 if (!$questionList->isInList($resultItemValue['qid'])) {
2087 continue;
2088 }
2089
2090 $filteredTestResult[] = $resultItemValue;
2091 }
2092
2093 return $filteredTestResult;
2094 }
2095
2097 {
2098 global $DIC; /* @var ILIAS\DI\Container $DIC */
2099
2100 $activeId = (int) $_GET["active_id"];
2101
2102 require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
2104
2105 require_once 'Modules/Test/classes/class.ilTestParticipantList.php';
2106 $participantData = new ilTestParticipantData($DIC->database(), $DIC->language());
2107 $participantData->setActiveIdsFilter(array($activeId));
2108 $participantData->setParticipantAccessFilter($accessFilter);
2109 $participantData->load($this->object->getTestId());
2110
2111 if (!in_array($activeId, $participantData->getActiveIds())) {
2113 }
2114
2115 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
2116 $cgui = new ilConfirmationGUI();
2117
2118 $cgui->setHeaderText(sprintf(
2119 $this->lng->txt("finish_pass_for_user_confirmation"),
2120 $participantData->getFormatedFullnameByActiveId($activeId)
2121 ));
2122
2123 $this->ctrl->setParameter($this, 'active_id', $activeId);
2124 $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2125
2126 $cgui->setCancel($this->lng->txt("cancel"), "redirectBackToParticipantsScreen");
2127 $cgui->setConfirm($this->lng->txt("proceed"), "confirmFinishTestPassForUser");
2128
2129 $this->tpl->setContent($cgui->getHTML());
2130 }
2131
2133 {
2134 global $DIC; /* @var ILIAS\DI\Container $DIC */
2135
2136 $activeId = (int) $_GET["active_id"];
2137
2138 require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
2140
2141 require_once 'Modules/Test/classes/class.ilTestParticipantList.php';
2142 $participantData = new ilTestParticipantData($DIC->database(), $DIC->language());
2143 $participantData->setActiveIdsFilter(array($activeId));
2144 $participantData->setParticipantAccessFilter($accessFilter);
2145 $participantData->load($this->object->getTestId());
2146
2147 if (in_array($activeId, $participantData->getActiveIds())) {
2148 $this->finishTestPass($activeId, $this->object->getId());
2149 }
2150
2152 }
2153
2154 public function finishAllUserPasses()
2155 {
2156 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
2157 $cgui = new ilConfirmationGUI();
2158 $cgui->setFormAction($this->ctrl->getFormAction($this));
2159 $cgui->setHeaderText($this->lng->txt("finish_pass_for_all_users"));
2160 $cgui->setCancel($this->lng->txt("cancel"), "redirectBackToParticipantsScreen");
2161 $cgui->setConfirm($this->lng->txt("proceed"), "confirmFinishTestPassForAllUser");
2162 $this->tpl->setContent($cgui->getHTML());
2163 }
2164
2166 {
2167 require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
2169
2170 require_once 'Modules/Test/classes/class.ilTestParticipantList.php';
2171 $participantList = new ilTestParticipantList($this->object);
2172 $participantList->initializeFromDbRows($this->object->getTestParticipants());
2173 $participantList = $participantList->getAccessFilteredList($accessFilter);
2174
2175 foreach ($participantList as $participant) {
2176 if (!$participant->hasUnfinishedPasses()) {
2177 continue;
2178 }
2179
2180 $this->finishTestPass($participant->getActiveId(), $this->object->getId());
2181 }
2182
2184 }
2185
2186 protected function finishTestPass($active_id, $obj_id)
2187 {
2188 $this->processLockerFactory->setActiveId($active_id);
2189 $processLocker = $this->processLockerFactory->getLocker();
2190
2191 $test_pass_finisher = new ilTestPassFinishTasks($active_id, $obj_id);
2192 $test_pass_finisher->performFinishTasks($processLocker);
2193 }
2194
2196 {
2197 $this->ctrl->redirectByClass("ilTestParticipantsGUI");
2198 }
2199}
$result
$factory
Definition: metadata.php:43
$filename
Definition: buildRTE.php:89
$_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.
Validates if an active certificate is stored in the database and can be downloaded by the user.
Just a wrapper class to create Unit Test for other classes.
Confirmation screen class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
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 accessViolationRedirect()
static _getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
static lookupExamId($active_id, $pass)
static lookupLastTestPassAccess($activeId, $passIndex)
static lookupPassResultsUpdateTimestamp($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 prepareGenerationRequest($service, $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
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.
outEvaluation()
Creates the evaluation output for the 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.
eval_a()
Output of anonymous aggregated results for the test.
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, $purpose=null)
Class ilTestPassFinishTasks.
Service GUI class for tests.
populateExamId(ilTemplate $tpl, int $activeId, int $pass)
populatePassFinishDate($tpl, $passFinishDate)
getResultsSignature()
Returns HTML code for a signature field.
getCommand($cmd)
Retrieves the ilCtrl command.
buildPassOverviewTableGUI($targetGUI)
getQuestionResultForTestUsers($question_id, $test_id)
Creates a HTML representation for the results of a given question in a test.
setContextResultPresentation($contextResultPresentation)
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectivesAdapter, ilTestQuestionSequence $testSequence)
getPassOverviewTableData(ilTestSession $testSession, $passes, $withResults)
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.
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.
$template
$i
Definition: disco.tpl.php:19
$pdf
Definition: example_001.php:31
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
const SCORE_BEST_PASS
const PDF_USER_RESULT
PDF Purposes.
Interface ilObjFileHandlingQuestionType.
$user
Definition: migrateto20.php:57
$row
Class ilPdfGeneratorConstantsTest.
$ret
Definition: parser.php:6
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
global $ilDB
$ilUser
Definition: imgupload.php:18
$data
Definition: bench.php:6
$context
Definition: webdav.php:25
$rows
Definition: xhr_table.php:10