View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
06541Bug reportsSurvey takingpublic2012-09-20 14:12
ReporterLouisD Assigned Toc_schmitz  
PriorityhighSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.00RC9 
Fixed in Version2.00+ 
Summary06541: Attempting to view multiple surveys at the same time causes survey to submit as incomplete, or questions disappear on refresh.
Description

If you have multiple surveys open at the same time in different tabs or iframes or similar when you attempt to submit the survey all answered questions will be discarded and the survey will be submitted as incomplete. If while the survey is in this state you refresh the page all of the questions will disappear. I have already found a fix for this and explain it in additional information. For a more detailed explanation I posted about this in the forums here:

http://www.limesurvey.org/en/forum/development/85092-problems-switching-between-multiple-surveys-at-same-time-with-possible-solution

Steps To Reproduce

Open more than one survey at ensure they are using the same session. Try refreshing and/or submitting the surveys.

Additional Information

The problem appears to be being caused by the cached LimeExpressionManager singleton not always being flagged as dirty in certain situations and therefor not always being reloaded with the correct current survey information.

To fix this I added the following static function to the file em_manager_helper.php.

----------START PHP----------
public static function getLEMsurveyId() {
$LEM =& LimeExpressionManager::singleton();
return $LEM->sid;
}
-----------END PHP-----------

Then starting at line 93 of SurveyRuntimeHelper.php I changed the code as follows:

Before:
----------START PHP----------
//RUN THIS IF THIS IS THE FIRST TIME , OR THE FIRST PAGE ########################################
if (!isset($_SESSION[$LEMsessid]['step'])) // || !$_SESSION[$LEMsessid]['step']) - don't do this for step0, else rebuild the session
{
buildsurveysession($surveyid);
$sTemplatePath = $SESSION['survey'.$surveyid]['templatepath'];

LimeExpressionManager::StartSurvey($thissurvey['sid'], $surveyMode, $surveyOptions, false, $LEMdebugLevel);
$_SESSION[$LEMsessid]['step'] = 0;
if ($surveyMode == 'survey')
{
    $move = "movenext"; // to force a call to NavigateForwards()
}
else if (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N')
{
    //If explicitply set, hide the welcome screen
    $_SESSION[$LEMsessid]['step'] = 0;
    $move = "movenext";
}

}
-----------END PHP-----------

After:
----------START PHP----------
//RUN THIS IF THIS IS THE FIRST TIME , OR THE FIRST PAGE ########################################
if (!isset($_SESSION[$LEMsessid]['step'])) // || !$_SESSION[$LEMsessid]['step']) - don't do this for step0, else rebuild the session
{
buildsurveysession($surveyid);
$sTemplatePath = $_SESSION[$LEMsessid]['templatepath'];

if($surveyid != LimeExpressionManager::getLEMsurveyId())
    LimeExpressionManager::SetDirtyFlag();

LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions, false, $LEMdebugLevel);
$_SESSION[$LEMsessid]['step'] = 0;
if ($surveyMode == 'survey' || (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N'))
{
    $move = "movenext"; // to force a call to NavigateForwards()
}

} else if($surveyid != LimeExpressionManager::getLEMsurveyId()) {
LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions, false, $LEMdebugLevel);
LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['step'], false, false);
}
-----------END PHP-----------

TagsNo tags attached.
Bug heat6
Complete LimeSurvey version number (& build)120816
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL 5.0.90
Server OS (if known)Linux
Webserver software & version (if known)Apache/2.2.3 (CentOS)
PHP Version5.3.13

Users monitoring this issue

There are no users monitoring this issue.

Activities

LouisD

LouisD

2012-09-04 00:29

reporter   ~20625

I forgot to mention that I am using the Yii branch of LimeSurvey.

DenisChenu

DenisChenu

2012-09-07 12:48

developer   ~20639

Hello,

public survey session parameter is in array:
$_SESSION[$surveyid], maybe the dirty flag have to be in this array. And unset only the array of this surveyid :).

Denis

LouisD

LouisD

2012-09-09 23:44

reporter   ~20649

The problem step by step:

  1. When the survey id changes the survey index action sets the new survey id in the LimeExpressionManager as it should. This occurs whenever a user switches from one survey to another with out finishing the previous.

  2. When LimeExpressionManager::setSurveyId($newSurveyId) is called it updates the session variable in $_SESSION['LEMsid'] to the new current survey id and flags the LimeExpressionManager as dirty.

  3. When an instance of LimeExpressionManager is requested it is reinstatiated and stored in self::$instance, since it is flagged dirty, but none of its values are updated yet which I guess is ok since the values are never immediately loaded into the LimeExpressionManager. It seems to be up to the SurveyRuntimeHelper to do that.

  4. SurveyRuntimeHelper fails to load the new values into the LimeExpressionManager because it will only populate it if $_SESSION[$LEMsessid]['step'] is not set. However, it is set because the user was just viewing that survey a moment ago before the user finished it.

  5. I do not want to unset $_SESSION[$LEMsessid]. I want to keep track of exactly what step the user was on. I want to allow the user to pick up right where they left off and not interfere with any other surveys that user may have opened in another tab or whatever.

  6. Because LimeExpressionManager is never repopulated with the correct survey data the questions will never be submitted. Instead if the user completes the survey and submits it, it will be submitted as incomplete to the database. None of the user's answers are saved. No error is reported what so ever. The user believes he/she has successfully completed a survey. If the user refreshes the page all the questions simply disappear (they are hidden).

The bottom line:

The data stored in $SESSION[survey$surveyid] is good data. I want to keep and use that data. The system never corrupts this data in all ways I have used LimeSurvey.

The data stored in LimeExpressionManager is bad if you switch between multiple surveys before completing them. I want to repopulate the data in LimeExpressioManager.

My solution I provided here works perfectly. I've been using LimeSurvey for over 2 weeks now with no issues since adding this bug fix. Perhaps there is a better solution to fix this problem. I just hope a fix for this problem makes it into an update soon. I'm tired of having to merge my bug fix with each update. If I had not found this bug and fixed it I would not be using LimeSurvey on my site right now.

c_schmitz

c_schmitz

2012-09-14 14:17

administrator   ~20708

Thank you very much. Very good patch written with alot of insight. If you want to join the development please let me know ;).

Issue History

Date Modified Username Field Change
2012-09-04 00:24 LouisD New Issue
2012-09-04 00:29 LouisD Note Added: 20625
2012-09-07 12:48 DenisChenu Note Added: 20639
2012-09-09 23:44 LouisD Note Added: 20649
2012-09-14 11:59 c_schmitz Assigned To => c_schmitz
2012-09-14 11:59 c_schmitz Status new => assigned
2012-09-14 14:17 c_schmitz Note Added: 20708
2012-09-14 14:17 c_schmitz Status assigned => resolved
2012-09-14 14:17 c_schmitz Fixed in Version => 2.00+
2012-09-14 14:17 c_schmitz Resolution open => fixed
2012-09-20 14:12 c_schmitz Status resolved => closed