Welcome to the LimeSurvey Community Forum

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

Having 4 different scorings at the end?!

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago #147988 by holch
Replied by holch on topic Having 4 different scorings at the end?!
No, this if code can be written directly into the end message or a text display question. Of course you could use also an equation question (if you want to save the final score into the database as well), but it must be a different one. I am sure you could include it also into the equation question where you calculate the base score, but then you will need to do a lot of coding to cater for that I think. Better to keep it separated.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: Reveb
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago #147990 by holch
Replied by holch on topic Having 4 different scorings at the end?!
To call your score that was written into the equation question with the name "Psych" you just call {Psych}, e.g.:

"score" was just an assumption on the name of the equation question, because I can't know how you actually called it in your questionnaire. So if you called the equation question where the score is calculated "Psych", then you need to use "Psych" to tall the content of this equation question. Something like:
Code:
{if(Psych==0, "Your score is 0 out of 100",)}

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: Reveb
The topic has been locked.
  • Reveb
  • Reveb's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #147995 by Reveb
Replied by Reveb on topic Having 4 different scorings at the end?!
I checked and noticed that the IF ELSEIF and ELSE is pretty complicated i found a working version from TMSWhite but the first if keeps being a problem saying: ´Missing 2 closing rigth parenthese; Conditional processesing; if(test,result_if_true,result_if_false)`

I guess it wants me to put a if false in but isn´t that where the rest is for.
The other 2 are completly fine it says.

Got this now:

if(Psych == 0, 'Your score is 0 out of 100', if(Psych == 1, 'Your score is 10,6 out of 100', if(Psych == 2, 'Your score is 17,5 out of 100')

Reveb
PS: Anyway of thanking you for the help?
The topic has been locked.
  • Reveb
  • Reveb's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #147997 by Reveb
Replied by Reveb on topic Having 4 different scorings at the end?!
Just adding )) won't work. It will make the last one wrong saying it doesn't support 2 arguments
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago #148001 by holch
Replied by holch on topic Having 4 different scorings at the end?!
Well, you need to close the parentheses that you opened. Looking at your code you opened a total of 3 "(" but you close only 1.
Code:
{if(Psych == 0, 'Your score is 0 out of 100', if(Psych == 1, 'Your score is 10,6 out of 100', if(Psych == 2, 'Your score is 17,5 out of 100')))}

This should work for the first 3 numbers. you can continue like this until you reach the end. If only those 5 outcomes that you showed before are possible with your calculation, then you only need to create 4 "if" clauses and in the last one you just include the last case out come.

Saying thank you is already enough. Personally I don't need/want anything else. Helping others in the forum is my way to "pay back" to a great open source project. Of course it would always be great if users would give back to the project. There are many ways to support Limesurvey, depending on your pockets and your skill set: contributing code, bug hunting/solving, translating, support others that are less experienced in the forum, sponsor a certain feature or plugin, etc.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: Reveb
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago #148003 by holch
Replied by holch on topic Having 4 different scorings at the end?!

Reveb wrote: Just adding )) won't work. It will make the last one wrong saying it doesn't support 2 arguments


I guess the problem is that you HAVE to give the "else" part.

Try something like this:
{if(score==0, "Your score is 0 out of 100",)}
{if(score==1, "Your score is 10,6 out of 100",)}
{if(score==2, "Your score is 17,5 out of 100",)}
{if(score==3, "Your score is 21,9 out of 100",)}
{if(score==10, "Your score is 37 out of 100",)}
Code:
{if(Psych == 0, 'Your score is 0 out of 100', if(Psych == 1, 'Your score is 10,6 out of 100', if(Psych == 2, 'Your score is 17,5 out of 100','Something went really, really wrong')))}

I guess the complete code would be this:
Code:
{if(Psych == 0, 'Your score is 0 out of 100', if(Psych == 1, 'Your score is 10,6 out of 100', if(Psych == 2, 'Your score is 17,5 out of 100', if(Psych==3, 'Your score is 21,9 out of 100','Your score is 37 out of 100'))))}

This of course will only work if 0, 1, 2, 3 and 10 are the ONLY results possible, because we don't check for the 10 at the end and just assume if it isn't 0, 1, 2 or 3 it must be 10.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: Reveb
The topic has been locked.
  • Reveb
  • Reveb's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #148004 by Reveb
Replied by Reveb on topic Having 4 different scorings at the end?!
Again thanks then :P

I'll try this, for now you can get a maximum of 34 assesment points in this group so it goes till 34. I'll try working it out cause when i used ELSE and ELSEIF it said it didn't excist.

Well i'll get back to trying over and over and hope for the best ;)

Reveb
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago - 7 years 2 months ago #148006 by holch
Replied by holch on topic Having 4 different scorings at the end?!
I think if there are 34 different assessment levels, then the if loop is gonna be tedious and prone to errors.

I think Denis posted once a solution how he does it to avoid going through many if else loops. I think it was like what I had shown at the beginning, which is a lot "cleaner" I guess.
Code:
{if(Psych==0,"Your score is 0 out of 100","")}

Maybe this works. It should write "your score is 0 out of 100" if Psych is 0, and nothing if it is not.
Then you can go just to the next line. I don't have the time to set up a test here at the moment, this is just guesswork.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 7 years 2 months ago by holch.
The topic has been locked.
  • Reveb
  • Reveb's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #148008 by Reveb
Replied by Reveb on topic Having 4 different scorings at the end?!
I've tried this but it's not working..

{if(Psych.NAOK==0, "Your score is 0 out of a 100", "er")}
{if(Psych.NAOK==1, "Your score is 10,6 out of a 100", "er")}
{if(Psych.NAOK==3, "Your score is 17,5 out of a 100", "er")}
{if(Psych.NAOK==4, "Your score is 21,9 out of a 100", "er")}

This just shows "er er er er" at the end.
Putting it to single quotes won't change it.

Also i tried this:

{if(Psych.NAOK == 0, 'Your score is 0 out of 100', if (Psych.NAOK == 1, 'Your score is 10,6 out of 100', if (Psych.NAOK == 2, 'Your score is 17,5 out of 100', 'Something went wrong')))}

It wil just show "Something went wrong" all the time..

I don't know what i am doing wrong but it just doesn't seem to be working.

Reveb
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago #148012 by holch
Replied by holch on topic Having 4 different scorings at the end?!
I am actually inclined not to answer anymore, because of your crosspost. This is a real no-go because it makes different people help you on issues that might have been already solved. I assume this was a beginners mistake for now. But next time this happens I'll just ignore your requests, because this is a waste of valuable resources. You are using up more time of different people instead of concentrating all in one thread (and others can see what has been tried already).

From the other post I see that you actually don't get any results for {Psych}? this was what I was saying before. Try to get one step right before you go to the next. How do you expect our code here to work if the input is already wrong?

Can you export a .lss file that ONLY contains the questions that are relevant for testing this? Set up a small example with one set of questions for creating the base score, then the equation that calculates the base score and then the equation where you test to output the text.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • Reveb
  • Reveb's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #148014 by Reveb
Replied by Reveb on topic Having 4 different scorings at the end?!
Well i didn't know this wasn't allowed if you look at it the way you do i'm indeed taking time from someone that he is trying things we already tried. But i thougth the developers will probaly be looking in the Development since u told me about Tpartner and Denis etc.

But i also put out the code where we ended so. But still my excuse, i placed TOPIC CLOSED in the other one.

I'll put the file in here with the questions from this group
The topic has been locked.
  • Reveb
  • Reveb's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 2 months ago #148015 by Reveb
Replied by Reveb on topic Having 4 different scorings at the end?!
Also the score shows above so Psych actually has 2 in it when i use it but still the "Your score" won't show for Psych.NAOK == 2.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose