Welcome, Guest
Username: Password: Remember me

TOPIC: Add a counter question

Add a counter question 3 years 2 days ago #65582

  • bmdavis
  • bmdavis's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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?
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #65667

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4180
  • Thank you received: 784
  • Karma: 358
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #65670

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #65866

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #65873

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4180
  • Thank you received: 784
  • Karma: 358
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #65966

  • bmdavis
  • bmdavis's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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}.
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #65969

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #65978

  • bmdavis
  • bmdavis's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
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!
The administrator has disabled public write access.

Re: Add a counter question 2 years 11 months ago #66016

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.117 seconds
Donation Image