Check out the LimeSurvey source code on GitHub!

Add a counter question

More
5 years 5 months ago #65582 by bmdavis
I'd like to keep track of a counter in a multi-use token survey form. What I want to do is have a question field (or text on the page) that auto-fills with the current iteration number of the survey... e.g. the first submitted multi-use token would get 1, the next 2, and so on.

Any way to implement this?

Please Log in to join the conversation.

More
5 years 5 months ago #65667 by tpartner
I think you will need to fire a remote PHP script to query the database to find the "usesleft" value for the token. I'm not a PHP expert so can't help with the details of that script.

Here's an example of how to fire a remote PHP script - www.limesurvey.org/en/forum/can-i-do-thi...on-of-a-survey#55975 ..

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
5 years 5 months ago #65670 by TMSWhite
How common is the need to use or analyze result data during a survey? One option for LimeSurvey 1.92 would be to create variable attributes that provide easy access to those data, similar to how Expression Manager provides access to variable attributes within a single survey.

For example (where VAR is a variable name):
(1) SID.started = number of started surveys
(2) SID.finished = number of completed surveys
(3) VAR.count = number of relevant responses
(4) VAR.min = minimum value of relevant responses
(5) VAR.max = maximum value of relevant responses
(6) VAR.mean = mean value of relevant responses

Please Log in to join the conversation.

More
5 years 5 months ago #65866 by Mazi

bmdavis wrote: I'd like to keep track of a counter in a multi-use token survey form. What I want to do is have a question field (or text on the page) that auto-fills with the current iteration number of the survey... e.g. the first submitted multi-use token would get 1, the next 2, and so on.

Any way to implement this?

If your survey can be filed out 10 times you can make use of the {USESLEFT} placeholder at your template, see bugs.limesurvey.org/view.php?id=5291
You can put that value into a hidden DIV element and then use Javascript to read out the current value and then do some math like
10 - <myvalue> = $currentiteration

You can then try to write the value of $currentiteration into the text field of question by using some Javascript.


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.

More
5 years 5 months ago #65873 by tpartner
Cool, I didn't know that placeholder existed.

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
5 years 5 months ago #65966 by bmdavis
Of course! That's exactly what I needed :)

I suppose if I had looked at the "LimeSurvey Replacement Field Properties" -- Lime Icon inside curly brackets{}, I would have seen this. Word to the wise... it's {TOKEN:USESLEFT}.

Please Log in to join the conversation.

More
5 years 5 months ago #65969 by Mazi
So once you have developed a working solution please share it with us.


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.

More
5 years 5 months ago #65978 by bmdavis
I will... right now I'm being lazy and just using a bolierplate (text) question to display some verbiage like "Including this, there are {TOKEN:USESLEFT} uses left". As you pointed out, using javascript (or Jquery since I'm learning that now) we could do a lot more. I'll eventually go that way and share with the forum once I do. Thanks again, for all the hard work on LimeSurvey and your help/support!

Please Log in to join the conversation.

More
5 years 5 months ago #66016 by Mazi
You're welcome!


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