Skip to content

Commit

Permalink
Fixed issue : #6226 & #6229 : Cannot edit answer (token and edit answ…
Browse files Browse the repository at this point in the history
…ers after submitting activated)

Fixed issue : cannot do a survey with edit answers after submitting activated or token answer persistance
Dev : buildsurveysession need surveyid in Yii : can be removed with a $thisurvey['sid'] ?
  • Loading branch information
Shnoulle committed Jun 18, 2012
1 parent 551dc76 commit 1664db8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions application/controllers/survey/index.php
Expand Up @@ -612,7 +612,7 @@ function sendreq(surveyid)
// - a token information has been provided
// - the survey is setup to allow token-response-persistence

if (!isset($_SESSION['srid']) && $thissurvey['anonymized'] == "N" && $thissurvey['active'] == "Y" && isset($token) && $token !='')
if (!isset($_SESSION['survey_'.$surveyid]['srid']) && $thissurvey['anonymized'] == "N" && $thissurvey['active'] == "Y" && isset($token) && $token !='')
{
// load previous answers if any (dataentry with nosubmit)
$srquery="SELECT id,submitdate,lastpage FROM {$thissurvey['tablename']}"
Expand All @@ -625,13 +625,13 @@ function sendreq(surveyid)
if(($row['submitdate']=='' && $thissurvey['tokenanswerspersistence'] == 'Y' )|| ($row['submitdate']!='' && $thissurvey['alloweditaftercompletion'] == 'Y'))
{
$_SESSION['survey_'.$surveyid]['srid'] = $row['id'];
if (!is_null($row['lastpage']))
if (!is_null($row['lastpage']) && $row['submitdate']=='')
{
$_SESSION['survey_'.$surveyid]['LEMtokenResume'] = true;
$_SESSION['survey_'.$surveyid]['step'] = $row['lastpage'];
}
}
buildsurveysession();
buildsurveysession($surveyid);
loadanswers();
}
}
Expand Down
21 changes: 14 additions & 7 deletions application/helpers/common_helper.php
Expand Up @@ -5621,19 +5621,26 @@ function getXMLWriter() {


/**
* Returns true when a token can not be used (either doesn't exist or has less then one usage left
* Returns true when a token can not be used (either doesn't exist, has less then one usage left or allao edit after completion aren't allowed)
*
* @param mixed $tid Token
*/
function usedTokens($token, $surveyid)
{
$utresult = true;
Tokens_dynamic::sid($surveyid);
$query=Tokens_dynamic::model()->findAllByAttributes(array("token"=>$token));

if (count($query) > 0) {
$row = $query[0];
if ($row->usesleft > 0) $utresult = false;
$thissurvey=getSurveyInfo($surveyid);;// ONLY for alloweditaftercompletion
if($thissurvey['alloweditaftercompletion'])
{
$utresult = false;
}
else
{
Tokens_dynamic::sid($surveyid);
$query=Tokens_dynamic::model()->findAllByAttributes(array("token"=>$token));
if (count($query) > 0) {
$row = $query[0];
if ($row->usesleft > 0) $utresult = false;
}
}
return $utresult;
}
Expand Down

0 comments on commit 1664db8

Please sign in to comment.