Skip to content

Commit

Permalink
Fixed issue #5817: "Allow editing answers after completion" setting c…
Browse files Browse the repository at this point in the history
…reates new answer and bypasses 'uses left' property
  • Loading branch information
c-schmitz committed Feb 28, 2012
1 parent 34dfab7 commit 5cde896
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions application/controllers/survey/index.php
Expand Up @@ -141,7 +141,7 @@ function action()
}
else
{
$sTempLanguage='';
$sTempLanguage='';
}
$clang = SetSurveyLanguage( $surveyid, $sTempLanguage);

Expand Down Expand Up @@ -573,9 +573,8 @@ function sendreq(surveyid)
// - a token information has been provided
// - the survey is setup to allow token-response-persistence

if ($thissurvey['tokenanswerspersistence'] == 'Y' && !isset($_SESSION['survey_'.$surveyid]['srid']) && $thissurvey['anonymized'] == "N" && $thissurvey['active'] == "Y" && isset($token) && $token !='')
if (!isset($_SESSION['srid']) && $thissurvey['anonymized'] == "N" && $thissurvey['active'] == "Y" && isset($token) && $token !='')
{

// load previous answers if any (dataentry with nosubmit)
$srquery="SELECT id FROM {$thissurvey['tablename']}"
. " WHERE {$thissurvey['tablename']}.token='".$token."' order by id desc";
Expand All @@ -584,36 +583,39 @@ function sendreq(surveyid)
if ($result->count()>0)
{
$row=reset($result->read());
if($row['submitdate']=='' || ($row['submitdate']!='' && $thissurvey['alloweditaftercompletion'] == 'Y'))
if(($row['submitdate']=='' && $thissurvey['tokenanswerspersistence'] == 'Y' )|| ($row['submitdate']!='' && $thissurvey['alloweditaftercompletion'] == 'Y'))
{
$_SESSION['survey_'.$surveyid]['srid'] = $row['id'];

}
buildsurveysession();
loadanswers();
}
buildsurveysession();
loadanswers();
}

// // SAVE POSTED ANSWERS TO DATABASE IF MOVE (NEXT,PREV,LAST, or SUBMIT) or RETURNING FROM SAVE FORM
// if (isset($move) || isset($_POST['saveprompt']))
// {
// $redata = compact(array_keys(get_defined_vars()));
// //save.php
// Yii::import("application.libraries.Save");
// $tmp = new Save();
// $tmp->run($redata);
//
// // RELOAD THE ANSWERS INCASE SOMEONE ELSE CHANGED THEM
// if ($thissurvey['active'] == "Y" &&
// ( $thissurvey['allowsave'] == "Y" || $thissurvey['tokenanswerspersistence'] == "Y") )
// {
// loadanswers();
// }
// }
}

// // SAVE POSTED ANSWERS TO DATABASE IF MOVE (NEXT,PREV,LAST, or SUBMIT) or RETURNING FROM SAVE FORM
// if (isset($move) || isset($_POST['saveprompt']))
// {
// $redata = compact(array_keys(get_defined_vars()));
// //save.php
// Yii::import("application.libraries.Save");
// $tmp = new Save();
// $tmp->run($redata);
//
// // RELOAD THE ANSWERS INCASE SOMEONE ELSE CHANGED THEM
// if ($thissurvey['active'] == "Y" &&
// ( $thissurvey['allowsave'] == "Y" || $thissurvey['tokenanswerspersistence'] == "Y") )
// {
// loadanswers();
// }
// }

if (isset($param['action']) && $param['action'] == 'previewgroup')
{
$thissurvey['format'] = 'G';
buildsurveysession($surveyid,true);
}

if (isset($param['action']) && $param['action'] == 'previewquestion')
{
$thissurvey['format'] = 'S';
Expand Down Expand Up @@ -741,7 +743,7 @@ function _isPreviewAction($param = array())
{
return isset($param['action']) && ($param['action'] == 'previewgroup' || $param['action'] == 'previewquestion');
}

function _surveyCantBeViewedWithCurrentPreviewAccess($surveyid, $bIsSurveyActive, $bSurveyExists)
{
$bSurveyPreviewRequireAuth = Yii::app()->getConfig('surveyPreview_require_Auth');
Expand Down

0 comments on commit 5cde896

Please sign in to comment.