View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
19155Bug reportsQuestion editorpublic2023-10-09 18:45
Reporterqualiquan Assigned Togabrieljenik  
PrioritynoneSeverityblock 
Status closedResolutionno change required 
Product Version6.2.x 
Summary19155: error when trying retrieving {QID} in a default response field
Description

I have defined answer default values in a question but when I assign the variable regarding the question number I get an error.

When we test the logic of the question, if we hover the mouse over the variable {QID} we can clearly see that the question number is displayed and yet when we test the question in the browser we have the following error:
<span class= 'em-expression em-haveerror' ><span class='em-error' title=' ' ><span title='Undefined variable' class='em-var em-var-error' >QID</span> </span></span>

In a previous question, I've set in the html window the {QID} and i obtain the relevant information (see attached file "Question and survey ID").

So why doesn't it work when we put the {QID} variable in a default response field (see also attached file "error in browser")?

Limesurvey details :
Votre configuration système :
Version de LimeSurvey
231004
Système d’exploitation
Linux webm392.cluster020.gra.hosting.ovh.net 5.15.80-ovh-vps-grsec-zfs-classid #1 SMP Wed Nov 30 08:49:06 UTC 2022 x86_64
Version de PHP
8.0.30
Nom du serveur web
www.qualiquan.digitalparentingfoundation.org
Logiciel du serveur web
Apache
Information sur le serveur web
Pilote de la base de données
mysql
Version du connecteur de base de données
mysqlnd 8.0.30
Information sur le serveur de base de données
Uptime: 1001156 Threads: 3 Questions: 182914383 Slow queries: 34 Opens: 18618709 Flush tables: 1 Open tables: 64 Queries per second avg: 182.703
Version du serveur de base de données
5.7.42-log

Steps To Reproduce

Steps to reproduce

(Replace this text with detailed step-by-step instructions on how to reproduce the issue)

Expected result

(Write here what you expected to happen)

Actual result

(Write here what happened instead)

TagsNo tags attached.
Attached Files
QID error .png (1,271,401 bytes)
error in browser.png (228,712 bytes)
Bug heat8
Complete LimeSurvey version number (& build)LimeSurvey Community Edition Version 6.2.10+231004
I will donate to the project if issue is resolvedNo
Browserchrome
Database type & version5.7.42-log
Server OS (if known)
Webserver software & version (if known)
PHP Version8.0

Users monitoring this issue

mfavetti

Activities

mfavetti

mfavetti

2023-10-07 00:24

developer   ~77552

Try this: {G2Q00001_question.qid}

qualiquan

qualiquan

2023-10-08 07:35

reporter   ~77559

Thanks for your answer, but how ro retrieve current question id ? I need to add this variable in this field and also in a Java script associated with a question ?

mfavetti

mfavetti

2023-10-08 09:09

developer   ~77560

Set the default answer for question "G2Q00001", subquestion "question" to be {G2Q00001_question.qid} and check if that works. (Instead of {QID} in your screenshot "QID error .png")

qualiquan

qualiquan

2023-10-08 15:40

reporter   ~77561

Thanks again, and I apologize for asking again: my precedent answer wasn't clear enough : you're right, the solution you've proposed works perfectly.
But remains two questions for me :
1- why can't I get {QID} or {GID} of the curent question, as default answers (see attached file)
2- How to get variables in the javascript tab of a question : I'm creating a question type, that will be reused many times in one survey and other surveys so that each time this question type will be assigned a new id. This question own a javascript that forms a name that must get and use : survey, question, suser ids : here is my actual script that works :
const defaultClipName = formattedDateTime + '_{idssurvey.NAOK}{idsgid.NAOK}{idsquestion.NAOK}{idsfamily.NAOK}{idsperson.NAOK}{ids2parentorchild}{ids2_gender.NAOK}';

Where ids and ids2 are previous questions codes, and survey, gid, etc are multiple answers codes.

But I'd like to adapt this script in order to access directly to variable, and would looks like :
const defaultClipName = formattedDateTime + '{SID}{GID}{QID}{{TOKEN:ATTRIBUTE2}}{{TOKEN:ATTRIBUTE1}}{TOKEN:ATTRIBUTE4}{TOKEN:ATTRIBUTE3}{TOKEN:ATTRIBUTE_5}'

mfavetti

mfavetti

2023-10-09 09:36

developer   ~77562

What type of question is record?

If it has subquestions, you need to do something like record_SQ001.qid and record_SQ001.gid instead (it doesn't matter which subquestion code you use)

qualiquan

qualiquan

2023-10-09 11:05

reporter   ~77563

Hi mfavetti, thanks for your reply.

gabrieljenik

gabrieljenik

2023-10-09 18:45

manager   ~77586

As per the comments, I think all is good and will be closing the ticket.
Please add any comments in case it should be reopened.
Thanks

Issue History

Date Modified Username Field Change
2023-10-06 19:23 qualiquan New Issue
2023-10-06 19:23 qualiquan File Added: QID error .png
2023-10-06 19:23 qualiquan File Added: Question and survey ID.png
2023-10-06 19:23 qualiquan File Added: error in browser.png
2023-10-07 00:24 mfavetti Note Added: 77552
2023-10-07 00:24 mfavetti Bug heat 0 => 2
2023-10-07 00:25 mfavetti Issue Monitored: mfavetti
2023-10-07 00:25 mfavetti Bug heat 2 => 4
2023-10-08 07:35 qualiquan Note Added: 77559
2023-10-08 07:35 qualiquan Bug heat 4 => 6
2023-10-08 09:09 mfavetti Note Added: 77560
2023-10-08 15:40 qualiquan Note Added: 77561
2023-10-08 15:40 qualiquan File Added: how to get QID and GID of curent question.png
2023-10-09 09:36 mfavetti Note Added: 77562
2023-10-09 11:05 qualiquan Note Added: 77563
2023-10-09 18:45 gabrieljenik Assigned To => gabrieljenik
2023-10-09 18:45 gabrieljenik Status new => closed
2023-10-09 18:45 gabrieljenik Resolution open => no change required
2023-10-09 18:45 gabrieljenik Note Added: 77586
2023-10-09 18:45 gabrieljenik Bug heat 6 => 8