Repeat through selected items

Hi,
Is it possible to select a number of items from a select_multiple list,
then build a repeat that will iterate through all the selected items?
I'm using SurveyCTO.
Thanks a lot!
Maria

1 Like

Hi Maria,

Yes, certainly, this is possible. For the repeat-count of the repeat group,
you would call count-selected() (as in "count-selected(${multiplechoice})"
when multiplechoice is the name of your select_multiple field). Then,
within the repeat group, you could have the following fields:

this_selection: this would be a calculate field with the calculation
expression "selected-at(${multiplechoice}, position(..))", again where
multiplechoice is the name of your select_multiple field. This takes your
current position in the repeat group ("position(..)") and fetches the
selection value (from the name column of your choices sheet) for the
associated selection.

this_selection_label: this would be a calculate field with the calculation
expression "jr:choice-name(${this_selection}, '${multiplechoice}')", just
to grab the label associated with the selection value -- in case it's
helpful for reference in notes or labels. (This jr:choice-name() function
was recently supported in SurveyCTO and recently fixed in ODK. See
https://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id.)

As a side note, I was just discussing a related process with another
client: taking a set of select_multiple choices and randomly selecting one.
For this, you can use fields defined like the following:

randomdraw: this would be a field calculated with the calculation
expression "random-once()". (We recently added random-once() to SurveyCTO
to avoid the possibility of random numbers being re-drawn when saved forms
are edited -- but, in standard ODK, you would call the standard random()
function. See recent discussions on this subject, in this community group.)

randomselectionindex: this would be a field calculated with the calculation
expression "round(${randomdraw}*count-selected(${multiplechoice})+0.5,0)"
where multiplechoice is the name of the select_multiple field. This
essentially takes the random draw between 0 and 1 and scales it to be a
whole number between 1 and the number of selections the user made in the
select_multiple. (Obviously, this won't work well for 0 selections. You
will want to make your later follow-up questions relevant only when
"count-selected(${multiplechoice}) > 0".)

randomselection: this would be a field calculated with the calculation
expression "selected-at(${multiplechoice}, ${randomselectionindex})". Given
the selection number in randomselectionindex (e.g., 1 for the user's first
selection), this returns the actual value of that selection (from the name
column of the choices sheet).

randomselectionlabel: this would be a field calculated with the calculation
expression "jr:choice-name(${randomselection}, '${multiplechoice}')", just
to grab the label associated with the selection value randomly chosen in
randomselection -- in case it's helpful for reference in notes or labels.
(This jr:choice-name() function was recently supported in SurveyCTO and
recently fixed in ODK. See
https://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id.)

I hope that's helpful.

Best,

Chris

P.S. As a SurveyCTO client, you can always request support via the Contact
Support option at http://www.surveycto.com/support/index.html.

ยทยทยท On Wed, Jul 24, 2013 at 5:51 AM, Maria Comanescu wrote:

Hi,
Is it possible to select a number of items from a select_multiple list,
then build a repeat that will iterate through all the selected items?
I'm using SurveyCTO.
Thanks a lot!
Maria

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

1 Like

Hi Chris
When I'm in select_multiple, is it possible to choose one or more items and disable what you don't need to choose because you have already the correct ones in other to minimize errors in data collection.
Thanks

Jean de Dieu
i'm using SurveyCTO in Kabeho study

Thanks Chris!
That's exactly what I needed.
Maria

ยทยทยท On Wednesday, July 24, 2013 6:12:32 AM UTC-4, Christopher Robert wrote: > > Hi Maria, > > Yes, certainly, this is possible. For the repeat-count of the repeat > group, you would call count-selected() (as in > "count-selected(${multiplechoice})" when multiplechoice is the name of your > select_multiple field). Then, within the repeat group, you could have the > following fields: > > this_selection: this would be a calculate field with the calculation > expression "selected-at(${multiplechoice}, position(..))", again where > multiplechoice is the name of your select_multiple field. This takes your > current position in the repeat group ("position(..)") and fetches the > selection value (from the name column of your choices sheet) for the > associated selection. > > this_selection_label: this would be a calculate field with the calculation > expression "jr:choice-name(${this_selection}, '${multiplechoice}')", just > to grab the label associated with the selection value -- in case it's > helpful for reference in notes or labels. (This jr:choice-name() function > was recently supported in SurveyCTO and recently fixed in ODK. See > https://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id.) > > > As a side note, I was just discussing a related process with another > client: taking a set of select_multiple choices and randomly selecting one. > For this, you can use fields defined like the following: > > randomdraw: this would be a field calculated with the calculation > expression "random-once()". (We recently added random-once() to SurveyCTO > to avoid the possibility of random numbers being re-drawn when saved forms > are edited -- but, in standard ODK, you would call the standard random() > function. See recent discussions on this subject, in this community group.) > > randomselectionindex: this would be a field calculated with the > calculation expression > "round(${randomdraw}*count-selected(${multiplechoice})+0.5,0)" where > multiplechoice is the name of the select_multiple field. This essentially > takes the random draw between 0 and 1 and scales it to be a whole number > between 1 and the number of selections the user made in the > select_multiple. (Obviously, this won't work well for 0 selections. You > will want to make your later follow-up questions relevant only when > "count-selected(${multiplechoice}) > 0".) > > randomselection: this would be a field calculated with the calculation > expression "selected-at(${multiplechoice}, ${randomselectionindex})". Given > the selection number in randomselectionindex (e.g., 1 for the user's first > selection), this returns the actual value of that selection (from the name > column of the choices sheet). > > randomselectionlabel: this would be a field calculated with the > calculation expression "jr:choice-name(${randomselection}, > '${multiplechoice}')", just to grab the label associated with the selection > value randomly chosen in randomselection -- in case it's helpful for > reference in notes or labels. (This jr:choice-name() function was recently > supported in SurveyCTO and recently fixed in ODK. See > https://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id.) > > > I hope that's helpful. > > Best, > > Chris > > P.S. As a SurveyCTO client, you can always request support via the Contact > Support option at http://www.surveycto.com/support/index.html. > > > > On Wed, Jul 24, 2013 at 5:51 AM, Maria Comanescu <mery.co...@gmail.com wrote: > >> Hi, >> Is it possible to select a number of items from a select_multiple list, >> then build a repeat that will iterate through all the selected items? >> I'm using SurveyCTO. >> Thanks a lot! >> Maria >> >> -- >> -- >> Post: opend...@googlegroups.com >> Unsubscribe: opendatakit...@googlegroups.com >> Options: http://groups.google.com/group/opendatakit?hl=en >> >> --- >> You received this message because you are subscribed to the Google Groups >> "ODK Community" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to opendatakit...@googlegroups.com . >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >

Hi,

I couldn't get this approach to work. I get an error in xlsform of
ava.lang.ArrayIndexOutOfBoundsException:
1 >= 0 in xlsform which seems to be caused by the calculation selected
-at(${multiplechoice}**, position(..)). Is this surveyCTO only?

Does position(..) get the position of the selected option in the select
multiple question that is being processed or the position in the loop?

regards

Neil

ยทยทยท On Wed, Jul 24, 2013 at 10:30 PM, Maria Comanescu wrote:

Thanks Chris!
That's exactly what I needed.
Maria

On Wednesday, July 24, 2013 6:12:32 AM UTC-4, Christopher Robert wrote:

Hi Maria,

Yes, certainly, this is possible. For the repeat-count of the repeat
group, you would call count-selected() (as in "count-selected(${**multiplechoice})"
when multiplechoice is the name of your select_multiple field). Then,
within the repeat group, you could have the following fields:

this_selection: this would be a calculate field with the calculation
expression "selected-at(${multiplechoice}**, position(..))", again where
multiplechoice is the name of your select_multiple field. This takes your
current position in the repeat group ("position(..)") and fetches the
selection value (from the name column of your choices sheet) for the
associated selection.

this_selection_label: this would be a calculate field with the
calculation expression "jr:choice-name(${this_selection},
'${multiplechoice}')", just to grab the label associated with the selection
value -- in case it's helpful for reference in notes or labels. (This
jr:choice-name() function was recently supported in SurveyCTO and recently
fixed in ODK. See https://code.google.com/p/

opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

As a side note, I was just discussing a related process with another
client: taking a set of select_multiple choices and randomly selecting one.
For this, you can use fields defined like the following:

randomdraw: this would be a field calculated with the calculation
expression "random-once()". (We recently added random-once() to SurveyCTO
to avoid the possibility of random numbers being re-drawn when saved forms
are edited -- but, in standard ODK, you would call the standard random()
function. See recent discussions on this subject, in this community group.)

randomselectionindex: this would be a field calculated with the
calculation expression "round(${randomdraw}count-*
selected(${multiplechoice})+0.**5,0)" where multiplechoice is the name
of the select_multiple field. This essentially takes the random draw
between 0 and 1 and scales it to be a whole number between 1 and the number
of selections the user made in the select_multiple. (Obviously, this won't
work well for 0 selections. You will want to make your later follow-up
questions relevant only when "count-selected(${**multiplechoice}) > 0".)

randomselection: this would be a field calculated with the calculation
expression "selected-at(${multiplechoice}**, ${randomselectionindex})".
Given the selection number in randomselectionindex (e.g., 1 for the user's
first selection), this returns the actual value of that selection (from the
name column of the choices sheet).

randomselectionlabel: this would be a field calculated with the
calculation expression "jr:choice-name(${**randomselection},
'${multiplechoice}')", just to grab the label associated with the selection
value randomly chosen in randomselection -- in case it's helpful for
reference in notes or labels. (This jr:choice-name() function was recently
supported in SurveyCTO and recently fixed in ODK. See
https://code.google.com/p/**opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

I hope that's helpful.

Best,

Chris

P.S. As a SurveyCTO client, you can always request support via the
Contact Support option at http://www.surveycto.com/**support/index.htmlhttp://www.surveycto.com/support/index.html
.

On Wed, Jul 24, 2013 at 5:51 AM, Maria Comanescu mery.co...@gmail.comwrote:

Hi,
Is it possible to select a number of items from a select_multiple list,
then build a repeat that will iterate through all the selected items?
I'm using SurveyCTO.
Thanks a lot!
Maria

--

Post: opend...@googlegroups.com
Unsubscribe: opendatakit...@**googlegroups.com
Options: http://groups.google.com/**group/opendatakit?hl=enhttp://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit...@**googlegroups.com.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Smap Consulting http://smap.com.au/| Mobile Data Collection Solutions
Application Developer - neilpenman@gmail.com minqiang.huang@gmail.com
Twitter: @dgmsot
Skype: ianaf4you
Phone: +61 402 975 959
Blog: http://blog.smap.com.au http://smap.com.au/blog

Hi Jean,

You can filter the list of options that appear, of course, based on
earlier-selected options. But you can't show them in the list but have them
disabled. There is no way to individually disable choice options (while
leaving them there on the screen).

Sorry!

Chris

ยทยทยท On Thu, May 15, 2014 at 9:05 AM, wrote:

Hi Chris
When I'm in select_multiple, is it possible to choose one or more items
and disable what you don't need to choose because you have already the
correct ones in other to minimize errors in data collection.
Thanks

Jean de Dieu
i'm using SurveyCTO in Kabeho study

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

Hi Neil,

We also discovered that selected-at() could be extremely picky, giving that
error whenever the passed index was invalid for the current list of
selections -- and that, during validation, it would reject basically any
index. Therefore, for some time you had to do something like...

if(position(..)-1 < count-selected(${multiplechoice}),
selected-at(${multiplechoice}, position(..)-1, -1)

...to be sure never to pass an invalid index to selected-at(). In this
example, if position(..) is somehow out of range (which it will be during
validation), it returns -1 rather than calling selected-at().

Note that I used position(..)-1 rather than position(..). I believe that
my original suggestion was off in that position(..) is 1 for the first
iteration, 2 for the second, and so on, but selected-at() wants 0 for the
first, 1 for the second, etc. Thus, the correct thing to pass to
selected-at() is position(..)-1, not position(..).

As soon as we discovered it, we removed this pickiness from SurveyCTO, so
that it wouldn't give these errors on validation or require elaborate if()
statements. We also submitted that change to the community, and I believe
that it was rolled into ODK's JavaRosa, and thus into its ODK_Validate, and
thus into its XLSForm. If you're using the online version of XLSForm and
it's still giving this error, let us know. Maybe it's just that the online
XLSForm hasn't been updated.

Thanks for catching this.

Best,

Chris

ยทยทยท On Wed, Jul 31, 2013 at 3:43 AM, Neil Penman wrote:

Hi,

I couldn't get this approach to work. I get an error in xlsform of ava.lang.ArrayIndexOutOfBoundsException:
1 >= 0 in xlsform which seems to be caused by the calculation selected
-at(${multiplechoice}**, position(..)). Is this surveyCTO only?

Does position(..) get the position of the selected option in the select
multiple question that is being processed or the position in the loop?

regards

Neil

On Wed, Jul 24, 2013 at 10:30 PM, Maria Comanescu < mery.comanescu@gmail.com> wrote:

Thanks Chris!
That's exactly what I needed.
Maria

On Wednesday, July 24, 2013 6:12:32 AM UTC-4, Christopher Robert wrote:

Hi Maria,

Yes, certainly, this is possible. For the repeat-count of the repeat
group, you would call count-selected() (as in "count-selected(${**multiplechoice})"
when multiplechoice is the name of your select_multiple field). Then,
within the repeat group, you could have the following fields:

this_selection: this would be a calculate field with the calculation
expression "selected-at(${multiplechoice}**, position(..))", again
where multiplechoice is the name of your select_multiple field. This takes
your current position in the repeat group ("position(..)") and fetches the
selection value (from the name column of your choices sheet) for the
associated selection.

this_selection_label: this would be a calculate field with the
calculation expression "jr:choice-name(${this_selection},
'${multiplechoice}')", just to grab the label associated with the selection
value -- in case it's helpful for reference in notes or labels. (This
jr:choice-name() function was recently supported in SurveyCTO and recently
fixed in ODK. See https://code.google.com/p/

opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

As a side note, I was just discussing a related process with another
client: taking a set of select_multiple choices and randomly selecting one.
For this, you can use fields defined like the following:

randomdraw: this would be a field calculated with the calculation
expression "random-once()". (We recently added random-once() to SurveyCTO
to avoid the possibility of random numbers being re-drawn when saved forms
are edited -- but, in standard ODK, you would call the standard random()
function. See recent discussions on this subject, in this community group.)

randomselectionindex: this would be a field calculated with the
calculation expression "round(${randomdraw}count-*
selected(${multiplechoice})+0.**5,0)" where multiplechoice is the name
of the select_multiple field. This essentially takes the random draw
between 0 and 1 and scales it to be a whole number between 1 and the number
of selections the user made in the select_multiple. (Obviously, this won't
work well for 0 selections. You will want to make your later follow-up
questions relevant only when "count-selected(${**multiplechoice}) > 0".)

randomselection: this would be a field calculated with the calculation
expression "selected-at(${multiplechoice}**, ${randomselectionindex})".
Given the selection number in randomselectionindex (e.g., 1 for the user's
first selection), this returns the actual value of that selection (from the
name column of the choices sheet).

randomselectionlabel: this would be a field calculated with the
calculation expression "jr:choice-name(${**randomselection},
'${multiplechoice}')", just to grab the label associated with the selection
value randomly chosen in randomselection -- in case it's helpful for
reference in notes or labels. (This jr:choice-name() function was recently
supported in SurveyCTO and recently fixed in ODK. See
https://code.google.com/p/**opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

I hope that's helpful.

Best,

Chris

P.S. As a SurveyCTO client, you can always request support via the
Contact Support option at http://www.surveycto.com/**support/index.htmlhttp://www.surveycto.com/support/index.html
.

On Wed, Jul 24, 2013 at 5:51 AM, Maria Comanescu mery.co...@gmail.comwrote:

Hi,
Is it possible to select a number of items from a select_multiple list,
then build a repeat that will iterate through all the selected items?
I'm using SurveyCTO.
Thanks a lot!
Maria

--

Post: opend...@googlegroups.com
Unsubscribe: opendatakit...@**googlegroups.com
Options: http://groups.google.com/**group/opendatakit?hl=enhttp://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit...@**googlegroups.com.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Smap Consulting http://smap.com.au/| Mobile Data Collection Solutions
Application Developer - neilpenman@gmail.com minqiang.huang@gmail.com
Twitter: @dgmsot
Skype: ianaf4you
Phone: +61 402 975 959
Blog: http://blog.smap.com.au http://smap.com.au/blog

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

I have not yet updated XSLForm and released an updated ODK Validate that
should address this issue.

Mitch

ยทยทยท On Wed, Jul 31, 2013 at 3:35 AM, Christopher Robert wrote:

Hi Neil,

We also discovered that selected-at() could be extremely picky, giving
that error whenever the passed index was invalid for the current list of
selections -- and that, during validation, it would reject basically any
index. Therefore, for some time you had to do something like...

if(position(..)-1 < count-selected(${multiplechoice}),
selected-at(${multiplechoice}, position(..)-1, -1)

...to be sure never to pass an invalid index to selected-at(). In this
example, if position(..) is somehow out of range (which it will be during
validation), it returns -1 rather than calling selected-at().

Note that I used position(..)-1 rather than position(..). I believe
that my original suggestion was off in that position(..) is 1 for the first
iteration, 2 for the second, and so on, but selected-at() wants 0 for the
first, 1 for the second, etc. Thus, the correct thing to pass to
selected-at() is position(..)-1, not position(..).

As soon as we discovered it, we removed this pickiness from SurveyCTO, so
that it wouldn't give these errors on validation or require elaborate if()
statements. We also submitted that change to the community, and I believe
that it was rolled into ODK's JavaRosa, and thus into its ODK_Validate, and
thus into its XLSForm. If you're using the online version of XLSForm and
it's still giving this error, let us know. Maybe it's just that the online
XLSForm hasn't been updated.

Thanks for catching this.

Best,

Chris

On Wed, Jul 31, 2013 at 3:43 AM, Neil Penman neilpenman@gmail.com wrote:

Hi,

I couldn't get this approach to work. I get an error in xlsform of ava.lang.ArrayIndexOutOfBoundsException:
1 >= 0 in xlsform which seems to be caused by the calculation selected
-at(${multiplechoice}**, position(..)). Is this surveyCTO only?

Does position(..) get the position of the selected option in the select
multiple question that is being processed or the position in the loop?

regards

Neil

On Wed, Jul 24, 2013 at 10:30 PM, Maria Comanescu < mery.comanescu@gmail.com> wrote:

Thanks Chris!
That's exactly what I needed.
Maria

On Wednesday, July 24, 2013 6:12:32 AM UTC-4, Christopher Robert wrote:

Hi Maria,

Yes, certainly, this is possible. For the repeat-count of the repeat
group, you would call count-selected() (as in "count-selected(${**multiplechoice})"
when multiplechoice is the name of your select_multiple field). Then,
within the repeat group, you could have the following fields:

this_selection: this would be a calculate field with the calculation
expression "selected-at(${multiplechoice}**, position(..))", again
where multiplechoice is the name of your select_multiple field. This takes
your current position in the repeat group ("position(..)") and fetches the
selection value (from the name column of your choices sheet) for the
associated selection.

this_selection_label: this would be a calculate field with the
calculation expression "jr:choice-name(${this_selection},
'${multiplechoice}')", just to grab the label associated with the selection
value -- in case it's helpful for reference in notes or labels. (This
jr:choice-name() function was recently supported in SurveyCTO and recently
fixed in ODK. See https://code.google.com/p/

opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

As a side note, I was just discussing a related process with another
client: taking a set of select_multiple choices and randomly selecting one.
For this, you can use fields defined like the following:

randomdraw: this would be a field calculated with the calculation
expression "random-once()". (We recently added random-once() to SurveyCTO
to avoid the possibility of random numbers being re-drawn when saved forms
are edited -- but, in standard ODK, you would call the standard random()
function. See recent discussions on this subject, in this community group.)

randomselectionindex: this would be a field calculated with the
calculation expression "round(${randomdraw}count-*
selected(${multiplechoice})+0.**5,0)" where multiplechoice is the name
of the select_multiple field. This essentially takes the random draw
between 0 and 1 and scales it to be a whole number between 1 and the number
of selections the user made in the select_multiple. (Obviously, this won't
work well for 0 selections. You will want to make your later follow-up
questions relevant only when "count-selected(${**multiplechoice}) >
0".)

randomselection: this would be a field calculated with the calculation
expression "selected-at(${multiplechoice}**,
${randomselectionindex})". Given the selection number in
randomselectionindex (e.g., 1 for the user's first selection), this returns
the actual value of that selection (from the name column of the choices
sheet).

randomselectionlabel: this would be a field calculated with the
calculation expression "jr:choice-name(${**randomselection},
'${multiplechoice}')", just to grab the label associated with the selection
value randomly chosen in randomselection -- in case it's helpful for
reference in notes or labels. (This jr:choice-name() function was recently
supported in SurveyCTO and recently fixed in ODK. See
https://code.google.com/p/**opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

I hope that's helpful.

Best,

Chris

P.S. As a SurveyCTO client, you can always request support via the
Contact Support option at http://www.surveycto.com/**support/index.htmlhttp://www.surveycto.com/support/index.html
.

On Wed, Jul 24, 2013 at 5:51 AM, Maria Comanescu mery.co...@gmail.comwrote:

Hi,
Is it possible to select a number of items from a select_multiple
list, then build a repeat that will iterate through all the selected items?
I'm using SurveyCTO.
Thanks a lot!
Maria

--

Post: opend...@googlegroups.com
Unsubscribe: opendatakit...@**googlegroups.com
Options: http://groups.google.com/**group/opendatakit?hl=enhttp://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit...@**googlegroups.com.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Smap Consulting http://smap.com.au/| Mobile Data Collection Solutions
Application Developer - neilpenman@gmail.com minqiang.huang@gmail.com
Twitter: @dgmsot
Skype: ianaf4you
Phone: +61 402 975 959
Blog: http://blog.smap.com.au http://smap.com.au/blog

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Thanks Chris,

That updated (older style) formula works nicely with the current xlsform.
There was a minor typo, a bracket was missing:
if(position(..)-1 < count-selected(${multiplechoice}),
selected-at(${multiplechoice}, position(..)-1), -1)

very impressive!

regards

Neil

ยทยทยท On Wed, Jul 31, 2013 at 8:35 PM, Christopher Robert wrote:

Hi Neil,

We also discovered that selected-at() could be extremely picky, giving
that error whenever the passed index was invalid for the current list of
selections -- and that, during validation, it would reject basically any
index. Therefore, for some time you had to do something like...

if(position(..)-1 < count-selected(${multiplechoice}),
selected-at(${multiplechoice}, position(..)-1, -1)

...to be sure never to pass an invalid index to selected-at(). In this
example, if position(..) is somehow out of range (which it will be during
validation), it returns -1 rather than calling selected-at().

Note that I used position(..)-1 rather than position(..). I believe
that my original suggestion was off in that position(..) is 1 for the first
iteration, 2 for the second, and so on, but selected-at() wants 0 for the
first, 1 for the second, etc. Thus, the correct thing to pass to
selected-at() is position(..)-1, not position(..).

As soon as we discovered it, we removed this pickiness from SurveyCTO, so
that it wouldn't give these errors on validation or require elaborate if()
statements. We also submitted that change to the community, and I believe
that it was rolled into ODK's JavaRosa, and thus into its ODK_Validate, and
thus into its XLSForm. If you're using the online version of XLSForm and
it's still giving this error, let us know. Maybe it's just that the online
XLSForm hasn't been updated.

Thanks for catching this.

Best,

Chris

On Wed, Jul 31, 2013 at 3:43 AM, Neil Penman neilpenman@gmail.com wrote:

Hi,

I couldn't get this approach to work. I get an error in xlsform of ava.lang.ArrayIndexOutOfBoundsException:
1 >= 0 in xlsform which seems to be caused by the calculation selected
-at(${multiplechoice}**, position(..)). Is this surveyCTO only?

Does position(..) get the position of the selected option in the select
multiple question that is being processed or the position in the loop?

regards

Neil

On Wed, Jul 24, 2013 at 10:30 PM, Maria Comanescu < mery.comanescu@gmail.com> wrote:

Thanks Chris!
That's exactly what I needed.
Maria

On Wednesday, July 24, 2013 6:12:32 AM UTC-4, Christopher Robert wrote:

Hi Maria,

Yes, certainly, this is possible. For the repeat-count of the repeat
group, you would call count-selected() (as in "count-selected(${**multiplechoice})"
when multiplechoice is the name of your select_multiple field). Then,
within the repeat group, you could have the following fields:

this_selection: this would be a calculate field with the calculation
expression "selected-at(${multiplechoice}**, position(..))", again
where multiplechoice is the name of your select_multiple field. This takes
your current position in the repeat group ("position(..)") and fetches the
selection value (from the name column of your choices sheet) for the
associated selection.

this_selection_label: this would be a calculate field with the
calculation expression "jr:choice-name(${this_selection},
'${multiplechoice}')", just to grab the label associated with the selection
value -- in case it's helpful for reference in notes or labels. (This
jr:choice-name() function was recently supported in SurveyCTO and recently
fixed in ODK. See https://code.google.com/p/

opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

As a side note, I was just discussing a related process with another
client: taking a set of select_multiple choices and randomly selecting one.
For this, you can use fields defined like the following:

randomdraw: this would be a field calculated with the calculation
expression "random-once()". (We recently added random-once() to SurveyCTO
to avoid the possibility of random numbers being re-drawn when saved forms
are edited -- but, in standard ODK, you would call the standard random()
function. See recent discussions on this subject, in this community group.)

randomselectionindex: this would be a field calculated with the
calculation expression "round(${randomdraw}count-*
selected(${multiplechoice})+0.**5,0)" where multiplechoice is the name
of the select_multiple field. This essentially takes the random draw
between 0 and 1 and scales it to be a whole number between 1 and the number
of selections the user made in the select_multiple. (Obviously, this won't
work well for 0 selections. You will want to make your later follow-up
questions relevant only when "count-selected(${**multiplechoice}) >
0".)

randomselection: this would be a field calculated with the calculation
expression "selected-at(${multiplechoice}**,
${randomselectionindex})". Given the selection number in
randomselectionindex (e.g., 1 for the user's first selection), this returns
the actual value of that selection (from the name column of the choices
sheet).

randomselectionlabel: this would be a field calculated with the
calculation expression "jr:choice-name(${**randomselection},
'${multiplechoice}')", just to grab the label associated with the selection
value randomly chosen in randomselection -- in case it's helpful for
reference in notes or labels. (This jr:choice-name() function was recently
supported in SurveyCTO and recently fixed in ODK. See
https://code.google.com/p/**opendatakit/issues/detail?id=**854&sort=-idhttps://code.google.com/p/opendatakit/issues/detail?id=854&sort=-id
.)

I hope that's helpful.

Best,

Chris

P.S. As a SurveyCTO client, you can always request support via the
Contact Support option at http://www.surveycto.com/**support/index.htmlhttp://www.surveycto.com/support/index.html
.

On Wed, Jul 24, 2013 at 5:51 AM, Maria Comanescu mery.co...@gmail.comwrote:

Hi,
Is it possible to select a number of items from a select_multiple
list, then build a repeat that will iterate through all the selected items?
I'm using SurveyCTO.
Thanks a lot!
Maria

--

Post: opend...@googlegroups.com
Unsubscribe: opendatakit...@**googlegroups.com
Options: http://groups.google.com/**group/opendatakit?hl=enhttp://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit...@**googlegroups.com.
For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Smap Consulting http://smap.com.au/| Mobile Data Collection Solutions
Application Developer - neilpenman@gmail.com minqiang.huang@gmail.com
Twitter: @dgmsot
Skype: ianaf4you
Phone: +61 402 975 959
Blog: http://blog.smap.com.au http://smap.com.au/blog

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Smap Consulting http://smap.com.au/| Mobile Data Collection Solutions
Application Developer - neilpenman@gmail.com minqiang.huang@gmail.com
Twitter: @dgmsot
Skype: ianaf4you
Phone: +61 402 975 959
Blog: http://blog.smap.com.au http://smap.com.au/blog

1 Like

Thank you Chris

ยทยทยท On Thu, May 15, 2014 at 4:29 PM, Christopher Robert wrote:

Hi Jean,

You can filter the list of options that appear, of course, based on
earlier-selected options. But you can't show them in the list but have them
disabled. There is no way to individually disable choice options (while
leaving them there on the screen).

Sorry!

Chris

On Thu, May 15, 2014 at 9:05 AM, kayidieu51@gmail.com wrote:

Hi Chris
When I'm in select_multiple, is it possible to choose one or more items
and disable what you don't need to choose because you have already the
correct ones in other to minimize errors in data collection.
Thanks

Jean de Dieu
i'm using SurveyCTO in Kabeho study

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/AkSq6VRSA_Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris, Neil, this is very helpful.

I was looking to solve exactly this problem, and your solution looks very close to working for me (still can't Validate it, but never mind that).

My problem is that the jr:choice-name(${this_selection}, '${multiplechoice}') values do not change. That is, I loop x times (based on count-selected(${multiplechoice})), but the this_selection_label value does not change change in each loop iteration. This could be an issue with the position or with how I've set things up. Perhaps some code would make this more clear (note that I'm very new to this, so might be making some very obvious mistakes):

      <CDH2_sum/>
      <CDH2_position/>
      <CDH2_name/>

      <CDH3_group>
        <CDH3/>
        <CDH3_SPE/>
      </CDH3_group>


      <text id="/data/CDH2_group:label">
        <value></value>
      </text>
      <text id="/data/CDH2_group/CDH2:label">
        <value>CDH2. What is the relationship to you of the person in your household that you told that you are HIV-positive?</value>
      </text>
      <text id="/data/CDH2_group/CDH2:option0">
        <value>Spouse/Partner</value>
      </text>
      <text id="/data/CDH2_group/CDH2:option1">
        <value>Mother</value>
      </text>
      <text id="/data/CDH2_group/CDH2:option2">
        <value>Father</value>
      </text>
      <text id="/data/CDH2_group/CDH2:option3">
        <value>Sister</value>
      </text>
      <text id="/data/CDH2_group/CDH2:option4">
        <value>Brother</value>
      </text>
      <text id="/data/CDH3_group:label">
        <value></value>
      </text>
      <text id="/data/CDH3_group/CDH3:label">
        <value>CDH3. Before you told your <output ref="/data/CDH2_name"/> that you are HIV-positive, how did you expect this person to react?</value>
      </text>


 <bind nodeset="/data/CDH2_group/CDH2" type="select" required="true()" relevant="(selected(/data/CDH1, '1'))"/>
  <bind nodeset="/data/CDH2_sum" type="int" calculate="count-selected(/data/CDH2_group/CDH2)" />
  <bind nodeset="/data/CDH2_position" type="int" calculate="selected-at(/data/CDH2_group/CDH2, position(..)-1)" />
  <bind nodeset="/data/CDH2_name" type="string" calculate="jr:choice-name(/data/CDH2_position, '/data/CDH2_group/CDH2')" /> 
  <bind nodeset="/data/CDH3_group/CDH3" type="select" relevant="(selected(/data/CDH1, '1'))"/>
  <bind nodeset="/data/CDH3_group/CDH3_SPE" type="string" relevant="(selected(/data/CDH1, '1'))"/>



<group appearance="field-list">
  <label ref="jr:itext('/data/CDH2_group:label')"/>
  <select ref="/data/CDH2_group/CDH2">
    <label ref="jr:itext('/data/CDH2_group/CDH2:label')"/>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option0')"/>
      <value>1</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option1')"/>
      <value>2</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option2')"/>
      <value>3</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option3')"/>
      <value>4</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option4')"/>
      <value>5</value>
    </item>
  </select>
  <input ref="/data/CDH2_group/CDH2_SPE">
    <label ref="jr:itext('/data/CDH2_group/CDH2_SPE:label')"/>
  </input>
</group>
<group appearance="field-list">
  <label ref="jr:itext('/data/CDH3_group:label')"/>
  <repeat nodeset="/data/CDH3_group" jr:count='/data/CDH2_sum'>
    <select ref="/data/CDH3_group/CDH3">
      <label ref="jr:itext('/data/CDH3_group/CDH3:label')"/>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option1')"/>
        <value>2</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option2')"/>
        <value>3</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option3')"/>
        <value>4</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option4')"/>
        <value>5</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option5')"/>
        <value>6</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option6')"/>
        <value>7</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option7')"/>
        <value>8</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option8')"/>
        <value>9</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option9')"/>
        <value>99</value>
      </item>
    </select>
  </repeat>
</group>

So the idea is that the user can select multiple people that they have discussed their HIV status with (in CDH2, say Mother and Father), then Collect will loop CDH3 2 times, displaying Mother the first time and Father the second.

However, what happens is that Mother is displayed in both iterations of the loop (instead of Mother then Father). I suspect this is because I have done the calculate in the wrong place? Or am not using variables where I should?

Do any obvious things jump out to you?

Thanks in advance,
Colin

Hi Colin,

For the position(..) to work properly, it needs to be called from within
the repeat group itself. Thus, CDH2_position and CDH2_name both need to be
inside the repeat group (CDH3_group, I believe). If you give that a shot, I
think that it might work.

Best,

Chris

ยทยทยท On Thu, Feb 6, 2014 at 1:17 PM, wrote:

Chris, Neil, this is very helpful.

I was looking to solve exactly this problem, and your solution looks very
close to working for me (still can't Validate it, but never mind that).

My problem is that the jr:choice-name(${this_selection},
'${multiplechoice}') values do not change. That is, I loop x times (based
on count-selected(${multiplechoice})), but the this_selection_label value
does not change change in each loop iteration. This could be an issue with
the position or with how I've set things up. Perhaps some code would make
this more clear (note that I'm very new to this, so might be making some
very obvious mistakes):

      <CDH2_sum/>
      <CDH2_position/>
      <CDH2_name/>

      <CDH3_group>
        <CDH3/>
        <CDH3_SPE/>
      </CDH3_group>


      <text id="/data/CDH2_group:label">
        <value></value>
      </text>
      <text id="/data/CDH2_group/CDH2:label">
        <value>CDH2. What is the relationship to you of the person in

your household that you told that you are HIV-positive?


Spouse/Partner


Mother


Father


Sister


Brother





CDH3. Before you told your that you are HIV-positive, how did you expect this
person to react?

 <bind nodeset="/data/CDH2_group/CDH2" type="select" required="true()"

relevant="(selected(/data/CDH1, '1'))"/>




<group appearance="field-list">
  <label ref="jr:itext('/data/CDH2_group:label')"/>
  <select ref="/data/CDH2_group/CDH2">
    <label ref="jr:itext('/data/CDH2_group/CDH2:label')"/>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option0')"/>
      <value>1</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option1')"/>
      <value>2</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option2')"/>
      <value>3</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option3')"/>
      <value>4</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2_group/CDH2:option4')"/>
      <value>5</value>
    </item>
  </select>
  <input ref="/data/CDH2_group/CDH2_SPE">
    <label ref="jr:itext('/data/CDH2_group/CDH2_SPE:label')"/>
  </input>
</group>
<group appearance="field-list">
  <label ref="jr:itext('/data/CDH3_group:label')"/>
  <repeat nodeset="/data/CDH3_group" jr:count='/data/CDH2_sum'>
    <select ref="/data/CDH3_group/CDH3">
      <label ref="jr:itext('/data/CDH3_group/CDH3:label')"/>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option1')"/>
        <value>2</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option2')"/>
        <value>3</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option3')"/>
        <value>4</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option4')"/>
        <value>5</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option5')"/>
        <value>6</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option6')"/>
        <value>7</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option7')"/>
        <value>8</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option8')"/>
        <value>9</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option9')"/>
        <value>99</value>
      </item>
    </select>
  </repeat>
</group>

So the idea is that the user can select multiple people that they have
discussed their HIV status with (in CDH2, say Mother and Father), then
Collect will loop CDH3 2 times, displaying Mother the first time and Father
the second.

However, what happens is that Mother is displayed in both iterations of
the loop (instead of Mother then Father). I suspect this is because I have
done the calculate in the wrong place? Or am not using variables where I
should?

Do any obvious things jump out to you?

Thanks in advance,
Colin

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

Thanks Chris,

That's a good call, something that I had tried - however, it doesn't fully solve the problem. Now, the person (ie Mother) no longer shows up in the CDH3 label.

So the output on the tablet looks like:
CDH3. Before you told your that you are HIV-positive, how did you expect this person to react?

I may have missed something re referencing?

Updated code below:
<CDH2_sum/>
<CDH3_group>
<CDH2_position/>
<CDH2_name/>

<CDH3_SPE/>
</CDH3_group>

CDH3. Before you told your that you are HIV-positive, how did you expect this person to react?
  <bind nodeset="/data/CDH2_sum" type="int" calculate="count-selected(/data/CDH2_group/CDH2)" />
  <bind nodeset="/data/CDH3_group/CDH2_position" type="int" calculate="selected-at(/data/CDH2_group/CDH2, position(..)-1)" />
  <bind nodeset="/data/CDH3_group/CDH2_name" type="string" calculate="jr:choice-name(/data/CDH2_position, '/data/CDH2_group/CDH2')" /> 
  <bind nodeset="/data/CDH3_group/CDH3" type="select" relevant="(selected(/data/CDH1, '1'))"/>
  <bind nodeset="/data/CDH3_group/CDH3_SPE" type="string" relevant="(selected(/data/CDH1, '1'))"/>

<group appearance="field-list">
  <label ref="jr:itext('/data/CDH3_group:label')"/>
  <repeat nodeset="/data/CDH3_group" jr:count='/data/CDH2_sum'>
    <select ref="/data/CDH3_group/CDH3">
      <label ref="jr:itext('/data/CDH3_group/CDH3:label')"/>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option1')"/>
        <value>2</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option2')"/>
        <value>3</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option3')"/>
        <value>4</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option4')"/>
        <value>5</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option5')"/>
        <value>6</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option6')"/>
        <value>7</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option7')"/>
        <value>8</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option8')"/>
        <value>9</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option9')"/>
        <value>99</value>
      </item>
    </select>
    <input ref="/data/CDH3_group/CDH3_SPE">
      <label ref="jr:itext('/data/CDH3_group/CDH3_SPE:label')"/>
    </input>
  </repeat>
</group>

Sorry, Colin. I'm not sure what's going on there. Maybe the CDH2_group
reference isn't working from within CDH3_group? I'm not an XML expert as we
deal almost exclusively with XLSForm (where there are far fewer things that
can go wrong).

I would suggest starting with a super-small, super-easy form with just the
bare minimum of groups and complications, and see if you can get something
to work. Then, if that works, very carefully sort out what's different in
your case that's not working.

Best,

Chris

ยทยทยท On Thu, Feb 6, 2014 at 1:57 PM, wrote:

Thanks Chris,

That's a good call, something that I had tried - however, it doesn't fully
solve the problem. Now, the person (ie Mother) no longer shows up in the
CDH3 label.

So the output on the tablet looks like:
CDH3. Before you told your that you are HIV-positive, how did you expect
this person to react?

I may have missed something re referencing?

Updated code below:
<CDH2_sum/>
<CDH3_group>
<CDH2_position/>
<CDH2_name/>

<CDH3_SPE/>
</CDH3_group>

CDH3. Before you told your that you are HIV-positive, how did you expect this person to react?
  <bind nodeset="/data/CDH2_sum" type="int"

calculate="count-selected(/data/CDH2_group/CDH2)" />



<group appearance="field-list">
  <label ref="jr:itext('/data/CDH3_group:label')"/>
  <repeat nodeset="/data/CDH3_group" jr:count='/data/CDH2_sum'>
    <select ref="/data/CDH3_group/CDH3">
      <label ref="jr:itext('/data/CDH3_group/CDH3:label')"/>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option1')"/>
        <value>2</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option2')"/>
        <value>3</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option3')"/>
        <value>4</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option4')"/>
        <value>5</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option5')"/>
        <value>6</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option6')"/>
        <value>7</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option7')"/>
        <value>8</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option8')"/>
        <value>9</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option9')"/>
        <value>99</value>
      </item>
    </select>
    <input ref="/data/CDH3_group/CDH3_SPE">
      <label ref="jr:itext('/data/CDH3_group/CDH3_SPE:label')"/>
    </input>
  </repeat>
</group>

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

That's a good idea Chris - I've pared it down as best I can and learned some interesting results.

In order to confirm that position and name are working/not working, I gave them their own outputs as well (good ole' println).

What I learned from that is that position is working - it tracks the data value from the multiselect (1, 3, 4, etc). What is not working is the name, ie the result of the jr:choice-name(/data/CDH2, '/data/CDH2').

I assume from the docs that choice-name takes a result from a previous select (an int, essentially) and a reference to the select. If that is the case, I'm baffled why it can't deal with the generated position value.

Code below:

      <CDH2/>
      <CDH2_sum/>
      <CDH3_group>
        <CDH3_position/>
        <CDH3_name/>
        <CDH3/>
      </CDH3_group> 

      <text id="/data/CDH2:label">
        <value>CDH2. What is the relationship to you of the person in your household that you told that you are HIV-positive?</value>
      </text>
      <text id="/data/CDH2:option0">
        <value>Spouse/Partner</value>
      </text>
      <text id="/data/CDH2:option1">
        <value>Mother</value>
      </text>
      <text id="/data/CDH2:option2">
        <value>Father</value>
      </text>
      <text id="/data/CDH2:option3">
        <value>Sister</value>
      </text>
      <text id="/data/CDH2:option4">
        <value>Brother</value>
      </text>
      <text id="/data/CDH2:option5">
        <value>Grandfather</value>
      </text>
      <text id="/data/CDH2:option6">
        <value>Grandmother</value>
      </text>
      <text id="/data/CDH2:option7">
        <value>Child</value>
      </text>

      <text id="/data/CDH3_group:label">
        <value></value>
      </text>
      <text id="/data/CDH3_group/CDH3:label">
        <value>CDH3. Before you told your <output ref="/data/CDH3_group/CDH3_name"/> that you are HIV-positive, how did you expect this person to react?</value>
      </text>
      <text id="/data/CDH3_group/CDH3:option0">
        <value>Feel sad</value>
      </text>
      <text id="/data/CDH3_group/CDH3:option1">
        <value>Be angry</value>
      </text>
      <text id="/data/CDH3_group/CDH3:option2">
        <value>Be afraid of me</value>
      </text>
      <text id="/data/CDH3_group/CDH3:option3">
        <value>Feel afraid FOR me</value>
      </text>
      <text id="/data/CDH3_group/CDH3_position:label">
        <value>POSITION: </value>
      </text>
      <text id="/data/CDH3_group/CDH3_name:label">
        <value>NAME: </value>
      </text>

  <bind nodeset="/data/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
  <bind nodeset="/data/CDH2" type="select" required="true()"/>
  <bind nodeset="/data/CDH2_sum" type="int" calculate="count-selected(/data/CDH2)" />
  <bind nodeset="/data/CDH3_group/CDH3_position" type="string" calculate="selected-at(/data/CDH2, position(..)-1)" />
  <bind nodeset="/data/CDH3_group/CDH3_name" type="string" calculate="jr:choice-name(/data/CDH2, '/data/CDH2')" /> 
  <!-- calculate="if(string-length(/widgets/yesno)!=0,jr:choice-name(/widgets/yesno,'/widgets/yesno'),'unspecified')" -->
  <bind nodeset="/data/CDH3_group/CDH3" type="select"/>

  <select ref="/data/CDH2">
    <label ref="jr:itext('/data/CDH2:label')"/>
    <item>
      <label ref="jr:itext('/data/CDH2:option0')"/>
      <value>1</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option1')"/>
      <value>2</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option2')"/>
      <value>3</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option3')"/>
      <value>4</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option4')"/>
      <value>5</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option5')"/>
      <value>6</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option6')"/>
      <value>7</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option7')"/>
      <value>8</value>
    </item>
  </select>


<group appearance="field-list">
  <label ref="jr:itext('/data/CDH3_group:label')"/>
  <repeat nodeset="/data/CDH3_group" jr:count='/data/CDH2_sum' appearance="field-list">
    <select ref="/data/CDH3_group/CDH3">
      <label ref="jr:itext('/data/CDH3_group/CDH3:label')"/>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option1')"/>
        <value>2</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option2')"/>
        <value>3</value>
      </item>
      <item>
        <label ref="jr:itext('/data/CDH3_group/CDH3:option3')"/>
        <value>4</value>
      </item>
    </select>
    <input ref="/data/CDH3_group/CDH3_position">
      <label ref="jr:itext('/data/CDH3_group/CDH3_position:label')"/>
    </input>
    <input ref="/data/CDH3_group/CDH3_name">
      <label ref="jr:itext('/data/CDH3_group/CDH3_name:label')"/>
    </input>
  </repeat>
</group>

Dear all,

I need to include a repeat with on a multiple selection list, as described in the correspondence above. But I can't figure out how to make it work in my excel. Is there someone who would be willing to send me an example in excel that shows how this can work so that I can use this as a reference in my excel? I also attached my own excel if that is more easy to change. Would be great! Many thanks in advance.

Kind regards,

Ed

Test_looping_with_select_multiple_v4.xls (62.5 KB)

ยทยทยท On Thursday, February 6, 2014 8:26:23 PM UTC+1, Chris wrote: > Sorry, Colin. I'm not sure what's going on there. Maybe the CDH2_group reference isn't working from within CDH3_group? I'm not an XML expert as we deal almost exclusively with XLSForm (where there are far fewer things that can go wrong). > > > > > I would suggest starting with a super-small, super-easy form with just the bare minimum of groups and complications, and see if you can get something to work. Then, if that works, very carefully sort out what's different in your case that's not working. > > > > > Best, > > > Chris > > > > > > On Thu, Feb 6, 2014 at 1:57 PM, wrote: > > > Thanks Chris, > > > > That's a good call, something that I had tried - however, it doesn't fully solve the problem. Now, the person (ie Mother) no longer shows up in the CDH3 label. > > > > So the output on the tablet looks like: > > CDH3. Before you told your that you are HIV-positive, how did you expect this person to react? > > > > I may have missed something re referencing? > > > > > > Updated code below: > > > > > > > > > > > > > > > > > > > > CDH3. Before you told your that you are HIV-positive, how did you expect this person to react? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1 > > > > > > > > 2 > > > > > > > > 3 > > > > > > > > 4 > > > > > > > > 5 > > > > > > > > 6 > > > > > > > > 7 > > > > > > > > 8 > > > > > > > > 9 > > > > > > > > 99 > > > > > > > > > > > > > > > > > > > > -- > > -- > > Post: opend...@googlegroups.com > > Unsubscribe: opendatakit...@googlegroups.com > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > --- > > You received this message because you are subscribed to the Google Groups "ODK Community" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit...@googlegroups.com. > > For more options, visit https://groups.google.com/groups/opt_out.

Hi Colin,

It sounds like you're making progress. Maybe just try passing a fixed
selection value as the first parameter into jr:choice-name() to see if that
works? If CDH2 is a multiple-select, then you need to call selected-at() to
get one of the selections to pass as the first parameters to
jr:choice-name() -- you can't just pass the entire list of selections.

Best,

Chris

ยทยทยท On Fri, Feb 7, 2014 at 12:47 PM, wrote:

That's a good idea Chris - I've pared it down as best I can and learned
some interesting results.

In order to confirm that position and name are working/not working, I gave
them their own outputs as well (good ole' println).

What I learned from that is that position is working - it tracks the data
value from the multiselect (1, 3, 4, etc). What is not working is the name,
ie the result of the jr:choice-name(/data/CDH2, '/data/CDH2').

I assume from the docs that choice-name takes a result from a previous
select (an int, essentially) and a reference to the select. If that is the
case, I'm baffled why it can't deal with the generated position value.

Code below:

      <CDH2/>
      <CDH2_sum/>
      <CDH3_group>
        <CDH3_position/>
        <CDH3_name/>
        <CDH3/>
      </CDH3_group>

      <text id="/data/CDH2:label">
        <value>CDH2. What is the relationship to you of the person in

your household that you told that you are HIV-positive?


Spouse/Partner


Mother


Father


Sister


Brother


Grandfather


Grandmother


Child

      <text id="/data/CDH3_group:label">
        <value></value>
      </text>
      <text id="/data/CDH3_group/CDH3:label">
        <value>CDH3. Before you told your <output

ref="/data/CDH3_group/CDH3_name"/> that you are HIV-positive, how did you
expect this person to react?


Feel sad


Be angry


Be afraid of me


Feel afraid FOR me


POSITION:


NAME:

  <bind nodeset="/data/meta/instanceID" type="string"

readonly="true()" calculate="concat('uuid:', uuid())"/>





  <select ref="/data/CDH2">
    <label ref="jr:itext('/data/CDH2:label')"/>
    <item>
      <label ref="jr:itext('/data/CDH2:option0')"/>
      <value>1</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option1')"/>
      <value>2</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option2')"/>
      <value>3</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option3')"/>
      <value>4</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option4')"/>
      <value>5</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option5')"/>
      <value>6</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option6')"/>
      <value>7</value>
    </item>
    <item>
      <label ref="jr:itext('/data/CDH2:option7')"/>
      <value>8</value>
    </item>
  </select>


<group appearance="field-list">
  <label ref="jr:itext('/data/CDH3_group:label')"/>
  <repeat nodeset="/data/CDH3_group" jr:count='/data/CDH2_sum'

appearance="field-list">




1



2



3



4









--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

Hey Chris,

Got it! Your last post really pointed me to the issue - I was passing in the list of selections, not one specific one (kind of dumb mistake, in the end, as expected).

Thus,
WRONG:

RIGHT:

Thanks so much for your assistance on this. Made my life (and the life of the prof I'm working for) much easier!

Excelent guidance, thanks a lot this is what I was looking for!