Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Save responses via javascript

  • ployrich
  • ployrich's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 7 months ago - 2 years 7 months ago #225368 by ployrich
Save responses via javascript was created by ployrich
Please help us help you and fill where relevant:
Your LimeSurvey version: 3.27.14
Own server or LimeSurvey hosting: own server
Survey theme/template: bootswatch (basic)
==================
Hi all,
I am redirecting participants conditionally on the answer the want to give in the middle of a survey. For that I am overriding the submit of the 'Next'-Button. But I want the response of this question page to be saved.
How do I do that? - via javascript (I suspect).
Enable token-based response persistence is on. In production we want to hide the "Resume later" Button. I have succeeded mimicking the click on it, but in a really hacky manor. But it inferes with the redirection.
So JS/ LimeSurvey wizards, how do I do it better? (I am open to suggestion also for the redirection part of this problem.)

Thanks in advance.
Last edit: 2 years 7 months ago by ployrich. Reason: Added more detail

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225371 by Joffm
Replied by Joffm on topic Save responses via javascript
Hi,
I do not understand what you mean by "redirect".
Call a webpage and come back to LS?
Call a webpage and leave LS?

Anyway:
Why override the "Next"-Button.
Have a look here
[url] manual.limesurvey.org/Workarounds:_Manip...cript#Alternate_exit [/url]

Use an empty "text display" and of course you don't use the INSERTANS stuff, but {QCode}.
This way the value is saved and you open a new window, either with target="_blank" or something else.

In production we want to hide the "Resume later" Button. I have succeeded mimicking the click on it, but in a really hacky manor. But it inferes with the redirection.

In my opinion better to remove the link in "navbar.twig" in an extended theme.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ployrich

Please Log in to join the conversation.

  • ployrich
  • ployrich's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 7 months ago #225378 by ployrich
Replied by ployrich on topic Save responses via javascript
Hi,
Thanks. Redirecting means, I call another LS-survey and then come back to the "original" survey.

Thank you for that page, makes sense to put in on a seperate question. And your way of removing the "Resume later" link is excactly why I asked this question, because I knew its not a good way to hide but still use it.

Thanks I will try out the alternate exit solution and come back if more questions come up.
 

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225390 by holch
Replied by holch on topic Save responses via javascript
Just out of curiosity: Why leaving the Limesurvey survey for another Limesurvey survey and then coming back to the first Limesurvey survey?

What is the reason for not including everything into one Limesurvey survey?

I mean I get it if there is some kind of experiment that can not be done in Limesurvey, or a special conjoint tool, etc. But if both surveys are Limesurvey surveys, special requirements can't be the reason.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • ployrich
  • ployrich's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 7 months ago #225398 by ployrich
Replied by ployrich on topic Save responses via javascript
The "external" survey mimics a loop. (But for those who enter we didnt want to restrict the amount of iterations from the beginning, and the DB max is definitely enough.) As not many participants will enter said loop we didnt want to bloat the original survey with the relevance and amout of questions necessary for that.
It's purely a design decision on our part as we know that we might need some survey "partitioning" and redirection we are choosing it to outsource the loop.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225402 by holch
Replied by holch on topic Save responses via javascript

he "external" survey mimics a loop.


Understood. Makes sense.

I was only asking, because often people just tell us "half the story" and then at the end of a lengthy thread in the forum we find out what they REALLY want to do and sometimes there is a very simple solution to it and a lot of back and forth in the forum could have been prevented.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: ployrich

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225404 by Joffm
Replied by Joffm on topic Save responses via javascript
Yeah, that's the way to do it with a "master-slave" scenario, which is in my opinion an option that only few of the user think about.

Some time ago I presented it, but with three surveys
1. First part that links by end-url to
2. Second (Loop) part that either calls itself or (after an end condition) links to
3. Third part

Your design seems to be better, especially when a lot of variables of part 1 has to be used in part 3 by ExpressionScript.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
2 years 7 months ago #225405 by DenisChenu
Replied by DenisChenu on topic Save responses via javascript
When i see loop now i think of questionExtraSurvey to have survey inside survey demo.sondages.pro/534236?token=ozi1hlp3FIhJstn
gitlab.com/SondagesPro/QuestionSettingsType/questionExtraSurvey

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • ployrich
  • ployrich's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 7 months ago #225407 by ployrich
Replied by ployrich on topic Save responses via javascript
( I usually avoid terms like master - slave) But yes our thoughts where exactly as you illustrated. Because "part 3" is using a lot of variables from "part 1" splitting those up would be a big overhead of url fields to transfer those values or some API action in the background.

And yes DenisChenu, I have not forgotten about questionExtraSurvey and relatedSurveyManagement (wonderful plugins). That would be an optimization step I want to try out if I have "too much time" until we are starting the survey.

But another question came up during my trials:
In a more restricted scenario we need to respond to a function call to auto submit the whole survey. As we don't know when that will happen we cannot have an empty question to submit before redirection.
How do I autosubmit all questions from a certain point on, going to the endscreen?
I know that skipping is not possible. So I was thinking about having an extra survey with an equation and the endscreen, to at least store the question id the participant was on. But of course I would like to submit the maybe given response. Should I put that into the equation as well?

Let me know if I need to explain this new scenario better.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 7 months ago #225408 by holch
Replied by holch on topic Save responses via javascript
All responses up to the current "page" are stored in the database. They are marked as incomplete, but the data up to the last submitted page of the survey are still stored in the database. Maybe I didn't understand the requirement correctly, but in my point of view, this already is happening.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • ployrich
  • ployrich's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 7 months ago #225415 by ployrich
Replied by ployrich on topic Save responses via javascript
I think the requirement weren't so clear from my end. Let me try better:
Let's say the participant is on the question with the title "hometown" in survey with id 523. They have just entered "Testtown" into the input field, but haven't clicked 'next' or 'submit' yet.
The test administrator gets word  to cancel the survey (could happen any time). -> he presses a button which triggers an eventListener. This eventListener will grab the questionId and the token and redirect the participant to another survey which displays a thank you screen and has a hidden equation to store the "final" questionID for each participant.
As far as I have tried the entry "Testtown" will be lost. How do I not loose that?

Please Log in to join the conversation.

More
2 years 7 months ago - 2 years 7 months ago #225427 by davebostockgmail
Replied by davebostockgmail on topic Save responses via javascript
I don't know if this will help but here is a way I use to jump out of a survey to a secondary page and then back into the same survey to complete it.

forums.limesurvey.org/forum/can-i-do-thi...ue-with-first-survey
Last edit: 2 years 7 months ago by davebostockgmail. Reason: Removed notification of replies.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose