diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 9aba6613976..60b018444e8 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -112,7 +112,9 @@ function run($surveyid,$args) { $move = "movenext"; $_SESSION[$LEMsessid]['step']=1; } - } else if($surveyid != LimeExpressionManager::getLEMsurveyId()) { + } + elseif($surveyid != LimeExpressionManager::getLEMsurveyId()) + { LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions, false, $LEMdebugLevel); LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['step'], false, false); } @@ -164,6 +166,10 @@ function run($surveyid,$args) { if (isset($_SESSION[$LEMsessid]['LEMtokenResume'])) { LimeExpressionManager::StartSurvey($thissurvey['sid'], $surveyMode, $surveyOptions, false,$LEMdebugLevel); + if(isset($_SESSION[$LEMsessid]['maxstep']) && $_SESSION[$LEMsessid]['maxstep']>$_SESSION[$LEMsessid]['step']) + { + LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['maxstep'], false, false); + } $moveResult = LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['step'],false,false); // if late in the survey, will re-validate contents, which may be overkill unset($_SESSION[$LEMsessid]['LEMtokenResume']); } @@ -279,6 +285,10 @@ function run($surveyid,$args) { { $cSave->showsaveform(); // generates a form and exits, awaiting input } + else + { + // TODO : update lastpage to $_SESSION[$LEMsessid]['step'] in Survey_dynamic + } } if ($thissurvey['active'] == "Y" && isset($_POST['saveprompt'])) diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index 6a53728a841..7f7c4eecb34 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -49,18 +49,19 @@ function loadanswers() { return; } - $aRow = Yii::app()->db->createCommand($query)->queryRow(); if (!$aRow) { safeDie($clang->gT("There is no matching saved survey")."
\n"); + return false; } else { //A match has been found. Let's load the values! //If this is from an email, build surveysession first $_SESSION['survey_'.$surveyid]['LEMtokenResume']=true; - + // Get if survey is been answered + $submitdate=$aRow['submitdate']; foreach ($aRow as $column => $value) { if ($column == "token") @@ -73,11 +74,18 @@ function loadanswers() $_SESSION['survey_'.$surveyid]['step']=$value; $thisstep=$value-1; } - elseif ($column =='lastpage' && isset($_GET['token']) && $thissurvey['alloweditaftercompletion'] != 'Y' ) + elseif ($column =='lastpage' && isset($_GET['token'])) { - if ($value<1) $value=1; - $_SESSION['survey_'.$surveyid]['step']=$value; - $thisstep=$value-1; + if(is_null($submitdate) || $submitdate=="N") + { + if ($value<1) $value=1; + $_SESSION['survey_'.$surveyid]['step']=$value; + $thisstep=$value-1; + } + else + { + $_SESSION['survey_'.$surveyid]['maxstep']=$value; + } } /* Commented this part out because otherwise startlanguage would overwrite any other language during a running survey.