Public Member Functions

OnlineTestCommandControl Class Reference

Inheritance diagram for OnlineTestCommandControl:
Collaboration diagram for OnlineTestCommandControl:

Public Member Functions

 OnlineTestCommandControl (&$gui, &$object)
 prepareRequestVariables ()
 prepare request variables
 onRunObjectEnter ()
 inherited behavior and checks access restrictions
 checkOnlineTestAccess ()
 check access restrictions like client ip, partipating user etc.
 handleStartCommands ()
 handle start commands
 handleCommands ()
 handle online test specific commands as well as standard commands
 isTestResumable ()
 resumable is when there exists a test and the restrictions (time, nr of tries etc) don't prevent an access
 canShowTestResults ()
 test can show results if it is submmited and matches inherited behaviour
 getSequence ()
 get sequence delivers introduction page if test is submitted

Detailed Description

Definition at line 37 of file class.ilOnlineTestCommandControl.php.


Member Function Documentation

OnlineTestCommandControl::canShowTestResults (  ) 

test can show results if it is submmited and matches inherited behaviour

Reimplemented from DefaultTestCommandControl.

Definition at line 215 of file class.ilOnlineTestCommandControl.php.

                                       {
                return parent::canShowTestResults() && $this->obj->isActiveTestSubmitted();
        }

OnlineTestCommandControl::checkOnlineTestAccess (  ) 

check access restrictions like client ip, partipating user etc.

Definition at line 102 of file class.ilOnlineTestCommandControl.php.

References $ilUser, $path, $user, exit, ilUtil::redirect(), and sendInfo().

Referenced by onRunObjectEnter().

        {
                global $ilUser;
                
                // check if user is invited to participate
                $user = $this->obj->getInvitedUsers($ilUser->getId());
                if (!is_array ($user) || count($user)!=1)
                {
                                sendInfo($this->lng->txt("user_not_invited"), true);
                                $path = $this->tree->getPathFull($this->obj->getRefID());
                                ilUtil::redirect($this->gui->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
                                exit();
                }
                        
                $user = array_pop($user);
                // check if client ip is set and if current remote addr is equal to stored client-ip                    
                if (strcmp($user->clientip,"")!=0 && strcmp($user->clientip,$_SERVER["REMOTE_ADDR"])!=0)
                {
                        sendInfo($this->lng->txt("user_wrong_clientip"), true);
                        $path = $this->tree->getPathFull($this->obj->getRefID());
                        ilUtil::redirect($this->gui->getReturnLocation("cancel","../repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
                        exit();
                }               
        }       

Here is the call graph for this function:

Here is the caller graph for this function:

OnlineTestCommandControl::getSequence (  ) 

get sequence delivers introduction page if test is submitted

Reimplemented from DefaultTestCommandControl.

Definition at line 223 of file class.ilOnlineTestCommandControl.php.

                                {
                if ($this->obj->isActiveTestSubmitted())
                        return "";
                return parent::getSequence();
        }

OnlineTestCommandControl::handleCommands (  ) 

handle online test specific commands as well as standard commands

Reimplemented from DefaultTestCommandControl.

Definition at line 146 of file class.ilOnlineTestCommandControl.php.

References $_GET, $_POST, $ilias, and $ilUser.

                                   {
                global $ilUser, $ilias;
                //print_r($_GET);
                
                $return = parent::handleCommands ();                            
                
                if ($return)
                        return $return;
                                        
                if ($_POST["cmd"]["show_answers"]) {
                        $this->gui->outShowAnswers(true, & $ilUser);
                        return true;
                }
                
                if ($_POST["cmd"]["submit_answers"]) {
                        $this->gui->confirmSubmitAnswers();
                        return true;
                }
                                
                if ($_POST["cmd"]["confirm_submit_answers"]) {                                          
                        $this->obj->setActiveTestSubmitted ($ilUser->id);
                        $ilias->auth->setIdle($ilias->ini->readVariable("session","expire"), false);
                        $ilias->auth->setExpire(0);
                        $this->gui->outIntroductionPage();
                        //$this->gui->outShowAnswers(false, & $ilUser);                 
                        return true;
                }
                
                // set solved in summary
                if (is_numeric($_GET["set_solved"]) && is_numeric($_GET["question_id"]))                 
                {
                        $this->obj->setQuestionSetSolved($_GET["set_solved"] , $_GET["question_id"], $ilUser->getId());
                        $_POST["cmd"]["summary"]="summary";
                }
                
                // set solved in question
                if ($_POST["cmd"]["resetsolved"] or $_POST["cmd"]["setsolved"] && $_GET["sequence"] )            
                {
                        $value = ($_POST["cmd"]["resetsolved"])?0:1;                    
                        $q_id  = $this->obj->getQuestionIdFromActiveUserSequence($_GET["sequence"]);            
                        $this->obj->setQuestionSetSolved($value , $q_id, $ilUser->getId());
                }
                
                
                if ($_POST["cmd"]["summary"] )//&& 
                        //(!$this->canSaveResult() || ($this->canSaveResult() && $this->gui->saveResults))) 
                {
                        $this->gui->outTestSummary();
                        return true;
                }
                
                return false;
                
        }

OnlineTestCommandControl::handleStartCommands (  ) 

handle start commands

Reimplemented from DefaultTestCommandControl.

Definition at line 130 of file class.ilOnlineTestCommandControl.php.

References $_POST, and $ilias.

                                       {
                global $ilias;
                $val = parent::handleStartCommands();
                        
                $ilias->auth->setIdle(0, false);                                        
                        
                if (!$this->obj->isActiveTestSubmitted()) 
                {
                        $_POST["cmd"]["summary"]="1";
                }                       
        }

OnlineTestCommandControl::isTestResumable (  ) 

resumable is when there exists a test and the restrictions (time, nr of tries etc) don't prevent an access

Reimplemented from DefaultTestCommandControl.

Definition at line 205 of file class.ilOnlineTestCommandControl.php.

                                    {
                if ($this->obj->isActiveTestSubmitted())
                        return false;
                else return parent::isTestResumable();
        }

OnlineTestCommandControl::OnlineTestCommandControl ( &$  gui,
&$  object 
)

Definition at line 39 of file class.ilOnlineTestCommandControl.php.

References CommandControl::$gui, and DefaultTestCommandControl::DefaultTestCommandControl().

Here is the call graph for this function:

OnlineTestCommandControl::onRunObjectEnter (  ) 

inherited behavior and checks access restrictions

Reimplemented from DefaultTestCommandControl.

Definition at line 91 of file class.ilOnlineTestCommandControl.php.

References checkOnlineTestAccess().

Here is the call graph for this function:

OnlineTestCommandControl::prepareRequestVariables (  ) 

prepare request variables

Reimplemented from DefaultTestCommandControl.

Definition at line 46 of file class.ilOnlineTestCommandControl.php.

References $_GET, $_POST, and DefaultTestCommandControl::isTestAccessible().

        {
                if ($_GET["sort_summary"])
                //      sort summary: click on title to sort in summary
                        $_POST["cmd"]["summary"]="1";

                if ($_POST["cmd"]["cancel_show_answers"]) {
                // cancel_show_answers: click on back in show_answer view
                        if ($this->isTestAccessible()) 
                        {       // everythings ok goto summary
                                $_POST["cmd"]["summary"]="1";
                        } 
                                else 
                        {
                                $_POST["cmd"]["run"]="1";
                                unset($_GET ["sequence"]);
                        }                       
                }
                
                if ($_POST["cmd"]["cancel_confirm_submit_answers"]) {
                        if ($this->obj->isActiveTestSubmitted()) 
                        {       
                                $_POST["cmd"]["run"]="1";
                        } 
                                else 
                        {
                                $_POST["cmd"]["show_answers"]="1";
                                unset($_GET ["sequence"]);                      
                        }                       
                        unset ($_POST["cmd"]["cancel_confirm_submit_answers"]);
                }
                                
                if ($_POST["cmd"]["show_answers"] or $_POST["cmd"]["back"] or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"]) {
                        unset($_GET ["sort_summary"]);                  
                        unset($_GET ["setsolved"]);
                        unset($_GET ["resetsolved"]);
                        if ($_POST["cmd"]["show_answers"]  or $_POST["cmd"]["submit_answers"] or $_POST["cmd"]["run"])                                  
                                unset($_GET ["sequence"]);              
                }                       
        }

Here is the call graph for this function:


The documentation for this class was generated from the following file: