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 $active = $this->object->getActiveTestUser($ilUser->getId());
00150 if ($this->object->isRandomTest())
00151 {
00152 $pass = $this->object->_getPass($active->active_id);
00153 }
00154 $this->saveResult = $question_gui->object->saveWorkingData($active->active_id, $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_SELF_ASSESSMENT);
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->redirectByClass("ilobjtestgui", "infoScreen");
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
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
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
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
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 include_once("classes/class.ilObjStyleSheet.php");
00325 $this->tpl->setCurrentBlock("ContentStyle");
00326 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00327 ilObjStyleSheet::getContentStylePath(0));
00328 $this->tpl->parseCurrentBlock();
00329
00330 $this->tpl->setCurrentBlock("SyntaxStyle");
00331 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00332 ilObjStyleSheet::getSyntaxStylePath());
00333 $this->tpl->parseCurrentBlock();
00334 $question_gui = $this->object->createQuestionGUI("", $this->object->getQuestionIdFromActiveUserSequence($sequence));
00335 if ($ilUser->prefs["tst_javascript"])
00336 {
00337 $question_gui->object->setOutputType(OUTPUT_JAVASCRIPT);
00338 }
00339
00340 $is_postponed = false;
00341 if (is_object($active))
00342 {
00343 if (!preg_match("/(^|\D)" . $question_gui->object->getId() . "($|\D)/", $active->postponed) and
00344 !($active->postponed == $question_gui->object->getId()))
00345 {
00346 $is_postponed = false;
00347 }
00348 else
00349 {
00350 $is_postponed = true;
00351 }
00352 }
00353
00354 $this->ctrl->setParameter($this, "sequence", "$sequence");
00355 $formaction = $this->ctrl->getFormAction($this, "redirectQuestion");
00356
00357 if($_GET['crs_show_result'])
00358 {
00359 $question_gui->setSequenceNumber(array_search($sequence,(array) $_SESSION['crs_sequence']) + 1);
00360 $question_gui->setQuestionCount(count($_SESSION['crs_sequence']));
00361 }
00362 else
00363 {
00364 $question_gui->setSequenceNumber($sequence);
00365 $question_gui->setQuestionCount(ilObjTest::_getQuestionCount($this->object->getTestId()));
00366 }
00367
00368 $user_post_solution = FALSE;
00369 if (array_key_exists("previouspost", $_SESSION))
00370 {
00371 $user_post_solution = $_SESSION["previouspost"];
00372 unset($_SESSION["previouspost"]);
00373 }
00374 $active = $this->object->getActiveTestUser($ilUser->getId());
00375 $question_gui->outQuestionForTest($formaction, $active->active_id, NULL, $is_postponed, $user_post_solution);
00376 if ($directfeedback)
00377 {
00378 if ($this->object->getShowSolutionDetails())
00379 {
00380 $solutionoutput = $question_gui->getSolutionOutput("", NULL, FALSE, FALSE, FALSE);
00381 $this->tpl->setCurrentBlock("solution_output");
00382 $this->tpl->setVariable("CORRECT_SOLUTION", $this->lng->txt("correct_solution_is"));
00383 $this->tpl->setVariable("QUESTION_FEEDBACK", $solutionoutput);
00384 $this->tpl->setVariable("RECEIVED_POINTS_INFORMATION", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->calculateReachedPoints($active->active_id, NULL), $question_gui->object->getMaximumPoints()));
00385 $this->tpl->parseCurrentBlock();
00386 }
00387 else
00388 {
00389 $this->tpl->setCurrentBlock("solution_output");
00390 $this->tpl->setVariable("RECEIVED_POINTS_INFORMATION", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->calculateReachedPoints($active->active_id, NULL), $question_gui->object->getMaximumPoints()));
00391 $this->tpl->parseCurrentBlock();
00392 }
00393 }
00394
00395
00396
00397 if($_GET['crs_show_result'])
00398 {
00399 $first_sequence = $_SESSION['crs_sequence'][0] ? $_SESSION['crs_sequence'][0] : 1;
00400 }
00401 else
00402 {
00403 $first_sequence = 1;
00404 }
00405 if ($sequence == $first_sequence)
00406 {
00407 $this->tpl->setCurrentBlock("prev");
00408 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_introduction"));
00409 $this->tpl->parseCurrentBlock();
00410 $this->tpl->setCurrentBlock("prev_bottom");
00411 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_introduction"));
00412 $this->tpl->parseCurrentBlock();
00413 }
00414 else
00415 {
00416 $this->tpl->setCurrentBlock("prev");
00417 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_previous"));
00418 $this->tpl->parseCurrentBlock();
00419 $this->tpl->setCurrentBlock("prev_bottom");
00420 $this->tpl->setVariable("BTN_PREV", "<< " . $this->lng->txt("save_previous"));
00421 $this->tpl->parseCurrentBlock();
00422 }
00423
00424 if ($postpone_allowed)
00425 {
00426 if (!$is_postponed)
00427 {
00428 $this->tpl->setCurrentBlock("postpone");
00429 $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
00430 $this->tpl->parseCurrentBlock();
00431 $this->tpl->setCurrentBlock("postpone_bottom");
00432 $this->tpl->setVariable("BTN_POSTPONE", $this->lng->txt("postpone"));
00433 $this->tpl->parseCurrentBlock();
00434 }
00435 }
00436
00437 if (($this->object->isOnlineTest() && !$finish) || ($this->object->getShowSummary() && !$this->object->isOnlineTest()))
00438 {
00439 $this->tpl->setCurrentBlock("summary");
00440 $this->tpl->setVariable("BTN_SUMMARY", $this->lng->txt("question_summary"));
00441 $this->tpl->parseCurrentBlock();
00442 $this->tpl->setCurrentBlock("summary_bottom");
00443 $this->tpl->setVariable("BTN_SUMMARY", $this->lng->txt("question_summary"));
00444 $this->tpl->parseCurrentBlock();
00445 }
00446
00447 if (!$this->object->isOnlineTest())
00448 {
00449 $this->tpl->setCurrentBlock("cancel_test");
00450 $this->tpl->setVariable("TEXT_CANCELTEST", $this->lng->txt("cancel_test"));
00451 $this->tpl->setVariable("TEXT_ALTCANCELTEXT", $this->lng->txt("cancel_test"));
00452 $this->tpl->setVariable("TEXT_TITLECANCELTEXT", $this->lng->txt("cancel_test"));
00453 $this->tpl->setVariable("HREF_IMGCANCELTEST", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00454 $this->tpl->setVariable("HREF_CANCELTEXT", $this->ctrl->getLinkTargetByClass(get_class($this), "outIntroductionPage") . "&cancelTest=true");
00455 $this->tpl->setVariable("IMAGE_CANCEL", ilUtil::getImagePath("cancel.gif"));
00456 $this->tpl->parseCurrentBlock();
00457 }
00458
00459 if ($finish)
00460 {
00461 if (!$this->object->isOnlineTest())
00462 {
00463 $this->tpl->setCurrentBlock("next");
00464 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " >>");
00465 $this->tpl->parseCurrentBlock();
00466 $this->tpl->setCurrentBlock("next_bottom");
00467 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_finish") . " >>");
00468 $this->tpl->parseCurrentBlock();
00469 }
00470 else
00471 {
00472 $this->tpl->setCurrentBlock("next");
00473 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("question_summary") . " >>");
00474 $this->tpl->parseCurrentBlock();
00475 $this->tpl->setCurrentBlock("next_bottom");
00476 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("question_summary") . " >>");
00477 $this->tpl->parseCurrentBlock();
00478 }
00479 }
00480 else
00481 {
00482 $this->tpl->setCurrentBlock("next");
00483 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " >>");
00484 $this->tpl->parseCurrentBlock();
00485 $this->tpl->setCurrentBlock("next_bottom");
00486 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("save_next") . " >>");
00487 $this->tpl->parseCurrentBlock();
00488 }
00489
00490 if ($this->object->isOnlineTest())
00491 {
00492 include_once "./assessment/classes/class.ilObjTest.php";
00493 $solved_array = ilObjTest::_getSolvedQuestions($active->active_id, $question_gui->object->getId());
00494 $solved = 0;
00495
00496 if (count ($solved_array) > 0)
00497 {
00498 $solved = array_pop($solved_array);
00499 $solved = $solved->solved;
00500 }
00501
00502 if ($solved==1)
00503 {
00504 $solved = ilUtil::getImagePath("solved.png", true);
00505 $solved_cmd = "resetsolved";
00506 $solved_txt = $this->lng->txt("tst_qst_resetsolved");
00507 }
00508 else
00509 {
00510 $solved = ilUtil::getImagePath("not_solved.png", true);
00511 $solved_cmd = "setsolved";
00512 $solved_txt = $this->lng->txt("tst_qst_setsolved");
00513 }
00514 $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>";
00515
00516 $this->tpl->setCurrentBlock("question_status");
00517 $this->tpl->setVariable("TEXT_QUESTION_STATUS_LABEL", $this->lng->txt("tst_question_solved_state").":");
00518 $this->tpl->setVariable("TEXT_QUESTION_STATUS", $solved);
00519 $this->tpl->parseCurrentBlock();
00520 }
00521
00522 $this->tpl->setCurrentBlock("adm_content");
00523
00524 $this->tpl->parseCurrentBlock();
00525 }
00526
00534 function showPasswordProtectionPage()
00535 {
00536 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_password_protection.html", true);
00537 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "checkPassword"));
00538 $this->tpl->setVariable("PASSWORD_INTRODUCTION", $this->lng->txt("tst_password_introduction"));
00539 $this->tpl->setVariable("TEXT_PASSWORD", $this->lng->txt("tst_password"));
00540 $this->tpl->setVariable("SUBMIT", $this->lng->txt("submit"));
00541 $this->tpl->parseCurrentBlock();
00542 }
00543
00551 function checkPassword()
00552 {
00553 if (strcmp($this->object->getPassword(), $_POST["password"]) == 0)
00554 {
00555 global $ilUser;
00556 $ilUser->setPref("tst_password_".$this->object->getTestId(), $this->object->getPassword());
00557 $ilUser->writePref("tst_password_".$this->object->getTestId(), $this->object->getPassword());
00558 $active_time_id = $this->object->startWorkingTime($ilUser->id);
00559 $_SESSION["active_time_id"] = $active_time_id;
00560 $this->ctrl->redirect($this, "start");
00561 }
00562 else
00563 {
00564 sendInfo($this->lng->txt("tst_password_entered_wrong_password"), true);
00565 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00566 }
00567 }
00568
00569 function setAnonymousId()
00570 {
00571 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00572 {
00573 $this->object->setAccessCodeSession($_POST["anonymous_id"]);
00574 }
00575 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00576 }
00577
00586 function start()
00587 {
00588 global $ilLog;
00589
00590
00591 if (strcmp($_SESSION["lock"], $_POST["lock"]) != 0)
00592 {
00593
00594 $_SESSION["lock"] = $_POST["lock"];
00595
00596 $this->handleStartCommands();
00597 $this->ctrl->redirect($this, "startTest");
00598 }
00599 else
00600 {
00601
00602 $this->ctrl->redirectByClass("ilobjtestgui", "redirectToInfoScreen");
00603 }
00604 }
00605
00613 function startTest()
00614 {
00615 global $ilLog;
00616 $ilLog->write("startTest");
00617 if ($this->object->checkMaximumAllowedUsers() == FALSE)
00618 {
00619 return $this->showMaximumAllowedUsersReachedMessage();
00620 }
00621 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00622 {
00623 $this->object->setAccessCodeSession($this->object->createNewAccessCode());
00624 }
00625 else
00626 {
00627 $this->object->unsetAccessCodeSession();
00628 }
00629 if (strlen($this->object->getPassword()))
00630 {
00631 global $ilUser;
00632 global $rbacsystem;
00633
00634 $pwd = $ilUser->getPref("tst_password_".$this->object->getTestId());
00635
00636 if ((strcmp($pwd, $this->object->getPassword()) != 0) && (!$rbacsystem->checkAccess("write", $this->object->getRefId())))
00637 {
00638 return $this->showPasswordProtectionPage();
00639 }
00640 }
00641 if ($this->object->isRandomTest())
00642 {
00643 $this->object->generateRandomQuestions();
00644 $this->object->loadQuestions();
00645 }
00646 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
00647 {
00648 $this->ctrl->redirect($this, "displayCode");
00649 }
00650 else
00651 {
00652 $this->ctrl->setParameter($this, "activecommand", "start");
00653 $this->ctrl->redirect($this, "redirectQuestion");
00654 }
00655 }
00656
00657 function displayCode()
00658 {
00659 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_anonymous_code_presentation.html", true);
00660 $this->tpl->setCurrentBlock("adm_content");
00661 $this->tpl->setVariable("TEXT_ANONYMOUS_CODE_CREATED", $this->lng->txt("tst_access_code_created"));
00662 $this->tpl->setVariable("TEXT_ANONYMOUS_CODE", $this->object->getAccessCodeSession());
00663 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00664 $this->tpl->setVariable("CONTINUE", $this->lng->txt("continue_work"));
00665 $this->tpl->parseCurrentBlock();
00666 }
00667
00668 function codeConfirmed()
00669 {
00670 $this->ctrl->setParameter($this, "activecommand", "start");
00671 $this->ctrl->redirect($this, "redirectQuestion");
00672 }
00673
00681 function resume()
00682 {
00683 if ($this->object->checkMaximumAllowedUsers() == FALSE)
00684 {
00685 return $this->showMaximumAllowedUsersReachedMessage();
00686 }
00687 $this->handleStartCommands();
00688 $this->ctrl->setParameter($this, "activecommand", "resume");
00689 $this->ctrl->redirect($this, "redirectQuestion");
00690 }
00691
00699 function handleStartCommands()
00700 {
00701 global $ilUser;
00702
00703
00704 if (!strlen($this->object->getPassword()))
00705 {
00706 $active_time_id = $this->object->startWorkingTime($ilUser->id);
00707 $_SESSION["active_time_id"] = $active_time_id;
00708 }
00709
00710 if ($_POST["chb_javascript"])
00711 {
00712 $ilUser->setPref("tst_javascript", 1);
00713 $ilUser->writePref("tst_javascript", 1);
00714 }
00715 else
00716 {
00717 $ilUser->setPref("tst_javascript", 0);
00718 $ilUser->writePref("tst_javascript", 0);
00719 }
00720
00721
00722 if ($this->object->getNrOfTries() != 1)
00723 {
00724 if ($this->object->getHidePreviousResults() != 1)
00725 {
00726 if ($_POST["chb_hide_previous_results"])
00727 {
00728 $ilUser->setPref("tst_hide_previous_results", 1);
00729 $ilUser->writePref("tst_hide_previous_results", 1);
00730 }
00731 else
00732 {
00733 $ilUser->setPref("tst_hide_previous_results", 0);
00734 $ilUser->writePref("tst_hide_previous_results", 0);
00735 }
00736 }
00737 }
00738
00739 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
00740 {
00741 global $ilias;
00742 $ilias->auth->setIdle(0, false);
00743 }
00744 }
00745
00746 function redirectQuestion()
00747 {
00748 global $ilUser;
00749 include_once "./assessment/classes/class.ilObjTest.php";
00750 switch ($_GET["activecommand"])
00751 {
00752 case "next":
00753 $this->sequence = $this->calculateSequence();
00754
00755
00756
00757
00758
00759 $questioncount = ilObjTest::_getQuestionCount($this->object->getTestId());
00760 if ($this->sequence > $questioncount)
00761 {
00762 if ($this->object->isOnlineTest())
00763 {
00764 $this->outTestSummary();
00765 }
00766 else
00767 {
00768 $this->ctrl->redirect($this, "finishTest");
00769 }
00770 }
00771 else
00772 {
00773 $this->object->setActiveTestUser($this->sequence);
00774 $this->outTestPage();
00775 }
00776 break;
00777 case "previous":
00778 $this->sequence = $this->calculateSequence();
00779 $this->object->setActiveTestUser($this->sequence);
00780 if (!$this->sequence)
00781 {
00782 $this->ctrl->redirect($this, "outIntroductionPage");
00783 }
00784 else
00785 {
00786 $this->outTestPage();
00787 }
00788 break;
00789 case "postpone":
00790 $this->sequence = $this->calculateSequence();
00791 $postpone = $this->sequence;
00792 $this->object->setActiveTestUser($this->sequence, $postpone);
00793 $this->outTestPage();
00794 break;
00795 case "setsolved":
00796 $this->sequence = $this->calculateSequence();
00797 $this->object->setActiveTestUser($this->sequence);
00798 $q_id = $this->object->getQuestionIdFromActiveUserSequence($_GET["sequence"]);
00799 $this->object->setQuestionSetSolved(1, $q_id, $ilUser->getId());
00800 $this->outTestPage();
00801 break;
00802 case "resetsolved":
00803 $this->sequence = $this->calculateSequence();
00804 $this->object->setActiveTestUser($this->sequence);
00805 $q_id = $this->object->getQuestionIdFromActiveUserSequence($_GET["sequence"]);
00806 $this->object->setQuestionSetSolved(0, $q_id, $ilUser->getId());
00807 $this->outTestPage();
00808 break;
00809 case "directfeedback":
00810 $this->sequence = $this->calculateSequence();
00811 $this->object->setActiveTestUser($this->sequence);
00812 $this->outTestPage();
00813 break;
00814 case "selectImagemapRegion":
00815 $this->sequence = $this->calculateSequence();
00816 $this->object->setActiveTestUser($this->sequence);
00817 $this->outTestPage();
00818 break;
00819 case "summary":
00820 if ($this->object->isOnlineTest())
00821 {
00822 $this->ctrl->redirect($this, "outTestSummary");
00823 }
00824 else
00825 {
00826 $this->ctrl->redirect($this, "outQuestionSummary");
00827 }
00828 break;
00829 case "start":
00830 case "resume":
00831 $this->sequence = $this->calculateSequence();
00832 $this->object->setActiveTestUser($this->sequence);
00833 $this->readFullSequence();
00834 if ($this->object->isOnlineTest())
00835 {
00836 $this->outTestSummary();
00837 }
00838 else
00839 {
00840 $this->outTestPage();
00841 }
00842 break;
00843 case "back":
00844 case "gotoquestion":
00845 default:
00846 $this->sequence = $this->calculateSequence();
00847 $this->object->setActiveTestUser($this->sequence);
00848 $this->outTestPage();
00849 break;
00850 }
00851 }
00852
00853 function calculateSequence()
00854 {
00855 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
00856 {
00857 if ($this->object->isActiveTestSubmitted()) return "";
00858 }
00859 $sequence = $_GET["sequence"];
00860 $questionCount = $this->object->getQuestionCount();
00861 if ($sequence > $questionCount) $sequence = $questionCount;
00862 if (!$sequence) $sequence = 1;
00863 if (array_key_exists("save_error", $_GET))
00864 {
00865 if ($_GET["save_error"] == 1)
00866 {
00867 return $sequence;
00868 }
00869 }
00870 switch ($_GET["activecommand"])
00871 {
00872 case "next":
00873 if($_GET['crs_show_result'])
00874 {
00875 $sequence = $this->getNextSequenceByResult($sequence);
00876 }
00877 else
00878 {
00879 $sequence++;
00880 }
00881 break;
00882 case "previous":
00883 if($_GET['crs_show_result'])
00884 {
00885 $sequence = $this->getPreviousSequenceByResult($sequence);
00886 }
00887 else
00888 {
00889 $sequence--;
00890 }
00891 break;
00892 }
00893
00894 if ($_GET['crs_show_result'])
00895 {
00896 if(isset($_SESSION['crs_sequence'][0]))
00897 {
00898 $sequence = max($sequence,$_SESSION['crs_sequence'][0]);
00899 }
00900 else
00901 {
00902 $sequence = max($sequence,$this->object->getFirstSequence());
00903 }
00904 }
00905 return $sequence;
00906 }
00907
00915 function next()
00916 {
00917 $this->saveQuestionSolution();
00918 $this->ctrl->setParameter($this, "activecommand", "next");
00919 $this->ctrl->redirect($this, "redirectQuestion");
00920 }
00921
00929 function previous()
00930 {
00931 $this->saveQuestionSolution();
00932 $this->ctrl->setParameter($this, "activecommand", "previous");
00933 $this->ctrl->redirect($this, "redirectQuestion");
00934 }
00935
00943 function postpone()
00944 {
00945 $this->saveQuestionSolution();
00946 $this->ctrl->setParameter($this, "activecommand", "postpone");
00947 $this->ctrl->redirect($this, "redirectQuestion");
00948 }
00949
00957 function summary()
00958 {
00959 $this->saveQuestionSolution();
00960 if ($this->saveResult == FALSE)
00961 {
00962 $this->ctrl->setParameter($this, "activecommand", "");
00963 $this->ctrl->redirect($this, "redirectQuestion");
00964 }
00965 else
00966 {
00967 $this->ctrl->setParameter($this, "activecommand", "summary");
00968 $this->ctrl->redirect($this, "redirectQuestion");
00969 }
00970 }
00971
00979 function setsolved()
00980 {
00981 $this->saveQuestionSolution();
00982 $this->ctrl->setParameter($this, "activecommand", "setsolved");
00983 $this->ctrl->redirect($this, "redirectQuestion");
00984 }
00985
00993 function resetsolved()
00994 {
00995 $this->saveQuestionSolution();
00996 $this->ctrl->setParameter($this, "activecommand", "resetsolved");
00997 $this->ctrl->redirect($this, "redirectQuestion");
00998 }
00999
01007 function directfeedback()
01008 {
01009 $this->saveQuestionSolution();
01010 $this->ctrl->setParameter($this, "activecommand", "directfeedback");
01011 $this->ctrl->redirect($this, "redirectQuestion");
01012 }
01013
01021 function selectImagemapRegion()
01022 {
01023 $this->saveQuestionSolution();
01024 $activecommand = "selectImagemapRegion";
01025 if (array_key_exists("cmd", $_POST))
01026 {
01027 $activecommand = key($_POST["cmd"]);
01028 }
01029 $this->ctrl->setParameter($this, "activecommand", $activecommand);
01030 $this->ctrl->redirect($this, "redirectQuestion");
01031 }
01032
01040 function gotoQuestion()
01041 {
01042 $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
01043 $this->ctrl->setParameter($this, "activecommand", "gotoquestion");
01044 $this->ctrl->redirect($this, "redirectQuestion");
01045 }
01046
01054 function backFromSummary()
01055 {
01056 $this->ctrl->setParameter($this, "activecommand", "back");
01057 $this->ctrl->redirect($this, "redirectQuestion");
01058 }
01059
01067 function confirmFinish()
01068 {
01069 $this->finishTest(false);
01070 }
01071
01079 function confirmFinishTest()
01080 {
01081 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish_confirmation.html", true);
01082 $this->tpl->setVariable("FINISH_QUESTION", $this->lng->txt("tst_finish_confirmation_question"));
01083 $this->tpl->setVariable("BUTTON_CONFIRM", $this->lng->txt("tst_finish_confirm_button"));
01084 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("tst_finish_confirm_cancel_button"));
01085 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01086 $this->tpl->parseCurrentBlock();
01087 }
01088
01096 function finishTest($confirm = true)
01097 {
01098 global $ilUser;
01099
01100 unset($_SESSION["tst_next"]);
01101
01102 $active = $this->object->getActiveTestUser($ilUser->getId());
01103 $actualpass = $this->object->_getPass($active->active_id);
01104 if (($confirm) && ($actualpass == $this->object->getNrOfTries() - 1))
01105 {
01106
01107 return $this->confirmFinishTest();
01108 }
01109 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
01110 {
01111
01112 $maxpass = $this->object->getNrOfTries();
01113 if (($maxpass == 0) || (($actualpass+1) < ($maxpass)))
01114 {
01115 $this->object->generateRandomQuestions($actualpass+1);
01116 }
01117 }
01118
01119 if ($this->object->isOnlineTest() && !$this->object->isActiveTestSubmitted($ilUser->getId()))
01120 {
01121 $this->outTestSummary();
01122 return;
01123 }
01124
01125 $this->object->setActiveTestUser(1, "", true);
01126
01127
01128 if (!$this->object->canViewResults())
01129 {
01130 $this->outIntroductionPage($maxprocessingtimereached);
01131 }
01132 else
01133 {
01134 $this->outResults();
01135 }
01136
01137 if($_GET['crs_show_result'])
01138 {
01139 $this->ctrl->redirectByClass("ilobjtestgui", "backToCourse");
01140 }
01141 }
01142
01150 function outTestPage()
01151 {
01152 global $rbacsystem;
01153
01154 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_output.html", true);
01155 if (!$rbacsystem->checkAccess("read", $this->object->getRefId()))
01156 {
01157
01158 $this->ilias->raiseError($this->lng->txt("cannot_execute_test"),$this->ilias->error_obj->MESSAGE);
01159 }
01160
01161 $this->prepareRequestVariables();
01162
01163 $this->onRunObjectEnter();
01164
01165
01166 $this->updateWorkingTime();
01167
01168 if ($this->isMaxProcessingTimeReached())
01169 {
01170 $this->maxProcessingTimeReached();
01171 return;
01172 }
01173
01174 if ($this->isEndingTimeReached())
01175 {
01176 $this->endingTimeReached();
01177 return;
01178 }
01179
01180 if ($this->object->getInstantVerification() == 1)
01181 {
01182 $this->tpl->setCurrentBlock("direct_feedback");
01183 $this->tpl->setVariable("TEXT_DIRECT_FEEDBACK", $this->lng->txt("direct_feedback"));
01184 $this->tpl->parseCurrentBlock();
01185 }
01186
01187
01188
01189 if ($this->sequence == $this->object->getQuestionCount())
01190 {
01191 $finish = true;
01192 }
01193 else
01194 {
01195 $finish = false;
01196 }
01197
01198 $postpone = false;
01199
01200 if ($this->object->getSequenceSettings() == TEST_POSTPONE)
01201 {
01202 $postpone = true;
01203 }
01204
01205 $active = $this->object->getActiveTestUser();
01206
01207 $user_question_order =& $this->object->getAllQuestionsForActiveUser();
01208 $this->outShortResult($user_question_order);
01209
01210 if ($this->object->getEnableProcessingTime())
01211 {
01212 $this->outProcessingTime();
01213 }
01214
01215 $this->tpl->setVariable("FORM_TIMESTAMP", time());
01216 $directfeedback = 0;
01217 if (strcmp($_GET["activecommand"], "directfeedback") == 0) $directfeedback = 1;
01218 $this->outWorkingForm($this->sequence, $finish, $this->object->getTestId(), $active, $postpone, $user_question_order, $directfeedback, $show_summary);
01219 }
01220
01224 function prepareRequestVariables()
01225 {
01226 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
01227 {
01228 if ($_GET["sort_summary"])
01229
01230 $_POST["cmd"]["summary"]="1";
01231
01232 if ($_POST["cmd"]["cancel_show_answers"])
01233 {
01234
01235 if ($this->isTestAccessible())
01236 {
01237 $_POST["cmd"]["summary"]="1";
01238 }
01239 else
01240 {
01241 $_POST["cmd"]["run"]="1";
01242 unset($_GET ["sequence"]);
01243 }
01244 }
01245
01246 if ($_POST["cmd"]["show_answers"] or $_POST["cmd"]["back"] or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"])
01247 {
01248 unset($_GET ["sort_summary"]);
01249 unset($_GET ["setsolved"]);
01250 unset($_GET ["resetsolved"]);
01251 if ($_POST["cmd"]["show_answers"] or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"])
01252 unset($_GET ["sequence"]);
01253 }
01254 }
01255 else
01256 {
01257
01258 if ($_GET["sortres"])
01259 $_POST["cmd"]["showresults"] = 1;
01260 }
01261 }
01262
01266 function onRunObjectEnter()
01267 {
01268
01269 if ($_POST["cmd"]["cancelTest"])
01270 {
01271 $this->handleCancelCommand();
01272 }
01273
01274 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
01275 {
01276 $this->checkOnlineTestAccess();
01277 }
01278 }
01279
01285 function checkOnlineTestAccess()
01286 {
01287 global $ilUser;
01288
01289
01290 $user = $this->object->getInvitedUsers($ilUser->getId());
01291 if (!is_array ($user) || count($user)!=1)
01292 {
01293 sendInfo($this->lng->txt("user_not_invited"), true);
01294 $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01295 }
01296
01297 $user = array_pop($user);
01298
01299 if (strcmp($user->clientip,"")!=0 && strcmp($user->clientip,$_SERVER["REMOTE_ADDR"])!=0)
01300 {
01301 sendInfo($this->lng->txt("user_wrong_clientip"), true);
01302 $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01303 }
01304 }
01305
01306 function readFullSequence()
01307 {
01308 global $ilUser;
01309
01310 if(!$_GET['crs_show_result'])
01311 {
01312 return true;
01313 }
01314
01315 $_SESSION['crs_sequence'] = array();
01316 $active = $this->object->getActiveTestUser($ilUser->getId());
01317 $results = $this->object->getTestResult($active->active_id);
01318 for($i = $this->object->getFirstSequence();
01319 $i <= $this->object->getQuestionCount();
01320 $i++)
01321 {
01322 $qid = $this->object->getQuestionIdFromActiveUserSequence($i);
01323 foreach($results as $result)
01324 {
01325 if($qid == $result['qid'])
01326 {
01327 if(!$result['max'] or $result['max'] != $result['reached'])
01328 {
01329 $_SESSION['crs_sequence'][] = $i;
01330 }
01331 }
01332 }
01333 }
01334 $this->sequence = $_SESSION['crs_sequence'][0];
01335 $_SESSION['crs_sequence'] = array_unique($_SESSION['crs_sequence']);
01336 return true;
01337 }
01338
01339 function getNextSequenceByResult($a_sequence)
01340 {
01341 if(!is_array($_SESSION['crs_sequence']))
01342 {
01343 return 1;
01344 }
01345 $counter = 0;
01346 foreach($_SESSION['crs_sequence'] as $sequence)
01347 {
01348 if($sequence == $a_sequence)
01349 {
01350 if($_SESSION['crs_sequence'][$counter+1])
01351 {
01352 return $_SESSION['crs_sequence'][$counter+1];
01353 }
01354 else
01355 {
01356 return $this->object->getQuestionCount() + 1;
01357 }
01358 }
01359 ++$counter;
01360 }
01361 return $this->object->getQuestionCount() + 1;
01362 }
01363
01364 function getPreviousSequenceByResult($a_sequence)
01365 {
01366 if(!is_array($_SESSION['crs_sequence']))
01367 {
01368 return 0;
01369 }
01370 $counter = 0;
01371 foreach($_SESSION['crs_sequence'] as $sequence)
01372 {
01373 if($sequence == $a_sequence)
01374 {
01375 if($_SESSION['crs_sequence'][$counter-1])
01376 {
01377 return $_SESSION['crs_sequence'][$counter-1];
01378 }
01379 else
01380 {
01381 return 0;
01382 }
01383 }
01384 ++$counter;
01385 }
01386 return 0;
01387 }
01388
01393 function isTestAccessible()
01394 {
01395 return !$this->isNrOfTriesReached()
01396 and !$this->isMaxProcessingTimeReached()
01397 and $this->object->startingTimeReached()
01398 and !$this->isEndingTimeReached();
01399 }
01400
01404 function isNrOfTriesReached()
01405 {
01406 $active = $this->object->getActiveTestUser();
01407 return $this->object->hasNrOfTriesRestriction() && is_object($active) && $this->object->isNrOfTriesReached($active->tries);
01408 }
01409
01414 function isTestResumable()
01415 {
01416 if ($this->object->getTestType() == TYPE_ONLINE_TEST)
01417 {
01418 if ($this->object->isActiveTestSubmitted()) return false;
01419 }
01420
01421 $active = $this->object->getActiveTestUser();
01422 return is_object($active) && $this->object->startingTimeReached() && !$this->object->endingTimeReached();
01423 }
01424
01429 function handleCancelCommand()
01430 {
01431 sendInfo($this->lng->txt("test_cancelled"), true);
01432 $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository");
01433 }
01434
01438 function showTestResults()
01439 {
01440 return $_GET['crs_show_result'];
01441 }
01442
01443 function outResults()
01444 {
01445 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
01446 {
01447 $this->outResultsOverview();
01448 }
01449 else
01450 {
01451 $this->outTestResults();
01452 }
01453 }
01454
01462 function outResultsOverview()
01463 {
01464 global $ilUser;
01465
01466 if ($this->object->getTestType() != TYPE_VARYING_RANDOMTEST)
01467 {
01468 $this->ctrl->redirect($this, "outIntroductionPage");
01469 }
01470 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish.html", true);
01471 $this->tpl->addBlockFile("TEST_RESULTS", "results", "tpl.il_as_tst_varying_results.html", true);
01472 $user_id = $ilUser->id;
01473 $color_class = array("tblrow1", "tblrow2");
01474 $counter = 0;
01475 include_once "./assessment/classes/class.ilObjTest.php";
01476 $active = $this->object->getActiveTestUser($ilUser->getId());
01477 $counted_pass = ilObjTest::_getResultPass($active->active_id);
01478 $reached_pass = $this->object->_getPass($active->active_id);
01479 $result_percentage = 0;
01480 $result_total_reached = 0;
01481 $result_total_max = 0;
01482 for ($pass = 0; $pass <= $reached_pass; $pass++)
01483 {
01484 $finishdate = $this->object->getPassFinishDate($active->active_id, $pass);
01485 if ($finishdate > 0)
01486 {
01487 $result_array =& $this->object->getTestResult($active->active_id, $pass);
01488 if (!$result_array["test"]["total_max_points"])
01489 {
01490 $percentage = 0;
01491 }
01492 else
01493 {
01494 $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
01495 }
01496 $total_max = $result_array["test"]["total_max_points"];
01497 $total_reached = $result_array["test"]["total_reached_points"];
01498 $this->tpl->setCurrentBlock("result_row");
01499 if ($pass == $counted_pass)
01500 {
01501 $this->tpl->setVariable("COLOR_CLASS", "tblrowmarked");
01502 $this->tpl->setVariable("VALUE_SCORED", "⊗");
01503 $result_percentage = $percentage;
01504 $result_total_reached = $total_reached;
01505 $result_total_max = $total_max;
01506 }
01507 else
01508 {
01509 $this->tpl->setVariable("COLOR_CLASS", $color_class[$pass % 2]);
01510 }
01511 $this->tpl->setVariable("VALUE_PASS", $pass + 1);
01512 $this->tpl->setVariable("VALUE_DATE", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($finishdate), "date"));
01513 $this->tpl->setVariable("VALUE_ANSWERED", $this->object->getAnsweredQuestionCount($active->active_id, $pass) . " " . strtolower($this->lng->txt("of")) . " " . (count($result_array)-1));
01514 $this->tpl->setVariable("VALUE_REACHED", $total_reached . " " . strtolower($this->lng->txt("of")) . " " . $total_max);
01515 $this->tpl->setVariable("VALUE_PERCENTAGE", sprintf("%.2f", $percentage) . "%");
01516 if ($this->object->canViewResults())
01517 {
01518 $this->tpl->setVariable("HREF_PASS_DETAILS", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "passDetails")."&pass=$pass\">" . $this->lng->txt("tst_pass_details") . "</a>");
01519 }
01520 $this->tpl->parseCurrentBlock();
01521 }
01522 }
01523 $this->tpl->setCurrentBlock("results");
01524 $this->tpl->setVariable("PASS_SCORED", $this->lng->txt("scored_pass"));
01525 $this->tpl->setVariable("PASS_COUNTER", $this->lng->txt("pass"));
01526 $this->tpl->setVariable("DATE", $this->lng->txt("date"));
01527 $this->tpl->setVariable("ANSWERED_QUESTIONS", $this->lng->txt("tst_answered_questions"));
01528 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
01529 $this->tpl->setVariable("PERCENTAGE_CORRECT", $this->lng->txt("tst_percent_solved"));
01530 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01531 $this->tpl->setVariable("BACK_TO_INTRODUCTION", $this->lng->txt("tst_results_back_introduction"));
01532 $this->tpl->parseCurrentBlock();
01533 $this->tpl->setCurrentBlock("test_user_name");
01534 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name"), $ilUser->getFullname()));
01535 $this->tpl->parseCurrentBlock();
01536
01537 if ($this->object->canViewResults())
01538 {
01539 $mark_obj = $this->object->mark_schema->getMatchingMark($result_percentage);
01540 if ($mark_obj)
01541 {
01542 if ($mark_obj->getPassed())
01543 {
01544 $mark = $this->lng->txt("tst_result_congratulations");
01545 }
01546 else
01547 {
01548 $mark = $this->lng->txt("tst_result_sorry");
01549 }
01550 $mark .= "<br />" . $this->lng->txt("tst_your_mark_is") . ": "" . $mark_obj->getOfficialName() . """;
01551 }
01552 if ($this->object->ects_output)
01553 {
01554 $ects_mark = $this->object->getECTSGrade($result_total_reached, $result_total_max);
01555 $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)) . ")";
01556 }
01557 $this->tpl->setVariable("USER_FEEDBACK", $mark);
01558 }
01559
01560 $this->tpl->setCurrentBlock("adm_content");
01561 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01562 $this->tpl->parseCurrentBlock();
01563 }
01564
01572 function passDetails()
01573 {
01574 if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
01575 {
01576 $this->ctrl->saveParameter($this, "pass");
01577 $this->outTestResults(false, $_GET["pass"]);
01578 }
01579 else
01580 {
01581 $this->outTestResults(false);
01582 }
01583 }
01584
01592 function outTestResults($print = false, $pass = NULL)
01593 {
01594 global $ilUser;
01595
01596 function sort_percent($a, $b) {
01597 if (strcmp($_GET["order"], "ASC")) {
01598 $smaller = 1;
01599 $greater = -1;
01600 } else {
01601 $smaller = -1;
01602 $greater = 1;
01603 }
01604 if ($a["percent"] == $b["percent"]) {
01605 if ($a["nr"] == $b["nr"]) return 0;
01606 return ($a["nr"] < $b["nr"]) ? -1 : 1;
01607 }
01608 $apercent = 0.0;
01609 if ($a["max"] != 0)
01610 {
01611 $apercent = $a["reached"] / $a["max"];
01612 }
01613 $bpercent = 0.0;
01614 if ($b["max"] != 0)
01615 {
01616 $bpercent = $b["reached"] / $b["max"];
01617 }
01618 return ($apercent < $bpercent) ? $smaller : $greater;
01619 }
01620
01621 function sort_nr($a, $b) {
01622 if (strcmp($_GET["order"], "ASC")) {
01623 $smaller = 1;
01624 $greater = -1;
01625 } else {
01626 $smaller = -1;
01627 $greater = 1;
01628 }
01629 if ($a["nr"] == $b["nr"]) return 0;
01630 return ($a["nr"] < $b["nr"]) ? $smaller : $greater;
01631 }
01632
01633 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_finish.html", true);
01634 $user_id = $ilUser->id;
01635 $active = $this->object->getActiveTestUser($ilUser->getId());
01636 $color_class = array("tblrow1", "tblrow2");
01637 $counter = 0;
01638 $this->tpl->addBlockFile("TEST_RESULTS", "results", "tpl.il_as_tst_results.html", true);
01639 $result_array =& $this->object->getTestResult($active->active_id, $pass);
01640
01641 if (!$result_array["test"]["total_max_points"])
01642 {
01643 $percentage = 0;
01644 }
01645 else
01646 {
01647 $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
01648 }
01649 $total_max = $result_array["test"]["total_max_points"];
01650 $total_reached = $result_array["test"]["total_reached_points"];
01651 $img_title_percent = "";
01652 $img_title_nr = "";
01653 switch ($_GET["sortres"]) {
01654 case "percent":
01655 usort($result_array, "sort_percent");
01656 $img_title_percent = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
01657 if (strcmp($_GET["order"], "ASC") == 0)
01658 {
01659 $sortpercent = "DESC";
01660 }
01661 else
01662 {
01663 $sortpercent = "ASC";
01664 }
01665 break;
01666 case "nr":
01667 usort($result_array, "sort_nr");
01668 $img_title_nr = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
01669 if (strcmp($_GET["order"], "ASC") == 0)
01670 {
01671 $sortnr = "DESC";
01672 }
01673 else
01674 {
01675 $sortnr = "ASC";
01676 }
01677 break;
01678 }
01679 if (!$sortpercent) {
01680 $sortpercent = "ASC";
01681 }
01682 if (!$sortnr) {
01683 $sortnr = "ASC";
01684 }
01685
01686 foreach ($result_array as $key => $value)
01687 {
01688 if (preg_match("/\d+/", $key)) {
01689 $this->tpl->setCurrentBlock("question");
01690 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01691 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
01692 if ($this->object->isOnlineTest() || ($this->object->getShowSolutionDetails() == 0))
01693 $this->tpl->setVariable("VALUE_QUESTION_TITLE", $value["title"]);
01694 else
01695 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "outEvaluationForm") . "&evaluation=" . $value["qid"] . "\">" . $value["title"] . "</a>");
01696 $this->tpl->setVariable("VALUE_MAX_POINTS", $value["max"]);
01697 $this->tpl->setVariable("VALUE_REACHED_POINTS", $value["reached"]);
01698 if ((preg_match("/http/", $value["solution"])) || (preg_match("/goto/", $value["solution"])))
01699 {
01700 $this->tpl->setVariable("SOLUTION_HINT", "<a href=\"".$value["solution"]."\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a>");
01701 }
01702 else
01703 {
01704 if ($value["solution"])
01705 {
01706 $this->tpl->setVariable("SOLUTION_HINT", $this->lng->txt($value["solution"]));
01707 }
01708 else
01709 {
01710 $this->tpl->setVariable("SOLUTION_HINT", "");
01711 }
01712 }
01713 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", $value["percent"]);
01714 $this->tpl->parseCurrentBlock();
01715 $counter++;
01716 }
01717 }
01718
01719 $this->tpl->setCurrentBlock("footer");
01720 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", "<strong>" . $this->lng->txt("total") . "</strong>");
01721 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "");
01722 $this->tpl->setVariable("SOLUTION_HINT", "");
01723 $this->tpl->setVariable("VALUE_MAX_POINTS", "<strong>$total_max</strong>");
01724 $this->tpl->setVariable("VALUE_REACHED_POINTS", "<strong>$total_reached</strong>");
01725 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", "<strong>" . sprintf("%2.2f", $percentage) . " %" . "</strong>");
01726 $this->tpl->parseCurrentBlock();
01727
01728 if ($this->object->canShowSolutionPrintview($ilUser->getId()))
01729 {
01730 $counter = 1;
01731
01732 foreach ($result_array as $question_data)
01733 {
01734 $question = $question_data["qid"];
01735 if (is_numeric($question))
01736 {
01737 $this->tpl->setCurrentBlock("printview_question");
01738 $question_gui = $this->object->createQuestionGUI("", $question);
01739
01740 $this->tpl->setVariable("COUNTER_QUESTION", $counter.". ");
01741 $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
01742
01743 $active = $this->object->getActiveTestUser($ilUser->getId());
01744 $result_output = $question_gui->getSolutionOutput($active->active_id, $pass, FALSE, FALSE, FALSE);
01745 $this->tpl->setVariable("SOLUTION_OUTPUT", $result_output);
01746 $this->tpl->parseCurrentBlock();
01747 $counter ++;
01748 }
01749 }
01750 $this->tpl->setCurrentBlock("printview_details");
01751 $this->tpl->setVariable("RESULTS_OVERVIEW", $this->lng->txt("tst_eval_results_by_pass"));
01752 $this->tpl->parseCurrentBlock();
01753 }
01754
01755 $this->tpl->setCurrentBlock("results");
01756 $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");
01757 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
01758 $this->tpl->setVariable("SOLUTION_HINT_HEADER", $this->lng->txt("solution_hint"));
01759 $this->tpl->setVariable("MAX_POINTS", $this->lng->txt("tst_maximum_points"));
01760 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
01761 $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");
01762 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01763 if ($this->object->getTestType() != TYPE_VARYING_RANDOMTEST)
01764 {
01765 $mark_obj = $this->object->mark_schema->getMatchingMark($percentage);
01766 if ($mark_obj)
01767 {
01768 if ($mark_obj->getPassed())
01769 {
01770 $mark = $this->lng->txt("tst_result_congratulations");
01771 }
01772 else
01773 {
01774 $mark = $this->lng->txt("tst_result_sorry");
01775 }
01776 $mark .= "<br />" . $this->lng->txt("tst_your_mark_is") . ": "" . $mark_obj->getOfficialName() . """;
01777 }
01778 if ($this->object->ects_output)
01779 {
01780 $ects_mark = $this->object->getECTSGrade($total_reached, $total_max);
01781 $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)) . ")";
01782 }
01783 $this->tpl->setVariable("USER_FEEDBACK", $mark);
01784 }
01785 if ($this->object->getTestType() == TYPE_VARYING_RANDOMTEST)
01786 {
01787 $this->tpl->setVariable("BACK_TO_OVERVIEW", $this->lng->txt("tst_results_back_overview"));
01788 }
01789 else
01790 {
01791 $this->tpl->setVariable("BACK_TO_OVERVIEW", $this->lng->txt("tst_results_back_introduction"));
01792 }
01793 $this->tpl->parseCurrentBlock();
01794 $this->tpl->setCurrentBlock("test_user_name");
01795 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name"), $ilUser->getFullname()));
01796 $this->tpl->parseCurrentBlock();
01797
01798 $this->tpl->setCurrentBlock("adm_content");
01799 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01800 $this->tpl->parseCurrentBlock();
01801 }
01802
01803 function outEvaluationForm()
01804 {
01805 global $ilUser;
01806
01807 $this->ctrl->saveParameter($this, "pass");
01808 include_once("classes/class.ilObjStyleSheet.php");
01809 $this->tpl->setCurrentBlock("ContentStyle");
01810 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
01811 $this->tpl->parseCurrentBlock();
01812
01813
01814 $this->tpl->setCurrentBlock("SyntaxStyle");
01815 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01816 ilObjStyleSheet::getSyntaxStylePath());
01817 $this->tpl->parseCurrentBlock();
01818
01819 $test_id = $this->object->getTestId();
01820 $question_gui = $this->object->createQuestionGUI("", $_GET["evaluation"]);
01821 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_evaluation.html", true);
01822 $this->tpl->setCurrentBlock("adm_content");
01823 $active = $this->object->getActiveTestUser($ilUser->getId());
01824 $result_output = $question_gui->getSolutionOutput($active->active_id, NULL, TRUE, FALSE, FALSE);
01825 $best_output = $question_gui->getSolutionOutput("", NULL, FALSE, FALSE, FALSE);
01826 $this->tpl->setVariable("TEXT_YOUR_SOLUTION", $this->lng->txt("tst_your_answer_was"));
01827 $this->tpl->setVariable("TEXT_BEST_SOLUTION", $this->lng->txt("tst_best_solution_is"));
01828 $maxpoints = $question_gui->object->getMaximumPoints();
01829 if ($maxpoints == 1)
01830 {
01831 $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle() . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
01832 }
01833 else
01834 {
01835 $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle() . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
01836 }
01837 $this->tpl->setVariable("SOLUTION_OUTPUT", $result_output);
01838 $this->tpl->setVariable("BEST_OUTPUT", $best_output);
01839 $this->tpl->setVariable("RECEIVED_POINTS", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->getReachedPoints($active->active_id), $maxpoints));
01840 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01841 $this->tpl->setVariable("BACKLINK_TEXT", "<< " . $this->lng->txt("back"));
01842 $this->tpl->parseCurrentBlock();
01843 }
01844
01852 function show_answers()
01853 {
01854 global $ilUser;
01855 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_answers_sheet_details.html", true);
01856 $this->outShowAnswersDetails($ilUser->getId(), true);
01857 }
01858
01866 function showAnswersOfUser()
01867 {
01868 global $ilUser;
01869 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_answers_sheet_details.html", true);
01870 $this->tpl->setCurrentBlock("generic_css");
01871 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./assessment/templates/default/test_print.css");
01872 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
01873 $this->tpl->parseCurrentBlock();
01874 $this->tpl->setCurrentBlock("navigation_buttons");
01875 $this->tpl->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
01876 $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
01877 $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
01878 $this->tpl->parseCurrentBlock();
01879 $invited_user =& $this->object->getInvitedUsers($ilUser->getId());
01880 $pagetitle = $this->object->getTitle() . " - " . $this->lng->txt("clientip") .
01881 ": " . $invited_user[$ilUser->getId()]->clientip . " - " .
01882 $this->lng->txt("matriculation") . ": " .
01883 $invited_user[$ilUser->getId()]->matriculation;
01884 $this->tpl->setVariable("PAGETITLE", $pagetitle);
01885 $this->outShowAnswersDetails($ilUser->getId());
01886 }
01887
01895 function outShowAnswersDetails($user_id, $isForm = false)
01896 {
01897 $active = $this->object->getActiveTestUser($user_id);
01898 $t = $active->submittimestamp;
01899 include_once "./classes/class.ilObjUser.php";
01900 $ilUser = new ilObjUser($user_id);
01901
01902 if (strlen($ilUser->getMatriculation()))
01903 {
01904 $this->tpl->setCurrentBlock("user_matric");
01905 $this->tpl->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
01906 $this->tpl->parseCurrentBlock();
01907 $this->tpl->setCurrentBlock("user_matric_value");
01908 $this->tpl->setVariable("VALUE_USR_MATRIC", $ilUser->getMatriculation());
01909 $this->tpl->parseCurrentBlock();
01910 $this->tpl->touchBlock("user_matric_separator");
01911 }
01912
01913 $invited_users = array_pop($this->object->getInvitedUsers($ilUser->getId()));
01914 if (strlen($invited_users->clientip))
01915 {
01916 $this->tpl->setCurrentBlock("user_clientip");
01917 $this->tpl->setVariable("TXT_CLIENT_IP", $this->lng->txt("clientip"));
01918 $this->tpl->parseCurrentBlock();
01919 $this->tpl->setCurrentBlock("user_clientip_value");
01920 $this->tpl->setVariable("VALUE_CLIENT_IP", $invited_users->clientip);
01921 $this->tpl->parseCurrentBlock();
01922 $this->tpl->touchBlock("user_clientip_separator");
01923 }
01924
01925 include_once "./classes/class.ilUtil.php";
01926
01927
01928 if ($active->submitted)
01929 {
01930
01931 $this->tpl->setCurrentBlock("freefield_bottom");
01932 $this->tpl->setVariable("TXT_DATE", $this->lng->txt("date"));
01933 $this->tpl->setVariable("VALUE_DATE", strftime("%Y-%m-%d %H:%M:%S", ilUtil::date_mysql2time($t)));
01934
01935 $freefieldtypes = array(
01936 "freefield_bottom" => array(
01937 array(
01938 "title" => $this->lng->txt("tst_signature"),
01939 "length" => 300
01940 )
01941 )
01942 );
01943
01944 foreach ($freefieldtypes as $type => $freefields)
01945 {
01946 $counter = 0;
01947 while ($counter < count($freefields))
01948 {
01949 $freefield = $freefields[$counter];
01950 $this->tpl->setVariable("TXT_FREE_FIELD", $freefield["title"]);
01951 $this->tpl->setVariable("IMG_SPACER", ilUtil::getImagePath("spacer.gif"));
01952 $counter ++;
01953 }
01954 }
01955 $this->tpl->parseCurrentBlock();
01956 }
01957
01958 $pass = NULL;
01959 if ($this->object->isRandomTest())
01960 {
01961 $pass = $this->object->_getResultPass($active->active_id);
01962 }
01963 $counter = 1;
01964
01965 $questions =& $this->object->getQuestions($active->active_id, $pass, TRUE);
01966
01967 foreach ($questions as $question)
01968 {
01969 $this->tpl->setCurrentBlock("question");
01970 $question_gui = $this->object->createQuestionGUI("", $question);
01971
01972 $this->tpl->setVariable("COUNTER_QUESTION", $counter.". ");
01973 $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
01974
01975 $active = $this->object->getActiveTestUser($ilUser->getId());
01976 $result_output = $question_gui->getSolutionOutput($active->active_id, $pass, FALSE, FALSE, FALSE);
01977 $this->tpl->setVariable("SOLUTION_OUTPUT", $result_output);
01978 $this->tpl->parseCurrentBlock();
01979 $counter ++;
01980 }
01981
01982
01983 if ($isForm && !$active->submitted)
01984 {
01985 $this->tpl->setCurrentBlock("confirm");
01986 $this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("tst_submit_answers_txt"));
01987 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("back"));
01988 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_answers"));
01989 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01990 $this->tpl->parseCurrentBlock();
01991 }
01992
01993 $this->tpl->setCurrentBlock("answer_sheet");
01994 $this->tpl->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
01995 $this->tpl->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
01996 $this->tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers"));
01997 $this->tpl->setVariable("TITLE", $this->object->getTitle());
01998 $this->tpl->setVariable("TXT_ANSWER_SHEET", $this->lng->txt("tst_answer_sheet"));
01999
02000 $this->tpl->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
02001 $this->tpl->setVariable("VALUE_USR_NAME", $ilUser->getLastname().", ".$ilUser->getFirstname());
02002 $this->tpl->parseCurrentBlock();
02003 }
02004
02010 function endingTimeReached()
02011 {
02012 sendInfo(sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime())));
02013 $this->object->setActiveTestUser(1, "", true);
02014 if (!$this->object->canViewResults())
02015 {
02016 $this->outIntroductionPage();
02017 }
02018 else
02019 {
02020 if ($this->object->isOnlineTest())
02021 $this->outTestSummary();
02022 else
02023 $this->outResults();
02024 }
02025 }
02026
02034 function maxProcessingTimeReached()
02035 {
02036 $this->outIntroductionPage();
02037 }
02038
02044 function confirmSubmitAnswers()
02045 {
02046 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_submit_answers_confirm.html", true);
02047 $this->tpl->setCurrentBlock("adm_content");
02048 if ($this->object->isActiveTestSubmitted())
02049 {
02050 $this->tpl->setCurrentBlock("not_submit_allowed");
02051 $this->tpl->setVariable("TEXT_ALREADY_SUBMITTED", $this->lng->txt("tst_already_submitted"));
02052 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_show_answer_sheet"));
02053 } else
02054 {
02055 $this->tpl->setCurrentBlock("submit_allowed");
02056 $this->tpl->setVariable("TEXT_CONFIRM_SUBMIT_RESULTS", $this->lng->txt("tst_confirm_submit_answers"));
02057 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_results"));
02058 }
02059 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
02060 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02061 $this->tpl->parseCurrentBlock();
02062 }
02063
02064 function outProcessingTime()
02065 {
02066 global $ilUser;
02067
02068 $starting_time = $this->object->getStartingTimeOfUser($ilUser->getId());
02069 $processing_time = $this->object->getProcessingTimeInSeconds();
02070 $processing_time_minutes = floor($processing_time / 60);
02071 $processing_time_seconds = $processing_time - $processing_time_minutes * 60;
02072 $str_processing_time = "";
02073 if ($processing_time_minutes > 0)
02074 {
02075 $str_processing_time = $processing_time_minutes . " " . $this->lng->txt("minutes");
02076 }
02077 if ($processing_time_seconds > 0)
02078 {
02079 if (strlen($str_processing_time) > 0) $str_processing_time .= " " . $this->lng->txt("and") . " ";
02080 $str_processing_time .= $processing_time_seconds . " " . $this->lng->txt("seconds");
02081 }
02082 $time_left = $starting_time + $processing_time - mktime();
02083 $testend_time = $this->object->getSecondsUntilEndingTime();
02084 if (($testend_time > 0) && ($testend_time < $time_left))
02085 {
02086 $time_left = $testend_time;
02087 }
02088 $time_left_minutes = floor($time_left / 60);
02089 $time_left_seconds = $time_left - $time_left_minutes * 60;
02090 $str_time_left = "";
02091 if ($time_left_minutes > 0)
02092 {
02093 $str_time_left = $time_left_minutes . " " . $this->lng->txt("minutes");
02094 }
02095 if ($time_left_seconds > 0)
02096 {
02097 if (strlen($str_time_left) > 0) $str_time_left .= " " . $this->lng->txt("and") . " ";
02098 $str_time_left .= $time_left_seconds . " " . $this->lng->txt("seconds");
02099 }
02100 $date = getdate($starting_time);
02101 $formattedStartingTime = ilFormat::formatDate(
02102 $date["year"]."-".
02103 sprintf("%02d", $date["mon"])."-".
02104 sprintf("%02d", $date["mday"])." ".
02105 sprintf("%02d", $date["hours"]).":".
02106 sprintf("%02d", $date["minutes"]).":".
02107 sprintf("%02d", $date["seconds"])
02108 );
02109 $datenow = getdate();
02110 $this->tpl->setCurrentBlock("enableprocessingtime");
02111 $this->tpl->setVariable("USER_WORKING_TIME",
02112 sprintf(
02113 $this->lng->txt("tst_time_already_spent"),
02114 $formattedStartingTime,
02115 $str_processing_time
02116 )
02117 );
02118 $this->tpl->setVariable("USER_REMAINING_TIME", sprintf($this->lng->txt("tst_time_already_spent_left"), $str_time_left));
02119 $this->tpl->parseCurrentBlock();
02120 $template = new ilTemplate("tpl.workingtime.js.html", TRUE, TRUE, TRUE);
02121 $template->setVariable("STRING_MINUTE", $this->lng->txt("minute"));
02122 $template->setVariable("STRING_MINUTES", $this->lng->txt("minutes"));
02123 $template->setVariable("STRING_SECOND", $this->lng->txt("second"));
02124 $template->setVariable("STRING_SECONDS", $this->lng->txt("seconds"));
02125 $template->setVariable("STRING_TIMELEFT", $this->lng->txt("tst_time_already_spent_left"));
02126 $template->setVariable("AND", strtolower($this->lng->txt("and")));
02127 $template->setVariable("YEAR", $date["year"]);
02128 $template->setVariable("MONTH", $date["mon"]-1);
02129 $template->setVariable("DAY", $date["mday"]);
02130 $template->setVariable("HOUR", $date["hours"]);
02131 $template->setVariable("MINUTE", $date["minutes"]);
02132 $template->setVariable("SECOND", $date["seconds"]);
02133 if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->object->getEndingTime(), $matches))
02134 {
02135 $template->setVariable("ENDYEAR", $matches[1]);
02136 $template->setVariable("ENDMONTH", $matches[2]-1);
02137 $template->setVariable("ENDDAY", $matches[3]);
02138 $template->setVariable("ENDHOUR", $matches[4]);
02139 $template->setVariable("ENDMINUTE", $matches[5]);
02140 $template->setVariable("ENDSECOND", $matches[6]);
02141 }
02142
02143 $template->setVariable("YEARNOW", $datenow["year"]);
02144 $template->setVariable("MONTHNOW", $datenow["mon"]-1);
02145 $template->setVariable("DAYNOW", $datenow["mday"]);
02146 $template->setVariable("HOURNOW", $datenow["hours"]);
02147 $template->setVariable("MINUTENOW", $datenow["minutes"]);
02148 $template->setVariable("SECONDNOW", $datenow["seconds"]);
02149 $template->setVariable("PTIME_M", $processing_time_minutes);
02150 $template->setVariable("PTIME_S", $processing_time_seconds);
02151
02152 $this->tpl->setCurrentBlock("HeadContent");
02153 $this->tpl->setVariable("CONTENT_BLOCK", $template->get());
02154 $this->tpl->parseCurrentBlock();
02155 }
02156
02162 function outTestSummary()
02163 {
02164 global $ilUser;
02165
02166
02167 if (is_numeric($_GET["set_solved"]) && is_numeric($_GET["question_id"]))
02168 {
02169 $this->object->setQuestionSetSolved($_GET["set_solved"] , $_GET["question_id"], $ilUser->getId());
02170 }
02171
02172 function sort_title($a, $b)
02173 {
02174 if (strcmp($_GET["order"], "ASC"))
02175 {
02176 $smaller = 1;
02177 $greater = -1;
02178 }
02179 else
02180 {
02181 $smaller = -1;
02182 $greater = 1;
02183 }
02184 if ($a["nr"] == $b["nr"]) return 0;
02185 if (strcmp($a["title"],$b["title"])< 0)
02186 return $smaller;
02187 else if (strcmp($a["title"],$b["title"])> 0)
02188 return $greater;
02189 return 0;
02190 }
02191
02192
02193 function sort_nr($a, $b)
02194 {
02195 if (strcmp($_GET["order"], "ASC"))
02196 {
02197 $smaller = 1;
02198 $greater = -1;
02199 }
02200 else
02201 {
02202 $smaller = -1;
02203 $greater = 1;
02204 }
02205 if ($a["nr"] == $b["nr"]) return 0;
02206 return ($a["nr"] < $b["nr"]) ? $smaller : $greater;
02207 }
02208
02209 function sort_visited($a, $b)
02210 {
02211 if (strcmp($_GET["order"], "ASC"))
02212 {
02213 $smaller = 1;
02214 $greater = -1;
02215 }
02216 else
02217 {
02218 $smaller = -1;
02219 $greater = 1;
02220 }
02221 if ($a["nr"] == $b["nr"])
02222 return 0;
02223 return ($a["visited"] < $b["visited"]) ? $smaller : $greater;
02224 }
02225
02226
02227 function sort_solved($a, $b)
02228 {
02229 if (strcmp($_GET["order"], "ASC"))
02230 {
02231 $smaller = 1;
02232 $greater = -1;
02233 }
02234 else
02235 {
02236 $smaller = -1;
02237 $greater = 1;
02238 }
02239 if ($a["nr"] == $b["nr"]) return 0;
02240 return ($a["solved"] < $b["solved"]) ? $smaller : $greater;
02241 }
02242
02243 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_summary.html", true);
02244 $user_id = $ilUser->id;
02245 $active = $this->object->getActiveTestUser($ilUser->getId());
02246 $color_class = array ("tblrow1", "tblrow2");
02247 $counter = 0;
02248
02249 $result_array = & $this->object->getTestSummary($active->active_id);
02250
02251 $img_title_nr = "";
02252 $img_title_title = "";
02253 $img_title_solved = "";
02254
02255 if (!$_GET["sort_summary"] )
02256 {
02257 $_GET["sort_summary"] = "nr";
02258 $_GET["order"] = "ASC";
02259 }
02260
02261 switch ($_GET["sort_summary"])
02262 {
02263 case nr:
02264 usort($result_array, "sort_nr");
02265 $img_title_nr = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
02266 if (strcmp($_GET["order"], "ASC") == 0)
02267 {
02268 $sortnr = "DESC";
02269 }
02270 else
02271 {
02272 $sortnr = "ASC";
02273 }
02274 break;
02275
02276 case "title":
02277 usort($result_array, "sort_title");
02278 $img_title_title = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
02279 if (strcmp($_GET["order"], "ASC") == 0)
02280 {
02281 $sorttitle = "DESC";
02282 }
02283 else
02284 {
02285 $sorttitle = "ASC";
02286 }
02287 break;
02288 case "solved":
02289 usort($result_array, "sort_solved");
02290 $img_title_solved = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
02291 if (strcmp($_GET["order"], "ASC") == 0)
02292 {
02293 $sortsolved = "DESC";
02294 }
02295 else
02296 {
02297 $sortsolved = "ASC";
02298 }
02299 break;
02300 }
02301 if (!$sorttitle)
02302 {
02303 $sorttitle = "ASC";
02304 }
02305 if (!$sortsolved)
02306 {
02307 $sortsolved = "ASC";
02308 }
02309 if (!$sortnr)
02310 {
02311 $sortnr = "ASC";
02312 }
02313
02314 $img_solved = " <img border=\"0\" align=\"middle\" src=\"" . ilUtil::getImagePath("solved.png", true) . "\" alt=\"".$this->lng->txt("tst_click_to_change_state")."\" />";
02315 $img_not_solved = " <img border=\"0\" align=\"middle\" src=\"" . ilUtil::getImagePath("not_solved.png", true) . "\" alt=\"".$this->lng->txt("tst_click_to_change_state")."\" />";
02316 $goto_question = " <img border=\"0\" align=\"middle\" src=\"" . ilUtil::getImagePath("goto_question.png", true) . "\" alt=\"".$this->lng->txt("tst_qst_goto")."\" />";
02317
02318 $disabled = $this->isMaxProcessingTimeReached() | $this->object->endingTimeReached();
02319
02320 foreach ($result_array as $key => $value)
02321 {
02322 if (preg_match("/\d+/", $key))
02323 {
02324 $this->tpl->setCurrentBlock("question");
02325 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
02326 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
02327 $this->tpl->setVariable("VALUE_QUESTION_TITLE", $value["title"]);
02328 $this->tpl->setVariable("VALUE_QUESTION_SOLVED", ($value["solved"] > 0) ?$img_solved : $img_not_solved);
02329 if (!$disabled)
02330 {
02331 $this->ctrl->setParameter($this, "sequence", $value["nr"]);
02332 $this->tpl->setVariable("VALUE_QUESTION_HREF_GOTO", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "gotoQuestion")."\">");
02333 $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
02334 }
02335 $this->tpl->setVariable("VALUE_QUESTION_GOTO", $goto_question);
02336 $solvedvalue = (($value["solved"]) ? "0" : "1");
02337 $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"]);
02338 $this->tpl->setVariable("VALUE_QUESTION_SET_SOLVED", ($value["solved"] > 0) ?$this->lng->txt("tst_qst_resetsolved"):$this->lng->txt("tst_qst_setsolved"));
02339 $this->tpl->setVariable("VALUE_QUESTION_DESCRIPTION", $value["description"]);
02340 $this->tpl->setVariable("VALUE_QUESTION_POINTS", $value["points"]." ".$this->lng->txt("points_short"));
02341 $this->tpl->parseCurrentBlock();
02342 $counter ++;
02343 }
02344 }
02345
02346 if (!$disabled)
02347 {
02348 $this->tpl->setCurrentBlock("back");
02349 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02350 $this->tpl->parseCurrentBlock();
02351 }
02352 else
02353 {
02354 sendinfo($this->lng->txt("detail_max_processing_time_reached"));
02355 }
02356
02357 $this->tpl->setVariable("QUESTION_ACTION","actions");
02358 $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);
02359 $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);
02360 $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);
02361 $this->tpl->setVariable("QUESTION_POINTS", $this->lng->txt("tst_maximum_points"));
02362 $this->tpl->setVariable("USER_FEEDBACK", $this->lng->txt("tst_qst_summary_text"));
02363 $this->tpl->setVariable("TXT_SHOW_AND_SUBMIT_ANSWERS", $this->lng->txt("save_finish"));
02364 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02365 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("question_summary"));
02366
02367 if ($this->object->getEnableProcessingTime())
02368 $this->outProcessingTime();
02369 }
02370
02371 function finalSubmission()
02372 {
02373 global $ilias, $ilUser;
02374
02375 $this->object->setActiveTestSubmitted($ilUser->id);
02376 $ilias->auth->setIdle($ilias->ini->readVariable("session","expire"), false);
02377 $ilias->auth->setExpire(0);
02378 $this->outIntroductionPage();
02379 }
02380
02386 function outQuestionSummary()
02387 {
02388 global $ilUser;
02389
02390 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_question_summary.html", true);
02391 $user_id = $ilUser->id;
02392 $active = $this->object->getActiveTestUser($ilUser->getId());
02393 $color_class = array ("tblrow1", "tblrow2");
02394 $counter = 0;
02395
02396 $result_array = & $this->object->getTestSummary($active->active_id);
02397 foreach ($result_array as $key => $value)
02398 {
02399 if (preg_match("/\d+/", $key))
02400 {
02401 $this->tpl->setCurrentBlock("question");
02402 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
02403 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
02404 $this->ctrl->setParameter($this, "sequence", $value["nr"]);
02405 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "gotoQuestion")."\">" . $value["title"] . "</a>");
02406 $this->ctrl->setParameter($this, "sequence", $_GET["sequence"]);
02407
02408 if ($value["worked_through"])
02409 {
02410 $this->tpl->setVariable("VALUE_WORKED_THROUGH", ilUtil::getImagePath("icon_ok.gif"));
02411 $this->tpl->setVariable("ALT_WORKED_THROUGH", $this->lng->txt("worked_through"));
02412 }
02413 else
02414 {
02415 $this->tpl->setVariable("VALUE_WORKED_THROUGH", ilUtil::getImagePath("icon_not_ok.gif"));
02416 $this->tpl->setVariable("ALT_WORKED_THROUGH", $this->lng->txt("not_worked_through"));
02417 }
02418 if ($value["postponed"])
02419 {
02420 $this->tpl->setVariable("VALUE_POSTPONED", $this->lng->txt("postponed"));
02421 }
02422 if (!$this->object->getHideTitlePoints())
02423 {
02424 $this->tpl->setVariable("VALUE_QUESTION_POINTS", $value["points"]." ".$this->lng->txt("points_short"));
02425 }
02426 $this->tpl->parseCurrentBlock();
02427 $counter ++;
02428 }
02429 }
02430
02431 $this->tpl->setVariable("QUESTION_ACTION","actions");
02432 $this->tpl->setVariable("QUESTION_COUNTER", $this->lng->txt("tst_qst_order"));
02433 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
02434 if (!$this->object->getHideTitlePoints())
02435 {
02436 $this->tpl->setVariable("QUESTION_POINTS", $this->lng->txt("tst_maximum_points"));
02437 }
02438 $this->tpl->setVariable("WORKED_THROUGH", $this->lng->txt("worked_through"));
02439 $this->tpl->setVariable("USER_FEEDBACK", $this->lng->txt("tst_qst_summary_text"));
02440 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02441 $this->tpl->setVariable("TXT_SHOW_AND_SUBMIT_ANSWERS", $this->lng->txt("save_finish"));
02442 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02443 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("question_summary"));
02444
02445 if ($this->object->getEnableProcessingTime())
02446 $this->outProcessingTime();
02447 }
02448
02449 function showMaximumAllowedUsersReachedMessage()
02450 {
02451 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_max_allowed_users_reached.html", true);
02452 $this->tpl->setCurrentBlock("adm_content");
02453 $this->tpl->setVariable("MAX_ALLOWED_USERS_MESSAGE", sprintf($this->lng->txt("tst_max_allowed_users_message"), $this->object->getAllowedUsersTimeGap()));
02454 $this->tpl->setVariable("MAX_ALLOWED_USERS_HEADING", sprintf($this->lng->txt("tst_max_allowed_users_heading"), $this->object->getAllowedUsersTimeGap()));
02455 $this->tpl->setVariable("BACK_TO_INTRODUCTION", $this->lng->txt("tst_results_back_introduction"));
02456 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
02457 $this->tpl->parseCurrentBlock();
02458 }
02459
02460 }
02461 ?>