data cleaning of answers in not relevant questions

More
1 month 3 weeks ago #179673 by KompetenzZ
Hi community,

is there an option (I guess with javascript) to remove the inputs (the answers given by respondents) from a multiple choice and multiple numerical input question when the question gets "hidden" because the question is currently not relevant (concerning relevance equation). So to say data cleaning.
In other words, when a question was answered, but then the relevance equation changes to wrong (not relevant), the question becomes hidden, and then the answer input of respondents in the question should be removed (cleaned).

LS Version 3.14

Cheers kompetenzz

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

LimeSurvey Partners
More
1 month 3 weeks ago #179686 by tpartner
There is no JavaScript method to detect when an element is hidden or to detect class changes so you would need to put listeners on the questions that are triggering the relevance change. These listeners (and the resulting callbacks) would vary depending on the question types and IDs.

Having said that, I don't see what the problem is. The answers in irrelevant questions only persist until the survey page (group) is submitted.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

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

More
1 month 3 weeks ago - 1 month 3 weeks ago #179690 by DenisChenu

tpartner wrote: There is no JavaScript method to detect when an element is hidden or to detect class changes so you would need to put listeners on the questions that are triggering the relevance change.

Sorry Tony,

Currently :
Relevance updated (set to on/off) : github.com/LimeSurvey/LimeSurvey/blob/2f...survey/survey.js#L24
Class change due to error : github.com/LimeSurvey/LimeSurvey/blob/ma...urvey/survey.js#L342

Else :

In other words, when a question was answered, but then the relevance equation changes to wrong (not relevant), the question becomes hidden, and then the answer input of respondents in the question should be removed (cleaned).

It's the case (by default) when move next only, then if user check a input:checkbox by error , it don't loose previous answer.
Why do you want to clean previous value ?

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 .
Last edit: 1 month 3 weeks ago by DenisChenu.

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

More
1 month 3 weeks ago #179692 by tpartner
@DenisChenu, no need to apologize. Do you have a solution?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

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

More
1 month 3 weeks ago #179695 by KompetenzZ
Hi,

sorry, I didn't know that the previous values are cleaned anyway by clicking next. In that case everything is fine. I just thought that I need to remove the answers of hidden questions afterwards in the data analysis in spss. Thank you.

Cheers kompetenzz

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

More
1 month 3 weeks ago #179722 by DenisChenu

tpartner wrote: @DenisChenu, no need to apologize. Do you have a solution?

I think we don't need solution, since LS behaviour cleanup value when move next.

But else : usage of on(!relevance:off' can do the trics

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 or Create an account to join the conversation.

More
1 month 2 weeks ago #179971 by KompetenzZ
Hi,

can you please tell me where to insert this '!relevance:off'. I would need the solution yet because I have this question multiple numeric question where the answer option 'thereof irrigated' is showed when 'cropland' is > 0. But when respondents type something in 'thereof irrigated' and then change back 'cropland' to 0 they cannot proceed further because 'thereof irrigated' cannot be greater than 'cropland' (I did it with max value of the <input type="number"> field). In that case the answer option 'thereof irrigated' is hidden (if it is shown, it would have a red background) and the respondent doesn't know why he cannot proceed.

'thereof irrigated' cannot be greater than 'cropland':


when 'cropland' is 0 and 'thereof irrigated' has a value inside, respondents cannot proceed:

Cheers kompetenzz
Attachments:

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

More
1 month 2 weeks ago - 1 month 2 weeks ago #179973 by DenisChenu
Can you send a lss with just this question ?

I think it must work out of the box, but maybe validation of question must be fixed :).

Demo.sondages.me/582387

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 .
Last edit: 1 month 2 weeks ago by DenisChenu.

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

More
1 month 2 weeks ago #179991 by DenisChenu
It's your script to fix :
var grass = $( '#question{QID} input.form-control.em_sq_validation:eq(2)').val();
if(grass > 0) {
    $( '#question{QID} input.form-control.em_sq_validation:eq(3)').attr({
       "max" : grass
    });
}else {
$( '#question{QID} input.form-control.em_sq_validation:eq(3)').removeAttr('max');
}

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 or Create an account to join the conversation.

More
1 month 2 weeks ago #179992 by KompetenzZ
Sure, never thought about a simple else statement :)
I'm sorry that I did not have this idea before.

Cheers kompetenzz

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!