Random number changes after finalization

Hi,

I am using the random() function to sample a respondent from a household
roster in the tablet. This is possible because the random() number doesn't
change while navigating within the form. However, I realized now that the
random() number is recalculated when the form is opened for editing after
saving it. While I can understand this behavior as long as the form is not
yet finalized, I was quite surprised that the random() number is also
recalculated if the form is edited after it was already finalized.

Is this behavior intended?

And is there anything I can do to avoid the recalculation of the random
number after the form was finalized?

Fortunately, the 'new' random number is not saved if one selects 'Ignore
Changes' but it is still very confusing since - in my case - a different
household member is shown if the form is opened after finalization

Another question along these lines: Is there an option to prohibit any
changes in 'finalized' forms? While I don't have a tablet in front of me
now, I think I only saw an option to make the button 'Edit Saved Forms'
disappear - but I sometimes need enumerators to edit/continue saved (but
not yet finalized) forms.

Thank you very much for your help, best,

Utz

··· -- Utz J Pape Economist (Consultant) World Bank, South Sudan +211 9541 58978

Hi Utz,
I have a suggestion for a work around you could use. You can generate your
own pseudo-random numbers using the form's start time. Since the start time
should never change you'll always get the save value every time you open
the form. Here's an example of how to generate a pseudo-random number
greater than or equal to 0 and less than X:
int((${start_time} - date(0)) * 100000) mod X
Multiplying by 100000 makes it so you get a new random number every second.
You wouldn't want all the forms started on the same day/hour/minute to have
the the same random value.
Regards,
-Nathan

··· On Wednesday, May 15, 2013 12:29:09 AM UTC-7, Utz Pape wrote: > > Hi, > > I am using the random() function to sample a respondent from a household > roster in the tablet. This is possible because the random() number doesn't > change while navigating within the form. However, I realized now that the > random() number is recalculated when the form is opened for editing after > saving it. While I can understand this behavior as long as the form is not > yet finalized, I was quite surprised that the random() number is also > recalculated if the form is edited after it was already finalized. > > Is this behavior intended? > > And is there anything I can do to avoid the recalculation of the random > number after the form was finalized? > > Fortunately, the 'new' random number is not saved if one selects 'Ignore > Changes' but it is still very confusing since - in my case - a different > household member is shown if the form is opened after finalization > > Another question along these lines: Is there an option to prohibit any > changes in 'finalized' forms? While I don't have a tablet in front of me > now, I think I only saw an option to make the button 'Edit Saved Forms' > disappear - but I sometimes need enumerators to edit/continue saved (but > not yet finalized) forms. > > Thank you very much for your help, best, > > Utz > > -- > Utz J Pape > Economist (Consultant) > World Bank, South Sudan > +211 9541 58978 >

Dear Nathan and others,

Thank you so much - I like the idea. Unfortunately, I don't really get it working properly because for some reason the variable with the start time only returns the date.

So, I created a test form in Excel:

type
name

start start_time

calculate number(${start_time})

However, this always returns 15841 (at least today) - and doesn't change. Now, I tried many things like multiplying by 1000 to get hours, minutes and seconds - but it seems that the ${start_time} only contains the date without the time. I also tried int() instead of number(); and even if I look at it as string(${start_time}) I get '2013-05-16'. Even if I say format-date(${start_time}, '%Y/%n/%e %H:%M'), I receive '2013/5/16 00:00'.

I also checked the form after filling it out - in the resulting Excel file, the field start contains '2013-05-16T12:04:00.561+03'.

Any idea what I do wrong?

Thank you!

Utz

··· -- Utz J Pape

Economist (Consultant)
World Bank, South Sudan
+211 9541 58978

-----Nathan nabreit@gmail.com wrote: -----

To: opendatakit@googlegroups.com
From: Nathan nabreit@gmail.com

Date: 05/15/2013 08:43PM
Cc: upape@worldbank.org
Subject: Re: random number changes after finalization

Hi Utz,

I have a suggestion for a work around you could use. You can generate your own pseudo-random numbers using the form's start time. Since the start time should never change you'll always get the save value every time you open the form. Here's an example of how to generate a pseudo-random number greater than or equal to 0 and less than X:

int((${start_time} - date(0)) * 100000) mod X
Multiplying by 100000 makes it so you get a new random number every second. You wouldn't want all the forms started on the same day/hour/minute to have the the same random value.

Regards,
-Nathan

On Wednesday, May 15, 2013 12:29:09 AM UTC-7, Utz Pape wrote:

Hi,

I am using the random() function to sample a respondent from a household roster in the tablet. This is possible because the random() number doesn't change while navigating within the form. However, I realized now that the random() number is recalculated when the form is opened for editing after saving it. While I can understand this behavior as long as the form is not yet finalized, I was quite surprised that the random() number is also recalculated if the form is edited after it was already finalized.

Is this behavior intended?

And is there anything I can do to avoid the recalculation of the random number after the form was finalized?

Fortunately, the 'new' random number is not saved if one selects 'Ignore Changes' but it is still very confusing since - in my case - a different household member is shown if the form is opened after finalization

Another question along these lines: Is there an option to prohibit any changes in 'finalized' forms? While I don't have a tablet in front of me now, I think I only saw an option to make the button 'Edit Saved Forms' disappear - but I sometimes need enumerators to edit/continue saved (but not yet finalized) forms.

Thank you very much for your help, best,

Utz

--
Utz J Pape

Economist (Consultant)

World Bank, South Sudan

+211 9541 58978

I'm really sorry Utz, I only tested the timestamp idea in enketo. It looks
like there is a bug in Collect/JavaRosa that makes the time portion of
timestamps inaccessible:
https://code.google.com/p/opendatakit/issues/detail?id=808&q=datetime
Hopefully that gets fixed soon.
Regards,
-Nathan

··· On Thursday, May 16, 2013 3:56:38 AM UTC-7, up...@worldbank.org wrote: > > Dear Nathan and others, > > Thank you so much - I like the idea. Unfortunately, I don't really get it > working properly because for some reason the variable with the start time > only returns the date. > > So, I created a test form in Excel: > > type name > start start_time > calculate number(${start_time}) > > However, this always returns 15841 (at least today) - and doesn't change. > Now, I tried many things like multiplying by 1000 to get hours, minutes and > seconds - but it seems that the ${start_time} only contains the date > without the time. I also tried int() instead of number(); and even if I > look at it as string(${start_time}) I get '2013-05-16'. Even if I say > format-date(${start_time}, '%Y/%n/%e %H:%M'), I receive '2013/5/16 00:00'. > > I also checked the form after filling it out - in the resulting Excel > file, the field start contains '2013-05-16T12:04:00.561+03'. > > Any idea what I do wrong? > > Thank you! > > Utz > > > -- > Utz J Pape > Economist (Consultant) > World Bank, South Sudan > +211 9541 58978 > > -----Nathan <nab...@gmail.com > wrote: ----- > > To: opend...@googlegroups.com > From: Nathan <nab...@gmail.com > > Date: 05/15/2013 08:43PM > Cc: up...@worldbank.org > Subject: Re: random number changes after finalization > > Hi Utz, > I have a suggestion for a work around you could use. You can generate your > own pseudo-random numbers using the form's start time. Since the start time > should never change you'll always get the save value every time you open > the form. Here's an example of how to generate a pseudo-random number > greater than or equal to 0 and less than X: > int((${start_time} - date(0)) * 100000) mod X > Multiplying by 100000 makes it so you get a new random number every > second. You wouldn't want all the forms started on the same day/hour/minute > to have the the same random value. > Regards, > -Nathan > > On Wednesday, May 15, 2013 12:29:09 AM UTC-7, Utz Pape wrote: >> >> Hi, >> >> I am using the random() function to sample a respondent from a household >> roster in the tablet. This is possible because the random() number doesn't >> change while navigating within the form. However, I realized now that the >> random() number is recalculated when the form is opened for editing after >> saving it. While I can understand this behavior as long as the form is not >> yet finalized, I was quite surprised that the random() number is also >> recalculated if the form is edited after it was already finalized. >> >> Is this behavior intended? >> >> And is there anything I can do to avoid the recalculation of the random >> number after the form was finalized? >> >> Fortunately, the 'new' random number is not saved if one selects 'Ignore >> Changes' but it is still very confusing since - in my case - a different >> household member is shown if the form is opened after finalization >> >> Another question along these lines: Is there an option to prohibit any >> changes in 'finalized' forms? While I don't have a tablet in front of me >> now, I think I only saw an option to make the button 'Edit Saved Forms' >> disappear - but I sometimes need enumerators to edit/continue saved (but >> not yet finalized) forms. >> >> Thank you very much for your help, best, >> >> Utz >> >> -- >> Utz J Pape >> Economist (Consultant) >> World Bank, South Sudan >> +211 9541 58978 >> > > >

There is also a fix for the random()/uuid() bug pending. Mitch will
know better, but I bet that fix it'll be in the next release of
Collect.

··· On Thu, May 16, 2013 at 10:50 AM, Nathan wrote: > I'm really sorry Utz, I only tested the timestamp idea in enketo. It looks > like there is a bug in Collect/JavaRosa that makes the time portion of > timestamps inaccessible: > https://code.google.com/p/opendatakit/issues/detail?id=808&q=datetime > Hopefully that gets fixed soon. > Regards, > -Nathan > > > On Thursday, May 16, 2013 3:56:38 AM UTC-7, up...@worldbank.org wrote: >> >> Dear Nathan and others, >> >> Thank you so much - I like the idea. Unfortunately, I don't really get it >> working properly because for some reason the variable with the start time >> only returns the date. >> >> So, I created a test form in Excel: >> >> type name >> start start_time >> calculate number(${start_time}) >> >> However, this always returns 15841 (at least today) - and doesn't change. >> Now, I tried many things like multiplying by 1000 to get hours, minutes and >> seconds - but it seems that the ${start_time} only contains the date without >> the time. I also tried int() instead of number(); and even if I look at it >> as string(${start_time}) I get '2013-05-16'. Even if I say >> format-date(${start_time}, '%Y/%n/%e %H:%M'), I receive '2013/5/16 00:00'. >> >> I also checked the form after filling it out - in the resulting Excel >> file, the field start contains '2013-05-16T12:04:00.561+03'. >> >> Any idea what I do wrong? >> >> Thank you! >> >> Utz >> >> >> -- >> Utz J Pape >> Economist (Consultant) >> World Bank, South Sudan >> +211 9541 58978 >> >> -----Nathan wrote: ----- >> >> To: opend...@googlegroups.com >> From: Nathan >> Date: 05/15/2013 08:43PM >> Cc: up...@worldbank.org >> >> Subject: Re: random number changes after finalization >> >> Hi Utz, >> I have a suggestion for a work around you could use. You can generate your >> own pseudo-random numbers using the form's start time. Since the start time >> should never change you'll always get the save value every time you open the >> form. Here's an example of how to generate a pseudo-random number greater >> than or equal to 0 and less than X: >> int((${start_time} - date(0)) * 100000) mod X >> Multiplying by 100000 makes it so you get a new random number every >> second. You wouldn't want all the forms started on the same day/hour/minute >> to have the the same random value. >> Regards, >> -Nathan >> >> On Wednesday, May 15, 2013 12:29:09 AM UTC-7, Utz Pape wrote: >>> >>> Hi, >>> >>> I am using the random() function to sample a respondent from a household >>> roster in the tablet. This is possible because the random() number doesn't >>> change while navigating within the form. However, I realized now that the >>> random() number is recalculated when the form is opened for editing after >>> saving it. While I can understand this behavior as long as the form is not >>> yet finalized, I was quite surprised that the random() number is also >>> recalculated if the form is edited after it was already finalized. >>> >>> Is this behavior intended? >>> >>> And is there anything I can do to avoid the recalculation of the random >>> number after the form was finalized? >>> >>> Fortunately, the 'new' random number is not saved if one selects 'Ignore >>> Changes' but it is still very confusing since - in my case - a different >>> household member is shown if the form is opened after finalization >>> >>> Another question along these lines: Is there an option to prohibit any >>> changes in 'finalized' forms? While I don't have a tablet in front of me >>> now, I think I only saw an option to make the button 'Edit Saved Forms' >>> disappear - but I sometimes need enumerators to edit/continue saved (but not >>> yet finalized) forms. >>> >>> Thank you very much for your help, best, >>> >>> Utz >>> >>> -- >>> Utz J Pape >>> Economist (Consultant) >>> World Bank, South Sudan >>> +211 9541 58978 >> >> >> > -- > -- > 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. > >