Welcome, Guest
Username: Password: Remember me

TOPIC: Change action of RESUME button on survey

Change action of RESUME button on survey 2 years 6 months ago #79537

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
How can I interrupt the RESUME button on a survey and change the behavior? I want it to be more of a "Save and Exit" button that redirects them to my own page where I can take care of some additional business...

Currently when you press the button that says “Resume Later" the following happens (assuming that tokens are enabled):

1. Saves questions on current page, even if page isn't finished
2. Pop-Up says responses are saved.
3. Browser stays on the current page (does not exit or go anywhere)
4. Sends email to Respondent containing link with survey id and token. Clicking on the link takes you back to survey on page where you last saved.
5. If a user presses the button multiple times they will get another pop up and email each time.

Instead this is what I would like to happen:
1. Saves questions on current page, even if page isn't finished (so I still need to use the core functions for this)
2. No pop-up
3. Browser exits Limesurvey and goes to a URL that I specify, along with sid and token parameters. This could possibly be just the endurl.
4. Don't send email to Respondent.
5. Since pressing the button will exit the survey, users won't press it more than once.

I could just put my own button in the navigator.pstpl, but I do need to do the routine that saves partial responses in case they are in the middle of a page.

Anybody do this before or have ideas?
The administrator has disabled public write access.

Re: Change action of RESUME button on survey 2 years 6 months ago #79605

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
I should have mentioned that these surveys ALWAYS use tokens with token persistence enabled. So I'm not talking about the saved_control style of survey.
The administrator has disabled public write access.

Re: Change action of RESUME button on survey 2 years 6 months ago #79609

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5424
  • Thank you received: 307
  • Karma: 252
I also agree that having your own button would be the easiest solution, but since your want the current results to be stored, there is no easy way to get it done. You have to touch one of the core files on order to change the workflow, and this might cause problems when updating later.

One alternative approach one could evaluate is to add such a feature to the Limesurvey 2.1 version so you can have some survey settings like:
- save & return later: URL (string with replacement fields like {SAVEDID} , {TOKEN}, ...)
- save & return later: send email (yes/no)
- save & return later: show popup (yes/no)

Question is if there will be lots of users interested in such a solution and/or if you or someone else could sponsor the development, because as so often at Open Source projects, we are short of human ressources :-(

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'"
Last Edit: 2 years 6 months ago by Mazi.
The administrator has disabled public write access.

Re: Change action of RESUME button on survey 2 years 6 months ago #79610

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5424
  • Thank you received: 307
  • Karma: 252
...I forgot to mention that I was writing "Limesurvey 2.1" because we are currently working on getting Limesurvey 2.0 stable, so the feature freeze for that version is near (though not decided yet).

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'"
The administrator has disabled public write access.

Re: Change action of RESUME button on survey 2 years 6 months ago #79931

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
Update on this issue.

First, since all of our surveys are using tokens with persistence enabled, I was mistaken about the email in step 4. LS doesn't seem to send the email for token surveys, but only in non-token surveys when the saved_control table is used to save the responses. So that took care of one of my complaints.

Second, regarding our need to force exit but still save the responses even if the participant is only partway through a group: Although we've always avoided "hacking" the LS core, I had to make an exception since we couldn't find another alternative.

The code that creates the popup is on line 892 of index.php:
echo "<script language='JavaScript'> $(document).ready( function() {alert('".$clang->gT("Your responses were successfully saved.","js")."');}) </script>";

So I just replaced that line with the following to point to our page and pass the surveyid and token:
header("Location: ../mysave.php?sid=$surveyid&token=$token");

It seems to work great. The survey closes and launches my script and the partial responses are saved to the database. Of course, now we have to start a list of customizations to re-apply every time LS is updated. :(

If any LS experts see any dangers or have any other ideas I'd love to hear them.
The administrator has disabled public write access.

Re: Change action of RESUME button on survey 2 years 6 months ago #79954

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5424
  • Thank you received: 307
  • Karma: 252
Thanks for your feedback.

The only danger I can think of is that surveyID and token might be displayed within the URL of the new window. The user could then introduce malicious code so I recommend to sanitize these values before using them in a follow up script:

$surveyid = sanitize_int($_GET);
$token= sanitize_token($_GET);

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'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.211 seconds
Donation Image