Check out the LimeSurvey source code on GitHub!

limesurvey in other website

More
6 years 1 month ago - 6 years 1 month ago #52767 by KRav
Hi there,

I'm using ls via iframe in Drupal.

To enter a survey I use this script:

bugs.limesurvey.org/view.php?id=2982

Forum
<?php
/*
When having a close token survey (token table exist)
you can create a token on the fly by giving as parameters sid and token                                                         lines  43- 49
In addition if someone has already complete a survey  he can review his answers an d correct them          lines  55- 61
 
Just put this script in limesurveys  root directory
Example:
 
http://localhost/limesurvey185plus-build7253-20090708/newtoken.php?sid=27644&newtest=Y&token=123456789012345678901234567890123456
 
Prerequisites:
1.  Anonymous answers?                            No       (This survey is NOT anonymous.)
2.  Enable Token-based answers persistence?       Yes
3.  Switch to closed-acces mode
4.  Use cookies?                                  No
 
*/
// Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB   
 
require_once(dirname(__FILE__).'/classes/core/startup.php');
require_once(dirname(__FILE__).'/config-defaults.php');
require_once(dirname(__FILE__).'/common.php');
require_once(dirname(__FILE__).'/classes/core/language.php');
@ini_set('session.gc_maxlifetime', $sessionlifetime);
 
$loadname=returnglobal('loadname');
$loadpass=returnglobal('loadpass');
$scid=returnglobal('scid');
$thisstep=returnglobal('thisstep');
$move=sanitize_paranoid_string(returnglobal('move'));
$clienttoken=trim(sanitize_xss_string(strip_tags(returnglobal('token'))));      
if (!isset($thisstep)) {$thisstep = "";}
 
 
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
else {
		//This next line ensures that the $surveyid value is never anything but a number.
		$surveyid=sanitize_int($surveyid);
	 }
 
// get variables from address bar
if (isset($_GET['sid'])) { $sid = $_GET['sid']; }
if (isset($_GET['myname'])) { $myname=urldecode($_GET['myname']); }
if (isset($_GET['token'])) { $token = $_GET['token']; }
//if (isset($_GET['token'])) { $token = $_GET['token']; }
if (isset($_GET['lang'])) { $lang = $_GET['lang']; }
 
$name = explode("|", $myname);
 
 
// short things are better
$tokentable = $dbprefix."tokens_".$sid;
$location = $rooturl;
$location .= '?sid='.$sid;
//$location .= '?=gr&newtest=Y'; // Problem? What is gr?
$location .= '&token='.$token; // Problem last page??
$location .= '&newtest=Y';
 
$iscompleted=mysql_query("SELECT `completed` FROM ". $tokentable. " WHERE token= '".$token."'");
$completed = mysql_num_rows($iscompleted);
 
if ($completed==0)                         //   there is no token so create one and procced to the survey
	{
	$wri = "INSERT INTO ".$tokentable." (firstname,lastname,email,language,sent,token) VALUES ('".$name[0]."','".$name[1]."',' ','".$lang." ','Y','".$token."')";
	mysql_query($wri) or die("Query error: ". mysql_error());
	header('Location:'.$location);
	// header('Location:'.$HTTP_REFERER.'?failed=1');
	}
 
else                                       //   Token exists
	{
	$fullycompleted =mysql_result($iscompleted,0,0);
 
	if ($fullycompleted="Y")               //    Survyey Is Completed So start editing the answers
		{
			$wri = "Update ".$tokentable." set completed = 'N' where token ='".$token."'";
			mysql_query($wri) or die("Query error: ". mysql_error());
			header('Location:'.$location);
			// header('Location:'.$HTTP_REFERER.'?failed=1');
		}
 
	if ($fullycompleted="N")               //    Survyey is not  Completed So procced
		{
			header('Location:'.$location);
		}
 
	}
 
?>

I've two questions..
1. It seems that I have the same issue like: bugs.limesurvey.org/view.php?id=2982 .

But I'm using Version 1.90+ Build 9487 - in this build the problem should be solved.
If I don't use token & newtest, I got my last page. If I use both, I step to the beginning.

In my opinion something is going wrong..

I never got the same page.. If I keep the browser open, access survey I got my last page.
If I close the browser, access the the survey again I got some other page..


2. Would it by possible to enter a survey via lsrc, or is this only for "admin" use.. found no hint to take part a survey via lsdrc


I've made an additional bug report, but cschmitz found no error.
bugs.limesurvey.org/view.php?id=4752


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.
Last Edit: 6 years 1 month ago by KRav.

Please Log in to join the conversation.

More
6 years 1 month ago #52771 by DenisChenu
Yes , and ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 1 month ago #52772 by KRav
pressed enter to fast.. B)


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in to join the conversation.

More
6 years 1 month ago #52777 by DenisChenu
Hello,

:laugh: too fast for me too ;)

Yes, understand .

Please reopen the bug report if:
You want to have:

newtest=Y and go to the lastpage if token already have some answer.

And give a link to this forum topic.

For Dev:
I don't understand why there are :
if (isset($_GET['newtest']) && $_GET['newtest'] = "Y") 
    {
        unset($_GET['token']);
    }

And to put at lastpage:
elseif ($column =='lastpage' && isset($_GET['token']))

I think we can have :
elseif ($column =='lastpage' && (isset($_GET['token'])||(isset($_GET['newtest']) && ($_GET['newtest']=='Y'))
(I don't verify the bracket :woohoo: )

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 1 month ago #52782 by KRav


research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in to join the conversation.

More
6 years 1 month ago #52800 by Mazi
Shnoulle wrote:

if (isset($_GET['newtest']) && $_GET['newtest'] = "Y") 
    {
        unset($_GET['token']);
    }

Should the IF statement read:
if (isset($_GET['newtest']) && $_GET['newtest'] == "Y") 
    {
        unset($_GET['token']);
    }
There has to be a "==" at the IF clause instead of "=".


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form