Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: run php script on completion of a survey

run php script on completion of a survey 3 years 4 months ago #93866

  • ivanleng
  • ivanleng's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
I need to do the same and use a PHP script at the end to send some stuff to an external web service.

I'm thinking about using PHP Session to store some values so they can be easily retrieved, this way my end URL won't be too long.
The administrator has disabled public write access.

run php script on completion of a survey 3 years 4 months ago #94006

  • davyhp
  • davyhp's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
ivanleng wrote:
I need to do the same and use a PHP script at the end to send some stuff to an external web service.

I'm thinking about using PHP Session to store some values so they can be easily retrieved, this way my end URL won't be too long.

PHP Session would solve the backend problem, but I can't get a PHP script running from within the code of a survey question... Where else would I put my sessions' variables?

tpartner wrote:
<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

$.get('upload/templates/yourTemplateName/survey_end.php', { name: 'John Doe', age: '38' } );

});

</script>

That was the code submitted by tpartner, which isn't working for me inside a survey. Just JavaScript works fine, but the PHP script doesn't run like it does when I use the end URL feature.
Last Edit: 3 years 4 months ago by davyhp.
The administrator has disabled public write access.

run php script on completion of a survey 2 months 1 day ago #136523

  • Maverick87Shaka
  • Maverick87Shaka's Avatar
  • Offline
  • Junior Lime
  • Posts: 33
  • Thank you received: 1
  • Karma: 1
Hi to all,
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		$.get('upload/templates/yourTemplateName/survey_end.php');
 
	});
 
</script>
it's this code valid?

I'm trying to run a custom .php script at the end of survey, but it's seams the survey doesn't execute my script on survey end.

My current version is: 2.50+ Build 160506
The administrator has disabled public write access.

run php script on completion of a survey 2 months 1 day ago #136526

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5058
  • Thank you received: 746
  • Karma: 226
Why not using the redirect feature of the End url feature and send the participant to your script?
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

run php script on completion of a survey 2 months 1 day ago #136528

  • Maverick87Shaka
  • Maverick87Shaka's Avatar
  • Offline
  • Junior Lime
  • Posts: 33
  • Thank you received: 1
  • Karma: 1
mainly because I don't want to make the users "land" on this different page to run my script.
I don't want that users is able to view the "new" url
And if it's possible, my goal it's to run local script in a determinate path, not exposed on the public internet directory.
In my "vision" I would like to "launch" the execution of the .php script when users click on "finish" button, and show the standard limesurvey end page at the end of survey ( If it's possible I also like to serve the standard end page to the users without wait the execution of the other script )
The administrator has disabled public write access.

run php script on completion of a survey 2 months 1 day ago #136529

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5058
  • Thank you received: 746
  • Karma: 226
Well, then you need to wait if someone else has an idea. I can imagine that running your own PHP within LS is prevented somehow.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

run php script on completion of a survey 2 months 1 day ago #136541

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6111
  • Thank you received: 1356
  • Karma: 532
Try it with an absolute path to the script.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

run php script on completion of a survey 2 months 21 hours ago #136551

  • Maverick87Shaka
  • Maverick87Shaka's Avatar
  • Offline
  • Junior Lime
  • Posts: 33
  • Thank you received: 1
  • Karma: 1
tpartner wrote:
Try it with an absolute path to the script.
seams not work for me with absolute path, Now I'm tuning my script to know if it's possible to do what I need!
The administrator has disabled public write access.

run php script on completion of a survey 2 months 1 minute ago #136587

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9254
  • Thank you received: 1318
  • Karma: 382
Hi,

afterSurveyComplete event is here to do that

But here : please don't answer to a topic 3 years after: the solution can be outdated.
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.224 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form