00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once "./assessment/classes/inc.AssessmentConstants.php";
00025
00038 class ilTestOutputGUI
00039 {
00040 var $object;
00041 var $lng;
00042 var $tpl;
00043 var $ctrl;
00044 var $ilias;
00045 var $tree;
00046
00047 var $saveResult;
00048 var $sequence;
00049 var $cmdCtrl;
00050 var $maxProcessingTimeReached;
00051 var $endingTimeReached;
00052
00061 function ilTestOutputGUI($a_object)
00062 {
00063 global $lng, $tpl, $ilCtrl, $ilias, $tree;
00064
00065 $this->lng =& $lng;
00066 $this->tpl =& $tpl;
00067 $this->ctrl =& $ilCtrl;
00068 $this->ilias =& $ilias;
00069 $this->object =& $a_object;
00070 $this->tree =& $tree;
00071 $this->ref_id = $_GET["ref_id"];
00072 }
00073
00077 function &executeCommand()
00078 {
00079 $cmd = $this->ctrl->getCmd();
00080 $next_class = $this->ctrl->getNextClass($this);
00081 $this->ctrl->saveParameter($this, "sequence");
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
00100 function getCommand($cmd)
00101 {
00102 return $cmd;
00103 }
00104
00109 function updateWorkingTime()
00110 {
00111 if ($_SESSION["active_time_id"])
00112 {
00113 $this->object->updateWorkingTime($_SESSION["active_time_id"]);
00114
00115 }
00116 }
00117
00121 function saveQuestionSolution()
00122 {
00123 $this->saveResult = false;
00124 $formtimestamp = $_POST["formtimestamp"];
00125 if (strlen($formtimestamp) == 0) $formtimestamp = $_GET["formtimestamp"];
00126 if ($formtimestamp != $_SESSION["formtimestamp"])
00127 {
00128 $_SESSION["formtimestamp"] = $formtimestamp;
00129 }
00130 else
00131 {
00132 return;
00133 }
00134
00135 if ($this->canSaveResult())
00136 {
00137
00138 $q_id = $this->object->getQuestionIdFromActiveUserSequence($_GET["sequence"]);
00139 if (is_numeric($q_id))
00140 {
00141 global $ilUser;
00142
00143 $question_gui = $this->object->createQuestionGUI("", $q_id);
00144 if ($ilUser->prefs["tst_javascript"])
00145 {
00146 $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
00147 }
00148 $pass = NULL;
00149 if ($this->object->isRandomTest())
00150 {
00151 global $ilUser;
00152 $pass = $this->object->_getPass($ilUser->getId(), $this->object->getTestId());
00153 }
00154 $this->saveResult = $question_gui->object->saveWorkingData($this->object->getTestId(), $pass);
00155 }
00156 }
00157 if ($this->saveResult == FALSE)
00158 {
00159 $this->ctrl->setParameter($this, "save_error", "1");
00160 $_SESSION["previouspost"] = $_POST;
00161 }
00162 }
00163
00168 function canSaveResult()
00169 {
00170 return !$this->isEndingTimeReached() && !$this->isMaxProcessingTimeReached() && !$this->isNrOfTriesReached();
00171 }
00172
00180 function outIntroductionPage()
00181 {
00182 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00183 }
00184
00193 function isMaxProcessingTimeReached()
00194 {
00195 global $ilUser;
00196 $starting_time = $this->object->getStartingTimeOfUser($ilUser->getId());
00197 if ($starting_time === FALSE)
00198 {
00199 return FALSE;
00200 }
00201 else
00202 {
00203 return $this->object->isMaxProcessingTimeReached($starting_time);
00204 }
00205 }
00206
00207 function isEndingTimeReached()
00208 {
00209 global $ilUser;
00210 if (!is_bool($this->endingTimeReached))
00211 $this->endingTimeReached = $this->object->endingTimeReached() && ($this->object->getTestType() == TYPE_ASSESSMENT || $this->object->isOnlineTest());
00212
00213 return $this->endingTimeReached;
00214 }
00215
00223 function deleteresults()
00224 {
00225 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_delete_results_confirm.html", true);
00226 $this->tpl->setCurrentBlock("adm_content");
00227 $this->tpl->setVariable("TEXT_CONFIRM_DELETE_RESULTS", $this->lng->txt("tst_confirm_delete_results"));
00228 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00229 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_delete_results"));
00230 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00231 $this->tpl->parseCurrentBlock();
00232 }
00233
00241 function confirmdeleteresults()
00242 {
00243 global $ilUser;
00244
00245 $this->object->deleteResults($ilUser->id);
00246 sendInfo($this->lng->txt("tst_confirm_delete_results_info"), true);
00247 $this->ctrl->redirect($this, "outIntroductionPage");
00248 }
00249
00257 function canceldeleteresults()
00258 {
00259 $this->ctrl->redirect($this, "outIntroductionPage");
00260 }
00261
00269 function outShortResult($user_question_order)
00270 {
00271 if(!$_GET['crs_show_result'])
00272 {
00273 $this->tpl->setCurrentBlock("percentage");
00274 $this->tpl->setVariable("PERCENTAGE", (int)(($this->sequence / count($user_question_order))*200));
00275 $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($this->sequence / count($user_question_order))*100));
00276 $this->tpl->setVariable("HUNDRED_PERCENT", "200");
00277 $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
00278 $this->tpl->parseCurrentBlock();
00279 $this->tpl->setCurrentBlock("percentage_bottom");
00280 $this->tpl->setVariable("PERCENTAGE", (int)(($this->sequence / count($user_question_order))*200));
00281 $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($this->sequence / count($user_question_order))*100));
00282 $this->tpl->setVariable("HUNDRED_PERCENT", "200");
00283 $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
00284 $this->tpl->parseCurrentBlock();
00285 }
00286 else
00287 {
00288 $num_wrong = count($_SESSION['crs_sequence']);
00289 $pos = 1;
00290 foreach($_SESSION['crs_sequence'] as $sequence)
00291 {
00292 if($sequence == $this->sequence)
00293 {
00294 break;
00295 }
00296 $pos++;
00297 }
00298
00299 $this->tpl->setCurrentBlock("percentage");
00300 $this->tpl->setVariable("PERCENTAGE", (int)(($pos / $num_wrong)*200));
00301 $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($pos / $num_wrong)*100));
00302 $this->tpl->setVariable("HUNDRED_PERCENT", "200");
00303 $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
00304 $this->tpl->parseCurrentBlock();
00305 $this->tpl->setCurrentBlock("percentage_bottom");
00306 $this->tpl->setVariable("PERCENTAGE", (int)(($pos / $num_wrong)*200));
00307 $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($pos / $num_wrong)*100));
00308 $this->tpl->setVariable("HUNDRED_PERCENT", "200");
00309 $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
00310 $this->tpl->parseCurrentBlock();
00311 }
00312 }
00313
00321 function outWorkingForm($sequence = 1, $finish = false, $test_id, $active, $postpone_allowed, $user_question_order, $directfeedback = 0)
00322 {
00323 global $ilUser;
00324
00325 include_once("classes/class.ilObjStyleSheet.php");
00326 $this->tpl->setCurrentBlock("ContentStyle");
00327 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00328 ilObjStyleSheet::getContentStylePath(0));
00329 $this->tpl->parseCurrentBlock();
00330
00331
00332 $this->tpl->setCurrentBlock("SyntaxStyle");
00333 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00334 ilObjStyleSheet::getSyntaxStylePath());
00335 $this->tpl->parseCurrentBlock();
00336 $question_gui = $this->object->createQuestionGUI("", $this->object->getQuestionIdFromActiveUserSequence($sequence));
00337 if (is_null($question_gui))
00338 {
00339 $questioncount = $this->object->getQuestionCount();
00340 while ((($sequence + 1) < $questioncount) && (is_null($question_gui)))
00341 {
00342 $sequence += 1;
00343 $question_gui = $this->object->createQuestionGUI("", $this->object->getQuestionIdFromActiveUserSequence($sequence));
00344 }
00345 if (is_null($question_gui))
00346 {
00347
00348 $this->object->setActiveTestUser($questioncount);
00349 $this->ctrl->redirect($this, "finishTest");
00350 }
00351 }
00352 if ($ilUser->prefs["tst_javascript"])
00353 {
00354 $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
00355 }
00356
00357
00358 $is_postponed = false;
00359 if (is_object($active))
00360 {
00361 if (!preg_match("/(^|\D)" . $question_gui->object->getId() . "($|\D)/", $active->postponed) and
00362 !($active->postponed == $question_gui->object->getId()))
00363 {
00364 $is_postponed = false;
00365 }
00366 else
00367 {
00368 $is_postponed = true;
00369 }
00370 }
00371
00372 $this->ctrl->setParameter($this, "sequence", "$sequence");
00373 $formaction = $this->ctrl->getFormAction($this);
00374 $question_gui->setSequenceNumber($sequence);
00375
00376
00377 if (array_key_exists("previouspost", $_SESSION))
00378 {
00379 $user_post_solution = $_SESSION["previouspost"];
00380 unset($_SESSION["previouspost"]);
00381 }
00382 switch ($question_gui->getQuestionType())
00383 {
00384 case "qt_imagemap":
00385 $this->ctrl->setParameter($this, "formtimestamp", time());
00386 $formaction = $this->ctrl->getLinkTargetByClass(get_class($this), "selectImagemapRegion");
00387 $question_gui->outWorkingForm($test_id, $is_postponed, $directfeedback, $formaction, true);
00388 if (ilObjTest::_getHidePreviousResults($test_id, true))
00389 {
00390 $pass = ilObjTest::_getPass($ilUser->id, $test_id);
00391 $info =& $question_gui->object->getSolutionValues($test_id, $ilUser, $pass);
00392 }
00393 else
00394 {
00395 $info =& $question_gui->object->getSolutionValues($test_id, $ilUser, NULL);
00396 }
00397 if (count($info))
00398 {
00399 if (strcmp($info[0]["value1"], "") != 0)
00400 {
00401 $formaction .= "&selImage=" . $info[0]["value1"];
00402 }
00403 }
00404 break;
00405
00406 default:
00407 $question_gui->outWorkingForm(
00408 $test_id,
00409 $is_postponed,
00410 $showsolution = $directfeedback,
00411 true, false, NULL, NULL, false, $user_post_solution
00412 );
00413 break;
00414 }
00415
00416
00417
00418 if($_GET['crs_show_result'])
00419 {
00420 $first_sequence = $_SESSION['crs_sequence'][0] ? $_SESSION['crs_sequence'][0] : 1;
00421 }
00422 else
00423 {
00424 $first_sequence = 1;
00425 }
00426 if ($sequence == $first_sequence)
00427 {
00428 $this->tpl->setCurrentBlock("prev");
00429 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_introduction"));
00430 $this->tpl->parseCurrentBlock();
00431 $this->tpl->setCurrentBlock("prev_bottom");
00432 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_introduction"));
00433 $this->tpl->parseCurrentBlock();
00434 }
00435 else
00436 {
00437 $this->tpl->setCurrentBlock("prev");
00438 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_previous"));
00439 $this->tpl->parseCurrentBlock();
00440 $this->tpl->setCurrentBlock("prev_bottom");
00441 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_previous"));
00442 $this->tpl->parseCurrentBlock();
00443 }
00444
00445 if ($postpone_allowed)
00446 {
00447 if (!$is_postponed)
00448 {
00449 $this->tpl->setCurrentBlock("postpone");
00450 $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
00451 $this->tpl->parseCurrentBlock();
00452 $this->tpl->setCurrentBlock("postpone_bottom");
00453 $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
00454 $this->tpl->parseCurrentBlock();
00455 }
00456 }
00457
00458 if ($this->object->isOnlineTest() && !$finish)
00459 {
00460 $this->tpl->setCurrentBlock("summary");
00461 $this->tpl->setVariable("BTN_SUMMARY", $this->lng->txt("summary"));
00462 $this->tpl->parseCurrentBlock();
00463 $this->tpl->setCurrentBlock("summary_bottom");
00464 $this->tpl->setVariable("BTN_SUMMARY", $this->lng->txt("summary"));
00465 $this->tpl->parseCurrentBlock();
00466 }
00467
00468 if (!$this->object->isOnlineTest())
00469 {
00470 $this->tpl->setCurrentBlock("cancel_test");
00471 $this->tpl->setVariable("TEXT_CANCELTEST", $this->lng->txt("cancel_test"));
00472 $this->tpl->setVariable("TEXT_ALTCANCELTEXT", $this->lng->txt("cancel_test"));
00473 $this->tpl->setVariable("TEXT_TITLECANCELTEXT", $this->lng->txt("cancel_test"));
00474 $this->tpl->setVariable("HREF_IMGCANCELTEST", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00475 $this->tpl->setVariable("HREF_CANCELTEXT", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00476 $this->tpl->setVariable("IMAGE_CANCEL", ilUtil::getImagePath("cancel.png"));
00477 $this->tpl->parseCurrentBlock();
00478 $this->tpl->setCurrentBlock("cancel_test_bottom");
00479 $this->tpl->setVariable("TEXT_CANCELTEST", $this->lng->txt("cancel_test"));
00480 $this->tpl->setVariable("TEXT_ALTCANCELTEXT", $this->lng->txt("cancel_test"));
00481 $this->tpl->setVariable("TEXT_TITLECANCELTEXT", $this->lng->txt("cancel_test"));
00482 $this->tpl->setVariable("HREF_IMGCANCELTEST", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00483 $this->tpl->setVariable("HREF_CANCELTEXT", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00484 $this->tpl->setVariable("IMAGE_CANCEL", ilUtil::getImagePath("cancel.png"));
00485 $this->tpl->parseCurrentBlock();
00486 }
00487
00488 if ($finish)
00489 {
00490 if (!$this->object->isOnlineTest())
00491 {
00492 $this->tpl->setCurrentBlock("next");
00493 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " >>");
00494 $this->tpl->parseCurrentBlock();
00495 $this->tpl->setCurrentBlock("next_bottom");
00496 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " >>");
00497 $this->tpl->parseCurrentBlock();
00498 }
00499 else
00500 {
00501 $this->tpl->setCurrentBlock("next");
00502 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("summary") . " >>");
00503 $this->tpl->parseCurrentBlock();
00504 $this->tpl->setCurrentBlock("next_bottom");
00505 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("summary") . " >>");
00506 $this->tpl->parseCurrentBlock();
00507 }
00508 }
00509 else
00510 {
00511 $this->tpl->setCurrentBlock("next");
00512 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " >>");
00513 $this->tpl->parseCurrentBlock();
00514 $this->tpl->setCurrentBlock("next_bottom");
00515 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " >>");
00516 $this->tpl->parseCurrentBlock();
00517 }
00518
00519 if ($this->object->isOnlineTest())
00520 {
00521 include_once "./assessment/classes/class.ilObjTest.php";
00522 $solved_array = ilObjTest::_getSolvedQuestions($this->object->test_id, $ilUser->getId(), $question_gui->object->getId());
00523 $solved = 0;
00524
00525 if (count ($solved_array) > 0)
00526 {
00527 $solved = array_pop($solved_array);
00528 $solved = $solved->solved;
00529 }
00530
00531 if ($solved==1)
00532 {
00533 $solved = ilUtil::getImagePath("solved.png", true);
00534 $solved_cmd = "resetsolved";
00535 $solved_txt = $this->lng->txt("tst_qst_resetsolved");
00536 }
00537 else
00538 {
00539 $solved = ilUtil::getImagePath("not_solved.png", true);
00540 $solved_cmd = "setsolved";
00541 $solved_txt = $this->lng->txt("tst_qst_setsolved");
00542 }
00543 $solved = "<input align=\"middle\" border=\"0\" alt=\"".$this->lng->txt("tst_qst_solved_state_click_to_change")."\" name=\"cmd[$solved_cmd]\" type=\"image\" src=\"$solved\" id=\"$solved_cmd\"> <small><label for=\"$solved_cmd\">$solved_txt</label></small>";
00544
00545 $this->tpl->setCurrentBlock("question_status");
00546 $this->tpl->setVariable("TEXT_QUESTION_STATUS_LABEL", $this->lng->txt("tst_question_solved_state").":");
00547 $this->tpl->setVariable("TEXT_QUESTION_STATUS", $solved);
00548 $this->tpl->parseCurrentBlock();
00549 }
00550
00551 $this->tpl->setCurrentBlock("adm_content");
00552 $this->tpl->setVariable("FORMACTION", $formaction);
00553 $this->tpl->parseCurrentBlock();
00554 }
00555
00563 function start()
00564 {
00565 $this->readFullSequence();
00566
00567 if ($this->object->isRandomTest())
00568 {
00569 $this->object->generateRandomQuestions();
00570 $this->object->loadQuestions();
00571 }
00572 $this->handleStartCommands();
00573 $this->ctrl->setParameter($this, "activecommand", "start");
00574 $this->ctrl->redirect($this, "redirectQuestion");
00575 }
00576
00584 function resume()
00585 {
00586 $this->readFullSequence();
00587 $this->handleStartCommands();
00588 $this->ctrl->setParameter($this, "activecommand", "resume");
00589 $this->ctrl->redirect($this, "redirectQuestion");
00590 }
00591
00599 function handleStartCommands()
00600 {
00601 global $ilUser;
00602
00603
00604 $active_time_id = $this->object->startWorkingTime($ilUser->id);
00605 $_SESSION["active_time_id"] = $active_time_id;
00606
00607 if ($_POST["chb_javascript"])
00608 {
00609 $ilUser->setPref("tst_javascript", 1);
00610 $ilUser->writePref("tst_javascript", 1);
00611 }
00612 else
00613 {
00614 $ilUser->setPref("tst_javascript", 0);
00615 $ilUser->writePref("tst_javascript", 0);
00616 }
00617
00618
00619 if ($this->object->getNrOfTries() != 1)
00620 {
00621 if ($this->object->getHidePreviousResults() != 1)
00622 {
00623 if ($_POST["chb_hide_previous_results"])
00624 {
00625 $ilUser->setPref("tst_hide_previous_results", 1);
00626 $ilUser->writePref("tst_hide_previous_results", 1);
00627 }
00628 else
00629 {
00630 $ilUser->setPref("tst_hide_previous_results", 0);
00631 $ilUser->writePref("tst_hide_previous_results", 0);
00632 }
00633 }
00634 }
00635
00636 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
00637 {
00638 global $ilias;
00639 $ilias->auth->setIdle(0, false);
00640 }
00641 }
00642
00643 function redirectQuestion()
00644 {
00645 global $ilUser;
00646 include_once "./assessment/classes/class.ilObjTest.php";
00647 switch ($_GET["activecommand"])
00648 {
00649 case "next":
00650 $this->sequence = $this->calculateSequence();
00651
00652
00653
00654
00655
00656 $questioncount = ilObjTest::_getQuestionCount($this->object->getTestId(), $ilUser->getId());
00657 if ($this->sequence > $questioncount)
00658
00659 {
00660 if ($this->object->isOnlineTest())
00661 {
00662 $this->outTestSummary();
00663 }
00664 else
00665 {
00666 $this->ctrl->redirect($this, "finishTest");
00667 }
00668 }
00669 else
00670 {
00671 $this->object->setActiveTestUser($this->sequence);
00672 $this->outTestPage();
00673 }
00674 break;
00675 case "previous":
00676 $this->sequence = $this->calculateSequence();
00677 $this->object->setActiveTestUser($this->sequence);
00678 if (!$this->sequence)
00679 {
00680 $this->ctrl->redirect($this, "outIntroductionPage");
00681 }
00682 else
00683 {
00684 $this->outTestPage();
00685 }
00686 break;
00687 case "postpone":
00688 $this->sequence = $this->calculateSequence();
00689 $postpone = $this->sequence;
00690 $this->object->setActiveTestUser($this->sequence, $postpone);
00691 $this->outTestPage();
00692 break;
00693 case "setsolved":
00694 $this->sequence = $this->calculateSequence();
00695 $this->object->setActiveTestUser($this->sequence);
00696 $q_id = $this->object->getQuestionIdFromActiveUserSequence($_GET["sequence"]);
00697 $this->object->setQuestionSetSolved(1, $q_id, $ilUser->getId());
00698 $this->outTestPage();
00699 break;
00700 case "resetsolved":
00701 $this->sequence = $this->calculateSequence();
00702 $this->object->setActiveTestUser($this->sequence);
00703 $q_id = $this->object->getQuestionIdFromActiveUserSequence($_GET["sequence"]);
00704 $this->object->setQuestionSetSolved(0, $q_id, $ilUser->getId());
00705 $this->outTestPage();
00706 break;
00707 case "directfeedback":
00708 $this->sequence = $this->calculateSequence();
00709 $this->object->setActiveTestUser($this->sequence);
00710 $this->outTestPage();
00711 break;
00712 case "selectImagemapRegion":
00713 $this->sequence = $this->calculateSequence();
00714 $this->object->setActiveTestUser($this->sequence);
00715 $this->outTestPage();
00716 break;
00717 case "summary":
00718 $this->ctrl->redirect($this, "outTestSummary");
00719 break;
00720 case "start":
00721 case "resume":
00722 $this->sequence = $this->calculateSequence();
00723 $this->object->setActiveTestUser($this->sequence);
00724 if ($this->object->isOnlineTest())
00725 {
00726 $this->outTestSummary();
00727 }
00728 else
00729 {
00730 $this->outTestPage();
00731 }
00732 break;
00733 default:
00734 $this->sequence = $this->calculateSequence();
00735 $this->object->setActiveTestUser($this->sequence);
00736 $this->outTestPage();
00737 break;
00738 }
00739 }
00740
00741 function calculateSequence()
00742 {
00743 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
00744 {
00745 if ($this->object->isActiveTestSubmitted()) return "";
00746 }
00747 $sequence = $_GET["sequence"];
00748 if (!$sequence) $sequence = 1;
00749 if ($_GET["save_error"] != 1)
00750 {
00751 switch ($_GET["activecommand"])
00752 {
00753 case "next":
00754 if($_GET['crs_show_result'])
00755 {
00756 $sequence = $this->getNextSequenceByResult($sequence);
00757 }
00758 else
00759 {
00760 $sequence++;
00761 }
00762 break;
00763 case "previous":
00764 if($_GET['crs_show_result'])
00765 {
00766 $sequence = $this->getPreviousSequenceByResult($sequence);
00767 }
00768 else
00769 {
00770 $sequence--;
00771 }
00772 break;
00773 }
00774 }
00775
00776 if ($_GET['crs_show_result'])
00777 {
00778 if(isset($_SESSION['crs_sequence'][0]))
00779 {
00780 $sequence = max($sequence,$_SESSION['crs_sequence'][0]);
00781 }
00782 else
00783 {
00784 $sequence = max($sequence,$this->object->getFirstSequence());
00785 }
00786 }
00787 return $sequence;
00788 }
00789
00797 function next()
00798 {
00799 global $ilUser;
00800 $this->saveQuestionSolution();
00801 $this->ctrl->setParameter($this, "activecommand", "next");
00802 $this->ctrl->redirect($this, "redirectQuestion");
00803 }
00804
00812 function previous()
00813 {
00814 $this->saveQuestionSolution();
00815 $this->ctrl->setParameter($this, "activecommand", "previous");
00816 $this->ctrl->redirect($this, "redirectQuestion");
00817 }
00818
00826 function postpone()
00827 {
00828 $this->saveQuestionSolution();
00829 $this->ctrl->setParameter($this, "activecommand", "postpone");
00830 $this->ctrl->redirect($this, "redirectQuestion");
00831 }
00832
00840 function summary()
00841 {
00842 $this->saveQuestionSolution();
00843 $this->ctrl->setParameter($this, "activecommand", "summary");
00844 $this->ctrl->redirect($this, "redirectQuestion");
00845 }
00846
00854 function setsolved()
00855 {
00856 $this->saveQuestionSolution();
00857 $this->ctrl->setParameter($this, "activecommand", "setsolved");
00858 $this->ctrl->redirect($this, "redirectQuestion");
00859 }
00860
00868 function resetsolved()
00869 {
00870 $this->saveQuestionSolution();
00871 $this->ctrl->setParameter($this, "activecommand", "resetsolved");
00872 $this->ctrl->redirect($this, "redirectQuestion");
00873 }
00874
00882 function directfeedback()
00883 {
00884 $this->saveQuestionSolution();
00885 $this->ctrl->setParameter($this, "activecommand", "directfeedback");
00886 $this->ctrl->redirect($this, "redirectQuestion");
00887 }
00888
00896 function selectImagemapRegion()
00897 {
00898 $this->saveQuestionSolution();
00899 $activecommand = "selectImagemapRegion";
00900 if (array_key_exists("cmd", $_POST))
00901 {
00902 $activecommand = key($_POST["cmd"]);
00903 }
00904 $this->ctrl->setParameter($this, "activecommand", $activecommand);
00905 $this->ctrl->redirect($this, "redirectQuestion");
00906 }
00907
00915 function gotoQuestion()
00916 {
00917 $this->sequence = $this->getSequence();
00918 $this->object->setActiveTestUser($this->sequence);
00919 $this->outTestPage();
00920 }
00921
00929 function backFromSummary()
00930 {
00931 $this->gotoQuestion();
00932 }
00933
00941 function confirmFinish()
00942 {
00943 $this->finishTest(false);
00944 }
00945
00953 function confirmFinishTest()
00954 {
00955 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish_confirmation.html", true);
00956 $this->tpl->setVariable("FINISH_QUESTION", $this->lng->txt("tst_finish_confirmation_question"));
00957 $this->tpl->setVariable("BUTTON_CONFIRM", $this->lng->txt("tst_finish_confirm_button"));
00958 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("tst_finish_confirm_cancel_button"));
00959 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00960 $this->tpl->parseCurrentBlock();
00961 }
00962
00970 function finishTest($confirm = true)
00971 {
00972 global $ilUser;
00973
00974 unset($_SESSION["tst_next"]);
00975
00976 $actualpass = $this->object->_getPass($ilUser->id, $this->object->getTestId());
00977 if (($confirm) && ($actualpass == $this->object->getNrOfTries() - 1))
00978 {
00979
00980 return $this->confirmFinishTest();
00981 }
00982 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
00983 {
00984
00985 $maxpass = $this->object->getNrOfTries();
00986 if (($maxpass == 0) || (($actualpass+1) < ($maxpass)))
00987 {
00988 $this->object->generateRandomQuestions($actualpass+1);
00989 }
00990 }
00991
00992 if ($this->object->isOnlineTest() && !$this->object->isActiveTestSubmitted($ilUser->getId()))
00993 {
00994 $this->outTestSummary();
00995 return;
00996 }
00997
00998 $this->object->setActiveTestUser(1, "", true);
00999
01000
01001 if (!$this->object->canViewResults())
01002 {
01003 $this->outIntroductionPage($maxprocessingtimereached);
01004 }
01005 else
01006 {
01007 $this->outResults();
01008 }
01009
01010 include_once './course/classes/class.ilCourseObjectiveResult.php';
01011 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
01012 $tmp_obj_res->updateResults($this->object->getTestResult($ilUser->getId()));
01013 unset($tmp_obj_res);
01014
01015 if($_GET['crs_show_result'])
01016 {
01017 $this->ctrl->redirectByClass("ilobjtestgui", "backToCourse");
01018 }
01019 }
01020
01028 function outTestPage()
01029 {
01030 global $rbacsystem;
01031
01032 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_output.html", true);
01033 if (!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01034 {
01035
01036 $this->ilias->raiseError($this->lng->txt("cannot_execute_test"),$this->ilias->error_obj->MESSAGE);
01037 }
01038
01039 $this->prepareRequestVariables();
01040
01041 $this->onRunObjectEnter();
01042
01043
01044 $this->updateWorkingTime();
01045
01046 if ($this->isMaxProcessingTimeReached())
01047 {
01048 $this->maxProcessingTimeReached();
01049 return;
01050 }
01051
01052 if ($this->isEndingTimeReached())
01053 {
01054 $this->endingTimeReached();
01055 return;
01056 }
01057
01058 if ($this->object->getScoreReporting() == REPORT_AFTER_QUESTION)
01059 {
01060 $this->tpl->setCurrentBlock("direct_feedback");
01061 $this->tpl->setVariable("TEXT_DIRECT_FEEDBACK", $this->lng->txt("direct_feedback"));
01062 $this->tpl->parseCurrentBlock();
01063 }
01064
01065
01066
01067 if ($this->sequence == $this->object->getQuestionCount())
01068 {
01069 $finish = true;
01070 }
01071 else
01072 {
01073 $finish = false;
01074 }
01075
01076 $postpone = false;
01077
01078 if ($this->object->getSequenceSettings() == TEST_POSTPONE)
01079 {
01080 $postpone = true;
01081 }
01082
01083 $active = $this->object->getActiveTestUser();
01084
01085 $user_question_order =& $this->object->getAllQuestionsForActiveUser();
01086 $this->outShortResult($user_question_order);
01087
01088 if ($this->object->getEnableProcessingTime())
01089 {
01090 $this->outProcessingTime();
01091 }
01092
01093 $this->tpl->setVariable("FORM_TIMESTAMP", time());
01094 $directfeedback = 0;
01095 if (strcmp($_GET["activecommand"], "directfeedback") == 0) $directfeedback = 1;
01096 $this->outWorkingForm($this->sequence, $finish, $this->object->getTestId(), $active, $postpone, $user_question_order, $directfeedback, $show_summary);
01097 }
01098
01102 function prepareRequestVariables()
01103 {
01104 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
01105 {
01106 if ($_GET["sort_summary"])
01107
01108 $_POST["cmd"]["summary"]="1";
01109
01110 if ($_POST["cmd"]["cancel_show_answers"])
01111 {
01112
01113 if ($this->isTestAccessible())
01114 {
01115 $_POST["cmd"]["summary"]="1";
01116 }
01117 else
01118 {
01119 $_POST["cmd"]["run"]="1";
01120 unset($_GET ["sequence"]);
01121 }
01122 }
01123
01124 if ($_POST["cmd"]["show_answers"] or $_POST["cmd"]["back"] or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"])
01125 {
01126 unset($_GET ["sort_summary"]);
01127 unset($_GET ["setsolved"]);
01128 unset($_GET ["resetsolved"]);
01129 if ($_POST["cmd"]["show_answers"] or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"])
01130 unset($_GET ["sequence"]);
01131 }
01132 }
01133 else
01134 {
01135
01136 if ($_GET["sortres"])
01137 $_POST["cmd"]["showresults"] = 1;
01138 }
01139 }
01140
01144 function onRunObjectEnter()
01145 {
01146
01147 if ($_POST["cmd"]["cancelTest"])
01148 {
01149 $this->handleCancelCommand();
01150 }
01151
01152 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
01153 {
01154 $this->checkOnlineTestAccess();
01155 }
01156 }
01157
01163 function checkOnlineTestAccess()
01164 {
01165 global $ilUser;
01166
01167
01168 $user = $this->object->getInvitedUsers($ilUser->getId());
01169 if (!is_array ($user) || count($user)!=1)
01170 {
01171 sendInfo($this->lng->txt("user_not_invited"), true);
01172 $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01173 }
01174
01175 $user = array_pop($user);
01176
01177 if (strcmp($user->clientip,"")!=0 && strcmp($user->clientip,$_SERVER["REMOTE_ADDR"])!=0)
01178 {
01179 sendInfo($this->lng->txt("user_wrong_clientip"), true);
01180 $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01181 }
01182 }
01183
01188 function getSequence()
01189 {
01190 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
01191 {
01192 if ($this->object->isActiveTestSubmitted()) return "";
01193 }
01194 $sequence = $_GET["sequence"];
01195 if (!$sequence) $sequence = 1;
01196 $saveResult = $this->saveResult;
01197 if (isset($_POST["cmd"]["next"]) && $saveResult == true)
01198 {
01199 if($_GET['crs_show_result'])
01200 {
01201 $sequence = $this->getNextSequenceByResult($sequence);
01202 }
01203 else
01204 {
01205 $sequence++;
01206 }
01207 }
01208 elseif (($_POST["cmd"]["previous"]) and ($sequence != 0) and ($saveResult))
01209 {
01210 if($_GET['crs_show_result'])
01211 {
01212 $sequence = $this->getPreviousSequenceByResult($sequence);
01213 }
01214 else
01215 {
01216 $sequence--;
01217 }
01218 }
01219 elseif($_GET['crs_show_result'])
01220 {
01221 if(isset($_SESSION['crs_sequence'][0]))
01222 {
01223 $sequence = max($sequence,$_SESSION['crs_sequence'][0]);
01224 }
01225 else
01226 {
01227 $sequence = max($sequence,$this->object->getFirstSequence());
01228 }
01229 }
01230 return $sequence;
01231 }
01232
01233 function readFullSequence()
01234 {
01235 global $ilUser;
01236
01237 $results = $this->object->getTestResult($ilUser->getId());
01238
01239 $_SESSION['crs_sequence'] = array();
01240 for($i = $this->object->getFirstSequence();
01241 $i <= $this->object->getQuestionCount();
01242 $i++)
01243 {
01244 $qid = $this->object->getQuestionIdFromActiveUserSequence($i);
01245
01246 foreach($results as $result)
01247 {
01248 if($qid == $result['qid'])
01249 {
01250 if(!$result['max'] or $result['max'] != $result['reached'])
01251 {
01252 $_SESSION['crs_sequence'][] = $i;
01253 }
01254 }
01255 }
01256 }
01257 return true;
01258 }
01259
01260 function getNextSequenceByResult($a_sequence)
01261 {
01262 if(!is_array($_SESSION['crs_sequence']))
01263 {
01264 return 1;
01265 }
01266 $counter = 0;
01267 foreach($_SESSION['crs_sequence'] as $sequence)
01268 {
01269 if($sequence == $a_sequence)
01270 {
01271 if($_SESSION['crs_sequence'][$counter+1])
01272 {
01273 return $_SESSION['crs_sequence'][$counter+1];
01274 }
01275 else
01276 {
01277 return $this->object->getQuestionCount() + 1;
01278 }
01279 }
01280 ++$counter;
01281 }
01282 return $this->object->getQuestionCount() + 1;
01283 }
01284
01285 function getPreviousSequenceByResult($a_sequence)
01286 {
01287 if(!is_array($_SESSION['crs_sequence']))
01288 {
01289 return 0;
01290 }
01291 $counter = 0;
01292 foreach($_SESSION['crs_sequence'] as $sequence)
01293 {
01294 if($sequence == $a_sequence)
01295 {
01296 if($_SESSION['crs_sequence'][$counter-1])
01297 {
01298 return $_SESSION['crs_sequence'][$counter-1];
01299 }
01300 else
01301 {
01302 return 0;
01303 }
01304 }
01305 ++$counter;
01306 }
01307 return 0;
01308 }
01309
01314 function isTestAccessible()
01315 {
01316 return !$this->isNrOfTriesReached()
01317 and !$this->isMaxProcessingTimeReached()
01318 and $this->object->startingTimeReached()
01319 and !$this->isEndingTimeReached();
01320 }
01321
01325 function isNrOfTriesReached()
01326 {
01327 $active = $this->object->getActiveTestUser();
01328 return $this->object->hasNrOfTriesRestriction() && is_object($active) && $this->object->isNrOfTriesReached($active->tries);
01329 }
01330
01335 function isTestResumable()
01336 {
01337 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
01338 {
01339 if ($this->object->isActiveTestSubmitted()) return false;
01340 }
01341
01342 $active = $this->object->getActiveTestUser();
01343 return is_object($active) && $this->object->startingTimeReached() && !$this->object->endingTimeReached();
01344 }
01345
01350 function handleCancelCommand()
01351 {
01352 sendInfo($this->lng->txt("test_cancelled"), true);
01353 $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01354 }
01355
01359 function showTestResults()
01360 {
01361 return $_GET['crs_show_result'];
01362 }
01363
01364 function outResults()
01365 {
01366 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
01367 {
01368 $this->outResultsOverview();
01369 }
01370 else
01371 {
01372 $this->outTestResults();
01373 }
01374 }
01375
01383 function outResultsOverview()
01384 {
01385 global $ilUser;
01386
01387 if ($this->object->getTestType() != TYPE_VARYING_RANDOMTEST)
01388 {
01389 $this->ctrl->redirect($this, "outIntroductionPage");
01390 }
01391 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish.html", true);
01392 $this->tpl->addBlockFile("TEST_RESULTS", "results", "tpl.il_as_tst_varying_results.html", true);
01393 $user_id = $ilUser->id;
01394 $color_class = array("tblrow1", "tblrow2");
01395 $counter = 0;
01396 include_once "./assessment/classes/class.ilObjTest.php";
01397 $counted_pass = ilObjTest::_getResultPass($ilUser->id, $this->object->getTestId());
01398 $reached_pass = $this->object->_getPass($ilUser->id, $this->object->getTestId());
01399 $result_percentage = 0;
01400 $result_total_reached = 0;
01401 $result_total_max = 0;
01402 for ($pass = 0; $pass <= $reached_pass; $pass++)
01403 {
01404 $finishdate = $this->object->getPassFinishDate($ilUser->id, $this->object->getTestId(), $pass);
01405 if ($finishdate > 0)
01406 {
01407 $result_array =& $this->object->getTestResult($user_id, $pass);
01408 if (!$result_array["test"]["total_max_points"])
01409 {
01410 $percentage = 0;
01411 }
01412 else
01413 {
01414 $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
01415 }
01416 $total_max = $result_array["test"]["total_max_points"];
01417 $total_reached = $result_array["test"]["total_reached_points"];
01418 $this->tpl->setCurrentBlock("result_row");
01419 if ($pass == $counted_pass)
01420 {
01421 $this->tpl->setVariable("COLOR_CLASS", "tblrowmarked");
01422 $result_percentage = $percentage;
01423 $result_total_reached = $total_reached;
01424 $result_total_max = $total_max;
01425 }
01426 else
01427 {
01428 $this->tpl->setVariable("COLOR_CLASS", $color_class[$pass % 2]);
01429 }
01430 $this->tpl->setVariable("VALUE_PASS", $pass + 1);
01431 $this->tpl->setVariable("VALUE_DATE", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($finishdate), "date"));
01432 $this->tpl->setVariable("VALUE_ANSWERED", $this->object->getAnsweredQuestionCount($ilUser->id, $this->object->getTestId(), $pass) . " " . strtolower($this->lng->txt("of")) . " " . (count($result_array)-1));
01433 $this->tpl->setVariable("VALUE_REACHED", $total_reached . " " . strtolower($this->lng->txt("of")) . " " . $total_max);
01434 $this->tpl->setVariable("VALUE_PERCENTAGE", sprintf("%.2f", $percentage) . "%");
01435 if ($this->object->canViewResults())
01436 {
01437 $this->tpl->setVariable("HREF_PASS_DETAILS", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "passDetails")."&pass=$pass\">" . $this->lng->txt("tst_pass_details") . "</a>");
01438 }
01439 $this->tpl->parseCurrentBlock();
01440 }
01441 }
01442 $this->tpl->setCurrentBlock("results");
01443 $this->tpl->setVariable("PASS_COUNTER", $this->lng->txt("pass"));
01444 $this->tpl->setVariable("DATE", $this->lng->txt("date"));
01445 $this->tpl->setVariable("ANSWERED_QUESTIONS", $this->lng->txt("tst_answered_questions"));
01446 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
01447 $this->tpl->setVariable("PERCENTAGE_CORRECT", $this->lng->txt("tst_percent_solved"));
01448 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01449 $this->tpl->setVariable("BACK_TO_INTRODUCTION", $this->lng->txt("tst_results_back_introduction"));
01450 $this->tpl->parseCurrentBlock();
01451 $this->tpl->setCurrentBlock("test_user_name");
01452 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name"), $ilUser->getFullname()));
01453 $this->tpl->parseCurrentBlock();
01454
01455 if ($this->object->canViewResults())
01456 {
01457 $mark_obj = $this->object->mark_schema->get_matching_mark($result_percentage);
01458 if ($mark_obj)
01459 {
01460 if ($mark_obj->get_passed())
01461 {
01462 $mark = $this->lng->txt("tst_result_congratulations");
01463 }
01464 else
01465 {
01466 $mark = $this->lng->txt("tst_result_sorry");
01467 }
01468 $mark .= "<br />" . $this->lng->txt("tst_your_mark_is") . ": "" . $mark_obj->get_official_name() . """;
01469 }
01470 if ($this->object->ects_output)
01471 {
01472 $ects_mark = $this->object->getECTSGrade($result_total_reached, $result_total_max);
01473 $mark .= "<br />" . $this->lng->txt("tst_your_ects_mark_is") . ": "" . $ects_mark . "" (" . $this->lng->txt("ects_grade_". strtolower($ects_mark) . "_short") . ": " . $this->lng->txt("ects_grade_". strtolower($ects_mark)) . ")";
01474 }
01475 $this->tpl->setVariable("USER_FEEDBACK", $mark);
01476 }
01477
01478 $this->tpl->setCurrentBlock("adm_content");
01479 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01480 $this->tpl->parseCurrentBlock();
01481 }
01482
01490 function passDetails()
01491 {
01492 if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
01493 {
01494 $this->ctrl->saveParameter($this, "pass");
01495 $this->outTestResults(false, $_GET["pass"]);
01496 }
01497 else
01498 {
01499 $this->outTestResults(false);
01500 }
01501 }
01502
01510 function outTestResults($print = false, $pass = NULL)
01511 {
01512 global $ilUser;
01513
01514 function sort_percent($a, $b) {
01515 if (strcmp($_GET["order"], "ASC")) {
01516 $smaller = 1;
01517 $greater = -1;
01518 } else {
01519 $smaller = -1;
01520 $greater = 1;
01521 }
01522 if ($a["percent"] == $b["percent"]) {
01523 if ($a["nr"] == $b["nr"]) return 0;
01524 return ($a["nr"] < $b["nr"]) ? -1 : 1;
01525 }
01526 $apercent = 0.0;
01527 if ($a["max"] != 0)
01528 {
01529 $apercent = $a["reached"] / $a["max"];
01530 }
01531 $bpercent = 0.0;
01532 if ($b["max"] != 0)
01533 {
01534 $bpercent = $b["reached"] / $b["max"];
01535 }
01536 return ($apercent < $bpercent) ? $smaller : $greater;
01537 }
01538
01539 function sort_nr($a, $b) {
01540 if (strcmp($_GET["order"], "ASC")) {
01541 $smaller = 1;
01542 $greater = -1;
01543 } else {
01544 $smaller = -1;
01545 $greater = 1;
01546 }
01547 if ($a["nr"] == $b["nr"]) return 0;
01548 return ($a["nr"] < $b["nr"]) ? $smaller : $greater;
01549 }
01550
01551 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish.html", true);
01552 $user_id = $ilUser->id;
01553 $color_class = array("tblrow1", "tblrow2");
01554 $counter = 0;
01555 $this->tpl->addBlockFile("TEST_RESULTS", "results", "tpl.il_as_tst_results.html", true);
01556 $result_array =& $this->object->getTestResult($user_id, $pass);
01557
01558 if (!$result_array["test"]["total_max_points"])
01559 {
01560 $percentage = 0;
01561 }
01562 else
01563 {
01564 $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
01565 }
01566 $total_max = $result_array["test"]["total_max_points"];
01567 $total_reached = $result_array["test"]["total_reached_points"];
01568 $img_title_percent = "";
01569 $img_title_nr = "";
01570 switch ($_GET["sortres"]) {
01571 case "percent":
01572 usort($result_array, "sort_percent");
01573 $img_title_percent = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
01574 if (strcmp($_GET["order"], "ASC") == 0)
01575 {
01576 $sortpercent = "DESC";
01577 }
01578 else
01579 {
01580 $sortpercent = "ASC";
01581 }
01582 break;
01583 case "nr":
01584 usort($result_array, "sort_nr");
01585 $img_title_nr = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
01586 if (strcmp($_GET["order"], "ASC") == 0)
01587 {
01588 $sortnr = "DESC";
01589 }
01590 else
01591 {
01592 $sortnr = "ASC";
01593 }
01594 break;
01595 }
01596 if (!$sortpercent) {
01597 $sortpercent = "ASC";
01598 }
01599 if (!$sortnr) {
01600 $sortnr = "ASC";
01601 }
01602
01603 foreach ($result_array as $key => $value) {
01604 if (preg_match("/\d+/", $key)) {
01605 $this->tpl->setCurrentBlock("question");
01606 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01607 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
01608 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "outEvaluationForm") . "&evaluation=" . $value["qid"] . "\">" . $value["title"] . "</a>");
01609 $this->tpl->setVariable("VALUE_MAX_POINTS", $value["max"]);
01610 $this->tpl->setVariable("VALUE_REACHED_POINTS", $value["reached"]);
01611 if ((preg_match("/http/", $value["solution"])) || (preg_match("/goto/", $value["solution"])))
01612 {
01613 $this->tpl->setVariable("SOLUTION_HINT", "<a href=\"".$value["solution"]."\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a>");
01614 }
01615 else
01616 {
01617 if ($value["solution"])
01618 {
01619 $this->tpl->setVariable("SOLUTION_HINT", $this->lng->txt($value["solution"]));
01620 }
01621 else
01622 {
01623 $this->tpl->setVariable("SOLUTION_HINT", "");
01624 }
01625 }
01626 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", $value["percent"]);
01627 $this->tpl->parseCurrentBlock();
01628 $counter++;
01629 }
01630 }
01631
01632 $this->tpl->setCurrentBlock("footer");
01633 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", "<strong>" . $this->lng->txt("total") . "</strong>");
01634 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "");
01635 $this->tpl->setVariable("SOLUTION_HINT", "");
01636 $this->tpl->setVariable("VALUE_MAX_POINTS", "<strong>" . sprintf("%d", $total_max) . "</strong>");
01637 $this->tpl->setVariable("VALUE_REACHED_POINTS", "<strong>" . sprintf("%d", $total_reached) . "</strong>");
01638 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", "<strong>" . sprintf("%2.2f", $percentage) . " %" . "</strong>");
01639 $this->tpl->parseCurrentBlock();
01640
01641 $this->tpl->setCurrentBlock("results");
01642 $this->tpl->setVariable("QUESTION_COUNTER", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "passDetails") . "&sortres=nr&order=$sortnr\">" . $this->lng->txt("tst_question_no") . "</a>$img_title_nr");
01643 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
01644 $this->tpl->setVariable("SOLUTION_HINT_HEADER", $this->lng->txt("solution_hint"));
01645 $this->tpl->setVariable("MAX_POINTS", $this->lng->txt("tst_maximum_points"));
01646 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
01647 $this->tpl->setVariable("PERCENT_SOLVED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "passDetails") . "&sortres=percent&order=$sortpercent\">" . $this->lng->txt("tst_percent_solved") . "</a>$img_title_percent");
01648 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01649 if ($this->object->getTestType() != TYPE_VARYING_RANDOMTEST)
01650 {
01651 $mark_obj = $this->object->mark_schema->get_matching_mark($percentage);
01652 if ($mark_obj)
01653 {
01654 if ($mark_obj->get_passed())
01655 {
01656 $mark = $this->lng->txt("tst_result_congratulations");
01657 }
01658 else
01659 {
01660 $mark = $this->lng->txt("tst_result_sorry");
01661 }
01662 $mark .= "<br />" . $this->lng->txt("tst_your_mark_is") . ": "" . $mark_obj->get_official_name() . """;
01663 }
01664 if ($this->object->ects_output)
01665 {
01666 $ects_mark = $this->object->getECTSGrade($total_reached, $total_max);
01667 $mark .= "<br />" . $this->lng->txt("tst_your_ects_mark_is") . ": "" . $ects_mark . "" (" . $this->lng->txt("ects_grade_". strtolower($ects_mark) . "_short") . ": " . $this->lng->txt("ects_grade_". strtolower($ects_mark)) . ")";
01668 }
01669 $this->tpl->setVariable("USER_FEEDBACK", $mark);
01670 }
01671 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
01672 {
01673 $this->tpl->setVariable("BACK_TO_OVERVIEW", $this->lng->txt("tst_results_back_overview"));
01674 }
01675 else
01676 {
01677 $this->tpl->setVariable("BACK_TO_OVERVIEW", $this->lng->txt("tst_results_back_introduction"));
01678 }
01679 $this->tpl->parseCurrentBlock();
01680 $this->tpl->setCurrentBlock("test_user_name");
01681 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name"), $ilUser->getFullname()));
01682 $this->tpl->parseCurrentBlock();
01683
01684 $this->tpl->setCurrentBlock("adm_content");
01685 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01686 $this->tpl->parseCurrentBlock();
01687 }
01688
01689 function outEvaluationForm()
01690 {
01691 global $ilUser;
01692
01693 $this->ctrl->saveParameter($this, "pass");
01694 include_once("classes/class.ilObjStyleSheet.php");
01695 $this->tpl->setCurrentBlock("ContentStyle");
01696 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
01697 $this->tpl->parseCurrentBlock();
01698
01699
01700 $this->tpl->setCurrentBlock("SyntaxStyle");
01701 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01702 ilObjStyleSheet::getSyntaxStylePath());
01703 $this->tpl->parseCurrentBlock();
01704
01705 $test_id = $this->object->getTestId();
01706 $question_gui = $this->object->createQuestionGUI("", $_GET["evaluation"]);
01707 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_evaluation.html", true);
01708
01709 switch ($question_gui->getQuestionType())
01710 {
01711 case "qt_imagemap":
01712 $question_gui->outWorkingForm($test_id, "", 1, $formaction);
01713 break;
01714 case "qt_javaapplet":
01715 $question_gui->outWorkingForm("", "", 0);
01716 break;
01717 default:
01718 $question_gui->outWorkingForm($test_id, "", 1);
01719 }
01720
01721 $this->tpl->setCurrentBlock("adm_content");
01722 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01723 $this->tpl->setVariable("BACKLINK_TEXT", "<< " . $this->lng->txt("back"));
01724 $this->tpl->parseCurrentBlock();
01725 }
01726
01734 function show_answers()
01735 {
01736 global $ilUser;
01737 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_answers_sheet_details.html", true);
01738 $this->outShowAnswersDetails($ilUser->getId(), true);
01739 }
01740
01748 function showAnswersOfUser()
01749 {
01750 global $ilUser;
01751 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_answers_sheet_details.html", true);
01752 $this->tpl->setCurrentBlock("generic_css");
01753 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./assessment/templates/default/test_print.css");
01754 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
01755 $this->tpl->parseCurrentBlock();
01756 $this->tpl->setCurrentBlock("navigation_buttons");
01757 $this->tpl->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
01758 $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
01759 $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
01760 $this->tpl->parseCurrentBlock();
01761 $invited_user =& $this->object->getInvitedUsers($ilUser->getId());
01762 $pagetitle = $this->object->getTitle() . " - " . $this->lng->txt("clientip") .
01763 ": " . $invited_user[$ilUser->getId()]->clientip . " - " .
01764 $this->lng->txt("matriculation") . ": " .
01765 $invited_user[$ilUser->getId()]->matriculation;
01766 $this->tpl->setVariable("PAGETITLE", $pagetitle);
01767 $this->outShowAnswersDetails($ilUser->getId());
01768 }
01769
01777 function outShowAnswersDetails($user_id, $isForm = false)
01778 {
01779 $active = $this->object->getActiveTestUser($user_id);
01780 $t = $active->submittimestamp;
01781 include_once "./classes/class.ilObjUser.php";
01782 $ilUser = new ilObjUser($user_id);
01783
01784 if (strlen($ilUser->getMatriculation()))
01785 {
01786 $this->tpl->setCurrentBlock("user_matric");
01787 $this->tpl->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
01788 $this->tpl->parseCurrentBlock();
01789 $this->tpl->setCurrentBlock("user_matric_value");
01790 $this->tpl->setVariable("VALUE_USR_MATRIC", $ilUser->getMatriculation());
01791 $this->tpl->parseCurrentBlock();
01792 $this->tpl->touchBlock("user_matric_separator");
01793 }
01794
01795 $invited_users = array_pop($this->object->getInvitedUsers($ilUser->getId()));
01796 if (strlen($invited_users->clientip))
01797 {
01798 $this->tpl->setCurrentBlock("user_clientip");
01799 $this->tpl->setVariable("TXT_CLIENT_IP", $this->lng->txt("matriculation"));
01800 $this->tpl->parseCurrentBlock();
01801 $this->tpl->setCurrentBlock("user_clientip_value");
01802 $this->tpl->setVariable("VALUE_CLIENT_IP", $invited_users->clientip);
01803 $this->tpl->parseCurrentBlock();
01804 $this->tpl->touchBlock("user_clientip_separator");
01805 }
01806
01807 include_once "./classes/class.ilUtil.php";
01808
01809
01810 if ($active->submitted)
01811 {
01812
01813 $this->tpl->setCurrentBlock("freefield_bottom");
01814 $this->tpl->setVariable("TXT_DATE", $this->lng->txt("date"));
01815 $this->tpl->setVariable("VALUE_DATE", strftime("%Y-%m-%d %H:%M:%S", ilUtil::date_mysql2time($t)));
01816
01817 $freefieldtypes = array(
01818 "freefield_bottom" => array(
01819 array(
01820 "title" => $this->lng->txt("tst_signature"),
01821 "length" => 300
01822 )
01823 )
01824 );
01825
01826 foreach ($freefieldtypes as $type => $freefields)
01827 {
01828 $counter = 0;
01829 while ($counter < count($freefields))
01830 {
01831 $freefield = $freefields[$counter];
01832 $this->tpl->setVariable("TXT_FREE_FIELD", $freefield["title"]);
01833 $this->tpl->setVariable("IMG_SPACER", ilUtil::getImagePath("spacer.gif"));
01834 $counter ++;
01835 }
01836 }
01837 $this->tpl->parseCurrentBlock();
01838 }
01839
01840 $counter = 1;
01841
01842 foreach ($this->object->questions as $question)
01843 {
01844 $this->tpl->setCurrentBlock("question");
01845 $question_gui = $this->object->createQuestionGUI("", $question);
01846
01847 $this->tpl->setVariable("COUNTER_QUESTION", $counter.". ");
01848 $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
01849
01850 $idx = $this->object->getTestId();
01851
01852 switch ($question_gui->getQuestionType())
01853 {
01854 case "qt_imagemap" :
01855 $question_gui->outWorkingForm($idx, false, $show_solutions=false, $formaction, $show_question_page=false, $show_solution_only = false, $ilUser, $pass = NULL, $mixpass = true);
01856 break;
01857 case "qt_javaapplet" :
01858 $question_gui->outWorkingForm("", $is_postponed = false, $showsolution = 0, $show_question_page=false, $show_solution_only = false, $ilUser, $pass = NULL, $mixpass = true);
01859 break;
01860 default :
01861 $question_gui->outWorkingForm($idx, $is_postponed = false, $showsolution = 0, $show_question_page=false, $show_solution_only = false, $ilUser, $pass = NULL, $mixpass = true);
01862 }
01863 $this->tpl->parseCurrentBlock();
01864 $counter ++;
01865 }
01866
01867
01868 if ($isForm && !$active->submitted)
01869 {
01870 $this->tpl->setCurrentBlock("confirm");
01871 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("tst_submit_answers_txt"));
01872 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("back"));
01873 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_answers"));
01874 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01875 $this->tpl->parseCurrentBlock();
01876 }
01877
01878 $this->tpl->setCurrentBlock("answer_sheet");
01879 $this->tpl->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
01880 $this->tpl->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
01881 $this->tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers"));
01882 $this->tpl->setVariable("TITLE", $this->object->getTitle());
01883 $this->tpl->setVariable("TXT_ANSWER_SHEET", $this->lng->txt("tst_answer_sheet"));
01884
01885 $this->tpl->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
01886 $this->tpl->setVariable("VALUE_USR_NAME", $ilUser->getLastname().", ".$ilUser->getFirstname());
01887 $this->tpl->parseCurrentBlock();
01888 }
01889
01895 function endingTimeReached()
01896 {
01897 sendInfo(sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime())));
01898 $this->object->setActiveTestUser(1, "", true);
01899 if (!$this->object->canViewResults())
01900 {
01901 $this->outIntroductionPage();
01902 }
01903 else
01904 {
01905 if ($this->object->isOnlineTest())
01906 $this->outTestSummary();
01907 else
01908 $this->outResults();
01909 }
01910 }
01911
01919 function maxProcessingTimeReached()
01920 {
01921 $this->outIntroductionPage();
01922 }
01923
01929 function confirmSubmitAnswers()
01930 {
01931 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_submit_answers_confirm.html", true);
01932 $this->tpl->setCurrentBlock("adm_content");
01933 if ($this->object->isActiveTestSubmitted())
01934 {
01935 $this->tpl->setCurrentBlock("not_submit_allowed");
01936 $this->tpl->setVariable("TEXT_ALREADY_SUBMITTED", $this->lng->txt("tst_already_submitted"));
01937 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_show_answer_sheet"));
01938 } else
01939 {
01940 $this->tpl->setCurrentBlock("submit_allowed");
01941 $this->tpl->setVariable("TEXT_CONFIRM_SUBMIT_RESULTS", $this->lng->txt("tst_confirm_submit_answers"));
01942 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_results"));
01943 }
01944 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
01945 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01946 $this->tpl->parseCurrentBlock();
01947 }
01948
01949 function outProcessingTime()
01950 {
01951 global $ilUser;
01952
01953 $starting_time = $this->object->getStartingTimeOfUser($ilUser->getId());
01954 $processing_time = $this->object->getProcessingTimeInSeconds();
01955 $processing_time_minutes = floor($processing_time / 60);
01956 $processing_time_seconds = $processing_time - $processing_time_minutes * 60;
01957 $str_processing_time = "";
01958 if ($processing_time_minutes > 0)
01959 {
01960 $str_processing_time = $processing_time_minutes . " " . $this->lng->txt("minutes");
01961 }
01962 if ($processing_time_seconds > 0)
01963 {
01964 if (strlen($str_processing_time) > 0) $str_processing_time .= " " . $this->lng->txt("and") . " ";
01965 $str_processing_time .= $processing_time_seconds . " " . $this->lng->txt("seconds");
01966 }
01967 $time_left = $starting_time + $processing_time - mktime();
01968 $time_left_minutes = floor($time_left / 60);
01969 $time_left_seconds = $time_left - $time_left_minutes * 60;
01970 $str_time_left = "";
01971 if ($time_left_minutes > 0)
01972 {
01973 $str_time_left = $time_left_minutes . " " . $this->lng->txt("minutes");
01974 }
01975 if ($time_left_seconds > 0)
01976 {
01977 if (strlen($str_time_left) > 0) $str_time_left .= " " . $this->lng->txt("and") . " ";
01978 $str_time_left .= $time_left_seconds . " " . $this->lng->txt("seconds");
01979 }
01980 $date = getdate($starting_time);
01981 $this->tpl->setCurrentBlock("enableprocessingtime");
01982 $this->tpl->setVariable("USER_WORKING_TIME",
01983 sprintf($this->lng->txt("tst_time_already_spent"),
01984 ilFormat::formatDate(
01985 $date["year"]."-".
01986 sprintf("%02d", $date["mon"])."-".
01987 sprintf("%02d", $date["mday"])." ".
01988 sprintf("%02d", $date["hours"]).":".
01989 sprintf("%02d", $date["minutes"]).":".
01990 sprintf("%02d", $date["seconds"])
01991 ),
01992 $str_processing_time,
01993 $str_time_left
01994 )
01995 );
01996 $this->tpl->parseCurrentBlock();
01997 }
01998
02004 function outTestSummary()
02005 {
02006 global $ilUser;
02007
02008
02009 if (is_numeric($_GET["set_solved"]) && is_numeric($_GET["question_id"]))
02010 {
02011 $this->object->setQuestionSetSolved($_GET["set_solved"] , $_GET["question_id"], $ilUser->getId());
02012 }
02013
02014 function sort_title($a, $b)
02015 {
02016 if (strcmp($_GET["order"], "ASC"))
02017 {
02018 $smaller = 1;
02019 $greater = -1;
02020 }
02021 else
02022 {
02023 $smaller = -1;
02024 $greater = 1;
02025 }
02026 if ($a["nr"] == $b["nr"]) return 0;
02027 if (strcmp($a["title"],$b["title"])< 0)
02028 return $smaller;
02029 else if (strcmp($a["title"],$b["title"])> 0)
02030 return $greater;
02031 return 0;
02032 }
02033
02034 function sort_nr($a, $b)
02035 {
02036 if (strcmp($_GET["order"], "ASC"))
02037 {
02038 $smaller = 1;
02039 $greater = -1;
02040 }
02041 else
02042 {
02043 $smaller = -1;
02044 $greater = 1;
02045 }
02046 if ($a["nr"] == $b["nr"]) return 0;
02047 return ($a["nr"] < $b["nr"]) ? $smaller : $greater;
02048 }
02049
02050 function sort_visited($a, $b)
02051 {
02052 if (strcmp($_GET["order"], "ASC"))
02053 {
02054 $smaller = 1;
02055 $greater = -1;
02056 }
02057 else
02058 {
02059 $smaller = -1;
02060 $greater = 1;
02061 }
02062 if ($a["nr"] == $b["nr"])
02063 return 0;
02064 return ($a["visited"] < $b["visited"]) ? $smaller : $greater;
02065 }
02066
02067
02068 function sort_solved($a, $b)
02069 {
02070 if (strcmp($_GET["order"], "ASC"))
02071 {
02072 $smaller = 1;
02073 $greater = -1;
02074 }
02075 else
02076 {
02077 $smaller = -1;
02078 $greater = 1;
02079 }
02080 if ($a["nr"] == $b["nr"]) return 0;
02081 return ($a["solved"] < $b["solved"]) ? $smaller : $greater;
02082 }
02083
02084 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_summary.html", true);
02085 $user_id = $ilUser->id;
02086 $color_class = array ("tblrow1", "tblrow2");
02087 $counter = 0;
02088
02089 $result_array = & $this->object->getTestSummary($user_id);
02090
02091 $img_title_nr = "";
02092 $img_title_title = "";
02093 $img_title_solved = "";
02094
02095 if (!$_GET["sort_summary"] )
02096 {
02097 $_GET["sort_summary"] = "nr";
02098 $_GET["order"] = "ASC";
02099 }
02100
02101 switch ($_GET["sort_summary"])
02102 {
02103 case nr:
02104 usort($result_array, "sort_nr");
02105 $img_title_nr = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
02106 if (strcmp($_GET["order"], "ASC") == 0)
02107 {
02108 $sortnr = "DESC";
02109 }
02110 else
02111 {
02112 $sortnr = "ASC";
02113 }
02114 break;
02115
02116 case "title":
02117 usort($result_array, "sort_title");
02118 $img_title_title = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
02119 if (strcmp($_GET["order"], "ASC") == 0)
02120 {
02121 $sorttitle = "DESC";
02122 }
02123 else
02124 {
02125 $sorttitle = "ASC";
02126 }
02127 break;
02128 case "solved":
02129 usort($result_array, "sort_solved");
02130 $img_title_solved = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
02131 if (strcmp($_GET["order"], "ASC") == 0)
02132 {
02133 $sortsolved = "DESC";
02134 }
02135 else
02136 {
02137 $sortsolved = "ASC";
02138 }
02139 break;
02140 }
02141 if (!$sorttitle)
02142 {
02143 $sorttitle = "ASC";
02144 }
02145 if (!$sortsolved)
02146 {
02147 $sortsolved = "ASC";
02148 }
02149 if (!$sortnr)
02150 {
02151 $sortnr = "ASC";
02152 }
02153
02154 $img_solved = " <img border=\"0\" align=\"middle\" src=\"" . ilUtil::getImagePath("solved.png", true) . "\" alt=\"".$this->lng->txt("tst_click_to_change_state")."\" />";
02155 $img_not_solved = " <img border=\"0\" align=\"middle\" src=\"" . ilUtil::getImagePath("not_solved.png", true) . "\" alt=\"".$this->lng->txt("tst_click_to_change_state")."\" />";
02156 $goto_question = " <img border=\"0\" align=\"middle\" src=\"" . ilUtil::getImagePath("goto_question.png", true) . "\" alt=\"".$this->lng->txt("tst_qst_goto")."\" />";
02157
02158 $disabled = $this->isMaxProcessingTimeReached() | $this->object->endingTimeReached();
02159
02160 foreach ($result_array as $key => $value)
02161 {
02162 if (preg_match("/\d+/", $key))
02163 {
02164 $this->tpl->setCurrentBlock("question");
02165 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
02166 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
02167 $this->tpl->setVariable("VALUE_QUESTION_TITLE", $value["title"]);
02168 $this->tpl->setVariable("VALUE_QUESTION_SOLVED", ($value["solved"] > 0) ?$img_solved : $img_not_solved);
02169 if (!$disabled)
02170 {
02171 $this->ctrl->setParameter($this, "sequence", $value["nr"]);
02172 $this->tpl->setVariable("VALUE_QUESTION_HREF_GOTO", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "gotoQuestion")."\">");
02173 $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
02174 }
02175 $this->tpl->setVariable("VALUE_QUESTION_GOTO", $goto_question);
02176 $solvedvalue = (($value["solved"]) ? "0" : "1");
02177 $this->tpl->setVariable("VALUE_QUESTION_HREF_SET_SOLVED", $this->ctrl->getLinkTargetByClass(get_class($this), "outTestSummary")."&order=".$_GET["order"]."&sort_summary=".$_GET["sort_summary"]."&set_solved=" . $solvedvalue."&question_id=".$value["qid"]);
02178 $this->tpl->setVariable("VALUE_QUESTION_SET_SOLVED", ($value["solved"] > 0) ?$this->lng->txt("tst_qst_resetsolved"):$this->lng->txt("tst_qst_setsolved"));
02179 $this->tpl->setVariable("VALUE_QUESTION_DESCRIPTION", $value["description"]);
02180 $this->tpl->setVariable("VALUE_QUESTION_POINTS", $value["points"]." ".$this->lng->txt("points_short"));
02181 $this->tpl->parseCurrentBlock();
02182 $counter ++;
02183 }
02184 }
02185
02186 if (!$disabled)
02187 {
02188 $this->tpl->setCurrentBlock("back");
02189 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02190 $this->tpl->parseCurrentBlock();
02191 }
02192 else
02193 {
02194 sendinfo($this->lng->txt("detail_max_processing_time_reached"));
02195 }
02196
02197 $this->tpl->setVariable("QUESTION_COUNTER","<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "outTestSummary")."&order=$sortnr&sort_summary=nr\">".$this->lng->txt("tst_qst_order")."</a>".$img_title_nr);
02198 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "outTestSummary")."&order=$sorttitle&sort_summary=title\">".$this->lng->txt("tst_question_title")."</a>".$img_title_title);
02199 $this->tpl->setVariable("QUESTION_SOLVED", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "outTestSummary")."&order=$sortsolved&sort_summary=solved\">".$this->lng->txt("tst_question_solved_state")."</a>".$img_title_solved);
02200 $this->tpl->setVariable("QUESTION_POINTS", $this->lng->txt("tst_maximum_points"));
02201 $this->tpl->setVariable("USER_FEEDBACK", $this->lng->txt("tst_qst_summary_text"));
02202 $this->tpl->setVariable("TXT_SHOW_AND_SUBMIT_ANSWERS", $this->lng->txt("save_finish"));
02203 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02204 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("summary"));
02205
02206 if ($this->object->getEnableProcessingTime())
02207 $this->outProcessingTime();
02208 }
02209
02210 function finalSubmission()
02211 {
02212 global $ilias, $ilUser;
02213
02214 $this->object->setActiveTestSubmitted($ilUser->id);
02215 $ilias->auth->setIdle($ilias->ini->readVariable("session","expire"), false);
02216 $ilias->auth->setExpire(0);
02217 $this->outIntroductionPage();
02218 }
02219
02220 }
02221 ?>