Repeat = 0 bug

Hi all,

I found what I think is a bug with repeats - but it may also be a coding mistake on my end. I'm using Collect 1.4.3 on a variety of Android tablets (with OSes ranging from 3.0 to 4.3).

I have coded the form to have an int field and then loop through a series of questions based on what number was entered into that field using jr:count (that is, if the user enters '3' it will loop 3 times). This works for all cases except when the user enters '0'. In that case, the repeat will loop once. To rephrase, if the user enters '0' or '1', the behaviour is the same. Thoughts?

Relevant xm snippetsl:

<DEM1_15/>
<DEM2_group>
<DEM2_1/>
<DEM2_2/>

      <text id="/data/DEM1_15:label">
        <value>DEM1_15. Besides yourself, how many other adults 18 years or older live in this house?</value>
      </text>
      <text id="/data/DEM2_group:label">
        <value></value>
      </text>
      <text id="/data/DEM2_group/DEM2_1:label">
        <value>DEM2_1. Just so we can keep track of you we are talking about, can you tell me this person's initials?</value>
      </text>
      <text id="/data/DEM2_group/DEM2_2:label">
        <value>DEM2_2. What is this person's sex?</value>
      </text>

  <bind nodeset="/data/DEM1_15" type="int" required="true()" constraint="(. &gt;= '0' and . &lt;= '99')" jr:constraintMsg="Value must be between 0 and 99" relevant="(selected(/data/consent_group/consent1, '1'))"/>
  <bind nodeset="/data/DEM2_group/DEM2_1" type="string" required="true()" constraint="(regex(., &quot;^.{1,3}$&quot;))" jr:constraintMsg="Response length must be between 1 and 3" relevant="(selected(/data/consent_group/consent1, '1'))"/>
  <bind nodeset="/data/DEM2_group/DEM2_2" type="select1" required="true()" relevant="(selected(/data/consent_group/consent1, '1'))"/>

<input ref="/data/DEM1_15">
  <label ref="jr:itext('/data/DEM1_15:label')"/>
</input>
<group>
  <label ref="jr:itext('/data/DEM2_group:label')"/>
  <repeat nodeset="/data/DEM2_group" jr:count='/data/DEM1_15'>
    <input ref="/data/DEM2_group/DEM2_1">
      <label ref="jr:itext('/data/DEM2_group/DEM2_1:label')"/>
    </input>
    <select1 ref="/data/DEM2_group/DEM2_2">
      <label ref="jr:itext('/data/DEM2_group/DEM2_2:label')"/>
      <item>
        <label ref="jr:itext('/data/DEM2_group/DEM2_2:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/DEM2_group/DEM2_2:option1')"/>
        <value>2</value>
      </item>
    </select1>

My guess is that deep in the bowels of the Javarosa library, there is
confusion between a null value and zero.

If you enter zero, are you limited to just 1 pass through the repeat group,
or can you continue to add more records? (i.e., the behavior if jr:count
is absent/null)

This is unlikely to get fixed anytime soon.

The simple work-around is to wrap the repeat in another group with a
relevant condition of: "/data/DEM1_15 > 0"

··· On Tue, May 13, 2014 at 6:34 AM, wrote:

Hi all,

I found what I think is a bug with repeats - but it may also be a coding
mistake on my end. I'm using Collect 1.4.3 on a variety of Android tablets
(with OSes ranging from 3.0 to 4.3).

I have coded the form to have an int field and then loop through a series
of questions based on what number was entered into that field using
jr:count (that is, if the user enters '3' it will loop 3 times). This works
for all cases except when the user enters '0'. In that case, the repeat
will loop once. To rephrase, if the user enters '0' or '1', the behaviour
is the same. Thoughts?

Relevant xm snippetsl:

<DEM1_15/>
<DEM2_group>
<DEM2_1/>
<DEM2_2/>

      <text id="/data/DEM1_15:label">
        <value>DEM1_15. Besides yourself, how many other adults 18

years or older live in this house?





DEM2_1. Just so we can keep track of you we are talking
about, can you tell me this person's initials?


DEM2_2. What is this person's sex?

  <bind nodeset="/data/DEM1_15" type="int" required="true()"

constraint="(. >= '0' and . <= '99')" jr:constraintMsg="Value must be
between 0 and 99" relevant="(selected(/data/consent_group/consent1, '1'))"/>

<input ref="/data/DEM1_15">
  <label ref="jr:itext('/data/DEM1_15:label')"/>
</input>
<group>
  <label ref="jr:itext('/data/DEM2_group:label')"/>
  <repeat nodeset="/data/DEM2_group" jr:count='/data/DEM1_15'>
    <input ref="/data/DEM2_group/DEM2_1">
      <label ref="jr:itext('/data/DEM2_group/DEM2_1:label')"/>
    </input>
    <select1 ref="/data/DEM2_group/DEM2_2">
      <label ref="jr:itext('/data/DEM2_group/DEM2_2:label')"/>
      <item>
        <label ref="jr:itext('/data/DEM2_group/DEM2_2:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/DEM2_group/DEM2_2:option1')"/>
        <value>2</value>
      </item>
    </select1>

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

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

And Colin, once you confirm, can you file a bug at
https://bitbucket.org/javarosa/javarosa/ so at least someone knows...

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Tue, May 13, 2014 at 10:40 AM, Mitch Sundt mitchellsundt@gmail.comwrote:

My guess is that deep in the bowels of the Javarosa library, there is
confusion between a null value and zero.

If you enter zero, are you limited to just 1 pass through the repeat
group, or can you continue to add more records? (i.e., the behavior if
jr:count is absent/null)

This is unlikely to get fixed anytime soon.

The simple work-around is to wrap the repeat in another group with a
relevant condition of: "/data/DEM1_15 > 0"

On Tue, May 13, 2014 at 6:34 AM, colindmccann@gmail.com wrote:

Hi all,

I found what I think is a bug with repeats - but it may also be a coding
mistake on my end. I'm using Collect 1.4.3 on a variety of Android tablets
(with OSes ranging from 3.0 to 4.3).

I have coded the form to have an int field and then loop through a series
of questions based on what number was entered into that field using
jr:count (that is, if the user enters '3' it will loop 3 times). This works
for all cases except when the user enters '0'. In that case, the repeat
will loop once. To rephrase, if the user enters '0' or '1', the behaviour
is the same. Thoughts?

Relevant xm snippetsl:

<DEM1_15/>
<DEM2_group>
<DEM2_1/>
<DEM2_2/>

      <text id="/data/DEM1_15:label">
        <value>DEM1_15. Besides yourself, how many other adults 18

years or older live in this house?





DEM2_1. Just so we can keep track of you we are
talking about, can you tell me this person's initials?


DEM2_2. What is this person's sex?

  <bind nodeset="/data/DEM1_15" type="int" required="true()"

constraint="(. >= '0' and . <= '99')" jr:constraintMsg="Value must be
between 0 and 99" relevant="(selected(/data/consent_group/consent1, '1'))"/>

<input ref="/data/DEM1_15">
  <label ref="jr:itext('/data/DEM1_15:label')"/>
</input>
<group>
  <label ref="jr:itext('/data/DEM2_group:label')"/>
  <repeat nodeset="/data/DEM2_group" jr:count='/data/DEM1_15'>
    <input ref="/data/DEM2_group/DEM2_1">
      <label ref="jr:itext('/data/DEM2_group/DEM2_1:label')"/>
    </input>
    <select1 ref="/data/DEM2_group/DEM2_2">
      <label ref="jr:itext('/data/DEM2_group/DEM2_2:label')"/>
      <item>
        <label ref="jr:itext('/data/DEM2_group/DEM2_2:option0')"/>
        <value>1</value>
      </item>
      <item>
        <label ref="jr:itext('/data/DEM2_group/DEM2_2:option1')"/>
        <value>2</value>
      </item>
    </select1>

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

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

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

Thanks Mitch and Yaw,

If you enter zero, are you limited to just 1 pass through the repeat group, or can you continue to add more records?

Just to be clear, the int for the repeat is set before any repeating happens. But, I can confirm that 0 is treated the same way as null. That is, if I leave the value as null (skip the question), I still go through the repeat once.

And Colin, once you confirm, can you file a bug at https://bitbucket.org/javarosa/javarosa/ so at least someone knows...

Will do. I'll use Mitch's suggestion of wrapping in a relevant for now.

··· On Tuesday, May 13, 2014 9:11:28 PM UTC+2, Yaw Anokwa wrote: > And Colin, once you confirm, can you file a bug at https://bitbucket.org/javarosa/javarosa/ so at least someone knows... > > > Yaw > > > > -- > Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK. > > > > > > On Tue, May 13, 2014 at 10:40 AM, Mitch Sundt wrote: > > > > > My guess is that deep in the bowels of the Javarosa library, there is confusion between a null value and zero. > > If you enter zero, are you limited to just 1 pass through the repeat group, or can you continue to add more records? (i.e., the behavior if jr:count is absent/null) > > > > > This is unlikely to get fixed anytime soon. > > The simple work-around is to wrap the repeat in another group with a relevant condition of: "/data/DEM1_15 > 0" > > > > > > > > > > > > On Tue, May 13, 2014 at 6:34 AM, wrote: > > > > Hi all, > > > > I found what I think is a bug with repeats - but it may also be a coding mistake on my end. I'm using Collect 1.4.3 on a variety of Android tablets (with OSes ranging from 3.0 to 4.3). > > > > I have coded the form to have an int field and then loop through a series of questions based on what number was entered into that field using jr:count (that is, if the user enters '3' it will loop 3 times). This works for all cases except when the user enters '0'. In that case, the repeat will loop once. To rephrase, if the user enters '0' or '1', the behaviour is the same. Thoughts? > > > > > > > Relevant xm snippetsl: > > > > > > > > > > > > > > > > DEM1_15. Besides yourself, how many other adults 18 years or older live in this house? > > > > > > > > > > > > DEM2_1. Just so we can keep track of you we are talking about, can you tell me this person's initials? > > > > > > DEM2_2. What is this person's sex? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1 > > > > > > > > 2 > > > > > > > > -- > > You received this message because you are subscribed to the Google Groups "ODK Developers" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > > > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitche...@gmail.com > > > > > > > > -- > > You received this message because you are subscribed to the Google Groups "ODK Developers" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit-developers+unsubscribe@googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout.