Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:
  • Seite:
  • 1
  • 2

THEMA: run php script on completion of a survey

run php script on completion of a survey 3 Jahre 6 Monate her #55972

  • ryanam
  • ryanams Avatar
I was wondering if it was possible to run a php (something like survey_end.php) script whenever someone completes a survey.

I know someone who did this back when this was phpsurveyor, but I don't know how they did it, and if it is possible with Lime Surveyor.

Thanks!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: run php script on completion of a survey 3 Jahre 6 Monate her #55975

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4117
  • Dank erhalten: 760
  • Karma: 346
Yes, you can fire a PHP script with a JavaScript/AJAX call. You can use the jQuery .get() function as shorthand for the AJAX calls.

Set up your survey to use JavaScript and place the something like this script in the source of the survey end message. This example will call a file "survey_end.php" in your template folder without passing any data to it.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$.get('upload/templates/yourTemplateName/survey_end.php');
 
	});
 
</script>

You can pass some values (for example, name and age) to the PHP file via the GET array like so:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$.get('upload/templates/yourTemplateName/survey_end.php', { name: 'John Doe', age: '38' } );
 
	});
 
</script>

More info on the jQuery .get() function here - api.jquery.com/jQuery.get
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: ryanam

Re: run php script on completion of a survey 3 Jahre 6 Monate her #56015

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5324
  • Dank erhalten: 293
  • Karma: 248
Another approach is to simply use the end URL feature and redirect the user to a certain URL which calls the PHP file.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: ryanam

Re: run php script on completion of a survey 3 Jahre 6 Monate her #56038

  • ryanam
  • ryanams Avatar
Thanks for the helpful replies. I don't have LimeSurvey installed yet, but hopefully should get that done today now that I know it is possible to do what I want to do.

The end URL feature seems pretty straight forward, but I don't believe I've seen anything about it. Is it something I would easily see once I've got LimeSurvey set up?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: run php script on completion of a survey 3 Jahre 6 Monate her #56073

  • Mazi
  • Mazis Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 5324
  • Dank erhalten: 293
  • Karma: 248
You'll find that at the survey settings, watch ut for "end URL": docs.limesurvey.org/Creating+a+new+surve...ation_amp_navigation

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: ryanam

Re: run php script on completion of a survey 1 Jahr 5 Monate her #93821

  • davyhp
  • davyhps Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Karma: 0
Hello,

Digging up an old message, but I'm trying to run a script to automate mailings at the end of a survey and I can't seem to get the JavaScript call my PHP script. I've enabled JavaScripts in Limesurvey, an
alert('test');
... prompts up a message box fine if inserted into the text value of some question for example. It also works fine when using the end URL feature redirection with values (but that solution isn't good enough for me since my URL is too long to fit, with 16 values to pass...)

So I wanted to use the code inside the survey, like mentionned :
$.get('upload/templates/yourTemplateName/survey_end.php');
... but this has no effect, even simple echoes won't show.

Am I doing something wrong? I'm a LS 2.00+ build 130226 user.

Thanks for reading me.

Regards,
Davy.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: run php script on completion of a survey 1 Jahr 5 Monate her #93829

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4117
  • Dank erhalten: 760
  • Karma: 346
even simple echoes won't show
Does that mean yo can't get the JavaScript alert to work from the end message?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: run php script on completion of a survey 1 Jahr 5 Monate her #93847

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6252
  • Dank erhalten: 799
  • Karma: 239
Mazi schrieb:
Another approach is to simply use the end URL feature and redirect the user to a certain URL which calls the PHP file.
This one is easy to do too.

Denis
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: run php script on completion of a survey 1 Jahr 5 Monate her #93862

  • davyhp
  • davyhps Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Karma: 0
If I use JavaScript or PHP through the "end URL" feature, everything works fine, it's when I add code into the survey elsewhere that it doesn't work.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: run php script on completion of a survey 1 Jahr 5 Monate her #93863

  • davyhp
  • davyhps Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Karma: 0
It's easy and works fine, but the size of that end URL textbox is too short for what I want it to share with my PHP script... ;-)
Der Administrator hat öffentliche Schreibrechte deaktiviert.
  • Seite:
  • 1
  • 2
Moderatoren: ITEd
Ladezeit der Seite: 0.167 Sekunden
Donation Image