Syntax for restricting choices

Some syntax questions:

  1. I want the users of my form to be forced to include exactly 12 'samples'
    in each survey and I want the form to count the number of samples already
    added:

Each sample will have multiple species- So I am using two loops- a repeat
loop for Sample_ID and then within that a repeat loop for Species_ID
I want to design it so that the form will automatically provide the
Sample_ID, so that when the species data is complete, and they add click to
add a "new Sample_ID" it will automatically be labelled "Sample 2".
Instead of them having to add an integer.

I want them to HAVE to complete 12 samples before they can finish the
survey. i.e the repeat for Sample_ID must be repeated 12 times..
Is this possible?
What syntax do i need to use?

  1. I want to prevent the user from entering the same species_ID within a
    single sample_ID.. so that they must chose a different species for each
    repeat of Species_ID but can then add the SAME species for different
    SAMPLE_ID repeats within a survey.. What syntax do I use?

  2. At the end of each Sample I would like to give a summary of the number
    of species they included- so the user can see
    [You have added "14" species to Sample Number "3"]
    How do i count the number of species repeated in a sample?

  3. Also I was trying to use a constraint syntax for integers- e.g the
    number must be between 1 and 100. I used : >=1, <100 But XLSForm doesnt
    like it.

I attach my xls if someone would care to look at it..

Thanks for your help!

Tania

nizzanim_plants.xlsx (13 KB)

Last question first:

(4) When writing expressions, you need to write everything out. e.g.,:

${fieldname} >= 1 and ${fieldname} < 100

ยทยทยท -------- (3) see the functions that are available for your expressions here: https://opendatakit.org/help/form-design/binding/ more documentation is here: http://xlsform.org/

(1a) w.r.t. repeats, you can define a jr:count column and enter a value on
the begin repeat row to force a certain number of repeats.

I think you can then just specify all of the fields within the repeats to
be required, which would force the user to enter values for them prior to
finalizing the form.

(1b) the sample form has examples of substituting a fieldname's value into
a label. You can leverage that by defining a variable that will hold the
current repeat group's ordinal number (1, 2, ...). via a calculation
referencing either position(.) or position(..) (not sure which) to get
that ordinal number. Unfortunately, that will add a rather meaningless
field to your result data.


(2) w.r.t. ensuring that each value within the set of repeats is
non-overlapping.

This is probably the hardest thing to ensure. Others have asked similar
questions, and the easiest solution has been to replicate the repeating
group N times in your form, changing it to a simple group, and then
handcraft the conditions for each of these to be what you need.

Perhaps others can recommend approaches?

On Tue, Apr 28, 2015 at 7:46 AM, taniabird taniabird@gmail.com wrote:

Some syntax questions:

  1. I want the users of my form to be forced to include exactly 12
    'samples' in each survey and I want the form to count the number of samples
    already added:

Each sample will have multiple species- So I am using two loops- a repeat
loop for Sample_ID and then within that a repeat loop for Species_ID
I want to design it so that the form will automatically provide the
Sample_ID, so that when the species data is complete, and they add click to
add a "new Sample_ID" it will automatically be labelled "Sample 2".
Instead of them having to add an integer.

I want them to HAVE to complete 12 samples before they can finish the
survey. i.e the repeat for Sample_ID must be repeated 12 times..
Is this possible?
What syntax do i need to use?

  1. I want to prevent the user from entering the same species_ID within a
    single sample_ID.. so that they must chose a different species for each
    repeat of Species_ID but can then add the SAME species for different
    SAMPLE_ID repeats within a survey.. What syntax do I use?

  2. At the end of each Sample I would like to give a summary of the number
    of species they included- so the user can see
    [You have added "14" species to Sample Number "3"]
    How do i count the number of species repeated in a sample?

  3. Also I was trying to use a constraint syntax for integers- e.g the
    number must be between 1 and 100. I used : >=1, <100 But XLSForm doesnt
    like it.

I attach my xls if someone would care to look at it..

Thanks for your help!

Tania

--

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.

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