ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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'),
50 $DIC->database()
51 );
52 }
53
57 public function executeCommand()
58 {
59 $cmd = $this->ctrl->getCmd();
60 $next_class = $this->ctrl->getNextClass($this);
61 $this->ctrl->saveParameter($this, "sequence");
62 $this->ctrl->saveParameter($this, "active_id");
63 $cmd = $this->getCommand($cmd);
64 switch ($next_class) {
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 public function &getHeaderNames()
81 {
82 $headernames = array();
83 if ($this->object->getAnonymity()) {
84 array_push($headernames, $this->lng->txt("counter"));
85 } else {
86 array_push($headernames, $this->lng->txt("name"));
87 array_push($headernames, $this->lng->txt("login"));
88 }
89 $additionalFields = $this->object->getEvaluationAdditionalFields();
90 if (count($additionalFields)) {
91 foreach ($additionalFields as $fieldname) {
92 array_push($headernames, $this->lng->txt($fieldname));
93 }
94 }
95 array_push($headernames, $this->lng->txt("tst_reached_points"));
96 array_push($headernames, $this->lng->txt("tst_mark"));
97 if ($this->object->getECTSOutput()) {
98 array_push($headernames, $this->lng->txt("ects_grade"));
99 }
100 array_push($headernames, $this->lng->txt("tst_answered_questions"));
101 array_push($headernames, $this->lng->txt("working_time"));
102 array_push($headernames, $this->lng->txt("detailed_evaluation"));
103 return $headernames;
104 }
105
106 public function &getHeaderVars()
107 {
108 $headervars = array();
109 if ($this->object->getAnonymity()) {
110 array_push($headervars, "counter");
111 } else {
112 array_push($headervars, "name");
113 array_push($headervars, "login");
114 }
115 array_push($headervars, "resultspoints");
116 array_push($headervars, "resultsmarks");
117 if ($this->object->getECTSOutput()) {
118 array_push($headervars, "ects_grade");
119 }
120 array_push($headervars, "qworkedthrough");
121 array_push($headervars, "timeofwork");
122 array_push($headervars, "");
123 return $headervars;
124 }
125
126 public function filterEvaluation()
127 {
128 include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
129 $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
130 $table_gui->writeFilterToSession();
131 $this->ctrl->redirect($this, "outEvaluation");
132 }
133
134 public function resetfilterEvaluation()
135 {
136 include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
137 $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
138 $table_gui->resetFilter();
139 $this->ctrl->redirect($this, "outEvaluation");
140 }
141
147 public function outEvaluation()
148 {
153 global $ilAccess, $ilToolbar;
154
155 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id))) {
156 // allow only evaluation access
157 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
158 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
159 }
160
161 include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
162
163 $table_gui = new ilEvaluationAllTableGUI(
164 $this,
165 'outEvaluation',
166 $this->object->getAnonymity(),
167 $this->object->isOfferingQuestionHintsEnabled()
168 );
169
170 $data = array();
171 $arrFilter = array();
172
173 foreach ($table_gui->getFilterItems() as $item) {
174 if ($item->getValue() !== false) {
175 switch ($item->getPostVar()) {
176 case 'group':
177 case 'name':
178 case 'course':
179 $arrFilter[$item->getPostVar()] = $item->getValue();
180 break;
181 case 'passed_only':
182 $passedonly = $item->getChecked();
183 break;
184 }
185 }
186 }
187 include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
188 $eval = new ilTestEvaluationData($this->object);
189 $eval->setFilterArray($arrFilter);
190 $foundParticipants =&$eval->getParticipants();
191 $counter = 1;
192 if (count($foundParticipants) > 0) {
193 if ($this->object->getECTSOutput()) {
194 $passed_array =&$this->object->getTotalPointsPassedArray();
195 }
196 foreach ($foundParticipants as $active_id => $userdata) {
197 /* @var $userdata ilTestEvaluationUserData */
198
199 $remove = false;
200 if ($passedonly) {
201 $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent());
202
203 if ($mark_obj->getPassed() == false || !$userdata->areObligationsAnswered()) {
204 $remove = true;
205 }
206 }
207 if (!$remove) {
208 // build the evaluation row
209 $evaluationrow = array();
210 if ($this->object->getAnonymity()) {
211 $evaluationrow['name'] = $counter;
212 $evaluationrow['login'] = '';
213 } else {
214 $evaluationrow['name'] = $userdata->getName();
215 if (strlen($userdata->getLogin())) {
216 $evaluationrow['login'] = "[" . $userdata->getLogin() . "]";
217 } else {
218 $evaluationrow['login'] = '';
219 }
220 }
221
222 $evaluationrow['reached'] = $userdata->getReached();
223 $evaluationrow['max'] = $userdata->getMaxpoints();
224 $evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass();
225 $percentage = $userdata->getReachedPointsInPercent();
226 $mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
227 if (is_object($mark)) {
228 $evaluationrow['mark'] = $mark->getShortName();
229 }
230 if ($this->object->getECTSOutput()) {
231 $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints());
232 $evaluationrow['ects_grade'] = $ects_mark;
233 }
234 $evaluationrow['answered'] = $userdata->getQuestionsWorkedThroughInPercent();
235 $evaluationrow['questions_worked_through'] = $userdata->getQuestionsWorkedThrough();
236 $evaluationrow['number_of_questions'] = $userdata->getNumberOfQuestions();
237 $time_seconds = $userdata->getTimeOfWork();
238 $time_hours = floor($time_seconds/3600);
239 $time_seconds -= $time_hours * 3600;
240 $time_minutes = floor($time_seconds/60);
241 $time_seconds -= $time_minutes * 60;
242 $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
243 $this->ctrl->setParameter($this, "active_id", $active_id);
244 $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
245 $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
246 $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>";
247 $userfields = ilObjUser::_lookupFields($userdata->getUserID());
248 $evaluationrow['gender'] = $userfields['gender'];
249 $evaluationrow['email'] = $userfields['email'];
250 $evaluationrow['institution'] = $userfields['institution'];
251 $evaluationrow['street'] = $userfields['street'];
252 $evaluationrow['city'] = $userfields['city'];
253 $evaluationrow['zipcode'] = $userfields['zipcode'];
254 $evaluationrow['country'] = $userfields['country'];
255 $evaluationrow['sel_country'] = $userfields['sel_country'];
256 $evaluationrow['department'] = $userfields['department'];
257 $evaluationrow['matriculation'] = $userfields['matriculation'];
258 $counter++;
259 $data[] = $evaluationrow;
260 }
261 }
262 }
263
264 $table_gui->setData($data);
265 if (count($foundParticipants) > 0) {
266 $ilToolbar->setFormName('form_output_eval');
267 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportEvaluation'));
268 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
269 $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
270 $options = array(
271 'excel' => $this->lng->txt('exp_type_excel'),
272 'csv' => $this->lng->txt('exp_type_spss')
273 );
274
275 if (!$this->object->getAnonymity()) {
276 include_once 'Services/Certificate/classes/class.ilCertificate.php';
277 include_once 'Modules/Test/classes/class.ilTestCertificateAdapter.php';
279 $options['certificate'] = $this->lng->txt('exp_type_certificate');
280 }
281 }
282
283 $export_type->setOptions($options);
284
285 $ilToolbar->addInputItem($export_type, true);
286 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
287 $button = ilSubmitButton::getInstance();
288 $button->setCommand('exportEvaluation');
289 $button->setCaption('export');
290 $button->getOmitPreventDoubleSubmission();
291 $ilToolbar->addButtonInstance($button);
292 }
293
294 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
295 if ($this->object->getShowSolutionAnswersOnly()) {
296 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
297 }
298
299 $this->tpl->setContent($table_gui->getHTML());
300 }
301
309 public function detailedEvaluation()
310 {
311 global $DIC;
312
313 if ((!$DIC->access()->checkAccess('tst_statistics', '', $this->ref_id)) && (!$DIC->access()->checkAccess('write', '', $this->ref_id))) {
314 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
315 $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
316 }
317
318 $active_id = $_GET['active_id'];
319 if (strlen($active_id) == 0) {
320 ilUtil::sendInfo($this->lng->txt('detailed_evaluation_missing_active_id'), true);
321 $this->ctrl->redirect($this, 'outEvaluation');
322 }
323
324 $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print');
325
326 $toolbar = $DIC['ilToolbar'];
327
328 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
329 $backBtn = ilLinkButton::getInstance();
330 $backBtn->setCaption('back');
331 $backBtn->setUrl($this->ctrl->getLinkTarget($this, 'outEvaluation'));
332 $toolbar->addInputItem($backBtn);
333
334 $data =&$this->object->getCompleteEvaluationData();
335
336 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
337 $form = new ilPropertyFormGUI();
338 $form->setTitle(sprintf(
339 $this->lng->txt('detailed_evaluation_for'),
340 $data->getParticipant($active_id)->getName()
341 ));
342
343 $resultPoints = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_resultspoints'));
344 $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()) . " %" . ")");
345 $form->addItem($resultPoints);
346
347 if (strlen($data->getParticipant($active_id)->getMark())) {
348 $resultMarks = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_resultsmarks'));
349 $resultMarks->setValue($data->getParticipant($active_id)->getMark());
350 $form->addItem($resultMarks);
351 if (strlen($data->getParticipant($active_id)->getECTSMark())) {
352 $ectsGrade = new ilNonEditableValueGUI($this->lng->txt('ects_grade'));
353 $ectsGrade->setValue($data->getParticipant($active_id)->getECTSMark());
354 $form->addItem($ectsGrade);
355 }
356 }
357
358 if ($this->object->isOfferingQuestionHintsEnabled()) {
359 $requestHints = new ilNonEditableValueGUI($this->lng->txt('tst_question_hints_requested_hint_count_header'));
360 $requestHints->setValue($data->getParticipant($active_id)->getRequestedHintsCountFromScoredPass());
361 $form->addItem($requestHints);
362 }
363
364 $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
365 $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
366 $time_hours = floor($time_seconds/3600);
367 $time_seconds -= $time_hours * 3600;
368 $time_minutes = floor($time_seconds/60);
369 $time_seconds -= $time_minutes * 60;
370 $timeOfWork = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_timeofwork'));
371 $timeOfWork->setValue(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
372 $form->addItem($timeOfWork);
373
374 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt(""));
375 $time_hours = floor($atime_seconds/3600);
376 $atime_seconds -= $time_hours * 3600;
377 $time_minutes = floor($atime_seconds/60);
378 $atime_seconds -= $time_minutes * 60;
379 $avgTimeOfWork = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_atimeofwork'));
380 $avgTimeOfWork->setValue(sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
381 $form->addItem($avgTimeOfWork);
382
383 $firstVisit = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_firstvisit'));
384 $firstVisit->setValue(ilDatePresentation::formatDate(new ilDateTime($data->getParticipant($active_id)->getFirstVisit(), IL_CAL_UNIX)));
385 $form->addItem($firstVisit);
386
387 $lastVisit = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_lastvisit'));
388 $lastVisit->setValue(ilDatePresentation::formatDate(new ilDateTime($data->getParticipant($active_id)->getLastVisit(), IL_CAL_UNIX)));
389 $form->addItem($lastVisit);
390
391 $nrPasses = new ilNonEditableValueGUI($this->lng->txt('tst_nr_of_passes'));
392 $nrPasses->setValue($data->getParticipant($active_id)->getLastPass() + 1);
393 $form->addItem($nrPasses);
394
395 $scoredPass = new ilNonEditableValueGUI($this->lng->txt('scored_pass'));
396 if ($this->object->getPassScoring() == SCORE_BEST_PASS) {
397 $scoredPass->setValue($data->getParticipant($active_id)->getBestPass() + 1);
398 } else {
399 $scoredPass->setValue($data->getParticipant($active_id)->getLastPass() + 1);
400 }
401 $form->addItem($scoredPass);
402
403 $median = $data->getStatistics()->getStatistics()->median();
404 $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
405 $mark = $this->object->mark_schema->getMatchingMark($pct);
406 if (is_object($mark)) {
407 $markMedian = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_mark_median'));
408 $markMedian->setValue($mark->getShortName());
409 $form->addItem($markMedian);
410 }
411
412 $rankParticipant = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_rank_participant'));
413 $rankParticipant->setValue($data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
414 $form->addItem($rankParticipant);
415
416 $rankMedian = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_rank_median'));
417 $rankMedian->setValue($data->getStatistics()->getStatistics()->rank_median());
418 $form->addItem($rankMedian);
419
420 $totalParticipants = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_total_participants'));
421 $totalParticipants->setValue($data->getStatistics()->getStatistics()->count());
422 $form->addItem($totalParticipants);
423
424 $medianField = new ilNonEditableValueGUI($this->lng->txt('tst_stat_result_median'));
425 $medianField->setValue($median);
426 $form->addItem($medianField);
427
428 $this->tpl->setContent($form->getHTML());
429
430 $tables = array();
431
432 for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++) {
433 $finishdate = ilObjTest::lookupPassResultsUpdateTimestamp($active_id, $pass);
434 if ($finishdate > 0) {
435 if (($DIC->access()->checkAccess('write', '', (int) $_GET['ref_id']))) {
436 $this->ctrl->setParameter($this, 'statistics', '1');
437 $this->ctrl->setParameter($this, 'active_id', $active_id);
438 $this->ctrl->setParameter($this, 'pass', $pass);
439 } else {
440 $this->ctrl->setParameter($this, 'statistics', '');
441 $this->ctrl->setParameter($this, 'active_id', '');
442 $this->ctrl->setParameter($this, 'pass', '');
443 }
444
445 require_once 'Modules/Test/classes/tables/class.ilTestDetailedEvaluationStatisticsTableGUI.php';
446 $table = new ilTestDetailedEvaluationStatisticsTableGUI($this, 'detailedEvaluation', ($pass + 1) . '_' . $this->object->getId());
447 $table->setTitle(sprintf($this->lng->txt("tst_eval_question_points"), $pass + 1));
448 if (($DIC->access()->checkAccess('write', '', (int) $_GET['ref_id']))) {
449 $table->addCommandButton('outParticipantsPassDetails', $this->lng->txt('tst_show_answer_sheet'));
450 }
451
452 $questions = $data->getParticipant($active_id)->getQuestions($pass);
453 if (!is_array($questions)) {
454 $questions = $data->getParticipant($active_id)->getQuestions(0);
455 }
456
457 $tableData = array();
458
459 $counter = 0;
460 foreach ((array) $questions as $question) {
461 $userDataData = array(
462 'counter' => ++$counter,
463 'id' => $question['id'],
464 'id_txt' => $this->lng->txt('question_id_short'),
465 'title' => $data->getQuestionTitle($question['id'])
466 );
467
468 $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
469 if (is_array($answeredquestion)) {
470 $percent = $answeredquestion['points'] ? $answeredquestion['reached'] / $answeredquestion['points'] * 100.0 : 0;
471 $userDataData['points'] = $answeredquestion['reached'] . ' ' . strtolower($this->lng->txt('of')) . " " . $answeredquestion['points'] . ' (' . sprintf("%.2f", $percent) . ' %)';
472 } else {
473 $userDataData['points'] = '0 ' . strtolower($this->lng->txt('of')) . ' ' . $question['points'] . ' (' . sprintf("%.2f", 0) . ' %) - ' . $this->lng->txt('question_not_answered');
474 }
475
476 $tableData[] = $userDataData;
477 }
478 $table->setData($tableData);
479
480 $tables[] = $table->getHTML();
481 }
482 }
483
484 $GLOBALS['tpl']->setContent($form->getHTML() . implode('', $tables));
485 }
486
492 {
493 $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
494 }
495
501 {
502 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
503 $question_object = assQuestion::_instanciateQuestion($_GET["qid"]);
504 if ($question_object instanceof ilObjFileHandlingQuestionType) {
505 $question_object->deliverFileUploadZIPFile($this->object->getTestId(), $this->object->getTitle());
506 } else {
507 $this->ctrl->redirect($this, "singleResults");
508 }
509 }
510
518 public function eval_a()
519 {
524 global $ilAccess, $ilToolbar;
525
526 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id))) {
527 // allow only evaluation access
528 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
529 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
530 }
531
532 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
533 $eval =&$this->object->getCompleteEvaluationData();
534 $data = array();
535 $foundParticipants =&$eval->getParticipants();
536 if (count($foundParticipants)) {
537 $ilToolbar->setFormName('form_output_eval');
538 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'exportAggregatedResults'));
539 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
540 $export_type = new ilSelectInputGUI($this->lng->txt('exp_eval_data'), 'export_type');
541 $export_type->setOptions(array(
542 'excel' => $this->lng->txt('exp_type_excel'),
543 'csv' => $this->lng->txt('exp_type_spss')
544 ));
545 $ilToolbar->addInputItem($export_type, true);
546 require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
547 $button = ilSubmitButton::getInstance();
548 $button->setCommand('exportAggregatedResults');
549 $button->setCaption('export');
550 $button->getOmitPreventDoubleSubmission();
551 $ilToolbar->addButtonInstance($button);
552
553 array_push($data, array(
554 'result' => $this->lng->txt("tst_eval_total_persons"),
555 'value' => count($foundParticipants)
556 ));
557 $total_finished = $this->object->evalTotalFinished();
558 array_push($data, array(
559 'result' => $this->lng->txt("tst_eval_total_finished"),
560 'value' => $total_finished
561 ));
562 $average_time = $this->object->evalTotalStartedAverageTime();
563 $diff_seconds = $average_time;
564 $diff_hours = floor($diff_seconds/3600);
565 $diff_seconds -= $diff_hours * 3600;
566 $diff_minutes = floor($diff_seconds/60);
567 $diff_seconds -= $diff_minutes * 60;
568 array_push($data, array(
569 'result' => $this->lng->txt("tst_eval_total_finished_average_time"),
570 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
571 ));
572 $total_passed = 0;
573 $total_passed_reached = 0;
574 $total_passed_max = 0;
575 $total_passed_time = 0;
576 foreach ($foundParticipants as $userdata) {
577 if ($userdata->getPassed()) {
578 $total_passed++;
579 $total_passed_reached += $userdata->getReached();
580 $total_passed_max += $userdata->getMaxpoints();
581 $total_passed_time += $userdata->getTimeOfWork();
582 }
583 }
584 $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
585 $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
586 $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
587 array_push($data, array(
588 'result' => $this->lng->txt("tst_eval_total_passed"),
589 'value' => $total_passed
590 ));
591 array_push($data, array(
592 'result' => $this->lng->txt("tst_eval_total_passed_average_points"),
593 'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)
594 ));
595 $average_time = $average_passed_time;
596 $diff_seconds = $average_time;
597 $diff_hours = floor($diff_seconds/3600);
598 $diff_seconds -= $diff_hours * 3600;
599 $diff_minutes = floor($diff_seconds/60);
600 $diff_seconds -= $diff_minutes * 60;
601 array_push($data, array(
602 'result' => $this->lng->txt("tst_eval_total_passed_average_time"),
603 'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
604 ));
605 }
606
607 include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
608 $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
609 $table_gui->setData($data);
610 $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
611
612 $rows = array();
613 foreach ($eval->getQuestionTitles() as $question_id => $question_title) {
614 $answered = 0;
615 $reached = 0;
616 $max = 0;
617 foreach ($foundParticipants as $userdata) {
618 for ($i = 0; $i <= $userdata->getLastPass(); $i++) {
619 if (is_object($userdata->getPass($i))) {
620 $question =&$userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
621 if (is_array($question)) {
622 $answered++;
623 $reached += $question["reached"];
624 $max += $question["points"];
625 }
626 }
627 }
628 }
629 $percent = $max ? $reached/$max * 100.0 : 0;
630 $counter++;
631 $this->ctrl->setParameter($this, "qid", $question_id);
632
633 $points_reached = ($answered ? $reached / $answered : 0);
634 $points_max = ($answered ? $max / $answered : 0);
635 array_push(
636 $rows,
637 array(
638 'qid' => $question_id,
639 'title' => $question_title,
640 'points' => $points_reached,
641 'points_reached' => $points_reached,
642 'points_max' => $points_max,
643 'percentage' => (float) $percent,
644 'answers' => $answered
645 )
646 );
647 }
648 include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
649 $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
650 $table_gui->setData($rows);
651 $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
652 }
653
657 public function exportEvaluation()
658 {
659 $filterby = "";
660 if (array_key_exists("g_filterby", $_GET)) {
661 $filterby = $_GET["g_filterby"];
662 }
663
664 $filtertext = "";
665 if (array_key_exists("g_userfilter", $_GET)) {
666 $filtertext = $_GET["g_userfilter"];
667 }
668
669 $passedonly = false;
670 if (array_key_exists("g_passedonly", $_GET)) {
671 if ($_GET["g_passedonly"] == 1) {
672 $passedonly = true;
673 }
674 }
675
676 require_once 'Modules/Test/classes/class.ilTestExportFactory.php';
677 $expFactory = new ilTestExportFactory($this->object);
678
679 switch ($_POST["export_type"]) {
680 case "excel":
681 $expFactory->getExporter('results')->exportToExcel(
682 $deliver = true,
683 $filterby,
684 $filtertext,
685 $passedonly
686 );
687 break;
688
689 case "csv":
690 $expFactory->getExporter('results')->exportToCSV(
691 $deliver = true,
692 $filterby,
693 $filtertext,
694 $passedonly
695 );
696 break;
697
698 case "certificate":
699 if ($passedonly) {
700 $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
701 }
702 if (strlen($filtertext)) {
703 $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
704 }
705 $this->ctrl->redirect($this, "exportCertificate");
706 break;
707 }
708 }
709
715 public function exportAggregatedResults()
716 {
717 require_once 'Modules/Test/classes/class.ilTestExportFactory.php';
718 $expFactory = new ilTestExportFactory($this->object);
719 $exportObj = $expFactory->getExporter('aggregated');
720
721 switch ($_POST["export_type"]) {
722 case "excel":
723 $exportObj->exportToExcel($deliver = true);
724 break;
725 case "csv":
726 $exportObj->exportToCSV($deliver = true);
727 break;
728 }
729 }
730
737 public function exportCertificate()
738 {
739 global $ilUser;
740
741 include_once "./Services/Utilities/classes/class.ilUtil.php";
742 include_once "./Services/Certificate/classes/class.ilCertificate.php";
743 include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
744 $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
745 $archive_dir = $certificate->createArchiveDirectory();
746 $total_users = array();
747 $total_users =&$this->object->evalTotalPersonsArray();
748 if (count($total_users)) {
749 foreach ($total_users as $active_id => $name) {
750 $user_id = $this->object->_getUserIdFromActiveId($active_id);
751 $pdf = $certificate->outCertificate(
752 array(
753 "active_id" => $active_id,
754 "userfilter" => $userfilter,
755 "passedonly" => $passedonly
756 ),
757 false
758 );
759 if (strlen($pdf)) {
760 $certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
761 }
762 }
763 $zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, true);
764 }
765 }
766
773 public function getEvaluationQuestionId($question_id, $original_id = "")
774 {
775 if ($original_id > 0) {
776 return $original_id;
777 } else {
778 return $question_id;
779 }
780 }
781
790 {
791 global $ilTabs, $ilAccess, $ilObjDataCache;
792
793 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
794 // allow only write access
795 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
796 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
797 }
798
799 $this->ctrl->saveParameter($this, "active_id");
800 $active_id = (int) $_GET["active_id"];
801 $testSession = $this->testSessionFactory->getSession($active_id);
802
803 // protect actives from other tests
804 if ($testSession->getTestId() != $this->object->getTestId()) {
805 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
806 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
807 }
808
809 $this->ctrl->saveParameter($this, "pass");
810 $pass = (int) $_GET["pass"];
811
812 if (isset($_GET['statistics']) && $_GET['statistics'] == 1) {
813 $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
814 $this->ctrl->saveParameter($this, 'statistics');
815
816 $ilTabs->setBackTarget(
817 $this->lng->txt('back'),
818 $this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'detailedEvaluation')
819 );
820 } elseif ($this->object->getNrOfTries() == 1) {
821 $ilTabs->setBackTarget(
822 $this->lng->txt('back'),
823 $this->ctrl->getLinkTargetByClass('ilobjtestgui', 'participants')
824 );
825 } else {
826 $ilTabs->setBackTarget(
827 $this->lng->txt('tst_results_back_overview'),
828 $this->ctrl->getLinkTarget($this, 'outParticipantsResultsOverview')
829 );
830 }
831
832 // prepare generation before contents are processed (for mathjax)
833 if ($this->isPdfDeliveryRequest()) {
834 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
836 }
837
838 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
839 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
840
841 $objectivesList = null;
842
843 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
844 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
845 $testSequence->loadFromDb();
846 $testSequence->loadQuestions();
847
848 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
849 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
850
851 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
852 $objectivesList->loadObjectivesTitles();
853
854 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
855 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
856 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
857 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
858 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
859 }
860
861 $result_array = $this->getFilteredTestResult($active_id, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired());
862
863 $overviewTableGUI = $this->getPassDetailsOverviewTableGUI($result_array, $active_id, $pass, $this, "outParticipantsPassDetails", '', true, $objectivesList);
864 $overviewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
865 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, false);
866 $user_id = $this->object->_getUserIdFromActiveId($active_id);
867
868 $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", true, true, "Modules/Test");
869
870 $toolbar = $this->buildUserTestResultsToolbarGUI();
871
872 $this->ctrl->setParameter($this, 'pdf', '1');
873 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
874 $this->ctrl->setParameter($this, 'pdf', '');
875
876 if (isset($_GET['show_best_solutions'])) {
877 $_SESSION['tst_results_show_best_solutions'] = true;
878 } elseif (isset($_GET['hide_best_solutions'])) {
879 $_SESSION['tst_results_show_best_solutions'] = false;
880 } elseif (!isset($_SESSION['tst_results_show_best_solutions'])) {
881 $_SESSION['tst_results_show_best_solutions'] = false;
882 }
883
884 if ($_SESSION['tst_results_show_best_solutions']) {
885 $this->ctrl->setParameter($this, 'hide_best_solutions', '1');
886 $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
887 $this->ctrl->setParameter($this, 'hide_best_solutions', '');
888 } else {
889 $this->ctrl->setParameter($this, 'show_best_solutions', '1');
890 $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'outParticipantsPassDetails'));
891 $this->ctrl->setParameter($this, 'show_best_solutions', '');
892 }
893
894 $toolbar->build();
895 $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
896
897 if ($this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1) {
898 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
899 $gradingMessageBuilder->buildList();
900
901 $template->setCurrentBlock('grading_message');
902 $template->setVariable('GRADING_MESSAGE', $gradingMessageBuilder->getList());
903 $template->parseCurrentBlock();
904 }
905
906 $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, $_SESSION['tst_results_show_best_solutions'], false, false, false, true, $objectivesList, $testResultHeaderLabelBuilder);
907 $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
908 $template->setVariable("PASS_DETAILS", $this->ctrl->getHTML($overviewTableGUI));
909
910 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
911 $template->setVariable("USER_DATA", $user_data);
912
913 $uname = $this->object->userLookupFullName($user_id);
914 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
915
916 $template->setVariable("TEXT_RESULTS", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
917 }
918
919 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
920
922
923 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
924 if ($this->object->getShowSolutionAnswersOnly()) {
925 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
926 }
927
928 if ($this->isPdfDeliveryRequest()) {
929 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
930 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_USER_RESULT);
931 } else {
932 $this->tpl->setVariable("ADM_CONTENT", $template->get());
933 }
934 }
935
942 {
943 global $ilTabs, $ilAccess, $ilObjDataCache;
944
945 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
946 // allow only write access
947 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
948 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
949 }
950
951 $active_id = (int) $_GET["active_id"];
952 $testSession = $this->testSessionFactory->getSession($active_id);
953
954 // protect actives from other tests
955 if ($testSession->getTestId() != $this->object->getTestId()) {
956 ilUtil::sendInfo($this->lng->txt('no_permission'), true);
957 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
958 }
959
960 if ($this->object->getNrOfTries() == 1) {
961 $this->ctrl->setParameter($this, "active_id", $active_id);
962 $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
963 $this->ctrl->redirect($this, "outParticipantsPassDetails");
964 }
965
966 $ilTabs->setBackTarget(
967 $this->lng->txt('back'),
968 $this->ctrl->getLinkTargetByClass('ilobjtestgui', 'participants')
969 );
970
971 // prepare generation before contents are processed (for mathjax)
972 if ($this->isPdfDeliveryRequest()) {
973 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
975 }
976
977 $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", true, true, "Modules/Test");
978
979 $toolbar = $this->buildUserTestResultsToolbarGUI();
980
981 $this->ctrl->setParameter($this, 'pdf', '1');
982 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, __FUNCTION__));
983 $this->ctrl->setParameter($this, 'pdf', '');
984
985 $toolbar->build();
986 $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
987
988 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
989 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
990 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
991 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
992 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
993 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
994 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
995 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
996 }
997
998 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
999 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
1000 $testPassesSelector->setActiveId($testSession->getActiveId());
1001 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1002
1003 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this, 'outParticipantsResultsOverview');
1004 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1005 $passOverViewTableGUI->setResultPresentationEnabled(true);
1006 $passOverViewTableGUI->setPassDetailsCommand('outParticipantsPassDetails');
1007 $passOverViewTableGUI->init();
1008 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getExistingPasses(), true, true));
1009 $passOverViewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassOverviewHeaderLabel());
1010 $template->setVariable("PASS_OVERVIEW", $passOverViewTableGUI->getHTML());
1011
1012 if ($this->isGradingMessageRequired()) {
1013 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1014 $gradingMessageBuilder->buildList();
1015
1016 $template->setCurrentBlock('grading_message');
1017 $template->setVariable('GRADING_MESSAGE', $gradingMessageBuilder->getList());
1018 $template->parseCurrentBlock();
1019 }
1020
1021 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1022 $user_id = $this->object->_getUserIdFromActiveId($active_id);
1023
1024 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1025 if ($this->object->getAnonymity()) {
1026 $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1027 } else {
1028 $uname = $this->object->userLookupFullName($user_id, true);
1029 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1030 $template->setVariable("USER_DATA", $user_data);
1031 }
1032 }
1033
1034 $template->parseCurrentBlock();
1035
1036
1037 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1038 if ($this->object->getShowSolutionAnswersOnly()) {
1039 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1040 }
1041
1042 if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1)) {
1043 //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1044
1045 $name = ilObjUser::_lookupName($user_id);
1046 $filename = $name['lastname'] . '_' . $name['firstname'] . '_' . $name['login'] . '__' . $this->object->getTitleFilenameCompliant();
1047 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
1049 //ilUtil::deliverData($file, ilUtil::getASCIIFilename($this->object->getTitle()) . ".pdf", "application/pdf", false, true);
1050 //$template->setVariable("PDF_FILE_LOCATION", $filename);
1051 } else {
1052 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1053 }
1054 }
1055
1057 {
1058 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1059 $tableGUI->initFilter();
1060 $tableGUI->resetOffset();
1061 $tableGUI->writeFilterToSession();
1062 $this->outUserPassDetails();
1063 }
1064
1066 {
1067 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1068 $tableGUI->initFilter();
1069 $tableGUI->resetOffset();
1070 $tableGUI->resetFilter();
1071 $this->outUserPassDetails();
1072 }
1073
1075 {
1076 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outParticipantsPassDetails');
1077 $tableGUI->initFilter();
1078 $tableGUI->resetOffset();
1079 $tableGUI->writeFilterToSession();
1081 }
1082
1084 {
1085 $tableGUI = $this->buildPassDetailsOverviewTableGUI($this, 'outParticipantsPassDetails');
1086 $tableGUI->initFilter();
1087 $tableGUI->resetOffset();
1088 $tableGUI->resetFilter();
1090 }
1091
1097 public function outUserPassDetails()
1098 {
1099 global $ilTabs, $ilUser, $ilObjDataCache;
1100
1101 $this->handleTabs('results_pass_oriented');
1102
1103 if ($this->object->getNrOfTries() == 1) {
1104 $ilTabs->setBackTarget($this->lng->txt('tst_results_back_introduction'), $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen'));
1105 } else {
1106 $ilTabs->setBackTarget($this->lng->txt('tst_results_back_overview'), $this->ctrl->getLinkTarget($this, 'outUserResultsOverview'));
1107 }
1108
1109 $testSession = $this->testSessionFactory->getSession();
1110
1111 if (!$this->object->getShowPassDetails()) {
1112 #$executable = $this->object->isExecutable($testSession, $ilUser->getId());
1113
1114 #if($executable["executable"])
1115 #{
1116 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1117 #}
1118 }
1119
1120 $active_id = $testSession->getActiveId();
1121 $user_id = $testSession->getUserId();
1122
1123 $this->ctrl->saveParameter($this, "pass");
1124 $pass = $_GET["pass"];
1125
1126 // prepare generation before contents are processed (for mathjax)
1127 if ($this->isPdfDeliveryRequest()) {
1128 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
1130 }
1131
1132 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1133 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1134
1135 $objectivesList = null;
1136
1137 $considerHiddenQuestions = true;
1138 $considerOptionalQuestions = true;
1139
1140 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1141 $considerHiddenQuestions = false;
1142
1143 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
1144 $testSequence->loadFromDb();
1145 $testSequence->loadQuestions();
1146
1147 if ($this->object->isRandomTest() && !$testSequence->isAnsweringOptionalQuestionsConfirmed()) {
1148 $considerOptionalQuestions = false;
1149 }
1150
1151 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
1152 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
1153
1154 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
1155 $objectivesList->loadObjectivesTitles();
1156
1157 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1158 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1159 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1160 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1161 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1162 }
1163
1164 $result_array = $this->getFilteredTestResult($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions);
1165
1166 $command_solution_details = "";
1167 if ($this->object->getShowSolutionDetails()) {
1168 $command_solution_details = "outCorrectSolution";
1169 }
1170 $questionAnchorNav = $this->object->canShowSolutionPrintview();
1171
1172 $tpl = new ilTemplate('tpl.il_as_tst_pass_details_overview_participants.html', true, true, "Modules/Test");
1173
1174 if (!$this->isPdfDeliveryRequest()) {
1175 $toolbar = $this->buildUserTestResultsToolbarGUI();
1176
1177 $this->ctrl->setParameter($this, 'pdf', '1');
1178 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, 'outUserPassDetails'));
1179 $this->ctrl->setParameter($this, 'pdf', '');
1180
1181 include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1182 if ($this->object->canShowCertificate($testSession, $user_id, $active_id)) {
1183 $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1184 }
1185
1186 $toolbar->build();
1187
1188 $tpl->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1189
1190 $tpl->setCurrentBlock('signature');
1191 $tpl->setVariable("SIGNATURE", $this->getResultsSignature());
1192 $tpl->parseCurrentBlock();
1193
1194 if ($this->object->isShowExamIdInTestResultsEnabled()) {
1195 $tpl->setCurrentBlock('exam_id');
1196 $tpl->setVariable('EXAM_ID', ilObjTest::lookupExamId(
1197 $testSession->getActiveId(),
1198 $pass
1199 ));
1200 $tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1201 $tpl->parseCurrentBlock();
1202 }
1203 }
1204
1205 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() &&
1206 $this->isGradingMessageRequired() && $this->object->getNrOfTries() == 1) {
1207 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1208 $gradingMessageBuilder->buildMessage();
1209 $gradingMessageBuilder->sendMessage();
1210
1211 #$template->setCurrentBlock('grading_message');
1212 #$template->setVariable('GRADING_MESSAGE', );
1213 #$template->parseCurrentBlock();
1214 }
1215
1216 $overviewTableGUI = $this->getPassDetailsOverviewTableGUI(
1217 $result_array,
1218 $active_id,
1219 $pass,
1220 $this,
1221 "outUserPassDetails",
1222 $command_solution_details,
1223 $questionAnchorNav,
1224 $objectivesList
1225 );
1226 $overviewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1));
1227 $tpl->setVariable("PASS_DETAILS", $this->ctrl->getHTML($overviewTableGUI));
1228
1229 if ($this->object->canShowSolutionPrintview()) {
1230 $list_of_answers = $this->getPassListOfAnswers(
1231 $result_array,
1232 $active_id,
1233 $pass,
1234 $this->object->getShowSolutionListComparison(),
1235 false,
1236 false,
1237 false,
1238 true,
1239 $objectivesList,
1240 $testResultHeaderLabelBuilder
1241 );
1242 $tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1243 }
1244
1245 $tpl->setVariable("TEXT_RESULTS", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass+1));
1246 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1247
1248 $uname = $this->object->userLookupFullName($user_id, true);
1249 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1250 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1251 if ($this->object->getAnonymity()) {
1252 $tpl->setVariable("TEXT_HEADING", $this->lng->txt("tst_result_pass"));
1253 } else {
1254 $tpl->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1255 $tpl->setVariable("USER_DATA", $user_data);
1256 }
1257 }
1258
1260
1261 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1262 if ($this->object->getShowSolutionAnswersOnly()) {
1263 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1264 }
1265
1266 if ($this->isPdfDeliveryRequest()) {
1267 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
1268 ilTestPDFGenerator::generatePDF($tpl->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_USER_RESULT);
1269 } else {
1270 $this->tpl->setContent($tpl->get());
1271 }
1272 }
1273
1279 public function outUserResultsOverview()
1280 {
1281 global $ilUser, $ilTabs, $ilObjDataCache;
1282
1283 $this->handleTabs('results_pass_oriented');
1284
1285 $ilTabs->setBackTarget(
1286 $this->lng->txt('tst_results_back_introduction'),
1287 $this->ctrl->getLinkTargetByClass('ilObjTestGUI', 'infoScreen')
1288 );
1289
1290 $testSession = $this->testSessionFactory->getSession();
1291 $active_id = $testSession->getActiveId();
1292 $user_id = $ilUser->getId();
1293 $uname = $this->object->userLookupFullName($user_id, true);
1294
1295 if (!$this->object->canShowTestResults($testSession)) {
1296 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1297 }
1298
1299 // prepare generation before contents are processed (for mathjax)
1300 if ($this->isPdfDeliveryRequest()) {
1301 require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
1303 }
1304
1305 $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", true, true, "Modules/Test");
1306 $template = new ilTemplate("tpl.il_as_tst_results_participant.html", true, true, "Modules/Test");
1307
1308 $toolbar = $this->buildUserTestResultsToolbarGUI();
1309
1310 $this->ctrl->setParameter($this, 'pdf', '1');
1311 $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, 'outUserResultsOverview'));
1312 $this->ctrl->setParameter($this, 'pdf', '');
1313
1314 include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1315 if ($this->object->canShowCertificate($testSession, $user_id, $active_id)) {
1316 $toolbar->setCertificateLinkTarget($this->ctrl->getLinkTarget($this, 'outCertificate'));
1317 }
1318
1319 $toolbar->build();
1320
1321 $templatehead->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
1322
1323 $passDetailsEnabled = $this->object->getShowPassDetails();
1324 #if (!$passDetailsEnabled)
1325 #{
1326 # $executable = $this->object->isExecutable($testSession, $ilUser->getId());
1327 # if (!$executable["executable"]) $passDetailsEnabled = true;
1328 #}
1329
1330 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1331 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1332 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1333 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1334 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1335 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1336 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1337 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1338 }
1339
1340 $template->setCurrentBlock("pass_overview");
1341
1342 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1343 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
1344 $testPassesSelector->setActiveId($testSession->getActiveId());
1345 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1346
1347 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this, 'outUserResultsOverview');
1348 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1349 $passOverViewTableGUI->setResultPresentationEnabled(true);
1350 if ($passDetailsEnabled) {
1351 $passOverViewTableGUI->setPassDetailsCommand('outUserPassDetails');
1352 }
1353 if ($this->object->isPassDeletionAllowed()) {
1354 $passOverViewTableGUI->setPassDeletionCommand('confirmDeletePass');
1355 }
1356 $passOverViewTableGUI->init();
1357 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getReportablePasses(), true));
1358 $passOverViewTableGUI->setTitle($testResultHeaderLabelBuilder->getPassOverviewHeaderLabel());
1359 $overview = $passOverViewTableGUI->getHTML();
1360 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1361 require_once 'Modules/Test/classes/class.ilTestLearningObjectivesStatusGUI.php';
1362 $loStatus = new ilTestLearningObjectivesStatusGUI($this->lng);
1363 $loStatus->setCrsObjId($this->getObjectiveOrientedContainer()->getObjId());
1364 $loStatus->setUsrId($testSession->getUserId());
1365 $overview .= "<br />" . $loStatus->getHTML();
1366 }
1367 $template->setVariable("PASS_OVERVIEW", $overview);
1368 $template->parseCurrentBlock();
1369
1370 if ($this->isGradingMessageRequired()) {
1371 $gradingMessageBuilder = $this->getGradingMessageBuilder($active_id);
1372 $gradingMessageBuilder->buildMessage();
1373 $gradingMessageBuilder->sendMessage();
1374
1375 #$template->setCurrentBlock('grading_message');
1376 #$template->setVariable('GRADING_MESSAGE', );
1377 #$template->parseCurrentBlock();
1378 }
1379
1380 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1381
1382 if (!$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1383 if ($this->object->getAnonymity()) {
1384 $template->setVariable("TEXT_HEADING", $this->lng->txt("tst_result"));
1385 } else {
1386 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1387 $template->setVariable("USER_DATA", $user_data);
1388 }
1389 }
1390
1391 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1392 if ($this->object->getShowSolutionAnswersOnly()) {
1393 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1394 }
1395 $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1396
1397 if ($this->isPdfDeliveryRequest()) {
1398 //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
1399 require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
1400 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_USER_RESULT);
1401 } else {
1402 $this->tpl->setContent($templatehead->get());
1403 }
1404 }
1405
1414 {
1415 global $ilUser, $ilObjDataCache;
1416
1417 if (!$this->object->getShowSolutionPrintview()) {
1418 ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1419 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1420 }
1421
1422 $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", true, true, "Modules/Test");
1423
1424 $pass = null;
1425 if (array_key_exists("pass", $_GET)) {
1426 if (strlen($_GET["pass"])) {
1427 $pass = $_GET["pass"];
1428 }
1429 }
1430 $user_id = $ilUser->getId();
1431
1432 $testSession = $this->testSessionFactory->getSession();
1433 $active_id = $testSession->getActiveId();
1434
1435 $overview = "";
1436 if ($this->object->getNrOfTries() == 1) {
1437 $pass = 0;
1438 } else {
1439 $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1440
1441 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
1442 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
1443 $testPassesSelector->setActiveId($testSession->getActiveId());
1444 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
1445
1446 $passOverViewTableGUI = $this->buildPassOverviewTableGUI($this, 'outUserListOfAnswerPasses');
1447 $passOverViewTableGUI->setActiveId($testSession->getActiveId());
1448 $passOverViewTableGUI->setResultPresentationEnabled(false);
1449 $passOverViewTableGUI->setPassDetailsCommand('outUserListOfAnswerPasses');
1450 $passOverViewTableGUI->init();
1451 $passOverViewTableGUI->setData($this->getPassOverviewTableData($testSession, $testPassesSelector->getClosedPasses(), false));
1452 $template->setVariable("PASS_OVERVIEW", $passOverViewTableGUI->getHTML());
1453 }
1454
1455 $signature = "";
1456 if (strlen($pass)) {
1457 require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
1458 $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
1459
1460 $objectivesList = null;
1461
1462 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1463 $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass);
1464 $testSequence->loadFromDb();
1465 $testSequence->loadQuestions();
1466
1467 require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
1468 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);
1469
1470 $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
1471 $objectivesList->loadObjectivesTitles();
1472
1473 $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId());
1474 $testResultHeaderLabelBuilder->setUserId($testSession->getUserId());
1475 $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
1476 $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
1477 $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
1478 }
1479
1480 $result_array = $this->object->getTestResult(
1481 $active_id,
1482 $pass,
1483 false,
1484 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
1485 );
1486
1487 $signature = $this->getResultsSignature();
1488 $user_id =&$this->object->_getUserIdFromActiveId($active_id);
1489 $showAllAnswers = true;
1490 if ($this->object->isExecutable($testSession, $user_id)) {
1491 $showAllAnswers = false;
1492 }
1493 $this->setContextResultPresentation(false);
1494 $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, false, $showAllAnswers, false, false, false, $objectivesList, $testResultHeaderLabelBuilder);
1495 $template->setVariable("PASS_DETAILS", $answers);
1496 }
1497 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1498 $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1499 $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1500 $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1501 $template->setVariable("PRINT_URL", "javascript:window.print();");
1502
1503 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($testSession, $active_id, true);
1504 $template->setVariable("USER_DATA", $user_data);
1505 $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1506 if (strlen($signature)) {
1507 $template->setVariable("SIGNATURE", $signature);
1508 }
1509 if (!is_null($pass) && $this->object->isShowExamIdInTestResultsEnabled()) {
1510 $template->setCurrentBlock('exam_id_footer');
1511 $template->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
1512 $testSession->getActiveId(),
1513 $pass
1514 ));
1515 $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1516 $template->parseCurrentBlock();
1517 }
1518 $this->tpl->setVariable("ADM_CONTENT", $template->get());
1519
1520 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1521 if ($this->object->getShowSolutionAnswersOnly()) {
1522 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1523 }
1524 }
1525
1533 public function passDetails()
1534 {
1535 if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0)) {
1536 $this->ctrl->saveParameter($this, "pass");
1537 $this->ctrl->saveParameter($this, "active_id");
1538 $this->outTestResults(false, $_GET["pass"]);
1539 } else {
1540 $this->outTestResults(false);
1541 }
1542 }
1543
1548 public function singleResults()
1549 {
1550 global $ilAccess;
1551
1552 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id))) {
1553 // allow only evaluation access
1554 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1555 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1556 }
1557
1558 $data =&$this->object->getCompleteEvaluationData();
1559 $color_class = array("tblrow1", "tblrow2");
1560 $counter = 0;
1561 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1562 $foundParticipants =&$data->getParticipants();
1563 if (count($foundParticipants) == 0) {
1564 ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
1565 return;
1566 } else {
1567 $rows = array();
1568 foreach ($data->getQuestionTitles() as $question_id => $question_title) {
1569 $answered = 0;
1570 $reached = 0;
1571 $max = 0;
1572 foreach ($foundParticipants as $userdata) {
1573 $pass = $userdata->getScoredPass();
1574 if (is_object($userdata->getPass($pass))) {
1575 $question =&$userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1576 if (is_array($question)) {
1577 $answered++;
1578 }
1579 }
1580 }
1581 $counter++;
1582 $this->ctrl->setParameter($this, "qid", $question_id);
1583 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
1584 $question_object = assQuestion::_instanciateQuestion($question_id);
1585 $download = "";
1586 if ($question_object instanceof ilObjFileHandlingQuestionType) {
1587 if ($question_object->hasFileUploads($this->object->getTestId())) {
1588 $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants") . "\">" . $this->lng->txt("download") . "</a>";
1589 }
1590 }
1591 array_push(
1592 $rows,
1593 array(
1594 'qid' => $question_id,
1595 'question_title' => $question_title,
1596 'number_of_answers' => $answered,
1597 'output' => "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants") . "\">" . $this->lng->txt("pdf_export") . "</a>",
1598 'file_uploads' => $download
1599 )
1600 );
1601 }
1602 if (count($rows)) {
1603 require_once './Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php';
1604 $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults");
1605 $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
1606 $table_gui->setData($rows);
1607
1608 $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
1609 } else {
1610 $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
1611 }
1612 }
1613 }
1614
1618 public function outCertificate()
1619 {
1620 $testSession = $this->testSessionFactory->getSession();
1621
1622 require_once './Services/Certificate/classes/class.ilCertificate.php';
1623 require_once './Modules/Test/classes/class.ilTestCertificateAdapter.php';
1624 $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
1625 $certificate->outCertificate(
1626 array(
1627 "active_id" => $testSession->getActiveId(),
1628 "pass" => ilObjTest::_getResultPass($testSession->getActiveId())
1629 )
1630 );
1631 }
1632
1633 public function confirmDeletePass()
1634 {
1635 if (isset($_GET['context']) && strlen($_GET['context'])) {
1636 $context = $_GET['context'];
1637 } else {
1639 }
1640
1641 if (!$this->object->isPassDeletionAllowed() && !$this->object->isDynamicTest()) {
1642 $this->redirectToPassDeletionContext($context);
1643 }
1644
1645 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1646
1647 $confirm = new ilTestPassDeletionConfirmationGUI($this->ctrl, $this->lng, $this);
1648 $confirm->build((int) $_GET['active_id'], (int) $_GET['pass'], $context);
1649
1650 global $tpl;
1651 $tpl->setContent($this->ctrl->getHTML($confirm));
1652 }
1653
1654 public function cancelDeletePass()
1655 {
1656 $this->redirectToPassDeletionContext($_POST['context']);
1657 }
1658
1659 private function redirectToPassDeletionContext($context)
1660 {
1661 require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
1662
1663 switch ($context) {
1665
1666 $this->ctrl->redirect($this, 'outUserResultsOverview');
1667
1668 // no break
1670
1671 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
1672
1673 // no break
1675
1676 $this->ctrl->redirectByClass('ilTestPlayerDynamicQuestionSetGUI', 'startTest');
1677 }
1678 }
1679
1680 public function performDeletePass()
1681 {
1682 if (isset($_POST['context']) && strlen($_POST['context'])) {
1683 $context = $_POST['context'];
1684 } else {
1686 }
1687
1688 if (!$this->object->isPassDeletionAllowed() && !$this->object->isDynamicTest()) {
1689 $this->redirectToPassDeletionContext($context);
1690 }
1692 global $ilDB;
1693
1694 $active_fi = null;
1695 $pass = null;
1696
1697 if (isset($_POST['active_id']) && (int) $_POST['active_id']) {
1698 $active_fi = $_POST['active_id'];
1699 }
1700
1701 if (isset($_POST['pass']) && is_numeric($_POST['pass'])) {
1702 $pass = $_POST['pass'];
1703 }
1704
1705 if (is_null($active_fi) || is_null($pass)) {
1706 $this->ctrl->redirect($this, 'outUserResultsOverview');
1707 }
1708
1709 if (!$this->object->isDynamicTest() && $pass == $this->object->_getResultPass($active_fi)) {
1710 $this->ctrl->redirect($this, 'outUserResultsOverview');
1711 }
1712
1713 // Get information
1714 $result = $ilDB->query("
1715 SELECT tst_active.tries, tst_active.last_finished_pass, tst_sequence.pass
1716 FROM tst_active
1717 LEFT JOIN tst_sequence
1718 ON tst_sequence.active_fi = tst_active.active_id
1719 AND tst_sequence.pass = tst_active.tries
1720 WHERE tst_active.active_id = {$ilDB->quote($active_fi, 'integer')}
1721 ");
1722
1723 $row = $ilDB->fetchAssoc($result);
1724
1725 $tries = $row['tries'];
1726 $lastFinishedPass = is_numeric($row['last_finished_pass']) ? $row['last_finished_pass'] : -1;
1727
1728 if ($pass < $lastFinishedPass) {
1729 $isActivePass = false;
1730 $must_renumber = true;
1731 } elseif ($pass == $lastFinishedPass) {
1732 $isActivePass = false;
1733
1734 if ($tries == $row['pass']) {
1735 $must_renumber = true;
1736 } else {
1737 $must_renumber = false;
1738 }
1739 } elseif ($pass == $row['pass']) {
1740 $isActivePass = true;
1741 $must_renumber = false;
1742 } else {
1743 throw new ilTestException('This should not happen, please contact Bjoern Heyser to clean up this pass salad!');
1744 }
1745
1746 if (!$this->object->isDynamicTest() && $isActivePass) {
1747 $this->ctrl->redirect($this, 'outUserResultsOverview');
1748 }
1749
1750 if ($pass == 0 && (
1751 ($lastFinishedPass == 0 && $tries == 1 && $tries != $row['pass'])
1752 || ($isActivePass == true) // should be equal to || ($lastFinishedPass == -1 && $tries == 0)
1753 )) {
1754 $last_pass = true;
1755 } else {
1756 $last_pass = false;
1757 }
1758
1759 // Work on tables:
1760 // tst_active
1761 if ($last_pass) {
1762 $ilDB->manipulate(
1763 'DELETE
1764 FROM tst_active
1765 WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1766 );
1767 } elseif (!$isActivePass) {
1768 $ilDB->manipulate(
1769 'UPDATE tst_active
1770 SET tries = ' . $ilDB->quote($tries-1, 'integer') . ',
1771 last_finished_pass = ' . $ilDB->quote($lastFinishedPass-1, 'integer') . '
1772 WHERE active_id = ' . $ilDB->quote($active_fi, 'integer')
1773 );
1774 }
1775 // tst_manual_fb
1776 $ilDB->manipulate(
1777 'DELETE
1778 FROM tst_manual_fb
1779 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1780 AND pass = ' . $ilDB->quote($pass, 'integer')
1781 );
1782
1783 if ($must_renumber) {
1784 $ilDB->manipulate(
1785 'UPDATE tst_manual_fb
1786 SET pass = pass - 1
1787 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1788 AND pass > ' . $ilDB->quote($pass, 'integer')
1789 );
1790 }
1791
1792 // tst_mark -> nothing to do
1793 //
1794 // tst_pass_result
1795 $ilDB->manipulate(
1796 'DELETE
1797 FROM tst_pass_result
1798 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1799 AND pass = ' . $ilDB->quote($pass, 'integer')
1800 );
1801
1802 if ($must_renumber) {
1803 $ilDB->manipulate(
1804 'UPDATE tst_pass_result
1805 SET pass = pass - 1
1806 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1807 AND pass > ' . $ilDB->quote($pass, 'integer')
1808 );
1809 }
1810
1811 // tst_qst_solved -> nothing to do
1812
1813 // tst_rnd_copy -> nothing to do
1814 // tst_rnd_qpl_title -> nothing to do
1815
1816 // tst_sequence
1817 $ilDB->manipulate(
1818 'DELETE
1819 FROM tst_sequence
1820 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1821 AND pass = ' . $ilDB->quote($pass, 'integer')
1822 );
1823
1824 if ($must_renumber) {
1825 $ilDB->manipulate(
1826 'UPDATE tst_sequence
1827 SET pass = pass - 1
1828 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1829 AND pass > ' . $ilDB->quote($pass, 'integer')
1830 );
1831 }
1832
1833 if ($this->object->isDynamicTest()) {
1834 $tables = array(
1835 'tst_seq_qst_tracking', 'tst_seq_qst_answstatus', 'tst_seq_qst_postponed', 'tst_seq_qst_checked'
1836 );
1837
1838 foreach ($tables as $table) {
1839 $ilDB->manipulate("
1840 DELETE FROM $table
1841 WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
1842 AND pass = {$ilDB->quote($pass, 'integer')}
1843 ");
1844
1845 if ($must_renumber) {
1846 $ilDB->manipulate("
1847 UPDATE $table
1848 SET pass = pass - 1
1849 WHERE active_fi = {$ilDB->quote($active_fi, 'integer')}
1850 AND pass > {$ilDB->quote($pass, 'integer')}
1851 ");
1852 }
1853 }
1854 }
1855
1856 // tst_solutions
1857 $ilDB->manipulate(
1858 'DELETE
1859 FROM tst_solutions
1860 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1861 AND pass = ' . $ilDB->quote($pass, 'integer')
1862 );
1863
1864 if ($must_renumber) {
1865 $ilDB->manipulate(
1866 'UPDATE tst_solutions
1867 SET pass = pass - 1
1868 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1869 AND pass > ' . $ilDB->quote($pass, 'integer')
1870 );
1871 }
1872
1873 // tst_test_result
1874 $ilDB->manipulate(
1875 'DELETE
1876 FROM tst_test_result
1877 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1878 AND pass = ' . $ilDB->quote($pass, 'integer')
1879 );
1880
1881 if ($must_renumber) {
1882 $ilDB->manipulate(
1883 'UPDATE tst_test_result
1884 SET pass = pass - 1
1885 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1886 AND pass > ' . $ilDB->quote($pass, 'integer')
1887 );
1888 }
1889
1890 // tst_test_rnd_qst -> nothing to do
1891
1892 // tst_times
1893 $ilDB->manipulate(
1894 'DELETE
1895 FROM tst_times
1896 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1897 AND pass = ' . $ilDB->quote($pass, 'integer')
1898 );
1899
1900 if ($must_renumber) {
1901 $ilDB->manipulate(
1902 'UPDATE tst_times
1903 SET pass = pass - 1
1904 WHERE active_fi = ' . $ilDB->quote($active_fi, 'integer') . '
1905 AND pass > ' . $ilDB->quote($pass, 'integer')
1906 );
1907 }
1908
1909 require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
1911 $this->object->logAction($this->lng->txtlng("assessment", "log_deleted_pass", ilObjAssessmentFolder::_getLogLanguage()));
1912 }
1913 // tst_result_cache
1914 // Ggfls. nur renumbern.
1915 require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
1917
1918 if ($this->object->isDynamicTest()) {
1919 require_once 'Modules/Test/classes/tables/class.ilTestDynamicQuestionSetStatisticTableGUI.php';
1921 }
1922
1923 $this->redirectToPassDeletionContext($context);
1924 }
1925
1926 protected function getFilteredTestResult($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions)
1927 {
1928 global $ilDB, $ilPluginAdmin;
1929
1930 $resultData = $this->object->getTestResult($active_id, $pass, false, $considerHiddenQuestions);
1931 $questionIds = array();
1932 foreach ($resultData as $resultItemKey => $resultItemValue) {
1933 if ($resultItemKey === 'test' || $resultItemKey === 'pass') {
1934 continue;
1935 }
1936
1937 $questionIds[] = $resultItemValue['qid'];
1938 }
1939
1940 $table_gui = $this->buildPassDetailsOverviewTableGUI($this, 'outUserPassDetails');
1941 $table_gui->initFilter();
1942
1943 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
1944 $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin);
1945
1946 $questionList->setIncludeQuestionIdsFilter($questionIds);
1947 $questionList->setQuestionInstanceTypeFilter(null);
1948
1949 foreach ($table_gui->getFilterItems() as $item) {
1950 if (substr($item->getPostVar(), 0, strlen('tax_')) == 'tax_') {
1951 $v = $item->getValue();
1952
1953 if (is_array($v) && count($v) && !(int) $v[0]) {
1954 continue;
1955 }
1956
1957 $taxId = substr($item->getPostVar(), strlen('tax_'));
1958 $questionList->addTaxonomyFilter($taxId, $item->getValue(), $this->object->getId(), 'tst');
1959 } elseif ($item->getValue() !== false) {
1960 $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
1961 }
1962 }
1963
1964 $questionList->load();
1965
1966 $filteredTestResult = array();
1967
1968 foreach ($resultData as $resultItemKey => $resultItemValue) {
1969 if ($resultItemKey === 'test' || $resultItemKey === 'pass') {
1970 continue;
1971 }
1972
1973 if (!$questionList->isInList($resultItemValue['qid'])) {
1974 continue;
1975 }
1976
1977 $filteredTestResult[] = $resultItemValue;
1978 }
1979
1980 return $filteredTestResult;
1981 }
1982
1984 {
1985 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1986 $cgui = new ilConfirmationGUI();
1987 $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
1988 $cgui->setHeaderText($this->lng->txt("finish_pass_for_user_confirmation"));
1989 $cgui->setCancel($this->lng->txt("cancel"), "redirectBackToParticipantsScreen");
1990 $cgui->setConfirm($this->lng->txt("proceed"), "confirmFinishTestPassForUser");
1991 $this->tpl->setContent($cgui->getHTML());
1992 }
1993
1995 {
1996 require_once 'Modules/Test/classes/class.ilTestPassFinishTasks.php';
1997 $active_id = (int) $_GET["active_id"];
1998 $this->finishTestPass($active_id, $this->object->getId());
2000 }
2001
2002 public function finishAllUserPasses()
2003 {
2004 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
2005 $cgui = new ilConfirmationGUI();
2006 $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2007 $cgui->setHeaderText($this->lng->txt("finish_pass_for_all_users"));
2008 $cgui->setCancel($this->lng->txt("cancel"), "redirectBackToParticipantsScreen");
2009 $cgui->setConfirm($this->lng->txt("proceed"), "confirmFinishTestPassForAllUser");
2010 $this->tpl->setContent($cgui->getHTML());
2011 }
2012
2014 {
2015 require_once 'Modules/Test/classes/class.ilTestPassFinishTasks.php';
2016 $participants = $this->object->getTestParticipants();
2017 foreach ($participants as $participant) {
2018 if (array_key_exists('unfinished_passes', $participant) && $participant['unfinished_passes'] == 1) {
2019 $this->finishTestPass($participant['active_id'], $this->object->getId());
2020 }
2021 }
2023 }
2024
2025 protected function finishTestPass($active_id, $obj_id)
2026 {
2027 $this->processLockerFactory->setActiveId($active_id);
2028 $processLocker = $this->processLockerFactory->getLocker();
2029
2030 $test_pass_finisher = new ilTestPassFinishTasks($active_id, $obj_id);
2031 $test_pass_finisher->performFinishTasks($processLocker);
2032 }
2033
2035 {
2036 $this->ctrl->redirectByClass("ilobjtestgui", "participants");
2037 }
2038}
sprintf('%.4f', $callTime)
$result
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$_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, $a_skip_day=false, $a_include_wd=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 _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 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, $purpose=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.
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.
$counter
$template
$userdata
Definition: demo.php:48
$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
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const SCORE_BEST_PASS
const PDF_USER_RESULT
PDF Purposes.
Interface ilObjFileHandlingQuestionType.
if($format !==null) $name
Definition: metadata.php:146
$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
$rows
Definition: xhr_table.php:10