Skip to content

Commit

Permalink
Fixed issue CT-55: multiple responses participants (Previous session …
Browse files Browse the repository at this point in the history
…is set to be finished) (#3024)

* dev: LS-CT-55 Previous session is set to be finished

* dev: LS-CT-55 Previous session is set to be finished (tokenanswerspersistence added to condition)

---------

Co-authored-by: pstelling <patricia.stelling@limesurvey.org>
  • Loading branch information
twilligls and Trischi80 committed Mar 30, 2023
1 parent 09f3940 commit b9d27a5
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions application/controllers/survey/index.php
Expand Up @@ -22,6 +22,13 @@ public function run()
$this->action();
}

/**
*
* todo: this function is toooo long, to many things happening here. Should be refactored asap!
* @return void
* @throws CException
* @throws CHttpException
*/
public function action()
{
global $surveyid;
Expand Down Expand Up @@ -211,22 +218,32 @@ public function action()
}

// No test for response update
if ($this->isSurveyFinished($surveyid) && ($thissurvey['alloweditaftercompletion'] != 'Y' || $thissurvey['tokenanswerspersistence'] != 'Y')) {
if ($this->isSurveyFinished($surveyid)) {
killSurveySession($surveyid);
$aReloadUrlParam = array('lang' => App()->language, 'newtest' => 'Y');

if (!empty($clienttoken)) {
$aReloadUrlParam['token'] = $clienttoken;
}

$aErrors = array(gT('Previous session is set to be finished.'));
$aMessage = array(gT('Your browser reports that it was used previously to answer this survey. We are resetting the session so that you can start from the beginning.'),);
//todo: this url is never shown to the participant in case of renderExitMessage (see below)
$restartUrl = $this->getController()->createUrl("/survey/index/sid/{$surveyid}", $aReloadUrlParam);
$aUrl = array(
'url' => $this->getController()->createUrl("/survey/index/sid/{$surveyid}", $aReloadUrlParam),
'url' => $restartUrl,
'type' => 'restart-survey',
'description' => gT("Click here to start the survey.")
);

killSurveySession($surveyid);
//Use case: if participant has possibility to run survey again
//instead of showing an error message, redirect participant to restart survey
//check if inherit value is set to 'Y'
$alloweditaftercompletion = ($thissurvey['alloweditaftercompletion'] == 'Y') ||
$oSurvey->getIsAllowEditAfterCompletion() || $thissurvey['tokenanswerspersistence'] == 'Y';
if ($alloweditaftercompletion) {
$this->getController()->redirect($restartUrl);
}

$aErrors = array(gT('Previous session is set to be finished.'));
$aMessage = array(gT('Your browser reports that it was used previously to answer this survey.
We are resetting the session so that you can start from the beginning.'),);
App()->getController()->renderExitMessage(
$surveyid,
'restart-survey',
Expand Down

0 comments on commit b9d27a5

Please sign in to comment.