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

assessment/classes/class.ilOnlineTestCommandControl.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004         +-----------------------------------------------------------------------------+
00005         | ILIAS open source                                                           |
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00008         |                                                                             |
00009         | This program is free software; you can redistribute it and/or               |
00010         | modify it under the terms of the GNU General Public License                 |
00011         | as published by the Free Software Foundation; either version 2              |
00012         | of the License, or (at your option) any later version.                      |
00013         |                                                                             |
00014         | This program is distributed in the hope that it will be useful,             |
00015         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017         | GNU General Public License for more details.                                |
00018         |                                                                             |
00019         | You should have received a copy of the GNU General Public License           |
00020         | along with this program; if not, write to the Free Software                 |
00021         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 //      sort summary: click on title to sort in summary
00050                         $_POST["cmd"]["summary"]="1";
00051 
00052                 if ($_POST["cmd"]["cancel_show_answers"]) {
00053                 // cancel_show_answers: click on back in show_answer view
00054                         if ($this->isTestAccessible()) 
00055                         {       // everythings ok goto summary
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                 // check if user is invited to participate
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                 // check if client ip is set and if current remote addr is equal to stored client-ip                    
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                 //print_r($_GET);
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                         //$this->gui->outShowAnswers(false, & $ilUser);                 
00171                         return true;
00172                 }
00173                 
00174                 // set solved in summary
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                 // set solved in question
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                         //(!$this->canSaveResult() || ($this->canSaveResult() && $this->gui->saveResults))) 
00192                 {
00193                         $this->gui->outTestSummary();
00194                         return true;
00195                 }
00196                 
00197                 return false;
00198                 
00199         }
00200                 
00201         /*
00202          * test is resumable if it is not submitted and matches inherited behaviour
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 ?>

Generated on Fri Dec 13 2013 10:18:26 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1