Skip to content

Commit

Permalink
Fixed issue #07020: "Show question index / allow jumping" with "Allow…
Browse files Browse the repository at this point in the history
… editing responses after completion" are incomplete

Dev: update maxstep to laststep and add a jumpto maxstep is set
Dev: fix issue with survey start over with "Allow editing responses after completion" too
  • Loading branch information
Shnoulle committed Dec 7, 2012
1 parent e11ba5d commit 96af872
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
12 changes: 11 additions & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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']);
}
Expand Down Expand Up @@ -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']))
Expand Down
20 changes: 14 additions & 6 deletions application/helpers/frontend_helper.php
Expand Up @@ -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")."<br />\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")
Expand All @@ -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.
Expand Down

0 comments on commit 96af872

Please sign in to comment.