Welcome to the LimeSurvey Community Forum

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

Access QID in twig file?

  • AuPath
  • AuPath's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 days ago - 4 years 6 days ago #197449 by AuPath
Access QID in twig file? was created 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: 4 years 6 days ago by AuPath.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 days 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.
  • AuPath
  • AuPath's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 days 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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 days 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.
  • AuPath
  • AuPath's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 5 days ago #197509 by AuPath
Replied by AuPath on topic Access QID in twig file?
{{ aQuestion.qid }} worked, thank you!
The topic has been locked.
  • AuPath
  • AuPath's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 5 days ago - 4 years 5 days 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: 4 years 5 days ago by AuPath.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose