Skip to content

Commit

Permalink
Dev: methods setNotAnsweredAndNotValidated() and moveSubmitIfNeeded()
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Nov 18, 2016
1 parent b28e50b commit 180cc06
Showing 1 changed file with 83 additions and 64 deletions.
147 changes: 83 additions & 64 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -962,67 +962,23 @@ private function saveSubmitIfNeeded()
}
}

private function runPage()
//Now, we check mandatory questions if necessary
//CHECK IF ALL CONDITIONAL MANDATORY QUESTIONS THAT APPLY HAVE BEEN ANSWERED
private function setNotAnsweredAndNotValidated()
{
// retrieve datas from local variable
$moveResult = $this->moveResult;

// Todo: check which ones are really needed
$LEMdebugLevel = $this->LEMdebugLevel ;
$LEMskipReprocessing = $this->LEMskipReprocessing ;
$thissurvey = $this->thissurvey ;
$surveyid = $this->surveyid ;
$show_empty_group = $this->show_empty_group ;
$surveyMode = $this->surveyMode ;
$surveyOptions = $this->surveyOptions ;
$totalquestions = $this->totalquestions ;
$bTokenAnswerPersitance = $this->bTokenAnswerPersitance ;
$assessments = $this->assessments ;
$moveResult = $this->moveResult ;
$move = $this->move ;
$invalidLastPage = $this->invalidLastPage ;
$backpopup = $this->backpopup ;
$popup = $this->popup ;
$oResponse = $this->oResponse ;
$unansweredSQList = $this->unansweredSQList ;
$notanswered = $this->notanswered ;
$invalidSQList = $this->invalidSQList ;
$filenotvalidated = $this->filenotvalidated ;
$completed = $this->completed ;
$content = $this->content ;
$blocks = $this->blocks ;
$notvalidated = $this->notvalidated ;
$LEMsessid = $this->LEMsessid ;

$this->initFirstStep(); // If it's the first time user load this survey, will init session and LEM
$this->initTotalAndMaxSteps();
$this->checkIfUseBrowserNav(); // Check if user used browser navigation, or relaoded page
$this->moveFirstChecks(); // If the move is clearcancel, or confirmquota, then the process will stop here
$this->checkPrevStep(); // Check if prev step is set, else set it
$this->setMoveResult();
$this->checkIfFinished(); // If $moveResult == finished, or not, various things to set
$this->displayFirstPageIfNeeded();
$this->saveAllIfNeeded();
$this->saveSubmitIfNeeded();

$move = $this->move;
$moveResult = $this->moveResult;

$totalquestions = $this->totalquestions = $_SESSION['survey_'.$surveyid]['totalquestions']; // Proabably for redata



//Now, we check mandatory questions if necessary
//CHECK IF ALL CONDITIONAL MANDATORY QUESTIONS THAT APPLY HAVE BEEN ANSWERED
global $notanswered;
$this->notvalidated = $notanswered;

if (isset($moveResult) && !$moveResult['finished']){
if (!$moveResult['finished']){
$unansweredSQList = $this->unansweredSQList = $moveResult['unansweredSQs'];
if (strlen($unansweredSQList) > 0){
$notanswered = $this->notanswered =explode('|', $unansweredSQList);
}else{
$notanswered = $this->notanswered = array();
}

//CHECK INPUT
$invalidSQList = $this->invalidSQList = $moveResult['invalidSQs'];
if (strlen($invalidSQList) > 0){
Expand All @@ -1031,21 +987,21 @@ private function runPage()
$notvalidated = $this->notvalidated = array();
}
}
}

// CHECK UPLOADED FILES
// TMSW - Move this into LEM::NavigateForwards?
$filenotvalidated = $this->filenotvalidated = checkUploadedFileValidity($surveyid, $move);

//SEE IF THIS GROUP SHOULD DISPLAY
$show_empty_group = $this->show_empty_group = false;

if ($_SESSION[$LEMsessid]['step'] == 0)
$show_empty_group = $this->show_empty_group = true;

$redata = compact(array_keys(get_defined_vars())); // must replace this by something better

//SUBMIT ###############################################################################
if ((isset($move) && $move == "movesubmit")){
private function moveSubmitIfNeeded($redata)
{
// retrieve datas from local variable
$surveyid = $this->surveyid;
$surveyMode = $this->surveyMode;
$surveyOptions = $this->surveyOptions;
$move = $this->move;
$moveResult = $this->moveResult;
$LEMsessid = $this->LEMsessid;
$thissurvey = $this->thissurvey;
$sTemplateViewPath = $this->sTemplateViewPath;

if ($move == "movesubmit"){
// setcookie("limesurvey_timers", "", time() - 3600); // remove the timers cookies //@todo fix - sometimes results in headers already sent error
if ($thissurvey['refurl'] == "Y"){
//Only add this if it doesn't already exist
Expand Down Expand Up @@ -1237,6 +1193,69 @@ private function runPage()
}
}

private function runPage()
{

// Todo: check which ones are really needed
$LEMdebugLevel = $this->LEMdebugLevel ;
$LEMskipReprocessing = $this->LEMskipReprocessing ;
$thissurvey = $this->thissurvey ;
$surveyid = $this->surveyid ;
$show_empty_group = $this->show_empty_group ;
$surveyMode = $this->surveyMode ;
$surveyOptions = $this->surveyOptions ;
$totalquestions = $this->totalquestions ;
$bTokenAnswerPersitance = $this->bTokenAnswerPersitance ;
$assessments = $this->assessments ;
$moveResult = $this->moveResult ;
$move = $this->move ;
$invalidLastPage = $this->invalidLastPage ;
$backpopup = $this->backpopup ;
$popup = $this->popup ;
$oResponse = $this->oResponse ;
$unansweredSQList = $this->unansweredSQList ;
$notanswered = $this->notanswered ;
$invalidSQList = $this->invalidSQList ;
$filenotvalidated = $this->filenotvalidated ;
$completed = $this->completed ;
$content = $this->content ;
$blocks = $this->blocks ;
$notvalidated = $this->notvalidated ;
$LEMsessid = $this->LEMsessid ;

$this->initFirstStep(); // If it's the first time user load this survey, will init session and LEM
$this->initTotalAndMaxSteps();
$this->checkIfUseBrowserNav(); // Check if user used browser navigation, or relaoded page
$this->moveFirstChecks(); // If the move is clearcancel, or confirmquota, then the process will stop here
$this->checkPrevStep(); // Check if prev step is set, else set it
$this->setMoveResult();
$this->checkIfFinished(); // If $moveResult == finished, or not, various things to set
$this->displayFirstPageIfNeeded();
$this->saveAllIfNeeded();
$this->saveSubmitIfNeeded();
$this->setNotAnsweredAndNotValidated();

// CHECK UPLOADED FILES
// TMSW - Move this into LEM::NavigateForwards?
$filenotvalidated = $this->filenotvalidated = checkUploadedFileValidity($surveyid, $this->move);


//SEE IF THIS GROUP SHOULD DISPLAY
if ($_SESSION[$LEMsessid]['step'] == 0)
$show_empty_group = $this->show_empty_group = true;

$move = $this->move;
$moveResult = $this->moveResult;

$totalquestions = $this->totalquestions = $_SESSION['survey_'.$surveyid]['totalquestions']; // Proabably for redata

$redata = compact(array_keys(get_defined_vars())); // must replace this by something better

//SUBMIT ###############################################################################
$this->moveSubmitIfNeeded($redata);

}

private function setVarFromArgs($args)
{
extract($args);
Expand Down

0 comments on commit 180cc06

Please sign in to comment.