Go to the documentation of this file.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
00025
00037 class OnlineTestCommandControl extends DefaultTestCommandControl {
00038
00039 function OnlineTestCommandControl (&$gui, &$object) {
00040 parent::DefaultTestCommandControl($gui, $object);
00041 }
00042
00046 function prepareRequestVariables ()
00047 {
00048 if ($_GET["sort_summary"])
00049
00050 $_POST["cmd"]["summary"]="1";
00051
00052 if ($_POST["cmd"]["cancel_show_answers"]) {
00053
00054 if ($this->isTestAccessible())
00055 {
00056 $_POST["cmd"]["summary"]="1";
00057 }
00058 else
00059 {
00060 $_POST["cmd"]["run"]="1";
00061 unset($_GET ["sequence"]);
00062 }
00063 }
00064
00065 if ($_POST["cmd"]["cancel_confirm_submit_answers"]) {
00066 if ($this->obj->isActiveTestSubmitted())
00067 {
00068 $_POST["cmd"]["run"]="1";
00069 }
00070 else
00071 {
00072 $_POST["cmd"]["show_answers"]="1";
00073 unset($_GET ["sequence"]);
00074 }
00075 unset ($_POST["cmd"]["cancel_confirm_submit_answers"]);
00076 }
00077
00078 if ($_POST["cmd"]["show_answers"] or $_POST["cmd"]["back"] or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"]) {
00079 unset($_GET ["sort_summary"]);
00080 unset($_GET ["setsolved"]);
00081 unset($_GET ["resetsolved"]);
00082 if ($_POST["cmd"]["show_answers"] or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"])
00083 unset($_GET ["sequence"]);
00084 }
00085 }
00086
00087
00091 function onRunObjectEnter ()
00092 {
00093 parent::onRunObjectEnter();
00094 $this->checkOnlineTestAccess();
00095 }
00096
00102 function checkOnlineTestAccess ()
00103 {
00104 global $ilUser;
00105
00106
00107 $user = $this->obj->getInvitedUsers($ilUser->getId());
00108 if (!is_array ($user) || count($user)!=1)
00109 {
00110 sendInfo($this->lng->txt("user_not_invited"), true);
00111 $path = $this->tree->getPathFull($this->obj->getRefID());
00112 ilUtil::redirect($this->gui->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00113 exit();
00114 }
00115
00116 $user = array_pop($user);
00117
00118 if (strcmp($user->clientip,"")!=0 && strcmp($user->clientip,$_SERVER["REMOTE_ADDR"])!=0)
00119 {
00120 sendInfo($this->lng->txt("user_wrong_clientip"), true);
00121 $path = $this->tree->getPathFull($this->obj->getRefID());
00122 ilUtil::redirect($this->gui->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
00123 exit();
00124 }
00125 }
00126
00130 function handleStartCommands() {
00131 global $ilias;
00132 $val = parent::handleStartCommands();
00133
00134 $ilias->auth->setIdle(0, false);
00135
00136 if (!$this->obj->isActiveTestSubmitted())
00137 {
00138 $_POST["cmd"]["summary"]="1";
00139 }
00140 }
00141
00146 function handleCommands () {
00147 global $ilUser, $ilias;
00148
00149
00150 $return = parent::handleCommands ();
00151
00152 if ($return)
00153 return $return;
00154
00155 if ($_POST["cmd"]["show_answers"]) {
00156 $this->gui->outShowAnswers(true, & $ilUser);
00157 return true;
00158 }
00159
00160 if ($_POST["cmd"]["submit_answers"]) {
00161 $this->gui->confirmSubmitAnswers();
00162 return true;
00163 }
00164
00165 if ($_POST["cmd"]["confirm_submit_answers"]) {
00166 $this->obj->setActiveTestSubmitted ($ilUser->id);
00167 $ilias->auth->setIdle($ilias->ini->readVariable("session","expire"), false);
00168 $ilias->auth->setExpire(0);
00169 $this->gui->outIntroductionPage();
00170
00171 return true;
00172 }
00173
00174
00175 if (is_numeric($_GET["set_solved"]) && is_numeric($_GET["question_id"]))
00176 {
00177 $this->obj->setQuestionSetSolved($_GET["set_solved"] , $_GET["question_id"], $ilUser->getId());
00178 $_POST["cmd"]["summary"]="summary";
00179 }
00180
00181
00182 if ($_POST["cmd"]["resetsolved"] or $_POST["cmd"]["setsolved"] && $_GET["sequence"] )
00183 {
00184 $value = ($_POST["cmd"]["resetsolved"])?0:1;
00185 $q_id = $this->obj->getQuestionIdFromActiveUserSequence($_GET["sequence"]);
00186 $this->obj->setQuestionSetSolved($value , $q_id, $ilUser->getId());
00187 }
00188
00189
00190 if ($_POST["cmd"]["summary"] )
00191
00192 {
00193 $this->gui->outTestSummary();
00194 return true;
00195 }
00196
00197 return false;
00198
00199 }
00200
00201
00202
00203
00204
00205 function isTestResumable() {
00206 if ($this->obj->isActiveTestSubmitted())
00207 return false;
00208 else return parent::isTestResumable();
00209 }
00210
00211
00215 function canShowTestResults () {
00216 return parent::canShowTestResults() && $this->obj->isActiveTestSubmitted();
00217 }
00218
00219
00223 function getSequence () {
00224 if ($this->obj->isActiveTestSubmitted())
00225 return "";
00226 return parent::getSequence();
00227 }
00228
00229 }
00230 ?>