# Building survey in Excel - Constraint question

Hi,

I am building my survey in excel and have a few questions:

1. We have a multiple_choice question (Q1), the results of which are used
to constrain several questions that follow (Q2). In testing the device, if
the person answered "1" to Q1, they are shown Q2, as should result.
However, if they answer both "1" and "2" to Q1, they are not shown Q2. I
was thinking that the constraint \${Q1} = '1' would hold for both cases, but
it turns out that it doesn't. Is there a way to write the code that would
account for this?

2. On a similar note, how are multiple_choice questions documented in
the dataset? I am used to having a separate dummy variable for each
option. We are having trouble opening the exported ODK aggregate CSV form
so we are unaware of how the data looks. Does an answer of both 1 and 2,
look like a 12?

3. In all of the examples shown on the website, I do not see an example
where the constraint refers to a previous question. For instance, we ask
how many children total are you taking care of? And then the next question
asks how many boys and how many girls. For quality control, I want to make
sure that the sum of boys and girls equals the total. Would the constraint
go on the last question (regarding boys) and say {total} = {boys} + {girls}
or perhaps \${total} = \${boys} + \${girls}.

I hope these are clear questions, but do let me know if you need me to
explain anything further.

Many many thanks.

Lisa

Hi Lisa,

1. When testing for values in a select_one or select_multiple question I
think you should always use the following notation:

selected(\$Q1}, '1')

This will return true if the value '1' is selected. Using \${Q1} = '1'
will only return true if the total answer is equal to '1'. That is if only
'1' has been selected.

1. I'm not sure how aggregate exports its multiple choice data.

2. Constraints always have to refer to the current question using a .
(dot). Ie ". < \${total}" where . (dot) is the value entered in the current
question and the constraint rule says it has to be less than the value
entered for the question with name "total". In your example I think you
would need:

. = \${total} - \${girls}.

Regards

Neil

··· On Tue, Sep 25, 2012 at 9:01 AM, Lisa Zook wrote:

Hi,

I am building my survey in excel and have a few questions:

1. We have a multiple_choice question (Q1), the results of which are used
to constrain several questions that follow (Q2). In testing the device, if
the person answered "1" to Q1, they are shown Q2, as should result.
However, if they answer both "1" and "2" to Q1, they are not shown Q2. I
was thinking that the constraint \${Q1} = '1' would hold for both cases, but
it turns out that it doesn't. Is there a way to write the code that would
account for this?

2. On a similar note, how are multiple_choice questions documented in
the dataset? I am used to having a separate dummy variable for each
option. We are having trouble opening the exported ODK aggregate CSV form
so we are unaware of how the data looks. Does an answer of both 1 and 2,
look like a 12?

3. In all of the examples shown on the website, I do not see an example
where the constraint refers to a previous question. For instance, we ask
how many children total are you taking care of? And then the next question
asks how many boys and how many girls. For quality control, I want to make
sure that the sum of boys and girls equals the total. Would the constraint
go on the last question (regarding boys) and say {total} = {boys} + {girls}
or perhaps \${total} = \${boys} + \${girls}.

I hope these are clear questions, but do let me know if you need me to
explain anything further.

Many many thanks.

Lisa

regarding question number 3. you use the syntax \${your_field} to refer to
fields values other than the current question

{total},{girls} and {boys} defaults to 0
constraint for boys: . <= \${total}-\${girls}
constraint for girls: . <= \${total}-\${boys}

··· On Tuesday, September 25, 2012, Lisa Zook wrote:

Hi,

I am building my survey in excel and have a few questions:

1. We have a multiple_choice question (Q1), the results of which are used
to constrain several questions that follow (Q2). In testing the device, if
the person answered "1" to Q1, they are shown Q2, as should result.
However, if they answer both "1" and "2" to Q1, they are not shown Q2. I
was thinking that the constraint \${Q1} = '1' would hold for both cases, but
it turns out that it doesn't. Is there a way to write the code that would
account for this?

2. On a similar note, how are multiple_choice questions documented in
the dataset? I am used to having a separate dummy variable for each
option. We are having trouble opening the exported ODK aggregate CSV form
so we are unaware of how the data looks. Does an answer of both 1 and 2,
look like a 12?

3. In all of the examples shown on the website, I do not see an example
where the constraint refers to a previous question. For instance, we ask
how many children total are you taking care of? And then the next question
asks how many boys and how many girls. For quality control, I want to make
sure that the sum of boys and girls equals the total. Would the constraint
go on the last question (regarding boys) and say {total} = {boys} + {girls}
or perhaps \${total} = \${boys} + \${girls}.

I hope these are clear questions, but do let me know if you need me to
explain anything further.

Many many thanks.

Lisa

--