Skip to content

Commit

Permalink
Fixed issue: Not possible to save or load saved survey when in anonym…
Browse files Browse the repository at this point in the history
…ized mode
  • Loading branch information
dominikvitt committed Oct 26, 2018
1 parent 272a492 commit 9de59cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -976,12 +976,13 @@ private function saveAllIfNeeded()

// Don't test if save is allowed
if ($this->aSurveyInfo['active'] == "Y" && Yii::app()->request->getPost('saveall')) {
$bAnonymized = $this->aSurveyInfo["anonymized"] == 'Y';
$bTokenAnswerPersitance = $this->aSurveyInfo['tokenanswerspersistence'] == 'Y' && $this->iSurveyid != null && tableExists('tokens_'.$this->iSurveyid);

// must do this here to process the POSTed values
$this->aMoveResult = LimeExpressionManager::JumpTo($_SESSION[$this->LEMsessid]['step'], false); // by jumping to current step, saves data so far

if (!isset($_SESSION[$this->LEMsessid]['scid']) && !$bTokenAnswerPersitance) {
if (!isset($_SESSION[$this->LEMsessid]['scid']) && (!$bTokenAnswerPersitance || $bAnonymized)) {
Yii::import("application.libraries.Save");
$cSave = new Save();
// $cSave->showsaveform($this->aSurveyInfo['sid']); // generates a form and exits, awaiting input
Expand Down
9 changes: 5 additions & 4 deletions application/helpers/frontend_helper.php
Expand Up @@ -1486,21 +1486,22 @@ function getNavigatorDatas()
App()->getClientScript()->registerScript("activateActionLink", "activateActionLink();\n", LSYii_ClientScript::POS_POSTSCRIPT);

// Fill some test here, more clear ....
$bAnonymized = $thissurvey["anonymized"] == 'Y';
$bTokenanswerspersistence = $thissurvey['tokenanswerspersistence'] == 'Y' && tableExists('tokens_'.$surveyid);
$bAlreadySaved = isset($_SESSION['survey_'.$surveyid]['scid']);
$iSessionStep = (isset($_SESSION['survey_'.$surveyid]['step']) ? $_SESSION['survey_'.$surveyid]['step'] : false);
$iSessionMaxStep = (isset($_SESSION['survey_'.$surveyid]['maxstep']) ? $_SESSION['survey_'.$surveyid]['maxstep'] : false);

// Find out if the user has any saved data
if ($thissurvey['format'] == 'A') {
if (!$bTokenanswerspersistence && !$bAlreadySaved) {
if ((!$bTokenanswerspersistence || $bAnonymized) && !$bAlreadySaved) {
$aNavigator['load']['show'] = true;
}
$aNavigator['save']['show'] = true;
} elseif (!$iSessionStep) {

//Welcome page, show load (but not save)
if (!$bTokenanswerspersistence && !$bAlreadySaved) {
if ((!$bTokenanswerspersistence || $bAnonymized) && !$bAlreadySaved) {
$aNavigator['load']['show'] = true;
}

Expand All @@ -1509,15 +1510,15 @@ function getNavigatorDatas()
}
} elseif ($iSessionMaxStep == 1 && $thissurvey['showwelcome'] == "N") {
//First page, show LOAD and SAVE
if (!$bTokenanswerspersistence && !$bAlreadySaved) {
if ((!$bTokenanswerspersistence || $bAnonymized) && !$bAlreadySaved) {
$aNavigator['load']['show'] = true;
}

$aNavigator['save']['show'] = true;
} elseif (getMove() != "movelast") {
// Not on last page or submited survey
$aNavigator['save']['show'] = true;
}
}
}

return $aNavigator;
Expand Down

0 comments on commit 9de59cc

Please sign in to comment.