Meta data as calculated items

Hi,

I noticed that a meta->instanceID is implemented as a calculated item in the
example form on the ODK website http://opendatakit.org/help/form-design/ instead
of a preload item (which is what I would have guessed).

The OpenRosa MetaDataScheme https://bitbucket.org/javarosa/javarosa/wiki/OpenRosaMetaDataSchemamentions
that bindings do not have to be present for meta data but doesn't specify
whether preloads and/or calculated items can be used as well.

My questions about using a binding with calculate for meta nodes relate to
how ODK Collect is prevented from recalculating these, e.g. when a draft
saved form is loaded from the device for further editing .

  1. Is instanceID treated as a special kind of calculated item or is ODK
    Collect never re-evaluating calculated items where the calculations have no
    dependencies on the values of other nodes && when these nodes are not empty?
  2. Can and meta nodes also be implemented as
    calculated items instead of preload items in ODK Collect?

Cheers,
Martijn van de Rijdt (enketo http://blog.aidwebsolutions.com/tag/enketo)

instanceID is not handled specially. From my testing, if the item is a
calculated field and the calculation does not depend upon other fields,
then it is only calculated once, when the form is first created (and the
field starts empty) and then the value is never updated. I am not familiar
enough with XForms processing to say whether this is expected or a
bug/feature of the JavaRosa implementation. In any case, once I confirmed
the behavior, I chose not to add an instanceId function to the preload
logic in JavaRosa.

timeStart could be declared to just be a calculate field. timeEnd,
however, must use the preload mechanism as you would want to always update
that at the end of the survey. If it were merely a calculate, it would be
assigned a value at the start of the survey, then never have that value
update at the end of the survey.

Mitch

··· On Mon, Oct 15, 2012 at 9:05 AM, Martijn van de Rijdt < martijn@aidwebsolutions.com> wrote:

Hi,

I noticed that a meta->instanceID is implemented as a calculated item in the
example form on the ODK website http://opendatakit.org/help/form-design/ instead
of a preload item (which is what I would have guessed).

The OpenRosa MetaDataScheme https://bitbucket.org/javarosa/javarosa/wiki/OpenRosaMetaDataSchemamentions
that bindings do not have to be present for meta data but doesn't specify
whether preloads and/or calculated items can be used as well.

My questions about using a binding with calculate for meta nodes relate to
how ODK Collect is prevented from recalculating these, e.g. when a draft
saved form is loaded from the device for further editing .

  1. Is instanceID treated as a special kind of calculated item or is
    ODK Collect never re-evaluating calculated items where the calculations
    have no dependencies on the values of other nodes && when these nodes are
    not empty?
  2. Can and meta nodes also be implemented as
    calculated items instead of preload items in ODK Collect?

Cheers,
Martijn van de Rijdt (enketo http://blog.aidwebsolutions.com/tag/enketo)

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

Created an issue:
http://code.google.com/p/opendatakit/issues/detail?id=706to track
this.

This change is considered low priority, as normal usage wouldn't really
need the UUID to stay fixed, though it would be desirable for extended
systems using partially prepopulated forms.

Mitch

··· On Tue, Oct 16, 2012 at 8:48 AM, wrote:

Thanks Mitch,

I noticed in the attached form where a calculated item without
dependencies has a default value (or is loaded from local storage) in the
latest version of ODK Collect is actually re-calculated upon loading.

So, I'm wondering if this could cause subtle problems (re-calculating
timeStart would be a problem and possibly features such as exporting data
from a client to a file and then uploading this manually or re-importing it
into a client, in both cases potentially creating duplicates).

I would advocate for using either a preload item for any meta data or
using no binding at all. In the latter case it would be dealt with in the
same way as a preload item but saving the trouble of having to create the
preload binding.

Look forward to hearing your further thoughts on this!

Best regards,
Martijn

On Monday, October 15, 2012 10:23:52 AM UTC-6, Mitch wrote:

instanceID is not handled specially. From my testing, if the item is a
calculated field and the calculation does not depend upon other fields,
then it is only calculated once, when the form is first created (and the
field starts empty) and then the value is never updated. I am not familiar
enough with XForms processing to say whether this is expected or a
bug/feature of the JavaRosa implementation. In any case, once I confirmed
the behavior, I chose not to add an instanceId function to the preload
logic in JavaRosa.

timeStart could be declared to just be a calculate field. timeEnd,
however, must use the preload mechanism as you would want to always update
that at the end of the survey. If it were merely a calculate, it would be
assigned a value at the start of the survey, then never have that value
update at the end of the survey.

Mitch

On Mon, Oct 15, 2012 at 9:05 AM, Martijn van de Rijdt < mar...@aidwebsolutions.com> wrote:

Hi,

I noticed that a meta->instanceID is implemented as a calculated item in
the example form on the ODK website instead of a preload item (which is
what I would have guessed).

The OpenRosa MetaDataScheme mentions that bindings do not have to be
present for meta data but doesn't specify whether preloads and/or
calculated items can be used as well.

My questions about using a binding with calculate for meta nodes relate
to how ODK Collect is prevented from recalculating these, e.g. when a draft
saved form is loaded from the device for further editing .

Is instanceID treated as a special kind of calculated item or is ODK
Collect never re-evaluating calculated items where the calculations have no
dependencies on the values of other nodes && when these nodes are not empty?

Can and meta nodes also be implemented as
calculated items instead of preload items in ODK Collect?
Cheers,
Martijn van de Rijdt (enketo)

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

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

Thanks Mitch,

Unfortunately, we currently don't have Android developers (at Modilabs) to
offer to work on this new preload item in ODK Collect. For us the issue is
fairly important as we're about to add the instanceID node generation logic
to pyxforms and have some near-future plans to add features to enketo that
would not work if instanceIDs are recalculated.

Anyway, thanks for adding the issue and we'll just hack around it until
it's completed!

Best regards,
Martijn van de Rijdt

P.S. for those interested, this is a testing/launch area for enketo:
http://enketo.org/launch that should work with most openrosa Xforms

··· On Tuesday, October 16, 2012 10:04:49 AM UTC-6, Mitch wrote: > > Created an issue: > http://code.google.com/p/opendatakit/issues/detail?id=706 to track this. > > This change is considered low priority, as normal usage wouldn't really > need the UUID to stay fixed, though it would be desirable for extended > systems using partially prepopulated forms. > > Mitch > > On Tue, Oct 16, 2012 at 8:48 AM, <mri...@gmail.com > wrote: > >> Thanks Mitch, >> >> I noticed in the attached form where a calculated item without >> dependencies has a default value (or is loaded from local storage) in the >> latest version of ODK Collect is actually re-calculated upon loading. >> >> So, I'm wondering if this could cause subtle problems (re-calculating >> timeStart would be a problem and possibly features such as exporting data >> from a client to a file and then uploading this manually or re-importing it >> into a client, in both cases potentially creating duplicates). >> >> I would advocate for using either a preload item for any meta data or >> using no binding at all. In the latter case it would be dealt with in the >> same way as a preload item but saving the trouble of having to create the >> preload binding. >> >> Look forward to hearing your further thoughts on this! >> >> Best regards, >> Martijn >> >> On Monday, October 15, 2012 10:23:52 AM UTC-6, Mitch wrote: >> > instanceID is not handled specially. From my testing, if the item is a >> calculated field and the calculation does not depend upon other fields, >> then it is only calculated once, when the form is first created (and the >> field starts empty) and then the value is never updated. I am not familiar >> enough with XForms processing to say whether this is expected or a >> bug/feature of the JavaRosa implementation. In any case, once I confirmed >> the behavior, I chose not to add an instanceId function to the preload >> logic in JavaRosa. >> > >> > >> > timeStart could be declared to just be a calculate field. timeEnd, >> however, must use the preload mechanism as you would want to always update >> that at the end of the survey. If it were merely a calculate, it would be >> assigned a value at the start of the survey, then never have that value >> update at the end of the survey. >> > >> > >> > Mitch >> > >> > >> > On Mon, Oct 15, 2012 at 9:05 AM, Martijn van de Rijdt < mar...@aidwebsolutions.com> wrote: >> > >> > Hi, >> > >> > >> > I noticed that a meta->instanceID is implemented as a calculated item >> in the example form on the ODK website instead of a preload item (which is >> what I would have guessed). >> > >> > >> > >> > The OpenRosa MetaDataScheme mentions that bindings do not have to be >> present for meta data but doesn't specify whether preloads and/or >> calculated items can be used as well. >> > >> > >> > >> > My questions about using a binding with calculate for meta nodes relate >> to how ODK Collect is prevented from recalculating these, e.g. when a draft >> saved form is loaded from the device for further editing . >> > >> > Is instanceID treated as a special kind of calculated item or is ODK >> Collect never re-evaluating calculated items where the calculations have no >> dependencies on the values of other nodes && when these nodes are not empty? >> > >> > Can and meta nodes also be implemented as >> calculated items instead of preload items in ODK Collect? >> > Cheers, >> > Martijn van de Rijdt (enketo) >> > >> > >> > >> > >> > >> > -- >> > Mitch Sundt >> > Software Engineer >> > University of Washington >> > mitche...@gmail.com >> >> > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitche...@gmail.com >