- Posts: 39
- Thank you received: 3
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Show correct / wrong answer in multiple choice quiz
- mariaa
- Topic Author
- Offline
- Junior Member
Less
More
5 years 2 months ago #179950
by mariaa
Show correct / wrong answer in multiple choice quiz was created by mariaa
Hi all,
Many thanks in advance for your help
I´ve created a quiz with a multiple choice question.
A1 "Which of the following statistical methods are multivariate?"
SQ001 Cluster analysis
SQ002 Variance
SQ003 Cross-tabulation
SQ004 Multiple regression
The question is answered correctly if (only) question answers "SQ001 Cluster analysis" and "SQ004 Multiple regression" are selected.
After having answered this question, the participant should be able to see if his answer was right or wrong.
I found this solution in the forum: ( I already adjusted the variable names of the question)
{if(A1_SQ001.NAOK == "Y" and A1_SQ002.NAOK == "" and A1_SQ003.NAOK == "" and A1_SQ004.NAOK == "Y"),("You chose this answer correctly.","You chose this answer incorrectly")}
Unfortuntaley it´s not working (no text is shown at all after having answered the question).
In the question summary, the "if " of the function is marked red and the following error message is shown:
"Function does not support 1 arguments Function supports this many arguments, where -1= unlimited : 2,3; Not a valid expression; Conditional processing; if (test, result_if_true[,result_if_false=""])
I´m a limesurvey newbie and didn´t succeed at finding the error.
Do you know how to adjust the code so that it´s working?
Thanks a lot! I attached a picture of the question summary.
Kind regards
Maria
Many thanks in advance for your help
I´ve created a quiz with a multiple choice question.
A1 "Which of the following statistical methods are multivariate?"
SQ001 Cluster analysis
SQ002 Variance
SQ003 Cross-tabulation
SQ004 Multiple regression
The question is answered correctly if (only) question answers "SQ001 Cluster analysis" and "SQ004 Multiple regression" are selected.
After having answered this question, the participant should be able to see if his answer was right or wrong.
I found this solution in the forum: ( I already adjusted the variable names of the question)
{if(A1_SQ001.NAOK == "Y" and A1_SQ002.NAOK == "" and A1_SQ003.NAOK == "" and A1_SQ004.NAOK == "Y"),("You chose this answer correctly.","You chose this answer incorrectly")}
Unfortuntaley it´s not working (no text is shown at all after having answered the question).
In the question summary, the "if " of the function is marked red and the following error message is shown:
"Function does not support 1 arguments Function supports this many arguments, where -1= unlimited : 2,3; Not a valid expression; Conditional processing; if (test, result_if_true[,result_if_false=""])
I´m a limesurvey newbie and didn´t succeed at finding the error.
Do you know how to adjust the code so that it´s working?
Thanks a lot! I attached a picture of the question summary.
Kind regards
Maria
The topic has been locked.
- elissa
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 193
- Thank you received: 69
5 years 2 months ago - 5 years 2 months ago #179965
by elissa
Elzbieta Lesinska
LS voluntary Polish translator and supervisor
Replied by elissa on topic Show correct / wrong answer in multiple choice quiz
Hi,
This works for me:
Regards
This works for me:
Code:
if( ! is_empty(A1_SQ001.NAOK) and is_empty(A1_SQ002.NAOK) and is_empty(A1_SQ003.NAOK) and ! is_empty(A1_SQ004.NAOK), "You chose this answer correctly.", "You chose this answer incorrectly")
Regards
Elzbieta Lesinska
LS voluntary Polish translator and supervisor
Last edit: 5 years 2 months ago by elissa.
The following user(s) said Thank You: mariaa
The topic has been locked.
- mariaa
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 3
5 years 2 months ago #180015
by mariaa
Replied by mariaa on topic Show correct / wrong answer in multiple choice quiz
Hi Elissa,
I´m sorry for my late response. Unfortunately I got ill and just found the time to have a look at you solution.
Thanks a lot for your answer! Your solution is working for me, too.
Do you know if there is any possibility to show the text "You chose this answer correctly." in green and "You chose this answer incorrectly" in red colour?
If yes, could you please show how the code needs to be adjusted in order to show the different text colours?
Many thanks in advance
Larissa
I´m sorry for my late response. Unfortunately I got ill and just found the time to have a look at you solution.
Thanks a lot for your answer! Your solution is working for me, too.
Do you know if there is any possibility to show the text "You chose this answer correctly." in green and "You chose this answer incorrectly" in red colour?
If yes, could you please show how the code needs to be adjusted in order to show the different text colours?
Many thanks in advance
Larissa
The topic has been locked.
- elissa
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 193
- Thank you received: 69
5 years 2 months ago #180021
by elissa
Elzbieta Lesinska
LS voluntary Polish translator and supervisor
Replied by elissa on topic Show correct / wrong answer in multiple choice quiz
Hi,
I'm not sure if you can use html code within an expression so my solution is:
Regards
I'm not sure if you can use html code within an expression so my solution is:
Code:
<font color="green">{if(!is_empty(A1_SQ001.NAOK) and is_empty(A1_SQ002.NAOK) and is_empty(A1_SQ003.NAOK) and !is_empty(A1_SQ004.NAOK),"You chose this answer correctly","")} </font> <font color="red"> {if(!is_empty(A1_SQ001.NAOK) and is_empty(A1_SQ002.NAOK) and is_empty(A1_SQ003.NAOK) and !is_empty(A1_SQ004.NAOK),"","You chose this answer incorrectly")} </font>
Elzbieta Lesinska
LS voluntary Polish translator and supervisor
The following user(s) said Thank You: mariaa
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
5 years 2 months ago #180027
by DenisChenu
With this restriction : manual.limesurvey.org/Expression_Manager#XSS_security
And just remind to use different quote
But for such purpose, i think usage of boostrap class can be better : getbootstrap.com/docs/3.3/css/#helper-classes-colors or getbootstrap.com/docs/3.3/components/#alerts
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Show correct / wrong answer in multiple choice quiz
You canelissa wrote: Hi,
I'm not sure if you can use html code
With this restriction : manual.limesurvey.org/Expression_Manager#XSS_security
And just remind to use different quote
Code:
{if(!is_empty(A1_SQ001.NAOK) and is_empty(A1_SQ002.NAOK) and is_empty(A1_SQ003.NAOK) and !is_empty(A1_SQ004.NAOK),"<font color='green'>You chose this answer correctly</font>","<font color='red'>You chose this answer incorrectly</strong> ")}
But for such purpose, i think usage of boostrap class can be better : getbootstrap.com/docs/3.3/css/#helper-classes-colors or getbootstrap.com/docs/3.3/components/#alerts
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: elissa, mariaa
The topic has been locked.
- mariaa
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 3
5 years 2 months ago #180095
by mariaa
Replied by mariaa on topic Show correct / wrong answer in multiple choice quiz
Thanks a lot for your support! It´s working now with this code.
{if(!is_empty(A1_SQ001.NAOK) and is_empty(A1_SQ002.NAOK) and is_empty(A1_SQ003.NAOK) and !is_empty(A1_SQ004.NAOK),"<font color='green'>You chose this answer correctly</font>","<font color='red'>You chose this answer incorrectly</strong> ")}
@DenisChenu Thanks a lot for your link, this seems to be very helpful for future problems.
{if(!is_empty(A1_SQ001.NAOK) and is_empty(A1_SQ002.NAOK) and is_empty(A1_SQ003.NAOK) and !is_empty(A1_SQ004.NAOK),"<font color='green'>You chose this answer correctly</font>","<font color='red'>You chose this answer incorrectly</strong> ")}
@DenisChenu Thanks a lot for your link, this seems to be very helpful for future problems.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- tammo
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 967
- Thank you received: 220
5 years 2 months ago #180207
by tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Replied by tammo on topic Show correct / wrong answer in multiple choice quiz
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The following user(s) said Thank You: mariaa
The topic has been locked.
- mariaa
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 3
5 years 2 months ago #180302
by mariaa
Replied by mariaa on topic Show correct / wrong answer in multiple choice quiz
The topic has been locked.
- tammo
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 967
- Thank you received: 220
5 years 2 months ago - 5 years 2 months ago #180315
by tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Replied by tammo on topic Show correct / wrong answer in multiple choice quiz
Hi Maria,
it is an example from the beautiful book by Hans Rosling: Factfulness.
All material form that book and the website gapminder.org is open for sharing.
Please see the attachment.
greetings from the Netherlands,
Tammo ter Hark
it is an example from the beautiful book by Hans Rosling: Factfulness.
All material form that book and the website gapminder.org is open for sharing.
Please see the attachment.
greetings from the Netherlands,
Tammo ter Hark
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Attachments:
Last edit: 5 years 2 months ago by tammo. Reason: Adding remark about attachment.
The following user(s) said Thank You: mariaa
The topic has been locked.
- mariaa
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 3
5 years 2 months ago #180323
by mariaa
Replied by mariaa on topic Show correct / wrong answer in multiple choice quiz
Hi Tammo,
thanks a lot for your attachment and all helpful information.
Kind regards
Maria
thanks a lot for your attachment and all helpful information.
Kind regards
Maria
The topic has been locked.