ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilTestServiceGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
5include_once 'Modules/Test/classes/class.ilTestService.php';
6
22{
26 public $object = null;
27
31 public $service = null;
32
36 protected $db;
37
38 var $lng;
39 var $tpl;
40
44 var $ctrl;
45
46 var $ilias;
47 var $tree;
49
55 protected $testSessionFactory = null;
56
62 protected $testSequenceFactory = null;
63
68
69 private $contextWithinTestPass = false;
70
74 public function isContextWithinTestPass()
75 {
77 }
78
83 {
84 $this->contextWithinTestPass = $contextWithinTestPass;
85 }
86
93 function ilTestServiceGUI(ilObjTest $a_object)
94 {
95 global $lng, $tpl, $ilCtrl, $ilias, $tree, $ilDB, $ilPluginAdmin;
96
97 $this->db = $ilDB;
98 $this->lng =& $lng;
99 $this->tpl =& $tpl;
100 $this->ctrl =& $ilCtrl;
101 $this->ilias =& $ilias;
102 $this->object =& $a_object;
103 $this->tree =& $tree;
104 $this->ref_id = $a_object->ref_id;
105
106 $this->service = new ilTestService($a_object);
107
108 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
109 $this->testSessionFactory = new ilTestSessionFactory($this->object);
110
111 require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
112 $this->testSequenceFactory = new ilTestSequenceFactory($this->db, $this->lng, $ilPluginAdmin, $this->object);
113 }
114
119 {
120 $this->participantData = $participantData;
121 }
122
126 public function getParticipantData()
127 {
129 }
130
134 function &executeCommand()
135 {
136 $cmd = $this->ctrl->getCmd();
137 $next_class = $this->ctrl->getNextClass($this);
138
139 $cmd = $this->getCommand($cmd);
140 switch($next_class)
141 {
142 default:
143 $ret =& $this->$cmd();
144 break;
145 }
146 return $ret;
147 }
148
154 function getCommand($cmd)
155 {
156 return $cmd;
157 }
158
162 protected function isPdfDeliveryRequest()
163 {
164 if( !isset($_GET['pdf']) )
165 {
166 return false;
167 }
168
169 if( !(bool)$_GET['pdf'] )
170 {
171 return false;
172 }
173
174 return true;
175 }
176
185 public function getPassOverview($active_id, $targetclass = "", $targetcommand = "", $short = FALSE, $hide_details = FALSE, $adminMode = false)
186 {
187 require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
188 require_once 'Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php';
189
190 $table = new ilTestPassOverviewTableGUI(
191 $this,
192 '',
194 (isset($_GET['pdf']) && $_GET['pdf'] == 1)
195 );
196 $data = array();
197
198 $counted_pass = $this->object->_getResultPass($active_id);
199 $reached_pass = $this->object->_getPass($active_id);
200
201 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
202 $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
203 $testPassesSelector->setAdminModeEnabled($adminMode);
204 $testPassesSelector->setActiveId($active_id);
205 $lastFinishedPass = $this->testSessionFactory->getSession($active_id)->getLastFinishedPass();
206 $testPassesSelector->setLastFinishedPass($lastFinishedPass);
207
208 foreach($testPassesSelector->getReportablePasses() as $pass)
209 {
210 $row = array();
211
212 if(!$short)
213 {
214 $result_array =& $this->object->getTestResult($active_id, $pass);
215 if(!$result_array['pass']['total_max_points'])
216 {
217 $percentage = 0;
218 }
219 else
220 {
221 $percentage = ($result_array['pass']['total_reached_points'] / $result_array['pass']['total_max_points']) * 100;
222 }
223 $total_max = $result_array['pass']['total_max_points'];
224 $total_reached = $result_array['pass']['total_reached_points'];
225 $total_requested_hints = $result_array['pass']['total_requested_hints'];
226 }
227 if(!$hide_details)
228 {
229 if(strlen($targetclass) && strlen($targetcommand))
230 {
231 $this->ctrl->setParameterByClass($targetclass, 'active_id', $active_id);
232 $this->ctrl->setParameterByClass($targetclass, 'pass', $pass);
233
234 $aslgui = new ilAdvancedSelectionListGUI();
235 $aslgui->setListTitle($this->lng->txt('actions'));
236 $aslgui->setId($pass);
237 $aslgui->addItem(
238 $this->lng->txt('tst_pass_details'),
239 'tst_pass_details',
240 $this->ctrl->getLinkTargetByClass($targetclass, $targetcommand)
241 );
242 if($this->object->isPassDeletionAllowed() && $pass != $counted_pass)
243 {
244 $aslgui->addItem(
245 $this->lng->txt('delete'),
246 'tst_pass_delete',
247 $this->ctrl->getLinkTargetByClass($targetclass, 'confirmDeletePass')
248 );
249 $delete_entry = true;
250 }
251
252 if($delete_entry == true)
253 {
254 $row['pass_details'] = $aslgui->getHTML();
255 }
256 else
257 {
258 $row['pass_details'] = '<a href="'.$this->ctrl->getLinkTargetByClass($targetclass, $targetcommand).'">'.$this->lng->txt('tst_pass_details').'</a>';
259 }
260 }
261 }
262
263 if(!$short)
264 {
265 if(($pass == $counted_pass))
266 {
267 $row['scored'] = '&otimes;';
268 }
269 else
270 {
271 $row['scored'] = '';
272 }
273 }
274
275 $row['pass'] = $pass + 1;
276 $row['date'] = $this->object->getPassFinishDate($active_id, $pass);
277 if(!$short)
278 {
279 $row['answered'] = $result_array['pass']['num_workedthrough'] . ' ' . strtolower($this->lng->txt('of')) . ' ' . (count($result_array) - 2);
280 if($this->object->isOfferingQuestionHintsEnabled())
281 {
282 $row['hints'] = $total_requested_hints;
283 }
284 $row['reached'] = $total_reached . ' ' . strtolower($this->lng->txt('of')) . ' ' . $total_max;
285 $row['percentage'] = $percentage;
286 }
287
288 $data[] = $row;
289 }
290
291 $table->setData($data);
292 return $table->getHTML();
293 }
294
305 function getPassListOfAnswers(&$result_array, $active_id, $pass, $show_solutions = FALSE, $only_answered_questions = FALSE, $show_question_only = FALSE, $show_reached_points = FALSE, $anchorNav = false)
306 {
307 $maintemplate = new ilTemplate("tpl.il_as_tst_list_of_answers.html", TRUE, TRUE, "Modules/Test");
308
309 $counter = 1;
310 // output of questions with solutions
311 foreach ($result_array as $question_data)
312 {
313 if (($question_data["workedthrough"] == 1) || ($only_answered_questions == FALSE))
314 {
315 $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", TRUE, TRUE, "Modules/TestQuestionPool");
316 $question = $question_data["qid"];
317 if (is_numeric($question))
318 {
319 $maintemplate->setCurrentBlock("printview_question");
320 $question_gui = $this->object->createQuestionGUI("", $question);
321 if (is_object($question_gui))
322 {
323 if($anchorNav)
324 {
325 $template->setCurrentBlock('block_id');
326 $template->setVariable('BLOCK_ID', "detailed_answer_block_act_{$active_id}_qst_{$question}");
327 $template->parseCurrentBlock();
328
329 $template->setCurrentBlock('back_anchor');
330 $template->setVariable('HREF_BACK_ANCHOR', "#pass_details_tbl_row_act_{$active_id}_qst_{$question}");
331 $template->setVariable('TXT_BACK_ANCHOR', $this->lng->txt('tst_back_to_question_list'));
332 $template->parseCurrentBlock();
333 }
334
335 if ($show_reached_points)
336 {
337 $template->setCurrentBlock("result_points");
338 $template->setVariable("RESULT_POINTS", $this->lng->txt("tst_reached_points") . ": " . $question_gui->object->getReachedPoints($active_id, $pass) . " " . $this->lng->txt("of") . " " . $question_gui->object->getMaximumPoints());
339 $template->parseCurrentBlock();
340 }
341 $template->setVariable("COUNTER_QUESTION", $counter.". ");
342 $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
343 $template->setVariable("QUESTION_ID", $question_gui->object->getId());
344 $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()));
345
346 $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
347
348 $showFeedback = !$this->isContextWithinTestPass() && $this->object->getShowSolutionFeedback();
349 $show_solutions = !$this->isContextWithinTestPass() && $show_solutions;
350
351 if($show_solutions)
352 {
353 $compare_template = new ilTemplate('tpl.il_as_tst_answers_compare.html', TRUE, TRUE, 'Modules/Test');
354 $compare_template->setVariable("HEADER_PARTICIPANT", $this->lng->txt('tst_header_participant'));
355 $compare_template->setVariable("HEADER_SOLUTION", $this->lng->txt('tst_header_solution'));
356 $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_solutions, FALSE, $show_question_only, $showFeedback);
357 $best_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, $show_question_only, FALSE, TRUE);
358
359 $compare_template->setVariable('PARTICIPANT', $result_output);
360 $compare_template->setVariable('SOLUTION', $best_output);
361 $template->setVariable('SOLUTION_OUTPUT', $compare_template->get());
362 }
363 else
364 {
365 $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_solutions, FALSE, $show_question_only, $showFeedback);
366 $template->setVariable('SOLUTION_OUTPUT', $result_output);
367 }
368
369 $maintemplate->setCurrentBlock("printview_question");
370 $maintemplate->setVariable("QUESTION_PRINTVIEW", $template->get());
371 $maintemplate->parseCurrentBlock();
372 $counter ++;
373 }
374 }
375 }
376 }
377 $maintemplate->setVariable("RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_eval_results_by_pass"), $pass + 1));
378 return $maintemplate->get();
379 }
380
393 function getPassListOfAnswersWithScoring(&$result_array, $active_id, $pass, $show_solutions = FALSE)
394 {
395 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
396
397 $maintemplate = new ilTemplate("tpl.il_as_tst_list_of_answers.html", TRUE, TRUE, "Modules/Test");
398
399 include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
401
402 $counter = 1;
403 // output of questions with solutions
404 foreach ($result_array as $question_data)
405 {
406 $question = $question_data["qid"];
407 if (is_numeric($question))
408 {
409 $question_gui = $this->object->createQuestionGUI("", $question);
410 if (in_array($question_gui->object->getQuestionTypeID(), $scoring))
411 {
412 $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", TRUE, TRUE, "Modules/TestQuestionPool");
413 $scoretemplate = new ilTemplate("tpl.il_as_tst_manual_scoring_points.html", TRUE, TRUE, "Modules/Test");
414 #mbecker: No such block. $this->tpl->setCurrentBlock("printview_question");
415 $template->setVariable("COUNTER_QUESTION", $counter.". ");
416 $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()));
417 $points = $question_gui->object->getMaximumPoints();
418 if ($points == 1)
419 {
420 $template->setVariable("QUESTION_POINTS", $points . " " . $this->lng->txt("point"));
421 }
422 else
423 {
424 $template->setVariable("QUESTION_POINTS", $points . " " . $this->lng->txt("points"));
425 }
426
427 $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
428 $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_solutions, FALSE, $show_question_only, $this->object->getShowSolutionFeedback(), FALSE, TRUE);
429
430 $solout = $question_gui->object->getSuggestedSolutionOutput();
431 if (strlen($solout))
432 {
433 $scoretemplate->setCurrentBlock("suggested_solution");
434 $scoretemplate->setVariable("TEXT_SUGGESTED_SOLUTION", $this->lng->txt("solution_hint"));
435 $scoretemplate->setVariable("VALUE_SUGGESTED_SOLUTION", $solout);
436 $scoretemplate->parseCurrentBlock();
437 }
438
439 $scoretemplate->setCurrentBlock("feedback");
440 $scoretemplate->setVariable("FEEDBACK_NAME_INPUT", $question);
441 $feedback = $this->object->getManualFeedback($active_id, $question, $pass);
442 $scoretemplate->setVariable("VALUE_FEEDBACK", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($feedback, TRUE)));
443 $scoretemplate->setVariable("TEXT_MANUAL_FEEDBACK", $this->lng->txt("set_manual_feedback"));
444 $scoretemplate->parseCurrentBlock();
445
446 $scoretemplate->setVariable("NAME_INPUT", $question);
447 $this->ctrl->setParameter($this, "active_id", $active_id);
448 $this->ctrl->setParameter($this, "pass", $pass);
449 $scoretemplate->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "manscoring"));
450 $scoretemplate->setVariable("LABEL_INPUT", $this->lng->txt("tst_change_points_for_question"));
451 $scoretemplate->setVariable("VALUE_INPUT", " value=\"" . assQuestion::_getReachedPoints($active_id, $question_data["qid"], $pass) . "\"");
452 $scoretemplate->setVariable("VALUE_SAVE", $this->lng->txt("save"));
453
454 $template->setVariable("SOLUTION_OUTPUT", $result_output);
455 $maintemplate->setCurrentBlock("printview_question");
456 $maintemplate->setVariable("QUESTION_PRINTVIEW", $template->get());
457 $maintemplate->setVariable("QUESTION_SCORING", $scoretemplate->get());
458 $maintemplate->parseCurrentBlock();
459 }
460 $counter ++;
461 }
462 }
463 if ($counter == 1)
464 {
465 // no scorable questions found
466 $maintemplate->setVariable("NO_QUESTIONS_FOUND", $this->lng->txt("manscoring_questions_not_found"));
467 }
468 $maintemplate->setVariable("RESULTS_OVERVIEW", sprintf($this->lng->txt("manscoring_results_pass"), $pass+1));
469
470 include_once "./Services/YUI/classes/class.ilYuiUtil.php";
472
473 return $maintemplate->get();
474 }
475
476 protected function getPassDetailsOverview($result_array, $active_id, $pass, $targetGUI, $targetCMD, $questionDetailsCMD, $questionAnchorNav)
477 {
478 $this->ctrl->setParameter($targetGUI, 'active_id', $active_id);
479 $this->ctrl->setParameter($targetGUI, 'pass', $pass);
480
481 $tableGUI = $this->buildPassDetailsOverviewTableGUI($targetGUI, $targetCMD);
482
483 $tableGUI->setAnswerListAnchorEnabled($questionAnchorNav);
484 $tableGUI->setSingleAnswerScreenCmd($questionDetailsCMD);
485 $tableGUI->setShowHintCount($this->object->isOfferingQuestionHintsEnabled());
486 $tableGUI->setActiveId($active_id);
487 $tableGUI->setPass($pass);
488 $tableGUI->setShowSuggestedSolution(false);
489
490 $tableGUI->initColumns()->initFilter();
491
492 $usersQuestionSolutions = array();
493
494 foreach($result_array as $key => $val)
495 {
496 if($key === 'test' || $key === 'pass')
497 {
498 continue;
499 }
500
501 if( $this->object->getShowSolutionSuggested() && strlen($val['solution']) )
502 {
503 $tableGUI->setShowSuggestedSolution(true);
504 }
505
506 $usersQuestionSolutions[$key] = $val;
507 }
508
509 $tableGUI->setFilterCommand($targetCMD.'SetTableFilter');
510 $tableGUI->setResetCommand($targetCMD.'ResetTableFilter');
511
512 $tableGUI->setData($usersQuestionSolutions);
513
514 return $this->ctrl->getHTML($tableGUI);
515 }
516
524 {
525 if ($this->object->getShowSolutionSignature() && !$this->object->getAnonymity())
526 {
527 $template = new ilTemplate("tpl.il_as_tst_results_userdata_signature.html", TRUE, TRUE, "Modules/Test");
528 $template->setVariable("TXT_DATE", $this->lng->txt("date"));
531 $template->setVariable("VALUE_DATE", ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX)));
533 $template->setVariable("TXT_SIGNATURE", $this->lng->txt("tst_signature"));
534 $template->setVariable("IMG_SPACER", ilUtil::getImagePath("spacer.png"));
535 return $template->get();
536 }
537 else
538 {
539 return "";
540 }
541 }
542
552 function getResultsUserdata($testSession, $active_id, $overwrite_anonymity = FALSE)
553 {
554 if(!is_object($testSession)) throw new TestException();
555 $template = new ilTemplate("tpl.il_as_tst_results_userdata.html", TRUE, TRUE, "Modules/Test");
556 include_once './Services/User/classes/class.ilObjUser.php';
557 $user_id = $this->object->_getUserIdFromActiveId($active_id);
558 if (strlen(ilObjUser::_lookupLogin($user_id)) > 0)
559 {
560 $user = new ilObjUser($user_id);
561 }
562 else
563 {
564 $user = new ilObjUser();
565 $user->setLastname($this->lng->txt("deleted_user"));
566 }
567 $t = $testSession->getSubmittedTimestamp();
568 if (!$t)
569 {
570 $t = $this->object->_getLastAccess($testSession->getActiveId());
571 }
572 $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
573
574 $title_matric = "";
575 if (strlen($user->getMatriculation()) && (($this->object->getAnonymity() == FALSE) || ($overwrite_anonymity)))
576 {
577 $template->setCurrentBlock("user_matric");
578 $template->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
579 $template->parseCurrentBlock();
580 $template->setCurrentBlock("user_matric_value");
581 $template->setVariable("VALUE_USR_MATRIC", $user->getMatriculation());
582 $template->parseCurrentBlock();
583 $template->touchBlock("user_matric_separator");
584 $title_matric = " - " . $this->lng->txt("matriculation") . ": " . $user->getMatriculation();
585 }
586
587 $invited_user = array_pop($this->object->getInvitedUsers($user_id));
588 if (strlen($invited_user["clientip"]))
589 {
590 $template->setCurrentBlock("user_clientip");
591 $template->setVariable("TXT_CLIENT_IP", $this->lng->txt("client_ip"));
592 $template->parseCurrentBlock();
593 $template->setCurrentBlock("user_clientip_value");
594 $template->setVariable("VALUE_CLIENT_IP", $invited_user["clientip"]);
595 $template->parseCurrentBlock();
596 $template->touchBlock("user_clientip_separator");
597 $title_client = " - " . $this->lng->txt("clientip") . ": " . $invited_user["clientip"];
598 }
599
600 $template->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
601 $template->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
602 $template->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
603 $uname = $this->object->userLookupFullName($user_id, $overwrite_anonymity);
604 $template->setVariable("VALUE_USR_NAME", $uname);
605 $template->setVariable("TXT_TEST_DATE", $this->lng->txt("tst_tst_date"));
606 $template->setVariable("TXT_PRINT_DATE", $this->lng->txt("tst_print_date"));
609 $template->setVariable("VALUE_TEST_DATE", ilDatePresentation::formatDate(new ilDateTime(ilUtil::date_mysql2time($t), IL_CAL_UNIX)));
610 $template->setVariable("VALUE_PRINT_DATE", ilDatePresentation::formatDate(new ilDateTime($print_date, IL_CAL_UNIX)));
612
613 // change the pagetitle
614 $pagetitle = ": " . $this->object->getTitle() . $title_matric . $title_client;
615 $this->tpl->setHeaderPageTitle($pagetitle);
616
617 return $template->get();
618 }
619
629 function getCorrectSolutionOutput($question_id, $active_id, $pass)
630 {
631 global $ilUser;
632
633 $test_id = $this->object->getTestId();
634 $question_gui = $this->object->createQuestionGUI("", $question_id);
635
636 $template = new ilTemplate("tpl.il_as_tst_correct_solution_output.html", TRUE, TRUE, "Modules/Test");
637 $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
638 $result_output = $question_gui->getSolutionOutput($active_id, $pass, TRUE, FALSE, $show_question_only, $this->object->getShowSolutionFeedback(), FALSE, FALSE, TRUE);
639 $best_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, $show_question_only, FALSE, TRUE, FALSE, FALSE);
640 if( $this->object->getShowSolutionFeedback() && $_GET['cmd'] != 'outCorrectSolution' )
641 {
642 $specificAnswerFeedback = $question_gui->getSpecificFeedbackOutput($active_id, $pass);
643 if( strlen($specificAnswerFeedback) )
644 {
645 $template->setCurrentBlock("outline_specific_feedback");
646 $template->setVariable("OUTLINE_SPECIFIC_FEEDBACK", $specificAnswerFeedback);
647 $template->parseCurrentBlock();
648 }
649 }
650 if ($this->object->isBestSolutionPrintedWithResult() && strlen($best_output))
651 {
652 $template->setCurrentBlock("best_solution");
653 $template->setVariable("TEXT_BEST_SOLUTION", $this->lng->txt("tst_best_solution_is"));
654 $template->setVariable("BEST_OUTPUT", $best_output);
655 $template->parseCurrentBlock();
656 }
657 $template->setVariable("TEXT_YOUR_SOLUTION", $this->lng->txt("tst_your_answer_was"));
658 $maxpoints = $question_gui->object->getMaximumPoints();
659 if ($maxpoints == 1)
660 {
661 $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
662 }
663 else
664 {
665 $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
666 }
667 $template->setVariable("SOLUTION_OUTPUT", $result_output);
668 $template->setVariable("RECEIVED_POINTS", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
669 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
670 $template->setVariable("BACKLINK_TEXT", "&lt;&lt; " . $this->lng->txt("back"));
671 return $template->get();
672 }
673
686 function getResultsOfUserOutput($testSession, $active_id, $pass, $targetGUI, $show_pass_details = TRUE, $show_answers = TRUE, $show_question_only = FALSE, $show_reached_points = FALSE)
687 {
688 global $ilias, $tpl;
689
690 include_once("./Services/UICore/classes/class.ilTemplate.php");
691 $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
692
693 if( $this->participantData instanceof ilTestParticipantData )
694 {
695 $user_id = $this->participantData->getUserIdByActiveId($active_id);
696 $uname = $this->participantData->getConcatedFullnameByActiveId($active_id, false);
697 }
698 else
699 {
700 $user_id = $this->object->_getUserIdFromActiveId($active_id);
701 $uname = $this->object->userLookupFullName($user_id, TRUE);
702 }
703
704 if (((array_key_exists("pass", $_GET)) && (strlen($_GET["pass"]) > 0)) || (!is_null($pass)))
705 {
706 if (is_null($pass)) $pass = $_GET["pass"];
707 }
708
709 $user_data = $this->getResultsUserdata($testSession, $active_id, TRUE);
710
711 if (!is_null($pass))
712 {
713 $result_array =& $this->object->getTestResult($active_id, $pass);
714 $command_solution_details = "";
715 if ($show_pass_details)
716 {
717 $detailsoverview = $this->getPassDetailsOverview($result_array, $active_id, $pass, $targetGUI, "getResultsOfUserOutput", $command_solution_details, $show_answers);
718 }
719
720 $user_id = $this->object->_getUserIdFromActiveId($active_id);
721 $showAllAnswers = TRUE;
722 if ($this->object->isExecutable($testSession, $user_id))
723 {
724 $showAllAnswers = FALSE;
725 }
726 if ($show_answers)
727 {
728 $list_of_answers = $this->getPassListOfAnswers(
729 $result_array, $active_id, $pass, $_SESSION['tst_results_show_best_solutions'],
730 $showAllAnswers, $show_question_only, $show_reached_points, $show_pass_details
731 );
732 }
733
734 $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
735 //$template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1));
736 $template->setVariable("PASS_DETAILS", $detailsoverview);
737
738 $signature = $this->getResultsSignature();
739 $template->setVariable("SIGNATURE", $signature);
740
741 if ($this->object->isShowExamIdInTestResultsEnabled())
742 {
743 $template->setCurrentBlock('exam_id_footer');
744 $template->setVariable('EXAM_ID_VAL', $this->object->lookupExamId(
745 $testSession->getActiveId(), $pass
746 ));
747 $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
748 $template->parseCurrentBlock();
749 }
750 }
751
752 $template->setCurrentBlock('participant_back_anchor');
753 $template->setVariable("HREF_PARTICIPANT_BACK_ANCHOR", "#tst_results_toolbar");
754 $template->setVariable("TXT_PARTICIPANT_BACK_ANCHOR", $this->lng->txt('tst_back_to_top'));
755 $template->parseCurrentBlock();
756
757 $template->setCurrentBlock('participant_block_id');
758 $template->setVariable("PARTICIPANT_BLOCK_ID", "participant_active_{$active_id}");
759 $template->parseCurrentBlock();
760
761 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
762 $template->setVariable("USER_DATA", $user_data);
763
764 if( $this->isGradingMessageRequired() )
765 {
766 $template->setCurrentBlock('grading_message');
767 $template->setVariable('GRADING_MESSAGE', $this->getGradingMessage($active_id));
768 $template->parseCurrentBlock();
769 }
770
771 $template->parseCurrentBlock();
772
773 return $template->get();
774 }
775
783 function getResultsHeadUserAndPass($active_id, $pass)
784 {
785 $template = new ilTemplate("tpl.il_as_tst_results_head_user_pass.html", TRUE, TRUE, "Modules/Test");
786 include_once './Services/User/classes/class.ilObjUser.php';
787 $user_id = $this->object->_getUserIdFromActiveId($active_id);
788 if (strlen(ilObjUser::_lookupLogin($user_id)) > 0)
789 {
790 $user = new ilObjUser($user_id);
791 }
792 else
793 {
794 $user = new ilObjUser();
795 $user->setLastname($this->lng->txt("deleted_user"));
796 }
797 $title_matric = "";
798 if (strlen($user->getMatriculation()) && (($this->object->getAnonymity() == FALSE)))
799 {
800 $template->setCurrentBlock("user_matric");
801 $template->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
802 $template->parseCurrentBlock();
803 $template->setCurrentBlock("user_matric_value");
804 $template->setVariable("VALUE_USR_MATRIC", $user->getMatriculation());
805 $template->parseCurrentBlock();
806 $template->touchBlock("user_matric_separator");
807 $title_matric = " - " . $this->lng->txt("matriculation") . ": " . $user->getMatriculation();
808 }
809
810 $invited_user = array_pop($this->object->getInvitedUsers($user_id));
811 if (strlen($invited_user["clientip"]))
812 {
813 $template->setCurrentBlock("user_clientip");
814 $template->setVariable("TXT_CLIENT_IP", $this->lng->txt("client_ip"));
815 $template->parseCurrentBlock();
816 $template->setCurrentBlock("user_clientip_value");
817 $template->setVariable("VALUE_CLIENT_IP", $invited_user["clientip"]);
818 $template->parseCurrentBlock();
819 $template->touchBlock("user_clientip_separator");
820 $title_client = " - " . $this->lng->txt("clientip") . ": " . $invited_user["clientip"];
821 }
822
823 $template->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
824 $uname = $this->object->userLookupFullName($user_id, FALSE);
825 $template->setVariable("VALUE_USR_NAME", $uname);
826 $template->setVariable("TXT_PASS", $this->lng->txt("scored_pass"));
827 $template->setVariable("VALUE_PASS", $pass);
828 return $template->get();
829 }
830
838 public function getQuestionResultForTestUsers($question_id, $test_id)
839 {
840 // REQUIRED, since we call this object regardless of the loop
841 $question_gui = $this->object->createQuestionGUI("", $question_id);
842
843 $foundusers = $this->object->getParticipantsForTestAndQuestion($test_id, $question_id);
844 $output = '';
845 foreach($foundusers as $active_id => $passes)
846 {
847 $resultpass = $this->object->_getResultPass($active_id);
848 for($i = 0; $i < count($passes); $i++)
849 {
850 if(($resultpass !== null) && ($resultpass == $passes[$i]["pass"]))
851 {
852 if($output)
853 {
854 $output .= "<br /><br /><br />";
855 }
856
857 // check if re-instantiation is really neccessary
858 $question_gui = $this->object->createQuestionGUI("", $passes[$i]["qid"]);
859 $output .= $this->getResultsHeadUserAndPass($active_id, $resultpass + 1);
860 $output .= $question_gui->getSolutionOutput(
861 $active_id,
862 $resultpass,
863 $graphicalOutput = FALSE,
864 $result_output = FALSE,
865 $show_question_only = FALSE,
866 $show_feedback = FALSE
867 );
868 }
869 }
870 }
871
872 require_once './Modules/Test/classes/class.ilTestPDFGenerator.php';
873 ilTestPDFGenerator::generatePDF($output, ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $question_gui->object->getTitle());
874 }
875
879 protected function buildPassDetailsOverviewTableGUI($targetGUI, $targetCMD)
880 {
881 require_once 'Modules/Test/classes/tables/class.ilTestPassDetailsOverviewTableGUI.php';
882 $tableGUI = new ilTestPassDetailsOverviewTableGUI($this->ctrl, $targetGUI, $targetCMD);
883 $tableGUI->setIsPdfGenerationRequest($this->isPdfDeliveryRequest());
884 return $tableGUI;
885 }
886
887 protected function isGradingMessageRequired()
888 {
889 if( $this->object->isShowGradingStatusEnabled() )
890 {
891 return true;
892 }
893
894 if( $this->object->isShowGradingMarkEnabled() )
895 {
896 return true;
897 }
898
899 if( $this->object->areObligationsEnabled() )
900 {
901 return true;
902 }
903
904 return false;
905 }
906
911 protected function getGradingMessage($activeId)
912 {
913 require_once 'Modules/Test/classes/class.ilTestGradingMessageBuilder.php';
914 $gradingMessageBuilder = new ilTestGradingMessageBuilder($this->lng, $this->object);
915
916 $gradingMessageBuilder->setActiveId($activeId);
917 $gradingMessageBuilder->build();
918
919 return $gradingMessageBuilder->getMessage();
920 }
921}
922
923// internal sort function to sort the result array
924function sortResults($a, $b)
925{
926 $sort = ($_GET["sort"]) ? ($_GET["sort"]) : "nr";
927 $sortorder = ($_GET["sortorder"]) ? ($_GET["sortorder"]) : "asc";
928 if (strcmp($sortorder, "asc"))
929 {
930 $smaller = 1;
931 $greater = -1;
932 }
933 else
934 {
935 $smaller = -1;
936 $greater = 1;
937 }
938 if ($a[$sort] == $b[$sort]) return 0;
939 return ($a[$sort] < $b[$sort]) ? $smaller : $greater;
940}
$_GET["client_id"]
const IL_CAL_UNIX
sortResults($a, $b)
_getReachedPoints($active_id, $question_id, $pass=NULL)
Returns the points, a learner has reached answering the question.
User interface class for advanced drop-down selection lists.
static setUseRelativeDates($a_status)
set use relative dates
static formatDate(ilDateTime $date)
Format a date @access public.
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
Class for single dates.
_getManualScoring()
Retrieve the manual scoring settings.
_lookupLogin($a_user_id)
lookup login
special template class to simplify handling of ITX/PEAR
static generatePDF($pdf_output, $output_mode, $filename=null)
Class ilTestPassOverviewTableGUI.
Service GUI class for tests.
getPassListOfAnswersWithScoring(&$result_array, $active_id, $pass, $show_solutions=FALSE)
Returns the list of answers of a users test pass and offers a scoring option.
ilTestServiceGUI(ilObjTest $a_object)
The constructor takes the test object reference as parameter.
getResultsOfUserOutput($testSession, $active_id, $pass, $targetGUI, $show_pass_details=TRUE, $show_answers=TRUE, $show_question_only=FALSE, $show_reached_points=FALSE)
Output of the pass overview for a test called by a test participant.
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.
getResultsUserdata($testSession, $active_id, $overwrite_anonymity=FALSE)
Returns the user data for a test results output.
getCorrectSolutionOutput($question_id, $active_id, $pass)
Returns an output of the solution to an answer compared to the correct solution.
setContextWithinTestPass($contextWithinTestPass)
getPassOverview($active_id, $targetclass="", $targetcommand="", $short=FALSE, $hide_details=FALSE, $adminMode=false)
Returns the pass overview for a given active ID.
& executeCommand()
execute command
getPassDetailsOverview($result_array, $active_id, $pass, $targetGUI, $targetCMD, $questionDetailsCMD, $questionAnchorNav)
getResultsHeadUserAndPass($active_id, $pass)
Returns the user and pass data for a test results output.
getPassListOfAnswers(&$result_array, $active_id, $pass, $show_solutions=FALSE, $only_answered_questions=FALSE, $show_question_only=FALSE, $show_reached_points=FALSE, $anchorNav=false)
Returns the list of answers of a users test pass.
setParticipantData($participantData)
buildPassDetailsOverviewTableGUI($targetGUI, $targetCMD)
Service class for tests.
static date_mysql2time($mysql_date_time)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static initDomEvent()
Init YUI DomEvent.
$GLOBALS['ct_recipient']
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
$cmd
Definition: sahs_server.php:35
global $ilDB
global $ilUser
Definition: imgupload.php:15