Public Member Functions

DefaultTestCommandControl Class Reference

class DefaultTestCommandControl More...

Inheritance diagram for DefaultTestCommandControl:
Collaboration diagram for DefaultTestCommandControl:

Public Member Functions

 DefaultTestCommandControl (&$gui, &$object)
 prepareRequestVariables ()
 prepare Request variables e.g.
 onRunObjectEnter ()
 what to when entering the run object
 handleCommands ()
 handle standard commands like confirmation, deletes, evaluation
 handleStartCommands ()
 handle start test commands
 handleCancelCommand ()
 handle cancel command
 getSequence ()
 get next or previous sequence
 isTestResumable ()
 resumable is when there exists a test and the restrictions (time, nr of tries etc) don't prevent an access
 isNrOfTriesReached ()
 nr of tries exceeded
 isTestAccessible ()
 test accessible returns true if the user can perform the test
 showTestResults ()
 showTestResults returns true if the according request is set
 canShowTestResults ()
 can show test results returns true if there exist results and the results may be viewed
 canSaveResult ()
 returns if answers can be saved

Detailed Description

class DefaultTestCommandControl

controls control flow through all test modes except online test

Definition at line 63 of file class.ilCommandControl.php.


Member Function Documentation

DefaultTestCommandControl::canSaveResult (  ) 

returns if answers can be saved

Definition at line 295 of file class.ilCommandControl.php.

References $_GET, $_POST, and isNrOfTriesReached().

                                   {
                #print_r($_POST);
                #print_r($_GET);
                $do_save = (($_POST["cmd"]["next"] || $_POST["cmd"]["previous"] || $_POST["cmd"]["postpone"]
                                        || ($_POST["cmd"]["summary"] && !$_GET["sort_summary"])  
                                        || $_POST["cmd"]["directfeedback"] ||  $_POST["cmd"]["setsolved"]  || $_POST["cmd"]["resetsolved"] 
                                    || isset($_GET["selImage"])) && (isset ($_GET["sequence"]) && is_numeric ($_GET["sequence"])));

                return $do_save == true &&                              
                                !$this->gui->isEndingTimeReached() && !$this->gui->isMaxProcessingTimeReached() && !$this->isNrOfTriesReached();
         }

Here is the call graph for this function:

DefaultTestCommandControl::canShowTestResults (  ) 

can show test results returns true if there exist results and the results may be viewed

Reimplemented in OnlineTestCommandControl.

Definition at line 285 of file class.ilCommandControl.php.

                                       {
                $active = $this->obj->getActiveTestUser();
                return ($active->tries > 0) and $this->obj->canViewResults();
        }

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

Definition at line 65 of file class.ilCommandControl.php.

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

Referenced by OnlineTestCommandControl::OnlineTestCommandControl().

                                                             {
                parent::CommandControl($gui, $object);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

DefaultTestCommandControl::getSequence (  ) 

get next or previous sequence

Reimplemented in OnlineTestCommandControl.

Definition at line 208 of file class.ilCommandControl.php.

References $_GET, and $_POST.

                                {
                $sequence = $_GET["sequence"];
                $saveResult = $this->gui->saveResult;
                
                if ($_POST["cmd"]["deleteresults"] or $_POST["cmd"]["canceldeleteresults"] or $_POST["cmd"]["confirmdeleteresults"])
                {
                        // reset sequence. it is not needed for test reset
                        $sequence = "";
                }
                                                        
                if (isset($_POST["cmd"]["next"]) and $saveResult == true)
                {
                        if($_GET['crs_show_result'])
                        {
                                $sequence = $this->obj->incrementSequenceByResult($sequence);
                        }
                        else
                        {
                                $sequence++;
                        }
                }
                elseif (($_POST["cmd"]["previous"]) and ($sequence != 0) and ($saveResult))
                {
                        if($_GET['crs_show_result'])
                        {
                                $sequence = $this->obj->decrementSequenceByResult($sequence);
                        }
                        else
                        {
                                $sequence--;
                        }
                }               
                
                return $sequence;
        }

DefaultTestCommandControl::handleCancelCommand (  ) 

handle cancel command

Definition at line 197 of file class.ilCommandControl.php.

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

Referenced by onRunObjectEnter().

                                       {
                sendInfo($this->gui->lng->txt("test_cancelled"), true);
                $path = $this->gui->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:

DefaultTestCommandControl::handleCommands (  ) 

handle standard commands like confirmation, deletes, evaluation

Reimplemented in OnlineTestCommandControl.

Definition at line 94 of file class.ilCommandControl.php.

References $_GET, $_POST, $ilUser, and sendInfo().

                                   {
                global $ilUser;
                if ($_POST["cmd"]["confirmdeleteresults"])
                {
                        $this->obj->deleteResults($ilUser->id);
                        sendInfo($this->gui->lng->txt("tst_confirm_delete_results_info"));
                }
                
                if ($_POST["cmd"]["deleteresults"])
                {
                        $this->gui->confirmDeleteResults();
                        return true;
                }
                
                if ($_GET["evaluation"])
                {
                        $this->gui->outEvaluationForm();
                        return true;
                }

                if (($_POST["cmd"]["showresults"]) or ($_GET["sortres"]))
                {
                        $this->gui->outTestResults();
                        return true;
                }
                
                return false;           
        }

Here is the call graph for this function:

DefaultTestCommandControl::handleStartCommands (  ) 

handle start test commands

Reimplemented in OnlineTestCommandControl.

Definition at line 127 of file class.ilCommandControl.php.

References $_POST, $_SESSION, and $ilUser.

                                        {
                global $ilUser;
                        
                if ($_POST["cmd"]["start"] && $this->obj->isRandomTest())
                {
                        if ($this->obj->getRandomQuestionCount() > 0)
                        {
                                $qpls =& $this->obj->getRandomQuestionpools();
                                $rndquestions = $this->obj->randomSelectQuestions($this->obj->getRandomQuestionCount(), 0, 1, $qpls);
                                $allquestions = array();
                                foreach ($rndquestions as $question_id)
                                {
                                        array_push($allquestions, $question_id);
                                }
                                srand ((float)microtime()*1000000);
                                shuffle($allquestions);
                                foreach ($allquestions as $question_id)
                                {
                                        $this->obj->saveRandomQuestion($question_id);
                                }
                                $this->obj->loadQuestions();
                        }
                        else
                        {
                                $qpls =& $this->obj->getRandomQuestionpools();
                                $allquestions = array();
                                foreach ($qpls as $key => $value)
                                {
                                        if ($value["count"] > 0)
                                        {
                                                $rndquestions = $this->obj->randomSelectQuestions($value["count"], $value["qpl"], 1);
                                                foreach ($rndquestions as $question_id)
                                                {
                                                        array_push($allquestions, $question_id);
                                                }
                                        }
                                }
                                srand ((float)microtime()*1000000);
                                shuffle($allquestions);
                                foreach ($allquestions as $question_id)
                                {
                                        $this->obj->saveRandomQuestion($question_id);
                                }
                                $this->obj->loadQuestions();
                        }
                }
                        
                // create new time dataset and set start time
                $active_time_id = $this->obj->startWorkingTime($ilUser->id);
                $_SESSION["active_time_id"] = $active_time_id;
                
                if ($_POST["chb_javascript"])
                {
                        $ilUser->setPref("tst_javascript", 1);
                        $ilUser->writePref("tst_javascript", 1);
                }
                else
                {
                        $ilUser->setPref("tst_javascript", 0);
                        $ilUser->writePref("tst_javascript", 0);
                }
                
                return true;
                                
        }

DefaultTestCommandControl::isNrOfTriesReached (  ) 

nr of tries exceeded

Definition at line 258 of file class.ilCommandControl.php.

Referenced by canSaveResult(), and isTestAccessible().

                                       {
                $active = $this->obj->getActiveTestUser();
                return $this->obj->hasNrOfTriesRestriction() && is_object($active) && $this->obj->isNrOfTriesReached ($active->tries);  
        }

Here is the caller graph for this function:

DefaultTestCommandControl::isTestAccessible (  ) 

test accessible returns true if the user can perform the test

Definition at line 267 of file class.ilCommandControl.php.

References isNrOfTriesReached().

Referenced by OnlineTestCommandControl::prepareRequestVariables().

                                    {           
                return  !$this->isNrOfTriesReached()                            
                                and      !$this->gui->isMaxProcessingTimeReached()
                                and  $this->obj->startingTimeReached()
                                and  !$this->gui->isEndingTimeReached();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

DefaultTestCommandControl::isTestResumable (  ) 

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

Reimplemented in OnlineTestCommandControl.

Definition at line 250 of file class.ilCommandControl.php.

                                    {
                $active = $this->obj->getActiveTestUser();              
                return is_object($active) && $this->obj->startingTimeReached() && !$this->obj->endingTimeReached();
        }

DefaultTestCommandControl::onRunObjectEnter (  ) 

what to when entering the run object

Reimplemented in OnlineTestCommandControl.

Definition at line 81 of file class.ilCommandControl.php.

References $_POST, and handleCancelCommand().

                                    {
                // cancel Test if it's not online test
                if ($_POST["cmd"]["cancelTest"])
                {
                        $this->handleCancelCommand();
                }               
                // check online exams access restrictions due to participants and client ip
        }       

Here is the call graph for this function:

DefaultTestCommandControl::prepareRequestVariables (  ) 

prepare Request variables e.g.

some get parameters have to be mapped to post params

Reimplemented in OnlineTestCommandControl.

Definition at line 72 of file class.ilCommandControl.php.

References $_GET, and $_POST.

                                           {
                // set showresult cmd if pressed on sort in result overview
                if ($_GET["sortres"])
                        $_POST["cmd"]["showresults"] = 1; 
        }

DefaultTestCommandControl::showTestResults (  ) 

showTestResults returns true if the according request is set

Definition at line 278 of file class.ilCommandControl.php.

References $_GET.

                                    {
                return $_GET['crs_show_result'];// && $this->obj->canViewResults();
        }


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