Report previous answers (checkboxes) to next question in order to rate them

Hi everyone !

I apologize in advance for my English, it might be a bit rusty... and for
my very long title!
I am discovering CommCare and am really enjoy it so far! Unfortunately, I'm
stuck trying to build my form.

Here is what I want to do (I hope you'll be able to help me out with these
issues):

1. There is a first question, displaying a list of names (
Names_Selection). I used the checkbox function. The user must choose 4
names out of 10.
I need the second question to be displayed only when the user has
selected exactly 4 names.
Here's what I did :

  • In Logic, I checked the *Required *box
  • In Logic > Validation Condition, I wrote this:
    count-selected(Names_Selection)=4
  • In the next question, in Logic > Validation Condition, I wrote this:
    count-selected(#form/Names_Selection)=4

Is it correct ? Because when I use the preview mode and start to tick the
checkboxes, there is a wheel that never ends turning and nothing happens...

*2. *Now, in the next question, I would like those 4 previous selected
names (whatever the user chose) to be displayed. And I want the users to
attribute a number (from 1 to 4) in order to rate their choices according
to their preference (1 being their favourite, and 4 being the one they like
the less).
And I have no clue how to do it properly...!

Any idea ?
(I feel like John Snow right now... Knowing nothing is exhausting!)

Thanks a lot for you help guys!
Cheers,

Laëtitia.

Hi Laëtitia,

For (1) I'd recommend replacing:

count-selected(Names_Selection)=4

with

count-selected(.)=4

The '.' character is used in validation conditions to refer to the question
itself.

For (2) there are a few ways I can imagine doing this. One possibility
would be to use selected-at function
https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-count-selected.
Since you know you'll always have four selected items you can retrieve
these items with selected-at(#forms/Names_Selection, 0),
selected-at(#forms/Names_Selection, 1), etc. Then you'd display these values
https://confluence.dimagi.com/display/commcarepublic/Hidden+Values+Tutorial+Part+4%3A+Displaying+an+Output
and
ask them to rate them from 1 to 4 using a select question, with a
validation condition to ensure that each value (1, 2, 3, 4) is only given
once.

Hope that makes sense.

Valar morghulis,
Will

··· On Tue, Dec 27, 2016 at 10:41 AM, LaetitiaV < laetitiavinet.management@gmail.com> wrote:

Hi everyone !

I apologize in advance for my English, it might be a bit rusty... and for
my very long title!
I am discovering CommCare and am really enjoy it so far! Unfortunately,
I'm stuck trying to build my form.

Here is what I want to do (I hope you'll be able to help me out with these
issues):

1. There is a first question, displaying a list of names (
Names_Selection). I used the checkbox function. The user must choose 4
names out of 10.
I need the second question to be displayed only when the user has
selected exactly 4 names.
Here's what I did :

  • In Logic, I checked the *Required *box
  • In Logic > Validation Condition, I wrote this:
    count-selected(Names_Selection)=4
  • In the next question, in Logic > Validation Condition, I wrote
    this: count-selected(#form/Names_Selection)=4

Is it correct ? Because when I use the preview mode and start to tick the
checkboxes, there is a wheel that never ends turning and nothing happens...

*2. *Now, in the next question, I would like those 4 previous selected
names (whatever the user chose) to be displayed. And I want the users to
attribute a number (from 1 to 4) in order to rate their choices according
to their preference (1 being their favourite, and 4 being the one they like
the less).
And I have no clue how to do it properly...!

Any idea ?
(I feel like John Snow right now... Knowing nothing is exhausting!)

Thanks a lot for you help guys!
Cheers,

Laëtitia.

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Will,

Thanks a lot for your answer!

I changed *count-selected(Names_Selection)=4 *for *count-selected(.)=4 *as
you told me (thanks for the "." tip by the way :wink: ).

Unfortunately, I'm not sure that I am using the select-at function
correctly.

For my second question, I have created a group, in which I added text
questions. It seemed nice in preview.... until I added the select-at
functions!
I thought that by typing the following functions, I would have each
previous selected name displayed in each group-question:

Question 1 > Label : selected-at(#forms/Names_Selection, 0)
Question 2 > Label :
selected-at(#forms/Names_Selection, 1)
Question 3 > Label : selected-at(#forms/Names_Selection, 2)
Question 4 > Label :
selected-at(#forms/Names_Selection, 3)

Instead, I have this :

https://lh3.googleusercontent.com/-Fk5ww5GGuGY/WGUJtWtJwNI/AAAAAAAAAGI/dOIsXSDFj18BqXO3n_6fYD-ra686qe1vwCLcB/s1600/Select-at_Error_capture.png

I guess I did something wrong... But what? Haha!

Thanks again for your help !
Cheers,

Laëtitia.

Ps: Gosh... How stupid is I : John instead of Jon.... No comment. ^^

Hey Laëtitia,

Glad that's working!

Please take a closer look at the second document I sent in my previous
email - those values will need to be in an tag to evaluate.

Cheers,
Will

··· On Thu, Dec 29, 2016 at 8:15 AM LaetitiaV < laetitiavinet.management@gmail.com> wrote:

Hi Will,

Thanks a lot for your answer!

I changed *count-selected(Names_Selection)=4 *for *count-selected(.)=4 *as
you told me (thanks for the "." tip by the way :wink: ).

Unfortunately, I'm not sure that I am using the select-at function
correctly.

For my second question, I have created a group, in which I added text
questions. It seemed nice in preview.... until I added the select-at
functions!
I thought that by typing the following functions, I would have each
previous selected name displayed in each group-question:

Question 1 > Label : selected-at(#forms/Names_Selection, 0)
Question 2 > Label :
selected-at(#forms/Names_Selection, 1)
Question 3 > Label : selected-at(#forms/Names_Selection, 2)
Question 4 > Label :
selected-at(#forms/Names_Selection, 3)

Instead, I have this :

https://lh3.googleusercontent.com/-Fk5ww5GGuGY/WGUJtWtJwNI/AAAAAAAAAGI/dOIsXSDFj18BqXO3n_6fYD-ra686qe1vwCLcB/s1600/Select-at_Error_capture.png

I guess I did something wrong... But what? Haha!

Thanks again for your help !
Cheers,

Laëtitia.

Ps: Gosh... How stupid is I : John instead of Jon.... No comment. ^^

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.