Check out the LimeSurvey source code on GitHub!

Inserting variables in IF formulas - keeping variables alive

More
2 years 5 months ago #112086 by tgrecu
Please take a look at this formula i'm trying to implement.

{if(Q1 == 0, "you answered Q1.shown and this is wrong","you answered Q1.shown and this is correct")}


If the answer has value 0 the answer is wrong and i want to show some text containing the variable Q1 so that the selected answer is displayed.

Problem is, i can't find a way to make the EM understand Q1 is a variable when i put it inside the "quotes"



I found very long workarounds, so i'm asking if any of you knows how to keep variables alive inside of columns, when using formulas.

Please Log in to join the conversation.

More
2 years 5 months ago - 2 years 5 months ago #112089 by fransmarcelissen
Hi Tgrecu,
I always use
{if(Q1 == 0, join("you answered ",Q1.shown," and this is wrong"),
join("you answered", Q1.shown," and this is correct"))}

but sprintf (see manual.limesurvey.org/Expression_Manager ) or implode(' ',.....) should also work.

Succes
Frans
Last Edit: 2 years 5 months ago by fransmarcelissen.
The following user(s) said Thank You: tgrecu

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form