Welcome to the LimeSurvey Community Forum

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

Access QID in twig file?

More
5 years 4 months ago - 5 years 4 months ago #197449 by AuPath
Is it possible to have access to the qid for the current question in the theme's question.twig file?
I tried
Code:
'{{ processString('{QID}') }}'
but it does not seem to work.
Last edit: 5 years 4 months ago by AuPath.
The topic has been locked.
More
5 years 4 months ago #197475 by tpartner
Replied by tpartner on topic Access QID in twig file?
No, because there may be several questions on a screen.

What are you trying to do?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 4 months ago #197476 by AuPath
Replied by AuPath on topic Access QID in twig file?
I have a script in a custom Theme that tracks the user's mouse movement while he is answering a question.
Each question is displayed as a separate page.
I then store all this data in the Limesurvey database in custom tables.
If i had access to the QID i could store it alongside the movement data, making a query like "get all movements for question 2" very simple.
The topic has been locked.
More
5 years 4 months ago #197481 by tpartner
Replied by tpartner on topic Access QID in twig file?
Try this:

Code:
{{ aQuestion.qid }}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, AuPath
The topic has been locked.
More
5 years 4 months ago #197509 by AuPath
Replied by AuPath on topic Access QID in twig file?
{{ aQuestion.qid }} worked, thank you!
The topic has been locked.
More
5 years 4 months ago - 5 years 4 months ago #197519 by AuPath
Replied by AuPath on topic Access QID in twig file?
For anyone else that might have the same problem, an example code snippet:
Code:
<script type="text/javascript" charset="utf-8">
  var qid = {{ aQuestion.qid }};
  console.log("QID: " + qid);
</script>
Last edit: 5 years 4 months ago by AuPath.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose