How to get the name (Code) of a question

More
2 years 11 months ago - 2 years 11 months ago #110559 by orvil
orvil created the topic: How to get the name (Code) of a question
Hi there,

does anyone know a solution for this:

Lets say there is a question called Q1.
What I'd like to have is exactly the 'Q1' as a result (string) of an expression within this very question.

Something like {self.????}
- self.code is used for other purposes
- self.name is not implemented
- self.jsName does not fit into my needs

If you are wondering why I'm asking: I do have a long list of almost similar questions from Q1 to Q15 (more than once) and I am too lazy to change the formulas in 15x10 subquestions containing the number given by the question name (ie 1 to 15)

THX for all your ideas

Best regards/Beste Grüße,
O. Villani
Last Edit: 2 years 11 months ago by orvil.

Please Log in to join the conversation.

More
2 years 11 months ago #110605 by DenisChenu
DenisChenu replied the topic: How to get the name (Code) of a question
Don't think we have a way in EM,

But if you need to refer to actual SGQA or Question num : {SGQ} or {QID}

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 11 months ago #110850 by Ari01
Ari01 replied the topic: How to get the name (Code) of a question
I'm hoping to get clarity on this topic.

I have a survey with 100 questions; each user gets asked only 10-15 of them. I'm trying to find a way to create only 1 survey, and then 'extract' a custom survey for each user just by specifying the questions to show in the token table (I have a spreadsheet of users and strings, so all it will take is uploading this into the token field). The problem I'm running into is that I have not yet figured out how to tell the logic statement which question *I am currently on*

My steps:
- Each question is named with a unique identifier (eg Q001 up to q100). This goes into the 'CODE' field
- In the Token table, I created a custom attribute where I listed all of the question IDs to show.

For example, for a specific user, I want the survey to show questions 1,4, and 99
- The question 'code' for the first question is "q001"
- In the token table, the custom Attribute_1 is a string that looks like this: "q001 q004 q099"
- The display logic (in the EM editor) that I am trying to use is as follows:
"Attribute_1 [From token table] Regular expression \b{CODE}\b"
where {CODE} is supposed to be this question's identifier (i.e. q001). (strictly speaking those \b may not be necessary, but that's not important right now)

Essentially I'm looking for a way to use EM to evaluate the following:
If (current question code appears in my token's attribute_1 field) then display the question.

Is this possible?

Please Log in to join the conversation.

More
2 years 11 months ago #110868 by Bigred01
Bigred01 replied the topic: How to get the name (Code) of a question
You could bring the token info into a hidden question then set the logic for its matched question to only show if logic q is equal to constant 'q0001'.

Please Log in to join the conversation.

More
2 years 11 months ago #110869 by Ari01
Ari01 replied the topic: How to get the name (Code) of a question
This sounds promising. Can you please elaborate?

Please Log in to join the conversation.

More
2 years 11 months ago #110870 by Ari01
Ari01 replied the topic: How to get the name (Code) of a question
The part I still have not figured out is how to identify the current question code so that I can compare it (to the token, constant, etc).

Thanks again.
Ari

Please Log in to join the conversation.

More
2 years 11 months ago #110871 by Bigred01
Bigred01 replied the topic: How to get the name (Code) of a question
You shouldn't have to track which question you are on.

For example, if you made an equation question in the first page of your survey and put {TOKEN:ATTRIBUTE_1} in the question text, what ever is in attribute 1 for that respondent will display in that question but also be stored as an answer. You can then use the question relevance to only show a specific question if this equation question answer equals a specific string.

Under the relevance for the question/questions you want to show based on attribute_1, select this equation question, set it to equals, select 'constant' then enter the exact string that will be in token one of the sample. Now this question will only show if token one is equal to the string of your choice in attribute_1.

Please Log in to join the conversation.

More
2 years 11 months ago #110872 by Bigred01
Bigred01 replied the topic: How to get the name (Code) of a question
You can actually just look directly at the sample so no need for the hidden question. Check out question relevance in the manual.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now