• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/Test/classes/class.ilTestOutputGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
00025 include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
00026 
00039 class ilTestOutputGUI extends ilTestServiceGUI
00040 {
00041         var $ref_id;
00042 
00043         var $saveResult;
00044         var $sequence;
00045         var $cmdCtrl;
00046         var $maxProcessingTimeReached;
00047         var $endingTimeReached;
00048 
00057   function ilTestOutputGUI($a_object)
00058   {
00059                 parent::ilTestServiceGUI($a_object);
00060                 $this->ref_id = $_GET["ref_id"];
00061         }
00062         
00066         function &executeCommand()
00067         {
00068                 global $ilUser;
00069                 $cmd = $this->ctrl->getCmd();
00070                 $next_class = $this->ctrl->getNextClass($this);
00071                 $this->ctrl->saveParameter($this, "sequence");
00072                 $this->ctrl->saveParameter($this, "active_id");
00073 
00074                 if ($_GET["active_id"])
00075                 {
00076                         $this->object->setTestSession($_GET["active_id"]);
00077                 }
00078                 else
00079                 {
00080                         $this->object->setTestSession();
00081                 }
00082 
00083                 $cmd = $this->getCommand($cmd);
00084                 switch($next_class)
00085                 {
00086                         default:
00087                                 $ret =& $this->$cmd();
00088                                 break;
00089                 }
00090                 return $ret;
00091         }
00092 
00097         function updateWorkingTime() 
00098         {
00099                 if ($_SESSION["active_time_id"])
00100                 {
00101                         $this->object->updateWorkingTime($_SESSION["active_time_id"]);
00102                 }       
00103         }       
00104 
00108         function saveQuestionSolution()
00109         {
00110                 $this->updateWorkingTime();
00111                 $this->saveResult = false;
00112                 $formtimestamp = $_POST["formtimestamp"];
00113                 if (strlen($formtimestamp) == 0) $formtimestamp = $_GET["formtimestamp"];
00114                 if ($formtimestamp != $_SESSION["formtimestamp"])
00115                 {
00116                         $_SESSION["formtimestamp"] = $formtimestamp;
00117                 }
00118                 else
00119                 {
00120                         return;
00121                 }
00122                 // save question solution
00123                 if ($this->canSaveResult())
00124                 {
00125                         // but only if the ending time is not reached
00126                         $q_id = $this->object->getTestSequence()->getQuestionForSequence($_GET["sequence"]);
00127                         if (is_numeric($q_id)) 
00128                         {
00129                                 global $ilUser;
00130                                 
00131                                 $question_gui = $this->object->createQuestionGUI("", $q_id);
00132                                 if ($this->object->getJavaScriptOutput())
00133                                 {
00134                                         $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
00135                                 }
00136                                 $pass = NULL;
00137                                 $active_id = $this->object->getTestSession()->getActiveId();
00138                                 if ($this->object->isRandomTest())
00139                                 {
00140                                         $pass = $this->object->_getPass($active_id);
00141                                 }
00142                                 $this->saveResult = $question_gui->object->saveWorkingData($active_id, $pass);
00143                         }                                                                                               
00144                 }
00145                 if ($this->saveResult == FALSE)
00146                 {
00147                         $this->ctrl->setParameter($this, "save_error", "1");
00148                         $_SESSION["previouspost"] = $_POST;
00149                 }
00150         }
00151         
00160          function canSaveResult() 
00161          {
00162                  return !$this->object->endingTimeReached() && !$this->isMaxProcessingTimeReached() && !$this->isNrOfTriesReached();
00163          }
00164          
00172         function outIntroductionPage()
00173         {
00174                 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen"); 
00175         }
00176         
00185         function isMaxProcessingTimeReached() 
00186         {
00187                 global $ilUser;
00188                 $active_id = $this->object->getTestSession()->getActiveId();
00189                 $starting_time = $this->object->getStartingTimeOfUser($active_id);
00190                 if ($starting_time === FALSE)
00191                 {
00192                         return FALSE;
00193                 }
00194                 else
00195                 {
00196                         return $this->object->isMaxProcessingTimeReached($starting_time);
00197                 }
00198         }
00199         
00207         function outWorkingForm($sequence = "", $test_id, $postpone_allowed, $directfeedback = 0)
00208         {
00209                 global $ilUser;
00210 
00211                 if ($sequence < 1) $sequence = $this->object->getTestSequence()->getFirstSequence();
00212                 $active_time_id = $this->object->startWorkingTime($this->object->getTestSession()->getActiveId(), $this->object->getTestSession()->getPass());
00213                 $_SESSION["active_time_id"] = $active_time_id;
00214 
00215                 include_once("classes/class.ilObjStyleSheet.php");
00216                 $this->tpl->setCurrentBlock("ContentStyle");
00217                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00218                 ilObjStyleSheet::getContentStylePath(0));
00219                 $this->tpl->parseCurrentBlock();
00220 
00221                 // syntax style
00222                 $this->tpl->setCurrentBlock("SyntaxStyle");
00223                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00224                 ilObjStyleSheet::getSyntaxStylePath());
00225                 $this->tpl->parseCurrentBlock();
00226                 $question_gui = $this->object->createQuestionGUI("", $this->object->getTestSequence()->getQuestionForSequence($sequence));
00227                 if ($this->object->getJavaScriptOutput())
00228                 {
00229                         $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
00230                 }
00231 
00232                 $is_postponed = $this->object->getTestSequence()->isPostponedQuestion($question_gui->object->getId());
00233 
00234                 $this->ctrl->setParameter($this, "sequence", "$sequence");
00235                 $formaction = $this->ctrl->getFormAction($this, "redirectQuestion");
00236 
00237                 $question_gui->setSequenceNumber($this->object->getTestSequence()->getPositionOfSequence($sequence));
00238                 $question_gui->setQuestionCount($this->object->getTestSequence()->getUserQuestionCount());
00239                 // output question
00240                 $user_post_solution = FALSE;
00241                 if (array_key_exists("previouspost", $_SESSION))
00242                 {
00243                         $user_post_solution = $_SESSION["previouspost"];
00244                         unset($_SESSION["previouspost"]);
00245                 }
00246                 $answer_feedback = FALSE;
00247                 if (($directfeedback) && ($this->object->getAnswerFeedback()))
00248                 {
00249                         $answer_feedback = TRUE;
00250                 }
00251                 global $ilNavigationHistory;
00252                 $ilNavigationHistory->addItem($_GET["ref_id"], $this->ctrl->getLinkTarget($this, "resume"), "tst");
00253                 $question_gui->outQuestionForTest($formaction, $this->object->getTestSession()->getActiveId(), NULL, $is_postponed, $user_post_solution, $answer_feedback);
00254                 if ($directfeedback)
00255                 {
00256                         if ($this->object->getInstantFeedbackSolution())
00257                         {
00258                                 $solutionoutput = $question_gui->getSolutionOutput("", NULL, FALSE, FALSE, FALSE);
00259                                 $this->tpl->setCurrentBlock("solution_output");
00260                                 $this->tpl->setVariable("CORRECT_SOLUTION", $this->lng->txt("tst_best_solution_is"));
00261                                 $this->tpl->setVariable("QUESTION_FEEDBACK", $solutionoutput);
00262                                 $this->tpl->parseCurrentBlock();
00263                         }
00264                         if ($this->object->getAnswerFeedbackPoints())
00265                         {
00266                                 $this->tpl->setCurrentBlock("solution_output");
00267                                 $this->tpl->setVariable("RECEIVED_POINTS_INFORMATION", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->calculateReachedPoints($this->object->getTestSession()->getActiveId(), NULL), $question_gui->object->getMaximumPoints()));
00268                                 $this->tpl->parseCurrentBlock();
00269                         }
00270                         if ($this->object->getAnswerFeedback())
00271                         {
00272                                 $this->tpl->setCurrentBlock("answer_feedback");
00273                                 $this->tpl->setVariable("ANSWER_FEEDBACK", $question_gui->getAnswerFeedbackOutput($this->object->getTestSession()->getActiveId(), NULL));
00274                                 $this->tpl->parseCurrentBlock();
00275                         }
00276                 }
00277 
00278                 if ($sequence == $this->object->getTestSequence()->getFirstSequence())
00279                 {
00280                         $this->tpl->setCurrentBlock("prev");
00281                         $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_introduction"));
00282                         $this->tpl->parseCurrentBlock();
00283                         $this->tpl->setCurrentBlock("prev_bottom");
00284                         $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_introduction"));
00285                         $this->tpl->parseCurrentBlock();
00286                 }
00287                 else
00288                 {
00289                         $this->tpl->setCurrentBlock("prev");
00290                         $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_previous"));
00291                         $this->tpl->parseCurrentBlock();
00292                         $this->tpl->setCurrentBlock("prev_bottom");
00293                         $this->tpl->setVariable("BTN_PREV", "&lt;&lt; " . $this->lng->txt("save_previous"));
00294                         $this->tpl->parseCurrentBlock();
00295                 }
00296 
00297                 if ($postpone_allowed)
00298                 {
00299                         if (!$is_postponed)
00300                         {
00301                                 if (!$finish)
00302                                 {
00303                                         $this->tpl->setCurrentBlock("postpone");
00304                                         $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
00305                                         $this->tpl->parseCurrentBlock();
00306                                         $this->tpl->setCurrentBlock("postpone_bottom");
00307                                         $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
00308                                         $this->tpl->parseCurrentBlock();
00309                                 }
00310                         }
00311                 }
00312                 
00313                 if ($this->object->getListOfQuestions()) 
00314                 {
00315                         if (!(($finish) && ($this->object->getListOfQuestionsEnd())))
00316                         {
00317                                 $this->tpl->setCurrentBlock("summary");
00318                                 $this->tpl->setVariable("BTN_SUMMARY", $this->lng->txt("question_summary"));
00319                                 $this->tpl->parseCurrentBlock();
00320                                 $this->tpl->setCurrentBlock("summary_bottom");
00321                                 $this->tpl->setVariable("BTN_SUMMARY", $this->lng->txt("question_summary"));
00322                                 $this->tpl->parseCurrentBlock();
00323                         }
00324                 }
00325 
00326                 if ($this->object->getShowCancel()) 
00327                 {
00328                         $this->tpl->setCurrentBlock("cancel_test");
00329                         $this->tpl->setVariable("TEXT_CANCELTEST", $this->lng->txt("cancel_test"));
00330                         $this->tpl->setVariable("TEXT_ALTCANCELTEXT", $this->lng->txt("cancel_test"));
00331                         $this->tpl->setVariable("TEXT_TITLECANCELTEXT", $this->lng->txt("cancel_test"));
00332                         $this->tpl->setVariable("HREF_IMGCANCELTEST", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00333                         $this->tpl->setVariable("HREF_CANCELTEXT", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00334                         $this->tpl->setVariable("IMAGE_CANCEL", ilUtil::getImagePath("cancel.gif"));
00335                         $this->tpl->parseCurrentBlock();
00336                 }               
00337 
00338                 if ($this->object->getTestSequence()->getQuestionForSequence($this->object->getTestSequence()->getLastSequence()) == $question_gui->object->getId())
00339                 {
00340                         if ($this->object->getListOfQuestionsEnd()) 
00341                         {
00342                                 $this->tpl->setCurrentBlock("next");
00343                                 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("question_summary") . " &gt;&gt;");
00344                                 $this->tpl->parseCurrentBlock();
00345                                 $this->tpl->setCurrentBlock("next_bottom");
00346                                 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("question_summary") . " &gt;&gt;");
00347                                 $this->tpl->parseCurrentBlock();                                
00348                         } 
00349                         else 
00350                         {
00351                                 $this->tpl->setCurrentBlock("next");
00352                                 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " &gt;&gt;");
00353                                 $this->tpl->parseCurrentBlock();
00354                                 $this->tpl->setCurrentBlock("next_bottom");
00355                                 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " &gt;&gt;");
00356                                 $this->tpl->parseCurrentBlock();
00357                         }
00358                 }
00359                 else
00360                 {
00361                         $this->tpl->setCurrentBlock("next");
00362                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " &gt;&gt;");
00363                         $this->tpl->parseCurrentBlock();
00364                         $this->tpl->setCurrentBlock("next_bottom");
00365                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " &gt;&gt;");
00366                         $this->tpl->parseCurrentBlock();
00367                 }
00368 
00369                 if ($this->object->getShowMarker())
00370                 {
00371                         include_once "./Modules/Test/classes/class.ilObjTest.php";
00372                         $solved_array = ilObjTest::_getSolvedQuestions($this->object->getTestSession()->getActiveId(), $question_gui->object->getId());
00373                         $solved = 0;
00374                         
00375                         if (count ($solved_array) > 0) 
00376                         {
00377                                 $solved = array_pop($solved_array);
00378                                 $solved = $solved->solved;
00379                         }                       
00380                         
00381                         if ($solved==1) 
00382                         {
00383                                 $this->tpl->setCurrentBlock("ismarked");
00384                                 $this->tpl->setVariable("TEXT_QUESTION_STATUS_LABEL", $this->lng->txt("tst_question_marked").":");
00385                                 $this->tpl->setVariable("TEXT_RESET_MARK", $this->lng->txt("remove"));
00386                                 $this->tpl->setVariable("ALT_MARKED", $this->lng->txt("tst_question_marked"));
00387                                 $this->tpl->setVariable("TITLE_MARKED", $this->lng->txt("tst_question_marked"));
00388                                 $this->tpl->setVariable("MARKED_SOURCE", ilUtil::getImagePath("marked.png"));
00389                                 $this->tpl->parseCurrentBlock();
00390                         } 
00391                         else 
00392                         {
00393                                 $this->tpl->setCurrentBlock("ismarked");
00394                                 $this->tpl->setVariable("TEXT_MARK_QUESTION", $this->lng->txt("tst_question_mark"));
00395                                 $this->tpl->parseCurrentBlock();
00396                         }
00397                 }
00398 
00399                 if ($this->object->getJavaScriptOutput())
00400                 {
00401                         $this->tpl->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript_disable.png"));
00402                         $this->tpl->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("disable_javascript"));
00403                         $this->tpl->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("disable_javascript"));
00404                         $this->ctrl->setParameter($this, "tst_javascript", "0");
00405                         $this->tpl->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this, "gotoQuestion"));
00406                 }
00407                 else
00408                 {
00409                         $this->tpl->setVariable("JAVASCRIPT_IMAGE", ilUtil::getImagePath("javascript.png"));
00410                         $this->tpl->setVariable("JAVASCRIPT_IMAGE_ALT", $this->lng->txt("enable_javascript"));
00411                         $this->tpl->setVariable("JAVASCRIPT_IMAGE_TITLE", $this->lng->txt("enable_javascript"));
00412                         $this->ctrl->setParameter($this, "tst_javascript", "1");
00413                         $this->tpl->setVariable("JAVASCRIPT_URL", $this->ctrl->getLinkTarget($this, "gotoQuestion"));
00414                 }
00415 
00416                 if ($question_gui->object->supportsJavascriptOutput())
00417                 {
00418                         $this->tpl->touchBlock("jsswitch");
00419                 }
00420 
00421                 $this->tpl->setCurrentBlock("adm_content");
00422                 //$this->tpl->setVariable("FORMACTION", $formaction);
00423                 $this->tpl->parseCurrentBlock();
00424         }
00425         
00433         function showPasswordProtectionPage()
00434         {
00435                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_password_protection.html", "Modules/Test");
00436                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "checkPassword"));
00437                 $this->tpl->setVariable("PASSWORD_INTRODUCTION", $this->lng->txt("tst_password_introduction"));
00438                 $this->tpl->setVariable("TEXT_PASSWORD", $this->lng->txt("tst_password"));
00439                 $this->tpl->setVariable("SUBMIT", $this->lng->txt("submit"));
00440                 $this->tpl->parseCurrentBlock();
00441         }
00442         
00450         function checkPassword()
00451         {
00452                 if (strcmp($this->object->getPassword(), $_POST["password"]) == 0)
00453                 {
00454                         global $ilUser;
00455                         if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
00456                         {
00457                                 $ilUser->setPref("tst_password_".$this->object->getTestId(), $this->object->getPassword());
00458                                 $ilUser->writePref("tst_password_".$this->object->getTestId(), $this->object->getPassword());
00459                         }
00460                         $this->ctrl->redirect($this, "start");
00461                 }
00462                 else
00463                 {
00464                         ilUtil::sendInfo($this->lng->txt("tst_password_entered_wrong_password"), true);
00465                         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen"); 
00466                 }
00467         }
00468         
00476         function setAnonymousId()
00477         {
00478                 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00479                 {
00480                         $this->object->setAccessCodeSession($_POST["anonymous_id"]);
00481                 }
00482                 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00483         }
00484 
00493         function start()
00494         {
00495                 if (strcmp($_SESSION["lock"], $_POST["lock"]) != 0)
00496                 {
00497                         $_SESSION["lock"] = $_POST["lock"];
00498                         $this->handleStartCommands();
00499                         $this->ctrl->redirect($this, "startTest");
00500                 }
00501                 else
00502                 {
00503                         $this->ctrl->redirectByClass("ilobjtestgui", "redirectToInfoScreen");
00504                 }
00505         }
00506 
00512         function startTest()
00513         {
00514                 if ($this->object->checkMaximumAllowedUsers() == FALSE)
00515                 {
00516                         return $this->showMaximumAllowedUsersReachedMessage();
00517                 }
00518                 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00519                 {
00520                         $this->object->setAccessCodeSession($this->object->createNewAccessCode());
00521                 }
00522                 else
00523                 {
00524                         $this->object->unsetAccessCodeSession();
00525                 }
00526                 if (strlen($this->object->getPassword()))
00527                 {
00528                         global $ilUser;
00529                         global $rbacsystem;
00530                         
00531                         $pwd = $ilUser->getPref("tst_password_".$this->object->getTestId());
00532                         if ((strcmp($pwd, $this->object->getPassword()) != 0) && (!$rbacsystem->checkAccess("write", $this->object->getRefId())))
00533                         {
00534                                 return $this->showPasswordProtectionPage();
00535                         }
00536                 }
00537                 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00538                 {
00539                         $this->ctrl->redirect($this, "displayCode");
00540                 }
00541                 else
00542                 {
00543                         $this->ctrl->setParameter($this, "activecommand", "start");
00544                         $this->ctrl->redirect($this, "redirectQuestion");
00545                 }
00546         }
00547         
00548         function displayCode()
00549         {
00550                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_anonymous_code_presentation.html", "Modules/Test");
00551                 $this->tpl->setCurrentBlock("adm_content");
00552                 $this->tpl->setVariable("TEXT_ANONYMOUS_CODE_CREATED", $this->lng->txt("tst_access_code_created"));
00553                 $this->tpl->setVariable("TEXT_ANONYMOUS_CODE", $this->object->getAccessCodeSession());
00554                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00555                 $this->tpl->setVariable("CONTINUE", $this->lng->txt("continue_work"));
00556                 $this->tpl->parseCurrentBlock();
00557         }
00558         
00559         function codeConfirmed()
00560         {
00561                 $this->ctrl->setParameter($this, "activecommand", "start");
00562                 $this->ctrl->redirect($this, "redirectQuestion");
00563         }
00564 
00572         function resume()
00573         {
00574                 if ($this->object->checkMaximumAllowedUsers() == FALSE)
00575                 {
00576                         return $this->showMaximumAllowedUsersReachedMessage();
00577                 }
00578                 $this->handleStartCommands();
00579                 $this->ctrl->setParameter($this, "activecommand", "resume");
00580                 $this->ctrl->redirect($this, "redirectQuestion");
00581         }
00582 
00590         function handleStartCommands()
00591         {
00592                 global $ilUser;
00593 
00594                 if ($_POST["chb_javascript"])
00595                 {
00596                         $ilUser->writePref("tst_javascript", 1);
00597                 }
00598                 else
00599                 {
00600                         $ilUser->writePref("tst_javascript", 0);
00601                 }
00602                 
00603                 // hide previous results
00604                 if ($this->object->getNrOfTries() != 1)
00605                 {
00606                         if ($this->object->getUsePreviousAnswers() == 1)
00607                         {
00608                                 if ($_POST["chb_use_previous_answers"])
00609                                 {
00610                                         $ilUser->writePref("tst_use_previous_answers", 1);
00611                                 }
00612                                 else
00613                                 { 
00614                                         $ilUser->writePref("tst_use_previous_answers", 0);
00615                                 }
00616                         }
00617                 }
00618         }
00619         
00628         function redirectQuestion()
00629         {
00630                 global $ilUser;
00631                 
00632                 // check the test restrictions to access the test in case one
00633                 // of the test navigation commands was called by an external script
00634                 // e.g. $ilNavigationHistory
00635                 $executable = $this->object->isExecutable($ilUser->getId());
00636                 if (!$executable["executable"])
00637                 {
00638                         ilUtil::sendInfo($executable["errormessage"], TRUE);
00639                         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00640                 }
00641                 switch ($_GET["activecommand"])
00642                 {
00643                         case "next":
00644                                 $this->sequence = $this->calculateSequence();
00645                                 if ($this->sequence === FALSE)
00646                                 {
00647                                         if ($this->object->getListOfQuestionsEnd())
00648                                         {
00649                                                 $this->outQuestionSummary();
00650                                         }
00651                                         else
00652                                         {
00653                                                 $this->ctrl->redirect($this, "finishTest");
00654                                         }
00655                                 }
00656                                 else
00657                                 {
00658                                         $this->object->getTestSession()->setLastSequence($this->sequence);
00659                                         $this->object->getTestSession()->saveToDb();
00660                                         $this->outTestPage();
00661                                 }
00662                                 break;
00663                         case "previous":
00664                                 $this->sequence = $this->calculateSequence();
00665                                 $this->object->getTestSession()->setLastSequence($this->sequence);
00666                                 $this->object->getTestSession()->saveToDb();
00667                                 if ($this->sequence === FALSE)
00668                                 {
00669                                         $this->ctrl->redirect($this, "outIntroductionPage");
00670                                 }
00671                                 else
00672                                 {
00673                                         $this->outTestPage();
00674                                 }
00675                                 break;
00676                         case "postpone":
00677                                 $this->sequence = $this->calculateSequence();
00678                                 $nextSequence = $this->object->getTestSequence()->getNextSequence($this->sequence);
00679                                 $this->object->getTestSequence()->postponeSequence($this->sequence);
00680                                 $this->object->getTestSequence()->saveToDb();
00681                                 $this->object->getTestSession()->setLastSequence($nextSequence);
00682                                 $this->object->getTestSession()->saveToDb();
00683                                 $this->sequence = $nextSequence;
00684                                 $this->outTestPage();
00685                                 break;
00686                         case "setmarked":
00687                                 $this->sequence = $this->calculateSequence();   
00688                                 $this->object->getTestSession()->setLastSequence($this->sequence);
00689                                 $this->object->getTestSession()->saveToDb();
00690                                 $q_id  = $this->object->getTestSequence()->getQuestionForSequence($_GET["sequence"]);
00691                                 $this->object->setQuestionSetSolved(1, $q_id, $ilUser->getId());
00692                                 $this->outTestPage();
00693                                 break;
00694                         case "resetmarked":
00695                                 $this->sequence = $this->calculateSequence();   
00696                                 $this->object->getTestSession()->setLastSequence($this->sequence);
00697                                 $this->object->getTestSession()->saveToDb();
00698                                 $q_id  = $this->object->getTestSequence()->getQuestionForSequence($_GET["sequence"]);
00699                                 $this->object->setQuestionSetSolved(0, $q_id, $ilUser->getId());
00700                                 $this->outTestPage();
00701                                 break;
00702                         case "directfeedback":
00703                                 $this->sequence = $this->calculateSequence();   
00704                                 $this->object->getTestSession()->setLastSequence($this->sequence);
00705                                 $this->object->getTestSession()->saveToDb();
00706                                 $this->outTestPage();
00707                                 break;
00708                         case "selectImagemapRegion":
00709                                 $this->sequence = $this->calculateSequence();   
00710                                 $this->object->getTestSession()->setLastSequence($this->sequence);
00711                                 $this->object->getTestSession()->saveToDb();
00712                                 $this->outTestPage();
00713                                 break;
00714                         case "summary":
00715                                 $this->ctrl->redirect($this, "outQuestionSummary");
00716                                 break;
00717                         case "start":
00718                                 $_SESSION['tst_pass_finish'] = 0;
00719                                 $this->object->createTestSession();
00720                                 $active_id = $this->object->getTestSession()->getActiveId();
00721                                 $this->ctrl->setParameter($this, "active_id", $active_id);
00722                                 $shuffle = $this->object->getShuffleQuestions();
00723                                 if ($this->object->isRandomTest())
00724                                 {
00725                                         $this->object->generateRandomQuestions($this->object->getTestSession()->getActiveId());
00726                                         $this->object->loadQuestions();
00727                                         $shuffle = FALSE; // shuffle is already done during the creation of the random questions
00728                                 }
00729                                 $this->object->createTestSequence($active_id, 0, $shuffle);
00730                                 $active_time_id = $this->object->startWorkingTime($this->object->getTestSession()->getActiveId(), $this->object->getTestSession()->getPass());
00731                                 $_SESSION["active_time_id"] = $active_time_id;
00732                                 $this->ctrl->setParameter($this, "sequence", $this->sequence);
00733                                 $this->ctrl->saveParameter($this, "tst_javascript");
00734                                 if ($this->object->getListOfQuestionsStart())
00735                                 {
00736                                         $this->ctrl->redirect($this, "outQuestionSummary");
00737                                 }
00738                                 else
00739                                 {
00740                                         $this->ctrl->setParameter($this, "activecommand", "gotoquestion");
00741                                         $this->ctrl->redirect($this, "redirectQuestion");
00742                                 }
00743                                 break;
00744                         case "resume":
00745                                 $_SESSION['tst_pass_finish'] = 0;
00746                                 $active_id = $this->object->getTestSession()->getActiveId();
00747                                 $this->ctrl->setParameter($this, "active_id", $active_id);
00748 
00749                                 if ($this->object->isRandomTest())
00750                                 {
00751                                         if (!$this->object->hasRandomQuestionsForPass($active_id, $this->object->getTestSession()->getPass()))
00752                                         {
00753                                                 // create a new set of random questions
00754                                                 $this->object->generateRandomQuestions($active_id, $this->object->getTestSession()->getPass());
00755                                         }
00756                                 }
00757 
00758                                 $shuffle = $this->object->getShuffleQuestions();
00759                                 if ($this->object->isRandomTest())
00760                                 {
00761                                         $shuffle = FALSE;
00762                                 }
00763                                 $this->object->createTestSequence($active_id, $this->object->getTestSession()->getPass(), $shuffle);
00764 
00765                                 $this->sequence = $this->object->getTestSession()->getLastSequence();
00766                                 $active_time_id = $this->object->startWorkingTime($active_id, $this->object->getTestSession()->getPass());
00767                                 $_SESSION["active_time_id"] = $active_time_id;
00768                                 $this->ctrl->setParameter($this, "sequence", $this->sequence);
00769                                 $this->ctrl->saveParameter($this, "tst_javascript");
00770                                 if ($this->object->getListOfQuestionsStart())
00771                                 {
00772                                         $this->ctrl->redirect($this, "outQuestionSummary");
00773                                 }
00774                                 else
00775                                 {
00776                                         $this->ctrl->setParameter($this, "activecommand", "gotoquestion");
00777                                         $this->ctrl->redirect($this, "redirectQuestion");
00778                                 }
00779                                 break;
00780                         case "back":
00781                         case "gotoquestion":
00782                         default:
00783                                 $_SESSION['tst_pass_finish'] = 0;
00784                                 if (array_key_exists("tst_javascript", $_GET))
00785                                 {
00786                                         $ilUser->writePref("tst_javascript", $_GET["tst_javascript"]);
00787                                 }
00788                                 $this->sequence = $this->calculateSequence();   
00789                                 $this->object->getTestSession()->setLastSequence($this->sequence);
00790                                 $this->object->getTestSession()->saveToDb();
00791                                 $this->outTestPage();
00792                                 break;
00793                 }
00794         }
00795         
00803         function calculateSequence() 
00804         {
00805                 $sequence = $_GET["sequence"];
00806                 if (!$sequence) $sequence = $this->object->getTestSequence()->getFirstSequence();
00807                 if (array_key_exists("save_error", $_GET))
00808                 {
00809                         if ($_GET["save_error"] == 1)
00810                         {
00811                                 return $sequence;
00812                         }
00813                 }
00814                 switch ($_GET["activecommand"])
00815                 {
00816                         case "next":
00817                                 $sequence = $this->object->getTestSequence()->getNextSequence($sequence);
00818                                 break;
00819                         case "previous":
00820                                 $sequence = $this->object->getTestSequence()->getPreviousSequence($sequence);
00821                                 break;
00822                 }
00823                 return $sequence;
00824         }
00825         
00833         function next()
00834         {
00835                 $this->saveQuestionSolution();
00836                 $this->ctrl->setParameter($this, "activecommand", "next");
00837                 $this->ctrl->redirect($this, "redirectQuestion");
00838         }
00839         
00847         function previous()
00848         {
00849                 $this->saveQuestionSolution();
00850                 $this->ctrl->setParameter($this, "activecommand", "previous");
00851                 $this->ctrl->redirect($this, "redirectQuestion");
00852         }
00853         
00861         function postpone()
00862         {
00863                 $this->saveQuestionSolution();
00864                 $this->ctrl->setParameter($this, "activecommand", "postpone");
00865                 $this->ctrl->redirect($this, "redirectQuestion");
00866         }
00867 
00875         function summary()
00876         {
00877                 $this->saveQuestionSolution();
00878                 if ($this->saveResult == FALSE)
00879                 {
00880                         $this->ctrl->setParameter($this, "activecommand", "");
00881                         $this->ctrl->redirect($this, "redirectQuestion");
00882                 }
00883                 else
00884                 {
00885                         $this->ctrl->setParameter($this, "activecommand", "summary");
00886                         $this->ctrl->redirect($this, "redirectQuestion");
00887                 }
00888         }
00889 
00897         function setmarked()
00898         {
00899                 $this->saveQuestionSolution();
00900                 $this->ctrl->setParameter($this, "activecommand", "setmarked");
00901                 $this->ctrl->redirect($this, "redirectQuestion");
00902         }
00903 
00911         function resetmarked()
00912         {
00913                 $this->saveQuestionSolution();
00914                 $this->ctrl->setParameter($this, "activecommand", "resetmarked");
00915                 $this->ctrl->redirect($this, "redirectQuestion");
00916         }
00917         
00925         function directfeedback()
00926         {
00927                 $this->saveQuestionSolution();
00928                 $this->ctrl->setParameter($this, "activecommand", "directfeedback");
00929                 $this->ctrl->redirect($this, "redirectQuestion");
00930         }
00931         
00939         function selectImagemapRegion()
00940         {
00941                 $this->saveQuestionSolution();
00942                 $activecommand = "selectImagemapRegion";
00943                 if (array_key_exists("cmd", $_POST))
00944                 {
00945                         $activecommand = key($_POST["cmd"]);
00946                 }
00947                 $this->ctrl->setParameter($this, "activecommand", $activecommand);
00948                 $this->ctrl->redirect($this, "redirectQuestion");
00949         }
00950         
00958         function gotoQuestion()
00959         {
00960                 $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
00961                 $this->ctrl->setParameter($this, "activecommand", "gotoquestion");
00962                 $this->ctrl->saveParameter($this, "tst_javascript");
00963                 $this->ctrl->redirect($this, "redirectQuestion");
00964         }
00965         
00973         function backFromSummary()
00974         {
00975                 $this->ctrl->setParameter($this, "activecommand", "back");
00976                 $this->ctrl->redirect($this, "redirectQuestion");
00977         }
00978 
00986         function confirmFinish()
00987         {
00988                 $this->finishTest(false);
00989         }
00990         
00998         function confirmFinishTest()
00999         {
01000                 global $ilUser;
01001                 
01002                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish_confirmation.html", "Modules/Test");
01003                 $this->tpl->setVariable("FINISH_QUESTION", $this->lng->txt("tst_finish_confirmation_question"));
01004                 $this->tpl->setVariable("BUTTON_CONFIRM", $this->lng->txt("tst_finish_confirm_button"));
01005                 if ($this->object->canShowSolutionPrintview($ilUser->getId()))
01006                 {
01007                         $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("tst_finish_confirm_list_of_answers_button"));
01008                 }
01009                 else
01010                 {
01011                         $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("tst_finish_confirm_cancel_button"));
01012                 }
01013                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01014                 $this->tpl->parseCurrentBlock();
01015         }
01016         
01024         function finishTest($confirm = true)
01025         {
01026                 global $ilUser;
01027                 global $ilias;
01028                 global $ilAuth;
01029                 
01030                 unset($_SESSION["tst_next"]);
01031                 
01032                 $active_id = $this->object->getTestSession()->getActiveId();
01033                 $actualpass = $this->object->_getPass($active_id);
01034                 if (($actualpass == $this->object->getNrOfTries() - 1) && (!$confirm))
01035                 {
01036                         $this->object->setActiveTestSubmitted($ilUser->getId());
01037                         $ilAuth->setIdle($ilias->ini->readVariable("session","expire"), false);
01038                         $ilAuth->setExpire(0);
01039                 }
01040                 
01041                 if (($confirm) && ($actualpass == $this->object->getNrOfTries() - 1))
01042                 {
01043                         if ($this->object->canShowSolutionPrintview($ilUser->getId()))
01044                         {
01045                                 $template = new ilTemplate("tpl.il_as_tst_finish_navigation.html", TRUE, TRUE, "Modules/Test");
01046                                 $template->setVariable("BUTTON_FINISH", $this->lng->txt("btn_next"));
01047                                 $template->setVariable("BUTTON_CANCEL", $this->lng->txt("btn_previous"));
01048                                 
01049                                 $template_top = new ilTemplate("tpl.il_as_tst_list_of_answers_topbuttons.html", TRUE, TRUE, "Modules/Test");
01050                                 $template_top->setCurrentBlock("button_print");
01051                                 $template_top->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
01052                                 $template_top->parseCurrentBlock();
01053 
01054                                 $this->showListOfAnswers($active_id, NULL, $template_top->get(), $template->get());
01055                                 return;
01056                         }
01057                         else
01058                         {
01059                                 // show confirmation page
01060                                 return $this->confirmFinishTest();
01061                         }
01062                 }
01063 
01064                 if (!$_SESSION['tst_pass_finish'])
01065                 {
01066                         if (!$_SESSION['tst_pass_finish']) $_SESSION['tst_pass_finish'] = 1;
01067                         $this->object->getTestSession()->increasePass();
01068                         $this->object->getTestSession()->setLastSequence(0);
01069                         $this->object->getTestSession()->saveToDb();
01070                 }
01071                 
01072                 if($_GET['crs_show_result'])
01073                 {
01074                         $this->ctrl->redirectByClass("ilobjtestgui", "backToCourse");
01075                 }
01076 
01077                 if (!$this->object->canViewResults()) 
01078                 {
01079                         $this->outIntroductionPage();
01080                 }
01081                 else
01082                 {
01083                         $this->ctrl->redirect($this, "outUserResultsOverview");
01084                 }
01085         }
01086         
01094         function outTestPage()
01095         {
01096                 global $rbacsystem;
01097                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_output.html", "Modules/Test");    
01098                 if (!$rbacsystem->checkAccess("read", $this->object->getRefId())) 
01099                 {
01100                         // only with read access it is possible to run the test
01101                         $this->ilias->raiseError($this->lng->txt("cannot_execute_test"),$this->ilias->error_obj->MESSAGE);
01102                 }
01103                 
01104                 if ($this->isMaxProcessingTimeReached())
01105                 {
01106                         $this->maxProcessingTimeReached();
01107                         return;
01108                 }
01109                 
01110                 if ($this->object->endingTimeReached())
01111                 {
01112                         $this->endingTimeReached();
01113                         return;
01114                 }
01115                         
01116                 if (($this->object->getInstantFeedbackSolution() == 1) || ($this->object->getAnswerFeedback() == 1) || ($this->object->getAnswerFeedbackPoints() == 1))
01117                 {
01118                         $this->tpl->setCurrentBlock("direct_feedback");
01119                         $this->tpl->setVariable("TEXT_DIRECT_FEEDBACK", $this->lng->txt("check"));
01120                         $this->tpl->parseCurrentBlock();
01121                 }
01122                 
01123                 $postpone = false;
01124                 if ($this->object->getSequenceSettings() == TEST_POSTPONE)
01125                 {
01126                         $postpone = true;
01127                 }
01128 
01129                 if ($this->object->getEnableProcessingTime())
01130                 {
01131                         $this->outProcessingTime($this->object->getTestSession()->getActiveId());
01132                 }
01133 
01134                 $this->tpl->setVariable("FORM_TIMESTAMP", time());
01135                 $directfeedback = 0;
01136                 if (strcmp($_GET["activecommand"], "directfeedback") == 0) $directfeedback = 1;
01137                 $this->outWorkingForm($this->sequence, $this->object->getTestId(), $postpone, $directfeedback, $show_summary);
01138         }
01139 
01147         function checkOnlineTestAccess() 
01148         {
01149                 global $ilUser;
01150                 
01151                 // check if user is invited to participate
01152                 $user = $this->object->getInvitedUsers($ilUser->getId());
01153                 if (!is_array ($user) || count($user)!=1)
01154                 {
01155                                 ilUtil::sendInfo($this->lng->txt("user_not_invited"), true);
01156                                 $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01157                 }
01158                         
01159                 $user = array_pop($user);
01160                 // check if client ip is set and if current remote addr is equal to stored client-ip                    
01161                 if (strcmp($user->clientip,"")!=0 && strcmp($user->clientip,$_SERVER["REMOTE_ADDR"])!=0)
01162                 {
01163                         ilUtil::sendInfo($this->lng->txt("user_wrong_clientip"), true);
01164                         $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01165                 }               
01166         }       
01167 
01168         
01172         function isTestAccessible() 
01173         {               
01174                 return  !$this->isNrOfTriesReached()                            
01175                                 and      !$this->isMaxProcessingTimeReached()
01176                                 and  $this->object->startingTimeReached()
01177                                 and  !$this->object->endingTimeReached();
01178         }
01179 
01183         function isNrOfTriesReached() 
01184         {
01185                 return $this->object->hasNrOfTriesRestriction() && $this->object->isNrOfTriesReached($this->object->getTestSession()->getPass());       
01186         }
01187         
01195         function passDetails()
01196         {
01197                 if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
01198                 {
01199                         $this->ctrl->saveParameter($this, "pass");
01200                         $this->ctrl->saveParameter($this, "active_id");
01201                         $this->outTestResults(false, $_GET["pass"]);
01202                 }
01203                 else
01204                 {
01205                         $this->outTestResults(false);
01206                 }
01207         }
01208         
01214         function endingTimeReached() 
01215         {
01216                 ilUtil::sendInfo(sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime())));
01217                 $this->object->getTestSession()->increasePass();
01218                 $this->object->getTestSession()->setLastSequence(0);
01219                 $this->object->getTestSession()->saveToDb();
01220                 if (!$this->object->canViewResults()) 
01221                 {
01222                         $this->outIntroductionPage();
01223                 }
01224                 else
01225                 {
01226                         $this->outUserResultsOverview();
01227                 }
01228         }
01229         
01237         function maxProcessingTimeReached()
01238         {
01239                 $this->outIntroductionPage();
01240         }               
01241 
01247         function confirmSubmitAnswers() 
01248         {
01249                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_submit_answers_confirm.html", "Modules/Test");
01250                 $this->tpl->setCurrentBlock("adm_content");
01251                 if ($this->object->isActiveTestSubmitted()) 
01252                 {
01253                         $this->tpl->setCurrentBlock("not_submit_allowed");
01254                         $this->tpl->setVariable("TEXT_ALREADY_SUBMITTED", $this->lng->txt("tst_already_submitted"));
01255                         $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_show_answer_sheet"));
01256                 } else 
01257                 {
01258                         $this->tpl->setCurrentBlock("submit_allowed");
01259                         $this->tpl->setVariable("TEXT_CONFIRM_SUBMIT_RESULTS", $this->lng->txt("tst_confirm_submit_answers"));
01260                         $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_results"));
01261                 }
01262                 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));           
01263                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "finalSubmission"));
01264                 $this->tpl->parseCurrentBlock();
01265         }
01266         
01267         function outProcessingTime($active_id) 
01268         {
01269                 global $ilUser;
01270 
01271                 $starting_time = $this->object->getStartingTimeOfUser($active_id);
01272                 $processing_time = $this->object->getProcessingTimeInSeconds();
01273                 $processing_time_minutes = floor($processing_time / 60);
01274                 $processing_time_seconds = $processing_time - $processing_time_minutes * 60;
01275                 $str_processing_time = "";
01276                 if ($processing_time_minutes > 0)
01277                 {
01278                         $str_processing_time = $processing_time_minutes . " " . $this->lng->txt("minutes");
01279                 }
01280                 if ($processing_time_seconds > 0)
01281                 {
01282                         if (strlen($str_processing_time) > 0) $str_processing_time .= " " . $this->lng->txt("and") . " ";
01283                         $str_processing_time .= $processing_time_seconds . " " . $this->lng->txt("seconds");
01284                 }
01285                 $time_left = $starting_time + $processing_time - mktime();
01286                 $time_left_minutes = floor($time_left / 60);
01287                 $time_left_seconds = $time_left - $time_left_minutes * 60;
01288                 $str_time_left = "";
01289                 if ($time_left_minutes > 0)
01290                 {
01291                         $str_time_left = $time_left_minutes . " " . $this->lng->txt("minutes");
01292                 }
01293                 if ($time_left_seconds > 0)
01294                 {
01295                         if (strlen($str_time_left) > 0) $str_time_left .= " " . $this->lng->txt("and") . " ";
01296                         $str_time_left .= $time_left_seconds . " " . $this->lng->txt("seconds");
01297                 }
01298                 $date = getdate($starting_time);
01299                 $formattedStartingTime = ilFormat::formatDate(
01300                         $date["year"]."-".
01301                         sprintf("%02d", $date["mon"])."-".
01302                         sprintf("%02d", $date["mday"])." ".
01303                         sprintf("%02d", $date["hours"]).":".
01304                         sprintf("%02d", $date["minutes"]).":".
01305                         sprintf("%02d", $date["seconds"])
01306                 );
01307                 $datenow = getdate();
01308                 $this->tpl->setCurrentBlock("enableprocessingtime");
01309                 $this->tpl->setVariable("USER_WORKING_TIME", 
01310                         sprintf(
01311                                 $this->lng->txt("tst_time_already_spent"),
01312                                 $formattedStartingTime,
01313                                 $str_processing_time
01314                         )
01315                 );
01316                 $this->tpl->setVariable("USER_REMAINING_TIME", sprintf($this->lng->txt("tst_time_already_spent_left"), $str_time_left));
01317                 $this->tpl->parseCurrentBlock();
01318                 $template = new ilTemplate("tpl.workingtime.js.html", TRUE, TRUE, TRUE);
01319                 $template->setVariable("STRING_MINUTE", $this->lng->txt("minute"));
01320                 $template->setVariable("STRING_MINUTES", $this->lng->txt("minutes"));
01321                 $template->setVariable("STRING_SECOND", $this->lng->txt("second"));
01322                 $template->setVariable("STRING_SECONDS", $this->lng->txt("seconds"));
01323                 $template->setVariable("STRING_TIMELEFT", $this->lng->txt("tst_time_already_spent_left"));
01324                 $template->setVariable("AND", strtolower($this->lng->txt("and")));
01325                 $template->setVariable("YEAR", $date["year"]);
01326                 $template->setVariable("MONTH", $date["mon"]-1);
01327                 $template->setVariable("DAY", $date["mday"]);
01328                 $template->setVariable("HOUR", $date["hours"]);
01329                 $template->setVariable("MINUTE", $date["minutes"]);
01330                 $template->setVariable("SECOND", $date["seconds"]);
01331                 if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->object->getEndingTime(), $matches))
01332                 {
01333                         $template->setVariable("ENDYEAR", $matches[1]);
01334                         $template->setVariable("ENDMONTH", $matches[2]-1);
01335                         $template->setVariable("ENDDAY", $matches[3]);
01336                         $template->setVariable("ENDHOUR", $matches[4]);
01337                         $template->setVariable("ENDMINUTE", $matches[5]);
01338                         $template->setVariable("ENDSECOND", $matches[6]);
01339                 }
01340                 $template->setVariable("YEARNOW", $datenow["year"]);
01341                 $template->setVariable("MONTHNOW", $datenow["mon"]-1);
01342                 $template->setVariable("DAYNOW", $datenow["mday"]);
01343                 $template->setVariable("HOURNOW", $datenow["hours"]);
01344                 $template->setVariable("MINUTENOW", $datenow["minutes"]);
01345                 $template->setVariable("SECONDNOW", $datenow["seconds"]);
01346                 $template->setVariable("PTIME_M", $processing_time_minutes);
01347                 $template->setVariable("PTIME_S", $processing_time_seconds);
01348                 
01349                 $this->tpl->setCurrentBlock("HeadContent");
01350                 $this->tpl->setVariable("CONTENT_BLOCK", $template->get());
01351                 $this->tpl->parseCurrentBlock();
01352         }
01353         
01359         function outQuestionSummary() 
01360         {
01361                 $active_id = $this->object->getTestSession()->getActiveId();
01362                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_question_summary.html", "Modules/Test");
01363                 $color_class = array ("tblrow1", "tblrow2");
01364                 $counter = 0;
01365                 
01366                 $result_array = & $this->object->getTestSequence()->getSequenceSummary();
01367                 $marked_questions = array();
01368                 if ($this->object->getShowMarker())
01369                 {
01370                         include_once "./Modules/Test/classes/class.ilObjTest.php";
01371                         $marked_questions = ilObjTest::_getSolvedQuestions($active_id);
01372                 }
01373                 foreach ($result_array as $key => $value) 
01374                 {
01375                         if (preg_match("/\d+/", $key)) 
01376                         {
01377                                 $this->tpl->setCurrentBlock("question");
01378                                 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01379                                 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
01380                                 $this->ctrl->setParameter($this, "sequence", $value["sequence"]);
01381                                 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "gotoQuestion")."\">" . $this->object->getQuestionTitle($value["title"]) . "</a>");
01382                                 $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
01383                                 if ($this->object->getListOfQuestionsDescription())
01384                                 {
01385                                         $this->tpl->setVariable("VALUE_QUESTION_DESCRIPTION", $value["description"]);
01386                                 }
01387                                 if ($value["worked_through"])
01388                                 {
01389                                         $this->tpl->setVariable("VALUE_WORKED_THROUGH", ilUtil::getImagePath("icon_ok.gif"));
01390                                         $this->tpl->setVariable("ALT_WORKED_THROUGH", $this->lng->txt("worked_through"));
01391                                 }
01392                                 else
01393                                 {
01394                                         $this->tpl->setVariable("VALUE_WORKED_THROUGH", ilUtil::getImagePath("icon_not_ok.gif"));
01395                                         $this->tpl->setVariable("ALT_WORKED_THROUGH", $this->lng->txt("not_worked_through"));
01396                                 }
01397                                 if ($value["postponed"])
01398                                 {
01399                                         $this->tpl->setVariable("VALUE_POSTPONED", $this->lng->txt("postponed"));
01400                                 }
01401                                 if (!$this->object->getTitleOutput())
01402                                 {
01403                                         $this->tpl->setVariable("VALUE_QUESTION_POINTS", $value["points"]."&nbsp;".$this->lng->txt("points_short"));
01404                                 }
01405                                 if (count($marked_questions))
01406                                 {
01407                                         if (array_key_exists($value["qid"], $marked_questions))
01408                                         {
01409                                                 $obj = $marked_questions[$value["qid"]];
01410                                                 if ($obj->solved == 1)
01411                                                 {
01412                                                         $this->tpl->setVariable("ALT_MARKED_IMAGE", $this->lng->txt("tst_question_marked"));
01413                                                         $this->tpl->setVariable("TITLE_MARKED_IMAGE", $this->lng->txt("tst_question_marked"));
01414                                                         $this->tpl->setVariable("MARKED_IMAGE", ilUtil::getImagePath("marked.png"));
01415                                                 }
01416                                         } 
01417                                 }
01418                                 $this->tpl->parseCurrentBlock();
01419                                 $counter ++;
01420                         }
01421                 }
01422 
01423                 $this->tpl->setVariable("QUESTION_ACTION","actions");
01424                 $this->tpl->setVariable("QUESTION_COUNTER", $this->lng->txt("tst_qst_order"));
01425                 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
01426                 if (!$this->object->getTitleOutput())
01427                 {
01428                         $this->tpl->setVariable("QUESTION_POINTS", $this->lng->txt("tst_maximum_points"));
01429                 }
01430                 if ($this->object->getShowMarker())
01431                 {
01432                         $this->tpl->setVariable("TEXT_MARKED", $this->lng->txt("tst_question_marker"));
01433                 }
01434                 $this->tpl->setVariable("WORKED_THROUGH", $this->lng->txt("worked_through"));
01435                 $this->tpl->setVariable("USER_FEEDBACK", $this->lng->txt("tst_qst_summary_text"));
01436                 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
01437                 $this->tpl->setVariable("TXT_SHOW_AND_SUBMIT_ANSWERS", $this->lng->txt("save_finish"));
01438                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "backFromSummary"));    
01439                 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("question_summary"));           
01440                 
01441                 if ($this->object->getEnableProcessingTime())
01442                         $this->outProcessingTime($active_id);
01443         }
01444         
01445         function showMaximumAllowedUsersReachedMessage()
01446         {
01447                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_max_allowed_users_reached.html", "Modules/Test");
01448                 $this->tpl->setCurrentBlock("adm_content");
01449                 $this->tpl->setVariable("MAX_ALLOWED_USERS_MESSAGE", sprintf($this->lng->txt("tst_max_allowed_users_message"), $this->object->getAllowedUsersTimeGap()));
01450                 $this->tpl->setVariable("MAX_ALLOWED_USERS_HEADING", sprintf($this->lng->txt("tst_max_allowed_users_heading"), $this->object->getAllowedUsersTimeGap()));
01451                 $this->tpl->setVariable("BACK_TO_INTRODUCTION", $this->lng->txt("tst_results_back_introduction"));
01452                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01453                 $this->tpl->parseCurrentBlock();
01454         }
01455         
01456         function backConfirmFinish()
01457         {
01458                 global $ilUser;
01459                 if ($this->object->canShowSolutionPrintview($ilUser->getId()))
01460                 {
01461                         $template = new ilTemplate("tpl.il_as_tst_finish_navigation.html", TRUE, TRUE, "Modules/Test");
01462                         $template->setVariable("BUTTON_FINISH", $this->lng->txt("btn_next"));
01463                         $template->setVariable("BUTTON_CANCEL", $this->lng->txt("btn_previous"));
01464                         
01465                         $template_top = new ilTemplate("tpl.il_as_tst_list_of_answers_topbuttons.html", TRUE, TRUE, "Modules/Test");
01466                         $template_top->setCurrentBlock("button_print");
01467                         $template_top->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
01468                         $template_top->parseCurrentBlock();
01469                         $active_id = $this->object->getTestSession()->getActiveId();
01470                         return $this->showListOfAnswers($active_id, NULL, $template_top->get(), $template->get());
01471                 }
01472                 else
01473                 {
01474                         $this->ctrl->redirect($this, "redirectQuestion");
01475                 }
01476         }
01477         
01478         function finishListOfAnswers()
01479         {
01480                 $this->confirmFinishTest();
01481         }
01482         
01488         function outCorrectSolution()
01489         {
01490                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_correct_solution.html", "Modules/Test");
01491 
01492                 include_once("classes/class.ilObjStyleSheet.php");
01493                 $this->tpl->setCurrentBlock("ContentStyle");
01494                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
01495                 $this->tpl->parseCurrentBlock();
01496 
01497                 $this->tpl->setCurrentBlock("SyntaxStyle");
01498                 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
01499                 $this->tpl->parseCurrentBlock();
01500 
01501                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
01502                 if ($this->object->getShowSolutionAnswersOnly())
01503                 {
01504                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
01505                 }
01506 
01507                 $this->tpl->setCurrentBlock("adm_content");
01508                 $solution = $this->getCorrectSolutionOutput($_GET["evaluation"], $_GET["active_id"], $_GET["pass"]);
01509                 $this->tpl->setVariable("OUTPUT_SOLUTION", $solution);
01510                 $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
01511                 $this->ctrl->saveParameter($this, "pass");
01512                 $this->ctrl->saveParameter($this, "active_id");
01513                 $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
01514                 $this->tpl->parseCurrentBlock();
01515         }
01516 
01526         function showListOfAnswers($active_id, $pass = NULL, $top_data = "", $bottom_data = "")
01527         {
01528                 global $ilUser;
01529 
01530                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish_list_of_answers.html", "Modules/Test");
01531 
01532                 $result_array =& $this->object->getTestResult($active_id, $pass);
01533 
01534                 $counter = 1;
01535                 // output of questions with solutions
01536                 foreach ($result_array as $question_data)
01537                 {
01538                         $question = $question_data["qid"];
01539                         if (is_numeric($question))
01540                         {
01541                                 $this->tpl->setCurrentBlock("printview_question");
01542                                 $question_gui = $this->object->createQuestionGUI("", $question);
01543                                 $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", TRUE, TRUE, "Modules/TestQuestionPool");
01544                                 $template->setVariable("COUNTER_QUESTION", $counter.". ");
01545                                 $template->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
01546                                 
01547                                 $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
01548                                 $result_output = $question_gui->getSolutionOutput($active_id, $pass, FALSE, FALSE, $show_question_only, $this->object->getShowSolutionFeedback());
01549                                 $template->setVariable("SOLUTION_OUTPUT", $result_output);
01550                                 $this->tpl->setVariable("QUESTION_OUTPUT", $template->get());
01551                                 $this->tpl->parseCurrentBlock();
01552                                 $counter ++;
01553                         }
01554                 }
01555 
01556                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
01557                 if ($this->object->getShowSolutionAnswersOnly())
01558                 {
01559                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
01560                 }
01561                 if (strlen($top_data))
01562                 {
01563                         $this->tpl->setCurrentBlock("top_data");
01564                         $this->tpl->setVariable("TOP_DATA", $top_data);
01565                         $this->tpl->parseCurrentBlock();
01566                 }
01567                 
01568                 if (strlen($bottom_data))
01569                 {
01570                         $this->tpl->setCurrentBlock("bottom_data");
01571                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01572                         $this->tpl->setVariable("BOTTOM_DATA", $bottom_data);
01573                         $this->tpl->parseCurrentBlock();
01574                 }
01575                 
01576                 $this->tpl->setCurrentBlock("adm_content");
01577                 $this->tpl->setVariable("TXT_ANSWER_SHEET", $this->lng->txt("tst_list_of_answers"));
01578                 $user_data = $this->getResultsUserdata($active_id, TRUE);
01579                 $signature = $this->getResultsSignature();
01580                 $this->tpl->setVariable("USER_DETAILS", $user_data);
01581                 $this->tpl->setVariable("SIGNATURE", $signature);
01582                 $this->tpl->setVariable("TITLE", $this->object->getTitle());
01583                 $this->tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers"));
01584                 $invited_user =& $this->object->getInvitedUsers($ilUser->getId());
01585                 $pagetitle = $this->object->getTitle() . " - " . $this->lng->txt("clientip") . 
01586                         ": " . $invited_user[$ilUser->getId()]->clientip . " - " . 
01587                         $this->lng->txt("matriculation") . ": " . 
01588                         $invited_user[$ilUser->getId()]->matriculation;
01589                 $this->tpl->setVariable("PAGETITLE", $pagetitle);
01590                 $this->tpl->parseCurrentBlock();
01591         }
01592  
01600         function outUserListOfAnswerPasses()
01601         {
01602                 global $ilUser;
01603                 
01604                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_info_list_of_answers.html", "Modules/Test");
01605 
01606                 $pass = null;
01607                 if (array_key_exists("pass", $_GET))
01608                 {
01609                         if (strlen($_GET["pass"])) $pass = $_GET["pass"];
01610                 }
01611                 $user_id = $ilUser->getId();
01612                 $active_id = $this->object->getTestSession()->getActiveId();
01613                 $overview = "";
01614                 if ($this->object->getNrOfTries() == 1)
01615                 {
01616                         $pass = 0;
01617                 }
01618                 else
01619                 {
01620                         $overview = $this->getPassOverview($active_id, "iltestoutputgui", "outUserListOfAnswerPasses", TRUE);
01621                         $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
01622                         $this->tpl->setVariable("PASS_OVERVIEW", $overview);
01623                 }
01624 
01625                 $signature = "";
01626                 if (strlen($pass))
01627                 {
01628                         $signature = $this->getResultsSignature();
01629                         $result_array =& $this->object->getTestResult($active_id, $pass);
01630                         $user_id =& $this->object->_getUserIdFromActiveId($active_id);
01631                         $showAllAnswers = TRUE;
01632                         if ($this->object->isExecutable($user_id))
01633                         {
01634                                 $showAllAnswers = FALSE;
01635                         }
01636                         $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers);
01637                         $this->tpl->setVariable("PASS_DETAILS", $answers);
01638                 }
01639                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01640                 $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
01641                 $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
01642                 $this->tpl->setVariable("PRINT_TEXT", $this->lng->txt("print"));
01643                 $this->tpl->setVariable("PRINT_URL", "javascript:window.print();");
01644                 
01645                 $user_data = $this->getResultsUserdata($active_id, TRUE);
01646                 $this->tpl->setVariable("USER_DATA", $user_data);
01647                 $this->tpl->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
01648                 if (strlen($signature))
01649                 {
01650                         $this->tpl->setVariable("SIGNATURE", $signature);
01651                 }
01652                 $this->tpl->parseCurrentBlock();
01653 
01654                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
01655                 if ($this->object->getShowSolutionAnswersOnly())
01656                 {
01657                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
01658                 }
01659         }
01660 
01668         function outUserResultsOverview()
01669         {
01670                 global $ilUser, $ilias;
01671 
01672                 include_once("./classes/class.ilTemplate.php");
01673                 $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test");
01674                 $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
01675 
01676                 $pass = null;
01677                 $user_id = $ilUser->getId();
01678                 $uname = $this->object->userLookupFullName($user_id, TRUE);
01679                 $active_id = $this->object->getTestSession()->getActiveId();
01680                 $hide_details = !$this->object->getShowPassDetails();
01681                 if ($hide_details)
01682                 {
01683                         $executable = $this->object->isExecutable($ilUser->getId());
01684                         if (!$executable["executable"]) $hide_details = FALSE;
01685                 }
01686                 if (($this->object->getNrOfTries() == 1) && (!$hide_details))
01687                 {
01688                         $pass = 0;
01689                 }
01690                 else
01691                 {
01692                         $template->setCurrentBlock("pass_overview");
01693                         $overview = $this->getPassOverview($active_id, "iltestoutputgui", "outUserResultsOverview", FALSE, $hide_details);
01694                         $template->setVariable("PASS_OVERVIEW", $overview);
01695                         $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results_overview"));
01696                         $template->parseCurrentBlock();
01697                 }
01698 
01699                 if (((array_key_exists("pass", $_GET)) && (strlen($_GET["pass"]) > 0)) || (!is_null($pass)))
01700                 {
01701                         if (is_null($pass))     $pass = $_GET["pass"];
01702                 }
01703 
01704                 if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
01705                 {
01706                         $this->ctrl->setParameter($this, "pass", $pass);
01707                         $this->ctrl->setParameter($this, "pdf", "1");
01708                         $templatehead->setCurrentBlock("pdf_export");
01709                         $templatehead->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
01710                         $this->ctrl->setParameter($this, "pass", "");
01711                         $this->ctrl->setParameter($this, "pdf", "");
01712                         $templatehead->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
01713                         $templatehead->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
01714                         $templatehead->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
01715                         $templatehead->parseCurrentBlock();
01716                         if ($this->object->canShowCertificate($user_id, $active_id))
01717                         {
01718                                 $templatehead->setCurrentBlock("certificate");
01719                                 $templatehead->setVariable("CERTIFICATE_URL", $this->ctrl->getLinkTargetByClass("iltestcertificategui", "outCertificate"));
01720                                 $templatehead->setVariable("CERTIFICATE_TEXT", $this->lng->txt("certificate"));
01721                                 $templatehead->parseCurrentBlock();
01722                         }
01723                 }
01724                 $templatehead->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
01725                 $templatehead->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
01726                 $templatehead->setVariable("PRINT_TEXT", $this->lng->txt("print"));
01727                 $templatehead->setVariable("PRINT_URL", "javascript:window.print();");
01728                 
01729                 $result_pass = $this->object->_getResultPass($active_id);
01730                 $result_array =& $this->object->getTestResult($active_id, $result_pass);
01731                 $statement = $this->getFinalStatement($result_array["test"]);
01732                 $user_data = $this->getResultsUserdata($active_id, TRUE);
01733 
01734                 // output of the details of a selected pass
01735                 $this->ctrl->saveParameter($this, "pass");
01736                 $this->ctrl->saveParameter($this, "active_id");
01737                 if (!is_null($pass))
01738                 {
01739                         $result_array =& $this->object->getTestResult($active_id, $pass);
01740                         $command_solution_details = "";
01741                         if ($this->object->getShowSolutionDetails())
01742                         {
01743                                 $command_solution_details = "outCorrectSolution";
01744                         }
01745                         $detailsoverview = (!$hide_details) ? $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestoutputgui", "outUserResultsOverview", $command_solution_details) : '';
01746         
01747                         $user_id = $this->object->_getUserIdFromActiveId($active_id);
01748         
01749                         if (!$hide_details && $this->object->canShowSolutionPrintview())
01750                         {
01751                                 $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
01752                         }
01753                         
01754                         $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
01755                         $template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1));
01756                         $template->setVariable("PASS_DETAILS", $detailsoverview);
01757 
01758                         $signature = $this->getResultsSignature();
01759                         $template->setVariable("SIGNATURE", $signature);
01760                 }
01761                 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
01762                 $template->setVariable("USER_DATA", $user_data);
01763                 $template->setVariable("USER_MARK", $statement["mark"]);
01764                 if (strlen($statement["markects"]))
01765                 {
01766                         $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
01767                 }
01768                 $template->parseCurrentBlock();
01769 
01770                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
01771                 if ($this->object->getShowSolutionAnswersOnly())
01772                 {
01773                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
01774                 }
01775                 $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
01776                 
01777                 if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
01778                 {
01779                         $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
01780                         $printbody->setVariable("TITLE", sprintf($this->lng->txt("tst_result_user_name"), $uname));
01781                         $printbody->setVariable("ADM_CONTENT", $template->get());
01782                         $printoutput = $printbody->get();
01783                         $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput);
01784                         $fo = $this->object->processPrintoutput2FO($printoutput);
01785                         $this->object->deliverPDFfromFO($fo);
01786                 }
01787                 else
01788                 {
01789                         $this->tpl->setVariable("PRINT_CONTENT", $templatehead->get());
01790                 }
01791         }
01792         
01800         function outUserPassDetails()
01801         {
01802                 $this->ctrl->saveParameter($this, "pass");
01803                 $this->ctrl->saveParameter($this, "active_id");
01804                 $active_id = $_GET["active_id"];
01805                 $pass = $_GET["pass"];
01806                 $result_array =& $this->object->getTestResult($active_id, $pass);
01807 
01808                 $command_solution_details = "";
01809                 if ($this->object->getShowSolutionDetails())
01810                 {
01811                         $command_solution_details = "outCorrectSolution";
01812                 }
01813                 $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestoutputgui", "outUserPassDetails", $command_solution_details);
01814 
01815                 $user_id = $this->object->_getUserIdFromActiveId($active_id);
01816 
01817                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_pass_details_overview_participants.html", "Modules/Test");
01818 
01819                 if ($this->object->getNrOfTries() == 1)
01820                 {
01821                         $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
01822                         $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
01823                 }
01824                 else
01825                 {
01826                         $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outUserResultsOverview"));
01827                         $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
01828                 }
01829 
01830                 $this->tpl->parseCurrentBlock();
01831 
01832                 if ($this->object->getNrOfTries() == 1)
01833                 {
01834                         $statement = $this->getFinalStatement($result_array["test"]);
01835                         $this->tpl->setVariable("USER_MARK", $statement["mark"]);
01836                         if (strlen($statement["markects"]))
01837                         {
01838                                 $this->tpl->setVariable("USER_MARK_ECTS", $statement["markects"]);
01839                         }
01840                 }
01841                 
01842                 $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
01843                 
01844                 $this->tpl->setCurrentBlock("adm_content");
01845                 $this->tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
01846                 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01847                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01848                 $this->tpl->setVariable("PASS_DETAILS", $overview);
01849                 $uname = $this->object->userLookupFullName($user_id, TRUE);
01850                 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
01851                 $this->tpl->parseCurrentBlock();
01852 
01853                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
01854                 if ($this->object->getShowSolutionAnswersOnly())
01855                 {
01856                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
01857                 }
01858         }
01859 
01867         function outParticipantsResultsOverview()
01868         {
01869                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_pass_overview_participants.html", "Modules/Test");
01870 
01871                 $active_id = $_GET["active_id"];
01872                 if ($this->object->getNrOfTries() == 1)
01873                 {
01874                         $this->ctrl->setParameter($this, "active_id", $active_id);
01875                         $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
01876                         $this->ctrl->redirect($this, "outParticipantsPassDetails");
01877                 }
01878 
01879                 $overview = $this->getPassOverview($active_id, "iltestoutputgui", "outParticipantsPassDetails");
01880                 $this->tpl->setVariable("PASS_OVERVIEW", $overview);
01881                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01882                 $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("back"));
01883                 $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
01884                 $this->tpl->setVariable("PRINT_TEXT", $this->lng->txt("print"));
01885                 $this->tpl->setVariable("PRINT_URL", "javascript:window.print();");
01886                 
01887                 $result_pass = $this->object->_getResultPass($active_id);
01888                 $result_array =& $this->object->getTestResult($active_id, $result_pass);
01889                 $statement = $this->getFinalStatement($result_array["test"]);
01890                 $user_id = $this->object->_getUserIdFromActiveId($active_id);
01891                 $user_data = $this->getResultsUserdata($active_id);
01892                 $this->tpl->setVariable("USER_DATA", $user_data);
01893                 $this->tpl->setVariable("TEXT_OVERVIEW", $this->lng->txt("tst_results_overview"));
01894                 $this->tpl->setVariable("USER_MARK", $statement["mark"]);
01895                 if (strlen($statement["markects"]))
01896                 {
01897                         $this->tpl->setVariable("USER_MARK_ECTS", $statement["markects"]);
01898                 }
01899                 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01900                 $this->tpl->parseCurrentBlock();
01901 
01902                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
01903                 if ($this->object->getShowSolutionAnswersOnly())
01904                 {
01905                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
01906                 }
01907         }
01908         
01916         function outParticipantsPassDetails()
01917         {
01918                 $this->ctrl->saveParameter($this, "pass");
01919                 $this->ctrl->saveParameter($this, "active_id");
01920                 $active_id = $_GET["active_id"];
01921                 $pass = $_GET["pass"];
01922                 $result_array =& $this->object->getTestResult($active_id, $pass);
01923 
01924                 $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestoutputgui", "outParticipantsPassDetails");
01925                 $user_data = $this->getResultsUserdata($active_id, FALSE);
01926 
01927                 $user_id = $this->object->_getUserIdFromActiveId($active_id);
01928 
01929                 $this->tpl->addBlockFile("PRINT_CONTENT", "adm_content", "tpl.il_as_tst_pass_details_overview_participants.html", "Modules/Test");
01930 
01931                 if (array_key_exists("statistics", $_GET) && ($_GET["statistics"] == 1))
01932                 {
01933                         $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("back"));
01934                         $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
01935                         $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilTestEvaluationGUI", "detailedEvaluation"));
01936                 }
01937                 else
01938                 {
01939                         if ($this->object->getNrOfTries() == 1)
01940                         {
01941                                 $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("back"));
01942                                 $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
01943                         }
01944                         else
01945                         {
01946                                 $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outParticipantsResultsOverview"));
01947                                 $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
01948                         }
01949                 }
01950                 $this->tpl->setVariable("PRINT_TEXT", $this->lng->txt("print"));
01951                 $this->tpl->setVariable("PRINT_URL", "javascript:window.print();");
01952 
01953                 $this->tpl->parseCurrentBlock();
01954 
01955                 if ($this->object->getNrOfTries() == 1)
01956                 {
01957                         $statement = $this->getFinalStatement($result_array["test"]);
01958                         $this->tpl->setVariable("USER_MARK", $statement["mark"]);
01959                         if (strlen($statement["markects"]))
01960                         {
01961                                 $this->tpl->setVariable("USER_MARK_ECTS", $statement["markects"]);
01962                         }
01963                 }
01964                 
01965                 $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, TRUE);
01966                 
01967                 $this->tpl->setCurrentBlock("adm_content");
01968                 $this->tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
01969                 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01970                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01971                 $this->tpl->setVariable("PASS_DETAILS", $overview);
01972                 $this->tpl->setVariable("USER_DETAILS", $user_data);
01973                 $uname = $this->object->userLookupFullName($user_id);
01974                 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
01975                 $this->tpl->parseCurrentBlock();
01976 
01977                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
01978                 if ($this->object->getShowSolutionAnswersOnly())
01979                 {
01980                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
01981                 }
01982         }
01983 }
01984 ?>

Generated on Fri Dec 13 2013 17:56:53 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1