Welcome to the LimeSurvey Community Forum

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

Get token value and the end of the survey

  • jonytrifulca
  • jonytrifulca's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago - 1 year 6 months ago #232812 by jonytrifulca
Get token value and the end of the survey was created by jonytrifulca
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.4.5+221010
Own server or LimeSurvey hosting: personal server
Survey theme/template: vanilla
==================
Hi guys I am looking for the way to retrieve the value of the token in the submit.twig end page of the survey using javascript but I can't do it.
Currently I start a survey in  "open-access" mode with this URL: http://127.0.0.1/ls/index.php/323251?lang=en&token=value1&hiddenQuestionCode=value2&newtest=Y


I have been taking a look some posts concerning that:

Option 1)
[url] forums.limesurvey.org/forum/can-i-do-thi...submit-twig-template [/url]
In the post above it is supposed that:
"""
Thank you all. I upgraded to the latest version 3.15.8+190130 and both {{ processString("{TOKEN}") }} and {{ processString("{TOKEN:TOKEN}") }} work.
"""
DenisChenu answered in the end ""Arg : i test for TOKEN : and it seem‘s it don't work in all twig :  bugs.limesurvey.org/view.php?id=14507 "" and I have tried it and can't get it work.

Option2)
[url] forums.limesurvey.org/forum/can-i-do-thi...end-page-with-jquery [/url]
Taking a look the post above the only solution that comes into my mind is add an extra hidden question with the duplicate value of token to be able to retrieve in the end doing:const hidenQuestionValue = '{{ processString("{hidenQuestionCode}") }}';but I don't like too much.

Does anyone know how to access the value of the initial token provided? I have been taking a look as well the info inside the object "aSurveyInfo" in the submit.twig but I can't find anything{{ dump(aSurveyInfo ) }}
Thanks in advance.

 
Last edit: 1 year 6 months ago by jonytrifulca.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232819 by tpartner
Replied by tpartner on topic Get token value and the end of the survey

Currently I start a survey in "open-access" mode

This indicates that there is no participant table.

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.

  • jonytrifulca
  • jonytrifulca's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago - 1 year 6 months ago #232821 by jonytrifulca
Replied by jonytrifulca on topic Get token value and the end of the survey
Hi tpartner, thanks for your reply.
You are right, there is not a participant table, I am referring to obtain the token inserted in the token table in lime_survey_XXX that, currently, is the token that I provide into the URL in open access mode.
Image attached
Last edit: 1 year 6 months ago by jonytrifulca.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232830 by holch
Replied by holch on topic Get token value and the end of the survey
In open access mode, there is no token...

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.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232833 by tpartner
Replied by tpartner on topic Get token value and the end of the survey
In my testing, version 5.4.4, if "Participants" is enabled (there is a participants/token table), both of these work:

Code:
{{ processString('{TOKEN:TOKEN}') }}
Code:
{{ processString('{TOKEN}') }}

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.

  • jonytrifulca
  • jonytrifulca's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago - 1 year 6 months ago #232840 by jonytrifulca
Replied by jonytrifulca on topic Get token value and the end of the survey
Thanks Holch and tpartner.

I guess I misunderstanding the "token" concept because I was think that the 
Code:
{{ processString('{TOKEN:TOKEN}') }}{{ processString('{TOKEN}') }}

sentences give you access as well to the field called "token" stored in the lime_survey_XXX tables started in "open-access" mode when you provide the token value in the URL like:
URL: http://127.0.0.1/ls/index.php/323251?lang=en&token=value1&hiddenQuestionCode=value2&newtest=Y

So, I guess that the question now is: There is a method to extract the value of the "token" field stored in a lime_survey_xxxx table when you running it in "open-access" mode??

As I said previously, I can access  to the value of questions in that survey doing:
Code:
const hidenQuestionValue = '{{ processString("{hidenQuestionCode}") }}'


but 
Code:
const hidenQuestionValue = '{{ processString("{token}") }}'


doesn't work.

Thanks
 
Last edit: 1 year 6 months ago by jonytrifulca.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232841 by holch
Replied by holch on topic Get token value and the end of the survey
What is this "token" value you are talking about? If it is not a Limesurvey token, stored in the token / participant table, then I assume you save some kind of external ID into a hidden question? If so, let's not call it token to stop confusions, but some kind of other id, especially as "token" is a limesurvey word and refers to something very specific, so does {TOKEN} or {TOKEN:TOKEN}.

If you just passed some kind of ID via URL into the survey and saved it in a hidden question, you can always access it by using {questionid}, with "questionid" being the ID/Name of the question that you have stored it in.

I would highly recommend to NOT call this question "token" though.

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.

  • jonytrifulca
  • jonytrifulca's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 6 months ago #232842 by jonytrifulca
Replied by jonytrifulca on topic Get token value and the end of the survey
Ok holch I got it, I have gone back on time to one of my previous question concerning this "field" in open access surveys where you were involved as well :)  trying to guess why this behaviour case this confusion ([url] forums.limesurvey.org/forum/installation...-open-access-surveys [/url]

The reason is that, even if you are in open access mode survey, if you pass a token in the URL like http://127.0.0.1/ls/index.php/323251?lang=en&token=value1, that value is stored in the token column that I guess it is supposed to be reserved just for surveys with participants not in open access mode.

My idea was to access this value in the end page due to it is stored in the database  as other questions but, I guess that , its treatment is different from the others due to it is reserved to the connection with the participants table and the fact of set it in the URL, even if its allowed, is wrong ( as Joffm said "misuse the "reserved" word "token" as parameter.")

So, even if a could export it, I think is a misuse, better go for a hidden question value as I was thinking as alternative.

Thanks

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 6 months ago #232843 by holch
Replied by holch on topic Get token value and the end of the survey

if you pass a token in the URL like http://127.0.0.1/ls/index.php/323251?lang=en&token=value1, that value is stored in the token column


Hmm, not sure if this is a feature or a bug. I would guess it is a bug.

So, even if a could export it, I think is a misuse, better go for a hidden question value as I was thinking as alternative.


Agreed! I think this is the way to go if you don't want to risk to run into trouble.

At the end of the day, it is easy for you to change "token" into something else and store and access it accordingly.

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.

Lime-years ahead

Online-surveys for every purse and purpose