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