Welcome, Guest
Username: Password: Remember me

TOPIC: Problems switching between multiple surveys at same time with possible solution

Problems switching between multiple surveys at same time with possible solution 1 year 7 months ago #85092

  • LouisD
  • LouisD's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
This is my first post on the forums so I hope I get it right.

I am using the Yii branch of LimeSurvey, version 2.0 RC9. The zip file from github was designated as follows LimeSurvey-LimeSurvey-2.00RC9_120816-62-g123efd5.

I just started using LimeSurvey yesterday so my knowledge of the system is limited.

I have 3 all in one surveys that I am working with. I had no problems building them and so far I really like how easy to use and feature rich LimeSurvey is. Unfortunately I have run into some issues.

If I view just one survey and complete that survey everything works great. The problem occurs when I have not yet completed a survey and try to view another survey. As soon as I do this any attempt to submit any survey even if I completed it will result in an incomplete submission and any answers I may have answered are not recorded. However, no errors are reported to the client. I receive the standard successful submission message with a link to view statistics. Also if I try to refresh a survey when in this state all of the questions and groups simply disappear and all I can see is the welcome message.

This is a problem for me because I have a page in which there are 3 embedded surveys. One is in an embedded iframe near the bottom of the page. The other two are in fancybox iframes and pop up when a user clicks that survey's respective button on the page.

I've been digging around the past 2 days in the source code and I think I have found a solution. Unfortunately I am not familiar enough with all of LimeSurvey's features and how they work under the hood to know for sure if my solution has not created a problem else where. Hopefully someone can answer that question for me here.

What I did:

My problems with LimeSurvey appear 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 a static function to access the sid of the current LimeExpressionManager.

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

Before:
//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";
	}
}

After:
//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);
}

I have heavily tested this and played around a lot on the backend. This change to the code seems to have fixed all my problems without any side effects, that I have found yet at least.

If someone with some more experience developing for LimeSurvey could tell me if what I have done here is a good thing or a bad thing and if I have created some evil an explanation would be awesome.
The administrator has disabled public write access.

Re: Problems switching between multiple surveys at same time with possible solution 1 year 7 months ago #85115

  • aaroncruz
  • aaroncruz's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 1
  • Karma: 0
I was searching for this code, I will try this hope it works for me.
The administrator has disabled public write access.

Re: Problems switching between multiple surveys at same time with possible solution 1 year 7 months ago #85116

  • mdekker
  • mdekker's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 340
  • Thank you received: 68
  • Karma: 38
Please report this in the bugtracker so one of the developers can take a look at what you did. When it stays in the forum it might get lost.
---
Menno Dekker
The administrator has disabled public write access.

Re: Problems switching between multiple surveys at same time with possible solution 1 year 7 months ago #85132

  • LouisD
  • LouisD's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
I have reported this bug and another I found with fixes for both to the bug tracker.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.217 seconds
Donation Image