Help logic code, answers to sub-answers

Discussions about CSEntry
Post Reply
Guest

Help logic code, answers to sub-answers

Post by Guest »

Hello,
This is my firs post, I'm glad I have found this very useful website.

I have a programming question, hope someone can help.

I need to create a new application for my work. We will use questionnaires with answers and sub-answers (even sub-sub-answers).
I am wondering if it is possible to have, for example, one question field with a selection of [1. yes], [2. no], [3. maybe], then a second question field with a selection of answers automatically reflecting the choice made in the first field. That is, if selected [1. yes], then [1.1 blue], [1.2 green], but if selected [2. no], then [2.1 Red], [2.2 Yellow] and so on.

Thus, it would dramatically reduce the length of the whole questionnaire.
Is there a way of using Logic code to have something like : If Q1 is 1, then set of answers 1, but if Q1 is 2, then set of answers 2 etc.?

For example:

Q1: 1. Yes
1.1 Blue
1.2 Green

2. No
2.1 Red
2.2 Yellow

3. Maybe
3.1Grey
3.1.1Dark grey
3.1.2 Light grey

Thank you
Gregory Martin
Posts: 1792
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Help logic code, answers to sub-answers

Post by Gregory Martin »

You can use the setvalueset function to change the value set for a field.

So you might create three value sets for the field and then you would write logic like this:
PROC Q1

    
if Q1 = 1 then
        
setvalueset(Q2,Q2_VS1);

    
elseif Q1 = 2 then
        
setvalueset(Q2,Q2_VS2);

    
elseif Q1 = 3 then
        
setvalueset(Q2,Q2_VS3);

    
endif;
Alternatively, you could write this if the names of your value sets are so defined:
PROC Q1

    
if Q1 in 1:3 then
        
setvaluesets(maketext("Q2_VS%d",Q1));
    
endif;
You can also create value sets dynamically, which is especially useful if creating a value set based on information from a lookup file. See here for an example of how to do this.
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: Help logic code, answers to sub-answers

Post by lls »

Fantastic, it works nicely.

I have used the second option.

I didn't try but would this also work with a multiple occurrence question which has multiple occurrence answers? In case multiple asnswers are allowed in both the main question and the sub-answers.

Thank you

lls
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: Help logic code, answers to sub-answers

Post by lls »

Would this work with an Alpha field?

Q34_ORIENTGDC is an alpha multiple answers (check box)
Q35_CONSEIL has two set (VS1 and VS2), as alpha multiple answers (check box)

Such as

if Q34_ORIENTGDC in "A:C" then
setvaluesets(maketext("Q35_CONSEIL_VS%s",Q34_ORIENTGDC));
endif;
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: Help logic code, answers to sub-answers

Post by lls »

resolved
Post Reply