Detect if question is answered

More
4 months 5 days ago #183448 by flobau
Hey,

is there a way i can check if a question has been answered? The intention is to give the user a visual indication when he has completed an answer.

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
4 months 5 days ago #183449 by DenisChenu
?

Adding a string like this
{if(!is_empty(QCODE.NAOK),"<span class='text-danger'>You don't answer</span>","<span class='text-success'>You answer to this question</span>")}

But more detail can be interesting
manual.limesurvey.org/Expression_Manager

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

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183450 by flobau
Thanks for your answer, that's kinda what i want. Where would i put this line, e.g. where do i have access to
QCODE.NAOK
?

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183451 by DenisChenu

Where would i put this line

Where you want it …

where do i have access to

I put a link : read it …
manual.limesurvey.org/Expression_Manager#Qcode_Variable_Naming

It's the code of the question …

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

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183453 by flobau
Thanks. What if i don't know the question code now and i want it for all question codes?

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183464 by tpartner
How would you not know the question codes? You are the survey author.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
The following user(s) said Thank You: DenisChenu

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183466 by flobau
Because i don't know yet what survey's i am going to create. I am currently just editing a template, and template are not for a specific surveys i suppose?

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183467 by tpartner
The solution supplied by Denis is to be placed in survey question or group text, not in a template.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183471 by DenisChenu
For template :
Something like this
{% if(processString("{self.NAOK}") == 0)) %}
You don't answer to this question
{% endif %}
in github.com/LimeSurvey/LimeSurvey/blob/ma..._text_container.twig for example

See manual.limesurvey.org/Theme_editor

I don't answer to next question if you don't explain more what do you want exactly and what did you try …

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

Please Log in or Create an account to join the conversation.

More
4 months 5 days ago #183475 by flobau
Thank you Denis!
I didn't know that you can do that inside a survey question or group text, sorry for that. And sorry for my bad explanation.

Please Log in or Create an account to join the conversation.

More
3 months 4 weeks ago #183718 by flobau
{% if(processString("{self.NAOK}") != 0) %}
        <span>question answered</span>
{% endif %}

I tried this code, but the condition is never true. My goal is to show a visual indication after the user successfully chose a answer from a single choice question - in the moment the user clicks on an answer.

Please Log in or Create an account to join the conversation.

More
3 months 4 weeks ago - 3 months 4 weeks ago #183720 by tpartner
Try:

{% if(processString("{!is_empty(self)}")) %}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Last edit: 3 months 4 weeks ago by tpartner.

Please Log in or Create an account to join the conversation.

More
3 months 4 weeks ago - 3 months 4 weeks ago #183723 by flobau
Thanks for your answer. This seems to be true everytime. Even when the question isn't answered yet.
{% if(processString("{is_empty(self)}")) %}
        <div class="{{ aSurveyInfo.class.questionasterix }} pull-left" {{ aSurveyInfo.attr.questionasterix }} >
            <small style="margin-right: 3px; font-size: 65%;" class="{{ aSurveyInfo.class.questionasterixsmall }} text-danger fa fa-asterisk small" {{ aSurveyInfo.attr.questionasterixsmall }}></small>
            <span class="{{ aSurveyInfo.class.questionasterixspan }} sr-only text-danger" {{ aSurveyInfo.attr.questionasterixspan }} >
                {{ gT("(This question is mandatory)") }}
            </span>
        </div>
    {% endif %}
 
    {% if(processString("{!is_empty(self)}")) %}
        <div class="{{ aSurveyInfo.class.questionasterix }} pull-left" {{ aSurveyInfo.attr.questionasterix }} >
            {{ image('./files/haken.png', 'Question answered') }} 
        </div>
    {% endif %}

Both of the if's equal to 'true' and the content is shown for both.
Last edit: 3 months 4 weeks ago by flobau.

Please Log in or Create an account to join the conversation.

More
3 months 4 weeks ago - 3 months 4 weeks ago #183734 by flobau
I now tried multiple variables of aQuestion, but there seems to be no indication variable if a question has been answered. Do you guys have any ideas for another approach? Maybe with JavaScript?
Last edit: 3 months 4 weeks ago by flobau.

Please Log in or Create an account to join the conversation.

More
3 months 4 weeks ago - 3 months 4 weeks ago #183737 by DenisChenu
Right … it get it when loadong and don't update it …

Can do like that :
{{ processString("{if(is_empty(self.NAOK),'<span class=\"text-danger\">Mandatory question not answered</span>',' <span class=\"text-success\">question answered</span>')}")  }}

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .
Last edit: 3 months 4 weeks ago by DenisChenu.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!