ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestOutputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
6 include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
7 require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
8 
27 {
28  var $ref_id;
29 
31  var $sequence;
32  var $cmdCtrl;
35 
42  function __construct($a_object)
43  {
44  parent::ilTestServiceGUI($a_object);
45  $this->ref_id = $_GET["ref_id"];
46  }
47 
48  /*
49  * Save tags for tagging gui
50  *
51  * Needed this function here because the test info page
52  * uses another class to send its form results
53  */
54  function saveTags()
55  {
56  include_once("./Services/Tagging/classes/class.ilTaggingGUI.php");
57  $tagging_gui = new ilTaggingGUI();
58  $tagging_gui->setObject($this->object->getId(), $this->object->getType());
59  $tagging_gui->saveInput();
60  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
61  }
62 
66  function executeCommand()
67  {
68  global $ilUser;
69 
70  $cmd = $this->ctrl->getCmd();
71  $next_class = $this->ctrl->getNextClass($this);
72 
73  $this->ctrl->saveParameter($this, "sequence");
74  $this->ctrl->saveParameter($this, "active_id");
75 
76  if (preg_match("/^gotoquestion_(\\d+)$/", $cmd, $matches))
77  {
78  $cmd = "gotoquestion";
79  if (strlen($matches[1]))
80  {
81  $this->ctrl->setParameter($this, 'gotosequence', $matches[1]);
82  }
83 
84  }
85 
86  if ($_GET["active_id"])
87  {
88  $this->object->setTestSession($_GET["active_id"]);
89  }
90  else
91  {
92  $this->object->setTestSession();
93  }
94 
95  include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
97  include_once "./Services/YUI/classes/class.ilYuiUtil.php";
99 
100  $cmd = $this->getCommand($cmd);
101 
102  switch($next_class)
103  {
104  case 'ilassquestionhintrequestgui':
105 
106  $questionGUI = $this->object->createQuestionGUI(
107  "", $this->object->getTestSequence()->getQuestionForSequence( $this->calculateSequence() )
108  );
109 
110  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
111  $gui = new ilAssQuestionHintRequestGUI($this, $this->object->getTestSession(), $questionGUI);
112 
113  $ret = $this->ctrl->forwardCommand($gui);
114 
115  break;
116 
117  default:
118 
119  $ret =& $this->$cmd();
120  break;
121  }
122  return $ret;
123  }
124 
129  public function outResultsToplist()
130  {
131  global $ilCtrl;
132  $ilCtrl->redirectByClass('ilTestToplistGUI', 'outResultsToplist');
133 
134  #require_once 'Modules/Test/classes/class.ilTestToplistGUI.php';
135  #$gui = new ilTestToplistGUI($this);
136  #return $this->ctrl->forwardCommand($gui);
137  }
138 
143  function updateWorkingTime()
144  {
145  if ($_SESSION["active_time_id"])
146  {
147  $this->object->updateWorkingTime($_SESSION["active_time_id"]);
148  }
149  }
150 
154  function saveQuestionSolution($force = FALSE)
155  {
156  $this->updateWorkingTime();
157  $this->saveResult = FALSE;
158  if (!$force)
159  {
160  $formtimestamp = $_POST["formtimestamp"];
161  if (strlen($formtimestamp) == 0) $formtimestamp = $_GET["formtimestamp"];
162  if ($formtimestamp != $_SESSION["formtimestamp"])
163  {
164  $_SESSION["formtimestamp"] = $formtimestamp;
165  }
166  else
167  {
168  return FALSE;
169  }
170  }
171  // save question solution
172  if ($this->canSaveResult() || $force)
173  {
174  // but only if the ending time is not reached
175  $q_id = $this->object->getTestSequence()->getQuestionForSequence($_GET["sequence"]);
176  if (is_numeric($q_id) && (int)$q_id)
177  {
178  global $ilUser;
179 
180  $question_gui = $this->object->createQuestionGUI("", $q_id);
181  if ($this->object->getJavaScriptOutput())
182  {
183  $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
184  }
185  $pass = NULL;
186  $active_id = $this->object->getTestSession()->getActiveId();
187  if ($this->object->isRandomTest())
188  {
189  $pass = $this->object->_getPass($active_id);
190  }
191  $this->saveResult = $question_gui->object->persistWorkingState(
192  $active_id, $pass, $this->object->areObligationsEnabled()
193  );
194 
195  // update learning progress (is done in ilTestSession)
196  //include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
197  //ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
198  }
199  }
200  if ($this->saveResult == FALSE)
201  {
202  $this->ctrl->setParameter($this, "save_error", "1");
203  $_SESSION["previouspost"] = $_POST;
204  }
205  return $this->saveResult;
206  }
207 
216  function canSaveResult()
217  {
218  return !$this->object->endingTimeReached() && !$this->isMaxProcessingTimeReached() && !$this->isNrOfTriesReached();
219  }
220 
229  {
230  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
231  }
232 
242  {
243  global $ilUser;
244  $active_id = $this->object->getTestSession()->getActiveId();
245  $starting_time = $this->object->getStartingTimeOfUser($active_id);
246  if ($starting_time === FALSE)
247  {
248  return FALSE;
249  }
250  else
251  {
252  return $this->object->isMaxProcessingTimeReached($starting_time);
253  }
254  }
255 
259  public function outWorkingForm($sequence = "", $test_id, $postpone_allowed, $directfeedback = 0)
260  {
261  global $ilUser;
262 
263  if ($sequence < 1) $sequence = $this->object->getTestSequence()->getFirstSequence();
264 
265  $_SESSION["active_time_id"]= $this->object->startWorkingTime($this->object->getTestSession()->getActiveId(),
266  $this->object->getTestSession()->getPass()
267  );
268 
269  $this->populateContentStyleBlock();
270  $this->populateSyntaxStyleBlock();
271 
272  if ($this->object->getListOfQuestions())
273  {
274  $this->showSideList();
275  }
276 
277  $question_gui = $this->object->createQuestionGUI("", $this->object->getTestSequence()->getQuestionForSequence($sequence));
278 
279  if ($this->object->getJavaScriptOutput())
280  {
281  $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
282  }
283 
284  $is_postponed = $this->object->getTestSequence()->isPostponedQuestion($question_gui->object->getId());
285  $this->ctrl->setParameter($this, "sequence", "$sequence");
286  $formaction = $this->ctrl->getFormAction($this, "gotoQuestion");
287 
288  $question_gui->setSequenceNumber($this->object->getTestSequence()->getPositionOfSequence($sequence));
289  $question_gui->setQuestionCount($this->object->getTestSequence()->getUserQuestionCount());
290 
291 
292  // output question
293  $user_post_solution = FALSE;
294  if (array_key_exists("previouspost", $_SESSION))
295  {
296  $user_post_solution = $_SESSION["previouspost"];
297  unset($_SESSION["previouspost"]);
298  }
299 
300  global $ilNavigationHistory;
301  $ilNavigationHistory->addItem($_GET["ref_id"], $this->ctrl->getLinkTarget($this, "resume"), "tst");
302 
303  // Determine $answer_feedback: It should hold a boolean stating if answer-specific-feedback is to be given.
304  // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Answer-Specific Feedback"
305  // $directfeedback holds a boolean stating if the instant feedback was requested using the "Check" button.
306  $answer_feedback = FALSE;
307  if (($directfeedback) && ($this->object->getSpecificAnswerFeedback()))
308  {
309  $answer_feedback = TRUE;
310  }
311 
312  // Answer specific feedback is rendered into the display of the test question with in the concrete question types outQuestionForTest-method.
313  // Notation of the params prior to getting rid of this crap in favor of a class
314  $question_gui->outQuestionForTest(
315  $formaction, #form_action
316  $this->object->getTestSession()->getActiveId(), #active_id
317  NULL, #pass
318  $is_postponed, #is_postponed
319  $user_post_solution, #user_post_solution
320  $answer_feedback #answer_feedback == inline_specific_feedback
321  );
322  // The display of specific inline feedback and specific feedback in an own block is to honor questions, which
323  // have the possibility to embed the specific feedback into their output while maintaining compatibility to
324  // questions, which do not have such facilities. E.g. there can be no "specific inline feedback" for essay
325  // questions, while the multiple-choice questions do well.
326 
327  $this->fillQuestionRelatedNavigation($question_gui);
328 
329  if ($directfeedback)
330  {
331  // This controls if the solution should be shown.
332  // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions"
333  if ($this->object->getInstantFeedbackSolution())
334  {
335  $show_question_inline_score = $this->determineInlineScoreDisplay();
336 
337  // Notation of the params prior to getting rid of this crap in favor of a class
338  $solutionoutput = $question_gui->getSolutionOutput(
339  $this->object->getTestSession()->getActiveId(), #active_id
340  NULL, #pass
341  FALSE, #graphical_output
342  $show_question_inline_score, #result_output
343  FALSE, #show_question_only
344  FALSE, #show_feedback
345  TRUE, #show_correct_solution
346  FALSE, #show_manual_scoring
347  FALSE #show_question_text
348  );
349  $this->populateSolutionBlock( $solutionoutput );
350  }
351 
352  // This controls if the score should be shown.
353  // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Results (Only Points)"
354  if ($this->object->getAnswerFeedbackPoints())
355  {
356  $reachedPoints = $question_gui->object->getAdjustedReachedPoints($this->object->getTestSession()->getActiveId(), NULL);
357  $maxPoints = $question_gui->object->getMaximumPoints();
358 
359  $this->populateScoreBlock( $reachedPoints, $maxPoints );
360  }
361 
362  // This controls if the generic feedback should be shown.
363  // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions"
364  if ($this->object->getGenericAnswerFeedback())
365  {
366  $this->populateGenericFeedbackBlock( $question_gui );
367  }
368 
369  // This controls if the specific feedback should be shown.
370  // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Answer-Specific Feedback"
371  if ($this->object->getSpecificAnswerFeedback())
372  {
373  $this->populateSpecificFeedbackBlock( $question_gui );
374  }
375  }
376 
378 
379  if ($postpone_allowed && !$is_postponed)
380  {
381  $this->populatePostponeButtons();
382  }
383 
384  if ($this->object->getListOfQuestions())
385  {
386  if (!(($finish) && ($this->object->getListOfQuestionsEnd())))
387  {
388  $this->populateSummaryButtons();
389  }
390  }
391 
392  if ($this->object->getShowCancel())
393  {
394  $this->populateCancelButtonBlock();
395  }
396 
397  if ($this->isLastQuestionInSequence( $question_gui ))
398  {
399  if ($this->object->getListOfQuestionsEnd())
400  {
402  }
403  else
404  {
406  }
407  }
408  else
409  {
411  }
412 
413  if ($this->object->getShowMarker())
414  {
415  include_once "./Modules/Test/classes/class.ilObjTest.php";
416  $solved_array = ilObjTest::_getSolvedQuestions($this->object->getTestSession()->getActiveId(), $question_gui->object->getId());
417  $solved = 0;
418 
419  if (count ($solved_array) > 0)
420  {
421  $solved = array_pop($solved_array);
422  $solved = $solved["solved"];
423  }
424 
425  if ($solved==1)
426  {
428  }
429  else
430  {
432  }
433  }
434 
435  if ($this->object->getJavaScriptOutput())
436  {
437  $this->tpl->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript_disable.png"));
438  $this->tpl->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("disable_javascript"));
439  $this->tpl->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("disable_javascript"));
440  $this->ctrl->setParameter($this, "tst_javascript", "0");
441  $this->tpl->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this, "gotoQuestion"));
442  }
443  else
444  {
445  $this->tpl->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript.png"));
446  $this->tpl->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("enable_javascript"));
447  $this->tpl->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("enable_javascript"));
448  $this->ctrl->setParameter($this, "tst_javascript", "1");
449  $this->tpl->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this, "gotoQuestion"));
450  }
451 
452  if ($question_gui->object->supportsJavascriptOutput() && !$this->object->getForceJS())
453  {
454  $this->tpl->touchBlock("jsswitch");
455  }
456 
457  $this->tpl->addJavaScript(ilUtil::getJSLocation("autosave.js", "Modules/Test"));
458 
459  $this->tpl->setVariable("AUTOSAVE_URL", $this->ctrl->getFormAction($this, "autosave", "", true));
460 
461  if ($question_gui->isAutosaveable()&& $this->object->getAutosave())
462  {
463  $this->tpl->touchBlock('autosave');
464  //$this->tpl->setVariable("BTN_SAVE", "Zwischenspeichern");
465  //$this->tpl->setVariable("CMD_SAVE", "gotoquestion_{$sequence}");
466  //$this->tpl->setVariable("AUTOSAVEFORMACTION", str_replace("&amp;", "&", $this->ctrl->getFormAction($this)));
467  $this->tpl->setVariable("AUTOSAVEFORMACTION", str_replace("&amp;", "&", $this->ctrl->getLinkTarget($this, "autosave")));
468  $this->tpl->setVariable("AUTOSAVEINTERVAL", $this->object->getAutosaveIval());
469  }
470 
471  if( $this->object->areObligationsEnabled() && ilObjTest::isQuestionObligatory($question_gui->object->getId()) )
472  {
473  $this->tpl->touchBlock('question_obligatory');
474  $this->tpl->setVariable('QUESTION_OBLIGATORY', $this->lng->txt('required_field'));
475  }
476  }
477 
478  private function determineInlineScoreDisplay()
479  {
480  $show_question_inline_score = FALSE;
481  if ($this->object->getAnswerFeedbackPoints())
482  {
483  $show_question_inline_score = TRUE;
484  return $show_question_inline_score;
485  }
486  return $show_question_inline_score;
487  }
488 
490  {
491  if ($this->isFirstPageInSequence( $sequence ))
492  {
494  }
495  else
496  {
498  }
499  }
500 
502  {
503  $this->tpl->setCurrentBlock( "isnotmarked" );
504  $this->tpl->setVariable( "IMAGE_UNSET", ilUtil::getImagePath( "marked_.png" ) );
505  $this->tpl->setVariable( "TEXT_UNSET", $this->lng->txt( "tst_question_mark" ) );
506  $this->tpl->parseCurrentBlock();
507  }
508 
510  {
511  $this->tpl->setCurrentBlock( "ismarked" );
512  $this->tpl->setVariable( "IMAGE_SET", ilUtil::getImagePath( "marked.png" ) );
513  $this->tpl->setVariable( "TEXT_SET", $this->lng->txt( "tst_remove_mark" ) );
514  $this->tpl->parseCurrentBlock();
515  }
516 
518  {
521  }
522 
524  {
525  $this->tpl->setCurrentBlock( "next_bottom" );
526  $this->tpl->setVariable( "BTN_NEXT", $this->lng->txt( "save_next" ) . " &gt;&gt;" );
527  $this->tpl->parseCurrentBlock();
528  }
529 
531  {
532  $this->tpl->setCurrentBlock( "next" );
533  $this->tpl->setVariable( "BTN_NEXT", $this->lng->txt( "save_next" ) . " &gt;&gt;" );
534  $this->tpl->parseCurrentBlock();
535  }
536 
537  private function isLastQuestionInSequence($question_gui)
538  {
539  return $this->object->getTestSequence()->getQuestionForSequence( $this->object->getTestSequence()
540  ->getLastSequence()
541  ) == $question_gui->object->getId();
542  }
543 
545  {
548  }
549 
551  {
552  $this->tpl->setCurrentBlock( "next_bottom" );
553  $this->tpl->setVariable( "BTN_NEXT", $this->lng->txt( "save_finish" ) . " &gt;&gt;" );
554  $this->tpl->parseCurrentBlock();
555  }
556 
558  {
559  $this->tpl->setCurrentBlock( "next" );
560  $this->tpl->setVariable( "BTN_NEXT", $this->lng->txt( "save_finish" ) . " &gt;&gt;" );
561  $this->tpl->parseCurrentBlock();
562  }
563 
565  {
568  }
569 
571  {
572  $this->tpl->setCurrentBlock( "next_bottom" );
573  $this->tpl->setVariable( "BTN_NEXT", $this->lng->txt( "question_summary" ) . " &gt;&gt;" );
574  $this->tpl->parseCurrentBlock();
575  }
576 
578  {
579  $this->tpl->setCurrentBlock( "next" );
580  $this->tpl->setVariable( "BTN_NEXT", $this->lng->txt( "question_summary" ) . " &gt;&gt;" );
581  $this->tpl->parseCurrentBlock();
582  }
583 
584  private function populateCancelButtonBlock()
585  {
586  $this->tpl->setCurrentBlock( "cancel_test" );
587  $this->tpl->setVariable( "TEXT_CANCELTEST", $this->lng->txt( "cancel_test" ) );
588  $this->tpl->setVariable( "TEXT_ALTCANCELTEXT", $this->lng->txt( "cancel_test" ) );
589  $this->tpl->setVariable( "TEXT_TITLECANCELTEXT", $this->lng->txt( "cancel_test" ) );
590  $this->tpl->setVariable( "HREF_IMGCANCELTEST",
591  $this->ctrl->getLinkTargetByClass( get_class( $this ), "outIntroductionPage"
592  ) . "&cancelTest=true"
593  );
594  $this->tpl->setVariable( "HREF_CANCELTEXT",
595  $this->ctrl->getLinkTargetByClass( get_class( $this ), "outIntroductionPage"
596  ) . "&cancelTest=true"
597  );
598  $this->tpl->setVariable( "IMAGE_CANCEL", ilUtil::getImagePath( "cancel.png" ) );
599  $this->tpl->parseCurrentBlock();
600  }
601 
602  private function populateSummaryButtons()
603  {
606  }
607 
609  {
610  $this->tpl->setCurrentBlock( "summary_bottom" );
611  $this->tpl->setVariable( "BTN_SUMMARY", $this->lng->txt( "question_summary" ) );
612  $this->tpl->parseCurrentBlock();
613  }
614 
616  {
617  $this->tpl->setCurrentBlock( "summary" );
618  $this->tpl->setVariable( "BTN_SUMMARY", $this->lng->txt( "question_summary" ) );
619  $this->tpl->parseCurrentBlock();
620  }
621 
622  private function populatePostponeButtons()
623  {
626  }
627 
629  {
630  $this->tpl->setCurrentBlock( "postpone_bottom" );
631  $this->tpl->setVariable( "BTN_POSTPONE", $this->lng->txt( "postpone" ) );
632  $this->tpl->parseCurrentBlock();
633  }
634 
636  {
637  $this->tpl->setCurrentBlock( "postpone" );
638  $this->tpl->setVariable( "BTN_POSTPONE", $this->lng->txt( "postpone" ) );
639  $this->tpl->parseCurrentBlock();
640  }
641 
643  {
644  return $sequence == $this->object->getTestSequence()->getFirstSequence();
645  }
646 
648  {
651  }
652 
654  {
655  $this->tpl->setCurrentBlock( "prev_bottom" );
656  $this->tpl->setVariable( "BTN_PREV", "&lt;&lt; " . $this->lng->txt( "save_previous" ) );
657  $this->tpl->parseCurrentBlock();
658  }
659 
661  {
662  $this->tpl->setCurrentBlock( "prev" );
663  $this->tpl->setVariable( "BTN_PREV", "&lt;&lt; " . $this->lng->txt( "save_previous" ) );
664  $this->tpl->parseCurrentBlock();
665  }
666 
668  {
671  }
672 
674  {
675  $this->tpl->setCurrentBlock( "prev_bottom" );
676  $this->tpl->setVariable( "BTN_PREV", "&lt;&lt; " . $this->lng->txt( "save_introduction" ) );
677  $this->tpl->parseCurrentBlock();
678  }
679 
681  {
682  $this->tpl->setCurrentBlock( "prev" );
683  $this->tpl->setVariable( "BTN_PREV", "&lt;&lt; " . $this->lng->txt( "save_introduction" ) );
684  $this->tpl->parseCurrentBlock();
685  }
686 
687  private function populateSpecificFeedbackBlock($question_gui)
688  {
689  $this->tpl->setCurrentBlock( "specific_feedback" );
690  $this->tpl->setVariable( "SPECIFIC_FEEDBACK",
691  $question_gui->getSpecificFeedbackOutput(
692  $this->object->getTestSession()->getActiveId(),
693  NULL
694  )
695  );
696  $this->tpl->parseCurrentBlock();
697  }
698 
699  private function populateGenericFeedbackBlock($question_gui)
700  {
701  $this->tpl->setCurrentBlock( "answer_feedback" );
702  $this->tpl->setVariable( "ANSWER_FEEDBACK",
703  $question_gui->getAnswerFeedbackOutput( $this->object->getTestSession()->getActiveId(),
704  NULL
705  )
706  );
707  $this->tpl->parseCurrentBlock();
708  }
709 
710  private function populateScoreBlock($reachedPoints, $maxPoints)
711  {
712  $this->tpl->setCurrentBlock( "solution_output" );
713  $this->tpl->setVariable( "RECEIVED_POINTS_INFORMATION",
714  sprintf( $this->lng->txt( "you_received_a_of_b_points" ), $reachedPoints, $maxPoints )
715  );
716  $this->tpl->parseCurrentBlock();
717  }
718 
719  private function populateSolutionBlock($solutionoutput)
720  {
721  $this->tpl->setCurrentBlock( "solution_output" );
722  $this->tpl->setVariable( "CORRECT_SOLUTION", $this->lng->txt( "tst_best_solution_is" ) );
723  $this->tpl->setVariable( "QUESTION_FEEDBACK", $solutionoutput );
724  $this->tpl->parseCurrentBlock();
725  }
726 
727  private function showSideList()
728  {
729  global $ilUser;
730  $show_side_list = $ilUser->getPref( 'side_list_of_questions' );
731  $this->tpl->setCurrentBlock( 'view_sidelist' );
732  $this->tpl->setVariable( 'IMAGE_SIDELIST',
733  ($show_side_list) ? ilUtil::getImagePath( 'view_remove.png'
734  ) : ilUtil::getImagePath( 'view_choose.png' )
735  );
736  $this->tpl->setVariable( 'TEXT_SIDELIST',
737  ($show_side_list) ? $this->lng->txt( 'tst_hide_side_list'
738  ) : $this->lng->txt( 'tst_show_side_list' )
739  );
740  $this->tpl->parseCurrentBlock();
741  if ($show_side_list)
742  {
743  $this->tpl->addCss( ilUtil::getStyleSheetLocation( "output", "ta_split.css", "Modules/Test" ), "screen" );
744  $this->outQuestionSummary( false );
745  }
746  }
747 
748  private function populateSyntaxStyleBlock()
749  {
750  $this->tpl->setCurrentBlock( "SyntaxStyle" );
751  $this->tpl->setVariable( "LOCATION_SYNTAX_STYLESHEET",
753  );
754  $this->tpl->parseCurrentBlock();
755  }
756 
757  private function populateContentStyleBlock()
758  {
759  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
760  $this->tpl->setCurrentBlock( "ContentStyle" );
761  $this->tpl->setVariable( "LOCATION_CONTENT_STYLESHEET",
763  );
764  $this->tpl->parseCurrentBlock();
765  }
766 
773  {
774  $template = new ilTemplate("tpl.il_as_tst_password_protection.html", TRUE, TRUE, "Modules/Test");
775  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "checkPassword"));
776  $template->setVariable("PASSWORD_INTRODUCTION", $this->lng->txt("tst_password_introduction"));
777  $template->setVariable("TEXT_PASSWORD", $this->lng->txt("tst_password"));
778  $template->setVariable("SUBMIT", $this->lng->txt("submit"));
779  $this->tpl->setVariable($this->getContentBlockName(), $template->get());
780  }
781 
787  function checkPassword()
788  {
789  if (strcmp($this->object->getPassword(), $_POST["password"]) == 0)
790  {
791  global $ilUser;
792  if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
793  {
794  $ilUser->setPref("tst_password_".$this->object->getTestId(), $this->object->getPassword());
795  $ilUser->writePref("tst_password_".$this->object->getTestId(), $this->object->getPassword());
796  }
797  else
798  {
799  $_SESSION['tst_password_'.$this->object->getTestId()] = $this->object->getPassword();
800  }
801  $this->ctrl->redirect($this, "start");
802  }
803  else
804  {
805  ilUtil::sendFailure($this->lng->txt("tst_password_entered_wrong_password"), true);
806  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
807  }
808  }
809 
817  function setAnonymousId()
818  {
819  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
820  {
821  $this->object->setAccessCodeSession($_POST["anonymous_id"]);
822  }
823  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
824  }
825 
834  function start()
835  {
836  if (strcmp($_SESSION["lock"], $_POST["lock"]) != 0)
837  {
838  $_SESSION["lock"] = $_POST["lock"];
839  $this->handleStartCommands();
840  $this->ctrl->redirect($this, "startTest");
841  }
842  else
843  {
844  $this->ctrl->redirectByClass("ilobjtestgui", "redirectToInfoScreen");
845  }
846  }
847 
853  function startTest()
854  {
855  if ($this->object->checkMaximumAllowedUsers() == FALSE)
856  {
858  }
859  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
860  {
861  $this->object->setAccessCodeSession($this->object->createNewAccessCode());
862  }
863  else
864  {
865  $this->object->unsetAccessCodeSession();
866  }
867  if (strlen($this->object->getPassword()))
868  {
869  global $ilUser;
870  global $rbacsystem;
871 
872  $pwd = '';
873  if( $_SESSION["AccountId"] != ANONYMOUS_USER_ID )
874  {
875  $pwd = $ilUser->getPref("tst_password_".$this->object->getTestId());
876  }
877  elseif( isset($_SESSION['tst_password_'.$this->object->getTestId()]) )
878  {
879  $pwd = $_SESSION['tst_password_'.$this->object->getTestId()];
880  }
881 
882  if ((strcmp($pwd, $this->object->getPassword()) != 0) && (!$rbacsystem->checkAccess("write", $this->object->getRefId())))
883  {
884  return $this->showPasswordProtectionPage();
885  }
886  }
887  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
888  {
889  $this->ctrl->redirect($this, "displayCode");
890  }
891  else
892  {
893  $this->ctrl->setParameter($this, "activecommand", "start");
894  $this->ctrl->redirect($this, "redirectQuestion");
895  }
896  }
897 
898  function displayCode()
899  {
900  $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_anonymous_code_presentation.html", "Modules/Test");
901  $this->tpl->setCurrentBlock("adm_content");
902  $this->tpl->setVariable("TEXT_ANONYMOUS_CODE_CREATED", $this->lng->txt("tst_access_code_created"));
903  $this->tpl->setVariable("TEXT_ANONYMOUS_CODE", $this->object->getAccessCodeSession());
904  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
905  $this->tpl->setVariable("CONTINUE", $this->lng->txt("continue_work"));
906  $this->tpl->parseCurrentBlock();
907  }
908 
909  function codeConfirmed()
910  {
911  $this->ctrl->setParameter($this, "activecommand", "start");
912  $this->ctrl->redirect($this, "redirectQuestion");
913  }
914 
922  function resume()
923  {
924  if ($this->object->checkMaximumAllowedUsers() == FALSE)
925  {
927  }
928  $this->handleStartCommands();
929  $this->ctrl->setParameter($this, "activecommand", "resume");
930  $this->ctrl->redirect($this, "redirectQuestion");
931  }
932 
936  public function handleStartCommands()
937  {
938  global $ilUser;
939 
940  if ($_POST["chb_javascript"])
941  {
942  $ilUser->writePref("tst_javascript", 1);
943  }
944  else
945  {
946  $ilUser->writePref("tst_javascript", 0);
947  }
948 
949  // hide previous results
950  if ($this->object->getNrOfTries() != 1)
951  {
952  if ($this->object->getUsePreviousAnswers() == 1)
953  {
954  if ($_POST["chb_use_previous_answers"])
955  {
956  $ilUser->writePref("tst_use_previous_answers", 1);
957  }
958  else
959  {
960  $ilUser->writePref("tst_use_previous_answers", 0);
961  }
962  }
963  }
964 /* if ($this->object->getTestType() == TYPE_ONLINE_TEST)
965  {
966  global $ilias;
967  $ilias->auth->setIdle(0, false);
968  }*/
969  }
970 
977  function redirectQuestion()
978  {
979  global $ilUser;
980 
981  // check the test restrictions to access the test in case one
982  // of the test navigation commands was called by an external script
983  // e.g. $ilNavigationHistory
984  $executable = $this->object->isExecutable($ilUser->getId());
985  if (!$executable["executable"])
986  {
987  ilUtil::sendInfo($executable["errormessage"], TRUE);
988  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
989  }
990  switch ($_GET["activecommand"])
991  {
992  case "next":
993  $this->sequence = $this->calculateSequence();
994  if ($this->sequence === FALSE)
995  {
996  if ($this->object->getListOfQuestionsEnd())
997  {
998 
999  $allObligationsAnswered = ilObjTest::allObligationsAnswered(
1000  $this->object->getTestSession()->getTestId(),
1001  $this->object->getTestSession()->getActiveId(),
1002  $this->object->getTestSession()->getPass()
1003  );
1004 
1005  if( $this->object->areObligationsEnabled() && !$allObligationsAnswered )
1006  {
1007  $this->ctrl->redirect($this, "outQuestionSummaryWithObligationsInfo");
1008  }
1009 
1010  $this->outQuestionSummary();
1011  }
1012  else
1013  {
1014  $this->ctrl->redirect($this, "finishTest");
1015  }
1016  }
1017  else
1018  {
1019  $this->object->getTestSession()->setLastSequence($this->sequence);
1020  $this->object->getTestSession()->saveToDb();
1021  $this->outTestPage();
1022  }
1023  break;
1024  case "previous":
1025  $this->sequence = $this->calculateSequence();
1026  $this->object->getTestSession()->setLastSequence($this->sequence);
1027  $this->object->getTestSession()->saveToDb();
1028  if ($this->sequence === FALSE)
1029  {
1030  $this->ctrl->redirect($this, "outIntroductionPage");
1031  }
1032  else
1033  {
1034  $this->outTestPage();
1035  }
1036  break;
1037  case "postpone":
1038  $this->sequence = $this->calculateSequence();
1039  $nextSequence = $this->object->getTestSequence()->getNextSequence($this->sequence);
1040  $this->object->getTestSequence()->postponeSequence($this->sequence);
1041  $this->object->getTestSequence()->saveToDb();
1042  $this->object->getTestSession()->setLastSequence($nextSequence);
1043  $this->object->getTestSession()->saveToDb();
1044  $this->sequence = $nextSequence;
1045  $this->outTestPage();
1046  break;
1047  case "setmarked":
1048  $this->sequence = $this->calculateSequence();
1049  $this->object->getTestSession()->setLastSequence($this->sequence);
1050  $this->object->getTestSession()->saveToDb();
1051  $q_id = $this->object->getTestSequence()->getQuestionForSequence($_GET["sequence"]);
1052  $this->object->setQuestionSetSolved(1, $q_id, $ilUser->getId());
1053  $this->outTestPage();
1054  break;
1055  case "resetmarked":
1056  $this->sequence = $this->calculateSequence();
1057  $this->object->getTestSession()->setLastSequence($this->sequence);
1058  $this->object->getTestSession()->saveToDb();
1059  $q_id = $this->object->getTestSequence()->getQuestionForSequence($_GET["sequence"]);
1060  $this->object->setQuestionSetSolved(0, $q_id, $ilUser->getId());
1061  $this->outTestPage();
1062  break;
1063  case "directfeedback":
1064  $this->sequence = $this->calculateSequence();
1065  $this->object->getTestSession()->setLastSequence($this->sequence);
1066  $this->object->getTestSession()->saveToDb();
1067  $this->outTestPage();
1068  break;
1069  case "selectImagemapRegion":
1070  $this->sequence = $this->calculateSequence();
1071  $this->object->getTestSession()->setLastSequence($this->sequence);
1072  $this->object->getTestSession()->saveToDb();
1073  $this->outTestPage();
1074  break;
1075  case "summary":
1076  $this->ctrl->redirect($this, "outQuestionSummary");
1077  break;
1078  case "summary_obligations":
1079  $this->ctrl->redirect($this, "outQuestionSummaryWithObligationsInfo");
1080  break;
1081  case "summary_obligations_only":
1082  $this->ctrl->redirect($this, "outObligationsOnlySummary");
1083  break;
1084  case "start":
1085  $_SESSION['tst_pass_finish'] = 0;
1086  $this->object->createTestSession();
1087  $active_id = $this->object->getTestSession()->getActiveId();
1088  $this->ctrl->setParameter($this, "active_id", $active_id);
1089  $shuffle = $this->object->getShuffleQuestions();
1090  if ($this->object->isRandomTest())
1091  {
1092  $this->object->generateRandomQuestions($this->object->getTestSession()->getActiveId());
1093  $this->object->loadQuestions();
1094  $shuffle = FALSE; // shuffle is already done during the creation of the random questions
1095  }
1096 
1098  $active_id, $this->object->getTestSession()->getPass(), $this->object->areObligationsEnabled()
1099  );
1100 
1101  $this->object->createTestSequence($active_id, 0, $shuffle);
1102  $active_time_id = $this->object->startWorkingTime($this->object->getTestSession()->getActiveId(), $this->object->getTestSession()->getPass());
1103  $_SESSION["active_time_id"] = $active_time_id;
1104  if ($this->object->getListOfQuestionsStart())
1105  {
1106  $this->ctrl->setParameter($this, "activecommand", "summary");
1107  $this->ctrl->redirect($this, "redirectQuestion");
1108  }
1109  else
1110  {
1111  $this->ctrl->setParameter($this, "sequence", $this->sequence);
1112  $this->ctrl->setParameter($this, "activecommand", "gotoquestion");
1113  $this->ctrl->saveParameter($this, "tst_javascript");
1114  $this->ctrl->redirect($this, "redirectQuestion");
1115  }
1116  break;
1117  case "resume":
1118  $_SESSION['tst_pass_finish'] = 0;
1119  $active_id = $this->object->getTestSession()->getActiveId();
1120  $this->ctrl->setParameter($this, "active_id", $active_id);
1121 
1122  if ($this->object->isRandomTest())
1123  {
1124  if (!$this->object->hasRandomQuestionsForPass($active_id, $this->object->getTestSession()->getPass()))
1125  {
1126  // create a new set of random questions
1127  $this->object->generateRandomQuestions($active_id, $this->object->getTestSession()->getPass());
1128  }
1129  }
1130  $shuffle = $this->object->getShuffleQuestions();
1131  if ($this->object->isRandomTest())
1132  {
1133  $shuffle = FALSE;
1134  }
1135 
1137  $active_id, $this->object->getTestSession()->getPass(), $this->object->areObligationsEnabled()
1138  );
1139 
1140  $this->object->createTestSequence($active_id, $this->object->getTestSession()->getPass(), $shuffle);
1141 
1142  $this->sequence = $this->object->getTestSession()->getLastSequence();
1143  $active_time_id = $this->object->startWorkingTime($active_id, $this->object->getTestSession()->getPass());
1144  $_SESSION["active_time_id"] = $active_time_id;
1145  if ($this->object->getListOfQuestionsStart())
1146  {
1147  $this->ctrl->setParameter($this, "activecommand", "summary");
1148  $this->ctrl->redirect($this, "redirectQuestion");
1149  }
1150  else
1151  {
1152  $this->ctrl->setParameter($this, "sequence", $this->sequence);
1153  $this->ctrl->setParameter($this, "activecommand", "gotoquestion");
1154  $this->ctrl->saveParameter($this, "tst_javascript");
1155  $this->ctrl->redirect($this, "redirectQuestion");
1156  }
1157  break;
1158 
1159  case "back":
1160  case "gotoquestion":
1161  default:
1162  $_SESSION['tst_pass_finish'] = 0;
1163  if (array_key_exists("tst_javascript", $_GET))
1164  {
1165  $ilUser->writePref("tst_javascript", $_GET["tst_javascript"]);
1166  }
1167  $this->sequence = $this->calculateSequence();
1168  if (strlen($_GET['gotosequence'])) $this->sequence = $_GET['gotosequence'];
1169  $this->object->getTestSession()->setLastSequence($this->sequence);
1170  $this->object->getTestSession()->saveToDb();
1171  $this->outTestPage();
1172  break;
1173  }
1174  }
1175 
1181  function calculateSequence()
1182  {
1183  $sequence = $_GET["sequence"];
1184  if (!$sequence) $sequence = $this->object->getTestSequence()->getFirstSequence();
1185  if (array_key_exists("save_error", $_GET))
1186  {
1187  if ($_GET["save_error"] == 1)
1188  {
1189  return $sequence;
1190  }
1191  }
1192  switch ($_GET["activecommand"])
1193  {
1194  case "next":
1195  $sequence = $this->object->getTestSequence()->getNextSequence($sequence);
1196  break;
1197  case "previous":
1198  $sequence = $this->object->getTestSequence()->getPreviousSequence($sequence);
1199  break;
1200  }
1201  return $sequence;
1202  }
1203 
1205  {
1206  $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_redirect_autosave.html", "Modules/Test");
1207  $this->tpl->setVariable("TEXT_REDIRECT", $this->lng->txt("redirectAfterSave"));
1208  $this->tpl->setCurrentBlock("HeadContent");
1209  $this->tpl->setVariable("CONTENT_BLOCK", "<meta http-equiv=\"refresh\" content=\"5; url=" . $this->ctrl->getLinkTarget($this, "redirectBack") . "\">");
1210  $this->tpl->parseCurrentBlock();
1211  }
1212 
1213  function autosave()
1214  {
1215  global $ilLog;
1216  $result = "";
1217  if (is_array($_POST) && count($_POST) > 0)
1218  {
1219  $res = $this->saveQuestionSolution(TRUE);
1220  if ($res)
1221  {
1222  $this->object->getTestSession()->saveToDb();
1223  $result = $this->lng->txt("autosave_success");
1224  }
1225  else
1226  {
1227  $result = $this->lng->txt("autosave_failed");
1228  }
1229  }
1230  if (!$this->canSaveResult())
1231  {
1232  // this was the last action in the test, saving is no longer allowed
1233  $result = $this->ctrl->getLinkTarget($this, "redirectAfterAutosave", "", true);
1234  }
1235  echo $result;
1236  exit;
1237  }
1238 
1242  public function togglesidelist()
1243  {
1244  global $ilUser;
1245 
1246  $show_side_list = $ilUser->getPref('side_list_of_questions');
1247  $ilUser->writePref('side_list_of_questions', !$show_side_list);
1248  $this->saveQuestionSolution();
1249  $this->ctrl->redirect($this, "redirectQuestion");
1250  }
1251 
1259  function next()
1260  {
1261  $this->saveQuestionSolution();
1262  $this->ctrl->setParameter($this, "activecommand", "next");
1263  $this->ctrl->redirect($this, "redirectQuestion");
1264  }
1265 
1273  function previous()
1274  {
1275  $this->saveQuestionSolution();
1276  $this->ctrl->setParameter($this, "activecommand", "previous");
1277  $this->ctrl->redirect($this, "redirectQuestion");
1278  }
1279 
1287  function postpone()
1288  {
1289  $this->saveQuestionSolution();
1290  $this->ctrl->setParameter($this, "activecommand", "postpone");
1291  $this->ctrl->redirect($this, "redirectQuestion");
1292  }
1293 
1301  function summary()
1302  {
1303  $this->saveQuestionSolution();
1304  if ($this->saveResult == FALSE)
1305  {
1306  $this->ctrl->setParameter($this, "activecommand", "");
1307  $this->ctrl->redirect($this, "redirectQuestion");
1308  }
1309  else
1310  {
1311  $this->ctrl->setParameter($this, "activecommand", "summary");
1312  $this->ctrl->redirect($this, "redirectQuestion");
1313  }
1314  }
1315 
1317  {
1318  $this->ctrl->setParameter($this, "activecommand", "summary");
1319  $this->ctrl->redirect($this, "redirectQuestion");
1320  }
1321 
1329  function setmarked()
1330  {
1331  $this->saveQuestionSolution();
1332  $this->ctrl->setParameter($this, "activecommand", "setmarked");
1333  $this->ctrl->redirect($this, "redirectQuestion");
1334  }
1335 
1343  function resetmarked()
1344  {
1345  $this->saveQuestionSolution();
1346  $this->ctrl->setParameter($this, "activecommand", "resetmarked");
1347  $this->ctrl->redirect($this, "redirectQuestion");
1348  }
1349 
1357  function directfeedback()
1358  {
1359  $this->saveQuestionSolution();
1360  $this->ctrl->setParameter($this, "activecommand", "directfeedback");
1361  $this->ctrl->redirect($this, "redirectQuestion");
1362  }
1363 
1372  {
1373  $this->saveQuestionSolution();
1374  $activecommand = "selectImagemapRegion";
1375  if (array_key_exists('cmd', $_POST))
1376  {
1377  $activecommand = key($_POST["cmd"]);
1378  }
1379  if (preg_match("/^gotoquestion_(\\d+)$/", $activecommand, $matches))
1380  {
1381  $activecommand = "gotoquestion";
1382  if (strlen($matches[1]))
1383  {
1384  $this->ctrl->setParameter($this, 'gotosequence', $matches[1]);
1385  }
1386  }
1387  if (strcmp($activecommand, "togglesidelist") == 0)
1388  {
1389  $this->togglesidelist();
1390  }
1391  else
1392  {
1393  $this->ctrl->setParameter($this, "activecommand", $activecommand);
1394  $this->ctrl->redirect($this, "redirectQuestion");
1395  }
1396  }
1397 
1405  function gotoQuestion()
1406  {
1407  if (is_array($_POST) && count($_POST) > 0) $this->saveQuestionSolution();
1408  $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
1409  $this->ctrl->setParameter($this, "activecommand", "gotoquestion");
1410  $this->ctrl->saveParameter($this, "tst_javascript");
1411  if (strlen($_GET['qst_selection'])) $_SESSION['qst_selection'] = $_GET['qst_selection'];
1412  $this->ctrl->redirect($this, "redirectQuestion");
1413  }
1414 
1422  function backFromSummary()
1423  {
1424  $this->ctrl->setParameter($this, "activecommand", "back");
1425  $this->ctrl->redirect($this, "redirectQuestion");
1426  }
1427 
1435  function confirmFinish()
1436  {
1437  $this->finishTest(false);
1438  }
1439 
1447  function confirmFinishTest()
1448  {
1452  global $ilUser;
1453 
1454  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1455  $confirmation = new ilConfirmationGUI();
1456  $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmFinish'));
1457  $confirmation->setHeaderText($this->lng->txt("tst_finish_confirmation_question"));
1458  $confirmation->setConfirm($this->lng->txt("tst_finish_confirm_button"), 'confirmFinish');
1459  if($this->object->canShowSolutionPrintview($ilUser->getId()))
1460  {
1461  $confirmation->setCancel($this->lng->txt("tst_finish_confirm_list_of_answers_button"), 'backConfirmFinish');
1462  }
1463  else
1464  {
1465  $confirmation->setCancel($this->lng->txt("tst_finish_confirm_cancel_button"), 'backConfirmFinish');
1466  }
1467  if($this->object->getKioskMode())
1468  {
1469  $this->tpl->addBlockfile($this->getContentBlockName(), 'content', "tpl.il_as_tst_kiosk_mode_content.html", "Modules/Test");
1470  $this->tpl->setContent($confirmation->getHtml());
1471  }
1472  else
1473  {
1474  $this->tpl->setVariable($this->getContentBlockName(), $confirmation->getHtml());
1475  }
1476  }
1477 
1485  function finishTest($confirm = true)
1486  {
1487  global $ilUser;
1488  global $ilias;
1489  global $ilAuth;
1490 
1491  unset($_SESSION["tst_next"]);
1492 
1493  $active_id = $this->object->getTestSession()->getActiveId();
1494  $actualpass = $this->object->_getPass($active_id);
1495 
1496  $allObligationsAnswered = ilObjTest::allObligationsAnswered($this->object->getTestSession()->getTestId(), $active_id, $actualpass);
1497 
1498  if( $this->object->areObligationsEnabled() && !$allObligationsAnswered )
1499  {
1500  if( $this->object->getListOfQuestions() )
1501  {
1502  $_GET['activecommand'] = 'summary_obligations';
1503  }
1504  else
1505  {
1506  $_GET['activecommand'] = 'summary_obligations_only';
1507  }
1508 
1509  $this->redirectQuestion();
1510  return;
1511  }
1512 
1513  if (($actualpass == $this->object->getNrOfTries() - 1) && (!$confirm))
1514  {
1515  $ilAuth->setIdle(ilSession::getIdleValue(), false);
1516  $ilAuth->setExpire(0);
1517  switch ($this->object->getMailNotification())
1518  {
1519  case 1:
1520  $this->object->sendSimpleNotification($active_id);
1521  break;
1522  case 2:
1523  $this->object->sendAdvancedNotification($active_id);
1524  break;
1525  }
1526  }
1527 
1528  if (($confirm) && ($actualpass == $this->object->getNrOfTries() - 1))
1529  {
1530  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
1531  {
1532  $template = new ilTemplate("tpl.il_as_tst_finish_navigation.html", TRUE, TRUE, "Modules/Test");
1533  $template->setVariable("BUTTON_FINISH", $this->lng->txt("btn_next"));
1534  $template->setVariable("BUTTON_CANCEL", $this->lng->txt("btn_previous"));
1535 
1536  $template_top = new ilTemplate("tpl.il_as_tst_list_of_answers_topbuttons.html", TRUE, TRUE, "Modules/Test");
1537  $template_top->setCurrentBlock("button_print");
1538  $template_top->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
1539  $template_top->parseCurrentBlock();
1540 
1541  $this->showListOfAnswers($active_id, NULL, $template_top->get(), $template->get());
1542  return;
1543  }
1544  else
1545  {
1546  // show confirmation page
1547  return $this->confirmFinishTest();
1548  }
1549  }
1550 
1551  if (!$_SESSION['tst_pass_finish'])
1552  {
1553  if (!$_SESSION['tst_pass_finish']) $_SESSION['tst_pass_finish'] = 1;
1554  if ($this->object->getMailNotificationType() == 1)
1555  {
1556  switch ($this->object->getMailNotification())
1557  {
1558  case 1:
1559  $this->object->sendSimpleNotification($active_id);
1560  break;
1561  case 2:
1562  $this->object->sendAdvancedNotification($active_id);
1563  break;
1564  }
1565  }
1566  if( !$this->object->getTestSession()->isSubmitted() )
1567  {
1568  $this->object->setActiveTestSubmitted($ilUser->getId());
1569  }
1570  $this->object->getTestSession()->increaseTestPass();
1571  }
1572  $this->redirectBack();
1573  }
1574 
1575  public function redirectBack()
1576  {
1577  if (!$_GET["skipfinalstatement"])
1578  {
1579  if ($this->object->getShowFinalStatement())
1580  {
1581  $this->ctrl->redirect($this, "showFinalStatement");
1582  }
1583  }
1584  if($_GET['crs_show_result'])
1585  {
1586  $this->ctrl->redirectByClass("ilobjtestgui", "backToCourse");
1587  }
1588 
1589  if (!$this->object->canViewResults())
1590  {
1591  $this->outIntroductionPage();
1592  }
1593  else
1594  {
1595  $this->ctrl->redirectByClass("ilTestEvaluationGUI", "outUserResultsOverview");
1596  }
1597  }
1598 
1599  /*
1600  * Presents the final statement of a test
1601  */
1602  public function showFinalStatement()
1603  {
1604  $template = new ilTemplate("tpl.il_as_tst_final_statement.html", TRUE, TRUE, "Modules/Test");
1605  $this->ctrl->setParameter($this, "crs_show_result", $_GET['crs_show_result']);
1606  $this->ctrl->setParameter($this, "skipfinalstatement", 1);
1607  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "redirectBack"));
1608  $template->setVariable("FINALSTATEMENT", $this->object->getFinalStatement());
1609  $template->setVariable("BUTTON_CONTINUE", $this->lng->txt("btn_next"));
1610  $this->tpl->setVariable($this->getContentBlockName(), $template->get());
1611  }
1612 
1613  public function getKioskHead()
1614  {
1615  global $ilUser;
1616 
1617  $template = new ilTemplate('tpl.il_as_tst_kiosk_head.html', true, true, 'Modules/Test');
1618  if ($this->object->getShowKioskModeTitle())
1619  {
1620  $template->setCurrentBlock("kiosk_show_title");
1621  $template->setVariable("TEST_TITLE", $this->object->getTitle());
1622  $template->parseCurrentBlock();
1623  }
1624  if ($this->object->getShowKioskModeParticipant())
1625  {
1626  $template->setCurrentBlock("kiosk_show_participant");
1627  $template->setVariable("PARTICIPANT_NAME", $this->lng->txt("login_as") . " " . $ilUser->getFullname());
1628  $template->parseCurrentBlock();
1629  }
1630  return $template->get();
1631  }
1632 
1636  function outTestPage()
1637  {
1638  global $rbacsystem, $ilUser;
1639 
1640  $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_output.html", "Modules/Test");
1641  if (!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1642  {
1643  // only with read access it is possible to run the test
1644  $this->ilias->raiseError($this->lng->txt("cannot_execute_test"),$this->ilias->error_obj->MESSAGE);
1645  }
1646 
1647  if ($this->isMaxProcessingTimeReached())
1648  {
1649  $this->maxProcessingTimeReached();
1650  return;
1651  }
1652 
1653  if ($this->object->endingTimeReached())
1654  {
1655  $this->endingTimeReached();
1656  return;
1657  }
1658 
1659  if ($this->object->getKioskMode())
1660  {
1661  ilUtil::sendInfo();
1662  $head = $this->getKioskHead();
1663  if (strlen($head))
1664  {
1665  $this->tpl->setCurrentBlock("kiosk_options");
1666  $this->tpl->setVariable("KIOSK_HEAD", $head);
1667  $this->tpl->parseCurrentBlock();
1668  }
1669  }
1670 
1671  if ($this->object->getEnableProcessingTime())
1672  {
1673  $this->outProcessingTime($this->object->getTestSession()->getActiveId());
1674  }
1675 
1676  $this->tpl->setVariable("FORM_TIMESTAMP", time());
1677 
1678  $this->tpl->setVariable("PAGETITLE", "- " . $this->object->getTitle());
1679 
1680  $postpone = false;
1681  if ($this->object->getSequenceSettings() == TEST_POSTPONE)
1682  {
1683  $postpone = true;
1684  }
1685  $directfeedback = 0;
1686  if (strcmp($_GET["activecommand"], "directfeedback") == 0)
1687  {
1688  $directfeedback = 1;
1689  }
1690 
1691  $this->outWorkingForm($this->sequence, $this->object->getTestId(), $postpone, $directfeedback, $show_summary);
1692  }
1693 
1702  {
1703  global $ilUser;
1704 
1705  // check if user is invited to participate
1706  $user = $this->object->getInvitedUsers($ilUser->getId());
1707  if (!is_array ($user) || count($user)!=1)
1708  {
1709  ilUtil::sendInfo($this->lng->txt("user_not_invited"), true);
1710  $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
1711  }
1712 
1713  $user = array_pop($user);
1714  // check if client ip is set and if current remote addr is equal to stored client-ip
1715  if (strcmp($user["clientip"],"")!=0 && strcmp($user["clientip"],$_SERVER["REMOTE_ADDR"])!=0)
1716  {
1717  ilUtil::sendInfo($this->lng->txt("user_wrong_clientip"), true);
1718  $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
1719  }
1720  }
1721 
1722 
1726  function isTestAccessible()
1727  {
1728  return !$this->isNrOfTriesReached()
1729  and !$this->isMaxProcessingTimeReached()
1730  and $this->object->startingTimeReached()
1731  and !$this->object->endingTimeReached();
1732  }
1733 
1738  {
1739  return $this->object->hasNrOfTriesRestriction() && $this->object->isNrOfTriesReached($this->object->getTestSession()->getPass());
1740  }
1741 
1749  function passDetails()
1750  {
1751  if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
1752  {
1753  $this->ctrl->saveParameter($this, "pass");
1754  $this->ctrl->saveParameter($this, "active_id");
1755  $this->outTestResults(false, $_GET["pass"]);
1756  }
1757  else
1758  {
1759  $this->outTestResults(false);
1760  }
1761  }
1762 
1768  function endingTimeReached()
1769  {
1770  ilUtil::sendInfo(sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime())));
1771  $this->object->getTestSession()->increasePass();
1772  $this->object->getTestSession()->setLastSequence(0);
1773  $this->object->getTestSession()->saveToDb();
1774  if (!$this->object->canViewResults())
1775  {
1776  $this->outIntroductionPage();
1777  }
1778  else
1779  {
1780  $this->ctrl->redirectByClass("ilTestEvaluationGUI", "outUserResultsOverview");
1781  }
1782  }
1783 
1792  {
1793  $this->outIntroductionPage();
1794  }
1795 
1802  {
1803  $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_submit_answers_confirm.html", "Modules/Test");
1804  $this->tpl->setCurrentBlock("adm_content");
1805  if ($this->object->isTestFinished($this->object->getTestSession()->getActiveId()))
1806  {
1807  $this->tpl->setCurrentBlock("not_submit_allowed");
1808  $this->tpl->setVariable("TEXT_ALREADY_SUBMITTED", $this->lng->txt("tst_already_submitted"));
1809  $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_show_answer_sheet"));
1810  } else
1811  {
1812  $this->tpl->setCurrentBlock("submit_allowed");
1813  $this->tpl->setVariable("TEXT_CONFIRM_SUBMIT_RESULTS", $this->lng->txt("tst_confirm_submit_answers"));
1814  $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_results"));
1815  }
1816  $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
1817  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "finalSubmission"));
1818  $this->tpl->parseCurrentBlock();
1819  }
1820 
1821  function outProcessingTime($active_id)
1822  {
1823  global $ilUser;
1824 
1825  $starting_time = $this->object->getStartingTimeOfUser($active_id);
1826  $processing_time = $this->object->getProcessingTimeInSeconds();
1827  $processing_time_minutes = floor($processing_time / 60);
1828  $processing_time_seconds = $processing_time - $processing_time_minutes * 60;
1829  $str_processing_time = "";
1830  if ($processing_time_minutes > 0)
1831  {
1832  $str_processing_time = $processing_time_minutes . " " . ($processing_time_minutes == 1 ? $this->lng->txt("minute") : $this->lng->txt("minutes"));
1833  }
1834  if ($processing_time_seconds > 0)
1835  {
1836  if (strlen($str_processing_time) > 0) $str_processing_time .= " " . $this->lng->txt("and") . " ";
1837  $str_processing_time .= $processing_time_seconds . " " . ($processing_time_seconds == 1 ? $this->lng->txt("second") : $this->lng->txt("seconds"));
1838  }
1839  $time_left = $starting_time + $processing_time - mktime();
1840  $time_left_minutes = floor($time_left / 60);
1841  $time_left_seconds = $time_left - $time_left_minutes * 60;
1842  $str_time_left = "";
1843  if ($time_left_minutes > 0)
1844  {
1845  $str_time_left = $time_left_minutes . " " . ($time_left_minutes == 1 ? $this->lng->txt("minute") : $this->lng->txt("minutes"));
1846  }
1847  if ($time_left < 300)
1848  {
1849  if ($time_left_seconds > 0)
1850  {
1851  if (strlen($str_time_left) > 0) $str_time_left .= " " . $this->lng->txt("and") . " ";
1852  $str_time_left .= $time_left_seconds . " " . ($time_left_seconds == 1 ? $this->lng->txt("second") : $this->lng->txt("seconds"));
1853  }
1854  }
1855  $date = getdate($starting_time);
1856  $formattedStartingTime = ilDatePresentation::formatDate(new ilDateTime($date,IL_CAL_FKT_GETDATE));
1857  /*
1858  $formattedStartingTime = ilFormat::formatDate(
1859  $date["year"]."-".
1860  sprintf("%02d", $date["mon"])."-".
1861  sprintf("%02d", $date["mday"])." ".
1862  sprintf("%02d", $date["hours"]).":".
1863  sprintf("%02d", $date["minutes"]).":".
1864  sprintf("%02d", $date["seconds"])
1865  );
1866  */
1867  $datenow = getdate();
1868  $this->tpl->setCurrentBlock("enableprocessingtime");
1869  $this->tpl->setVariable("USER_WORKING_TIME",
1870  sprintf(
1871  $this->lng->txt("tst_time_already_spent"),
1872  $formattedStartingTime,
1873  $str_processing_time
1874  )
1875  );
1876  $this->tpl->setVariable("USER_REMAINING_TIME", sprintf($this->lng->txt("tst_time_already_spent_left"), $str_time_left));
1877  $this->tpl->parseCurrentBlock();
1878  $template = new ilTemplate("tpl.workingtime.js.html", TRUE, TRUE, TRUE);
1879  $template->setVariable("STRING_MINUTE", $this->lng->txt("minute"));
1880  $template->setVariable("STRING_MINUTES", $this->lng->txt("minutes"));
1881  $template->setVariable("STRING_SECOND", $this->lng->txt("second"));
1882  $template->setVariable("STRING_SECONDS", $this->lng->txt("seconds"));
1883  $template->setVariable("STRING_TIMELEFT", $this->lng->txt("tst_time_already_spent_left"));
1884  $template->setVariable("AND", strtolower($this->lng->txt("and")));
1885  $template->setVariable("YEAR", $date["year"]);
1886  $template->setVariable("MONTH", $date["mon"]-1);
1887  $template->setVariable("DAY", $date["mday"]);
1888  $template->setVariable("HOUR", $date["hours"]);
1889  $template->setVariable("MINUTE", $date["minutes"]);
1890  $template->setVariable("SECOND", $date["seconds"]);
1891  if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->object->getEndingTime(), $matches))
1892  {
1893  $template->setVariable("ENDYEAR", $matches[1]);
1894  $template->setVariable("ENDMONTH", $matches[2]-1);
1895  $template->setVariable("ENDDAY", $matches[3]);
1896  $template->setVariable("ENDHOUR", $matches[4]);
1897  $template->setVariable("ENDMINUTE", $matches[5]);
1898  $template->setVariable("ENDSECOND", $matches[6]);
1899  }
1900  $template->setVariable("YEARNOW", $datenow["year"]);
1901  $template->setVariable("MONTHNOW", $datenow["mon"]-1);
1902  $template->setVariable("DAYNOW", $datenow["mday"]);
1903  $template->setVariable("HOURNOW", $datenow["hours"]);
1904  $template->setVariable("MINUTENOW", $datenow["minutes"]);
1905  $template->setVariable("SECONDNOW", $datenow["seconds"]);
1906  $template->setVariable("PTIME_M", $processing_time_minutes);
1907  $template->setVariable("PTIME_S", $processing_time_seconds);
1908 
1909  $this->tpl->setCurrentBlock("HeadContent");
1910  $this->tpl->setVariable("CONTENT_BLOCK", $template->get());
1911  $this->tpl->parseCurrentBlock();
1912  }
1913 
1917  public function outQuestionSummary($fullpage = true, $contextFinishTest = false, $obligationsNotAnswered = false, $obligationsFilter = false)
1918  {
1919  if( $fullpage )
1920  {
1921  $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_question_summary.html", "Modules/Test");
1922  }
1923 
1924  if( $obligationsNotAnswered )
1925  {
1926  ilUtil::sendFailure($this->lng->txt('not_all_obligations_answered'));
1927  }
1928 
1929  $active_id = $this->object->getTestSession()->getActiveId();
1930  $result_array = & $this->object->getTestSequence()->getSequenceSummary($obligationsFilter);
1931  $marked_questions = array();
1932 
1933  if( $this->object->getKioskMode() && $fullpage )
1934  {
1935  $head = $this->getKioskHead();
1936  if( strlen($head) )
1937  {
1938  $this->tpl->setCurrentBlock("kiosk_options");
1939  $this->tpl->setVariable("KIOSK_HEAD", $head);
1940  $this->tpl->parseCurrentBlock();
1941  }
1942  }
1943 
1944  if( $this->object->getShowMarker() )
1945  {
1946  include_once "./Modules/Test/classes/class.ilObjTest.php";
1947  $marked_questions = ilObjTest::_getSolvedQuestions($active_id);
1948  }
1949 
1950  $data = array();
1951 
1952  foreach( $result_array as $key => $value )
1953  {
1954  $this->ctrl->setParameter($this, "sequence", $value["sequence"]);
1955 
1956  $href = $this->ctrl->getLinkTargetByClass(get_class($this), "gotoQuestion");
1957 
1958  $this->tpl->setVariable("VALUE_QUESTION_TITLE", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "gotoQuestion")."\">" . $this->object->getQuestionTitle($value["title"]) . "</a>");
1959 
1960  $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
1961 
1962  $description = "";
1963  if( $this->object->getListOfQuestionsDescription() )
1964  {
1965  $description = $value["description"];
1966  }
1967 
1968  $points = "";
1969  if( !$this->object->getTitleOutput() )
1970  {
1971  $points = $value["points"]."&nbsp;".$this->lng->txt("points_short");
1972  }
1973 
1974  $marked = false;
1975  if( count($marked_questions) )
1976  {
1977  if( array_key_exists($value["qid"], $marked_questions) )
1978  {
1979  $obj = $marked_questions[$value["qid"]];
1980  if( $obj["solved"] == 1 )
1981  {
1982  $marked = true;
1983  }
1984  }
1985  }
1986 
1987  array_push($data, array(
1988  'order' => $value["nr"],
1989  'href' => $href,
1990  'title' => $this->object->getQuestionTitle($value["title"]),
1991  'description' => $description,
1992  'worked_through' => ($value["worked_through"]) ? true : false,
1993  'postponed' => ($value["postponed"]) ? $this->lng->txt("postponed") : '',
1994  'points' => $points,
1995  'marked' => $marked,
1996  'sequence' => $value["sequence"],
1997  'obligatory' => $value['obligatory']
1998  ));
1999  }
2000 
2001  $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
2002 
2003  if( $fullpage )
2004  {
2005  include_once "./Modules/Test/classes/tables/class.ilListOfQuestionsTableGUI.php";
2006  $table_gui = new ilListOfQuestionsTableGUI(
2007  $this, 'backFromSummary', !$this->object->getTitleOutput(), $this->object->getShowMarker(),
2008  $obligationsNotAnswered, $obligationsFilter
2009  );
2010 
2011  $table_gui->setData($data);
2012 
2013  $this->tpl->setVariable('TABLE_LIST_OF_QUESTIONS', $table_gui->getHTML());
2014 
2015  if( $this->object->getEnableProcessingTime() )
2016  {
2017  $this->outProcessingTime($active_id);
2018  }
2019  }
2020  else
2021  {
2022  $template = new ilTemplate('tpl.il_as_tst_list_of_questions_short.html', true, true, 'Modules/Test');
2023 
2024  foreach( $data as $row )
2025  {
2026  if( strlen($row['description']) )
2027  {
2028  $template->setCurrentBlock('description');
2029  $template->setVariable("DESCRIPTION", $row['description']);
2030  $template->parseCurrentBlock();
2031  }
2032 
2033  $active = ($row['sequence'] == $this->sequence) ? ' active' : '';
2034 
2035  $template->setCurrentBlock('item');
2036  $template->setVariable('CLASS', ($row['walked_through']) ? ('answered'.$active) : ('unanswered'.$active));
2037  $template->setVariable('ITEM', ilUtil::prepareFormOutput($row['title']));
2038  $template->setVariable('SEQUENCE', $row['sequence']);
2039  $template->parseCurrentBlock();
2040  }
2041 
2042  $template->setVariable('LIST_OF_QUESTIONS', $this->lng->txt('list_of_questions'));
2043 
2044  $this->tpl->setVariable('LIST_OF_QUESTIONS', $template->get());
2045  }
2046  }
2047 
2049  {
2050  return $this->outQuestionSummary(true, true, true, false);
2051  }
2052 
2053  public function outObligationsOnlySummary()
2054  {
2055  return $this->outQuestionSummary(true, true, true, true);
2056  }
2057 
2059  {
2060  $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_max_allowed_users_reached.html", "Modules/Test");
2061  $this->tpl->setCurrentBlock("adm_content");
2062  $this->tpl->setVariable("MAX_ALLOWED_USERS_MESSAGE", sprintf($this->lng->txt("tst_max_allowed_users_message"), $this->object->getAllowedUsersTimeGap()));
2063  $this->tpl->setVariable("MAX_ALLOWED_USERS_HEADING", sprintf($this->lng->txt("tst_max_allowed_users_heading"), $this->object->getAllowedUsersTimeGap()));
2064  $this->tpl->setVariable("BACK_TO_INTRODUCTION", $this->lng->txt("tst_results_back_introduction"));
2065  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2066  $this->tpl->parseCurrentBlock();
2067  }
2068 
2070  {
2071  global $ilUser;
2072  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
2073  {
2074  $template = new ilTemplate("tpl.il_as_tst_finish_navigation.html", TRUE, TRUE, "Modules/Test");
2075  $template->setVariable("BUTTON_FINISH", $this->lng->txt("btn_next"));
2076  $template->setVariable("BUTTON_CANCEL", $this->lng->txt("btn_previous"));
2077 
2078  $template_top = new ilTemplate("tpl.il_as_tst_list_of_answers_topbuttons.html", TRUE, TRUE, "Modules/Test");
2079  $template_top->setCurrentBlock("button_print");
2080  $template_top->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
2081  $template_top->parseCurrentBlock();
2082  $active_id = $this->object->getTestSession()->getActiveId();
2083  return $this->showListOfAnswers($active_id, NULL, $template_top->get(), $template->get());
2084  }
2085  else
2086  {
2087  $this->ctrl->redirect($this, 'gotoQuestion');
2088  }
2089  }
2090 
2092  {
2093  $this->confirmFinishTest();
2094  }
2095 
2102  {
2103  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_correct_solution.html", "Modules/Test");
2104 
2105  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2106  $this->tpl->setCurrentBlock("ContentStyle");
2107  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
2108  $this->tpl->parseCurrentBlock();
2109 
2110  $this->tpl->setCurrentBlock("SyntaxStyle");
2111  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
2112  $this->tpl->parseCurrentBlock();
2113 
2114  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2115  if ($this->object->getShowSolutionAnswersOnly())
2116  {
2117  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
2118  }
2119 
2120  $this->tpl->setCurrentBlock("adm_content");
2121  $solution = $this->getCorrectSolutionOutput($_GET["evaluation"], $_GET["active_id"], $_GET["pass"]);
2122  $this->tpl->setVariable("OUTPUT_SOLUTION", $solution);
2123  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
2124  $this->ctrl->saveParameter($this, "pass");
2125  $this->ctrl->saveParameter($this, "active_id");
2126  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
2127  $this->tpl->parseCurrentBlock();
2128  }
2129 
2139  function showListOfAnswers($active_id, $pass = NULL, $top_data = "", $bottom_data = "")
2140  {
2141  global $ilUser;
2142 
2143  $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_finish_list_of_answers.html", "Modules/Test");
2144 
2145  $result_array =& $this->object->getTestResult($active_id, $pass);
2146 
2147  $counter = 1;
2148  // output of questions with solutions
2149  foreach ($result_array as $question_data)
2150  {
2151  $question = $question_data["qid"];
2152  if (is_numeric($question))
2153  {
2154  $this->tpl->setCurrentBlock("printview_question");
2155  $question_gui = $this->object->createQuestionGUI("", $question);
2156  $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", TRUE, TRUE, "Modules/TestQuestionPool");
2157  $template->setVariable("COUNTER_QUESTION", $counter.". ");
2158  $template->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
2159 
2160  $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
2161  $result_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, $show_question_only, $this->object->getShowSolutionFeedback());
2162  $template->setVariable("SOLUTION_OUTPUT", $result_output);
2163  $this->tpl->setVariable("QUESTION_OUTPUT", $template->get());
2164  $this->tpl->parseCurrentBlock();
2165  $counter ++;
2166  }
2167  }
2168 
2169  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2170  if ($this->object->getShowSolutionAnswersOnly())
2171  {
2172  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
2173  }
2174  if (strlen($top_data))
2175  {
2176  $this->tpl->setCurrentBlock("top_data");
2177  $this->tpl->setVariable("TOP_DATA", $top_data);
2178  $this->tpl->parseCurrentBlock();
2179  }
2180 
2181  if (strlen($bottom_data))
2182  {
2183  $this->tpl->setCurrentBlock("bottom_data");
2184  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2185  $this->tpl->setVariable("BOTTOM_DATA", $bottom_data);
2186  $this->tpl->parseCurrentBlock();
2187  }
2188 
2189  $this->tpl->setCurrentBlock("adm_content");
2190  $this->tpl->setVariable("TXT_ANSWER_SHEET", $this->lng->txt("tst_list_of_answers"));
2191  $user_data = $this->getResultsUserdata($active_id, TRUE);
2192  $signature = $this->getResultsSignature();
2193  $this->tpl->setVariable("USER_DETAILS", $user_data);
2194  $this->tpl->setVariable("SIGNATURE", $signature);
2195  $this->tpl->setVariable("TITLE", $this->object->getTitle());
2196  $this->tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers"));
2197  $invited_user =& $this->object->getInvitedUsers($ilUser->getId());
2198  $pagetitle = $this->object->getTitle() . " - " . $this->lng->txt("clientip") .
2199  ": " . $invited_user[$ilUser->getId()]["clientip"] . " - " .
2200  $this->lng->txt("matriculation") . ": " .
2201  $invited_user[$ilUser->getId()]["matriculation"];
2202  $this->tpl->setVariable("PAGETITLE", $pagetitle);
2203  $this->tpl->parseCurrentBlock();
2204  }
2205 
2212  private function getContentBlockName()
2213  {
2214  if ($this->object->getKioskMode())
2215  {
2216  $this->tpl->setBodyClass("kiosk");
2217  $this->tpl->setAddFooter(FALSE);
2218  return "CONTENT";
2219  }
2220  else
2221  {
2222  return "ADM_CONTENT";
2223  }
2224  }
2225 
2227  {
2228  $this->ctrl->redirectByClass("iltestevaluationgui", "outUserResultsOverview");
2229  }
2230 
2232  {
2233  $this->ctrl->redirectByClass("iltestevaluationgui", "outUserListOfAnswerPasses");
2234  }
2235 
2241  private function showRequestedHintList()
2242  {
2243  $this->saveQuestionSolution();
2244 
2245  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
2246  $this->ctrl->redirectByClass('ilAssQuestionHintRequestGUI', ilAssQuestionHintRequestGUI::CMD_SHOW_LIST);
2247  }
2248 
2254  private function confirmHintRequest()
2255  {
2256  $this->saveQuestionSolution();
2257 
2258  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintRequestGUI.php';
2259  $this->ctrl->redirectByClass('ilAssQuestionHintRequestGUI', ilAssQuestionHintRequestGUI::CMD_CONFIRM_REQUEST);
2260  }
2261 
2270  private function fillQuestionRelatedNavigation(assQuestionGUI $questionGUI)
2271  {
2272  global $tpl, $lng;
2273 
2274  $parseQuestionRelatedNavigation = false;
2275 
2276  switch( 1 )
2277  {
2278  case $this->object->getSpecificAnswerFeedback():
2279  case $this->object->getGenericAnswerFeedback():
2280  case $this->object->getAnswerFeedbackPoints():
2281  case $this->object->getInstantFeedbackSolution():
2282 
2283  $tpl->setCurrentBlock("direct_feedback");
2284  $tpl->setVariable("TEXT_DIRECT_FEEDBACK", $lng->txt("check"));
2285  $tpl->parseCurrentBlock();
2286 
2287  $parseQuestionRelatedNavigation = true;
2288  }
2289 
2290  if( $this->object->isOfferingQuestionHintsEnabled() )
2291  {
2292  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
2293 
2294  $questionId = $questionGUI->object->getId();
2295  $activeId = $this->object->getTestSession()->getActiveId();
2296  $pass = $this->object->getTestSession()->getPass();
2297 
2298  $requestsExist = ilAssQuestionHintTracking::requestsExist($questionId, $activeId, $pass);
2299  $requestsPossible = ilAssQuestionHintTracking::requestsPossible($questionId, $activeId, $pass);
2300 
2301  if( $requestsPossible )
2302  {
2303  if( $requestsExist )
2304  {
2305  $buttonText = $lng->txt("button_request_next_question_hint");
2306  }
2307  else
2308  {
2309  $buttonText = $lng->txt("button_request_question_hint");
2310  }
2311 
2312  $tpl->setCurrentBlock("button_request_next_question_hint");
2313  $tpl->setVariable("CMD_REQUEST_NEXT_QUESTION_HINT", 'confirmHintRequest');
2314  $tpl->setVariable("TEXT_REQUEST_NEXT_QUESTION_HINT", $buttonText);
2315  $tpl->parseCurrentBlock();
2316 
2317  $parseQuestionRelatedNavigation = true;
2318  }
2319 
2320  if( $requestsExist )
2321  {
2322  $tpl->setCurrentBlock("button_show_requested_question_hints");
2323  $tpl->setVariable("CMD_SHOW_REQUESTED_QUESTION_HINTS", 'showRequestedHintList');
2324  $tpl->setVariable("TEXT_SHOW_REQUESTED_QUESTION_HINTS", $lng->txt("button_show_requested_question_hints"));
2325  $tpl->parseCurrentBlock();
2326 
2327  $parseQuestionRelatedNavigation = true;
2328  }
2329  }
2330 
2331  if( $parseQuestionRelatedNavigation )
2332  {
2333  $tpl->setCurrentBlock("question_related_navigation");
2334  $tpl->parseCurrentBlock();
2335  }
2336  }
2337 }