Validation within a form

i have developed a form for data collection but i am having serious
challenges when it comes to validating input data i.e i'm trying to
create a constraint that will prevent the data collector from moving
to the next question if a particular selection was made(One to One
Session) in a previous question AND the sum of input values in other
previous questions is greater than 1. I have tried several options but
without success. Please help, the form is as shown below.

<?xml version="1.0"?>

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://
www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://
openrosa.org/javarosa">
<h:head>
<h:title>validation test</h:title>












					<!-- Bindings -->
					<bind nodeset="/SMC/InterventionDetails/InterventionType"

type="string" required="true()"/>



			</model>
    </h:head>
    <h:body>

			<!-- User interface -->
			<select1 ref="/SMC/InterventionDetails/InterventionType">
				<label>Type of Intervention</label>
				<item>
					<label>One to One Session</label>
					<value>OneToOne</value>
				</item>
				<item>
					<label>Group Session</label>
					<value>GroupSession</value>
				</item>
				<item>
					<label>School Campaign</label>
					<value>SchoolCampaign</value>
				</item>
				<item>
					<label>Church Rally</label>
					<value>ChurchRally</value>
				</item>
				<item>
					<label>Edutainment Sessions</label>
					<value>Edutainment</value>
				</item>
				<item>
					<label>Launch</label>
					<value>Launch</value>
				</item>
				<item>
					<label>Sensitisation Workshop</label>
					<value>SensitisationWorkshop</value>
				</item>

			</select1>

			<input ref="/SMC/InterventionDetails/MalesReached">
                    <label>Total number of males reached.</label>
			</input>
			<input ref="/SMC/InterventionDetails/FemalesReached">
                    <label>Total number of females reached.</

label>

			<input ref="/SMC/InterventionDetails/CalcTotalReach">
                    <label>Total number of people reached.</label>
			</input>
			<input ref="/SMC/InterventionDetails/ValidateReach">
                    <label>Check validity.</label>
			</input>

    </h:body>

</h:html>

Christopher,

Constraints should work on previous values, but I guess they don't. Try this...

I've made the ValidateReach relevant only when the total is > 1 and
when OneToOne selected. Because the prompt is required and readonly
and the default value is blank, once it's relevant, it will never go
past that prompt. You could use a constraint on a constant to do
something similar if you want to use use a jr:constraintMsg.

Yaw

ยทยทยท On Mon, Mar 5, 2012 at 12:16, christopher serumola wrote: > i have developed a form for data collection but i am having serious > challenges when it comes to validating input data i.e i'm trying to > create a constraint that will prevent the data collector from moving > to the next question if a particular selection was made(One to One > Session) in a previous question AND the sum of input values in other > previous questions is greater than 1. I have tried several options but > without success. Please help, the form is as shown below. > > <?xml version="1.0"?> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http:// > openrosa.org/javarosa"> > > validation test > > > > > > > > > > > > > > > > type="string" required="true()"/> > required="true()" constraint=". >= 0" jr:constraintMsg="Males > reached can only be 0 or more!"/> > type="int" required="true()" constraint=". >= 0" > jr:constraintMsg="Females reached can only be 0 or more!"/> > type="int" calculate="../MalesReached+../FemalesReached" > required="true()" readonly="true()"/> > type="int" constraint="/SMC/InterventionDetails/CalcTotalReach = 1" > relevant="selected(/SMC/InterventionDetails/InterventionType, > 'OneToOne')" readonly="true()"/> > > > > > > > > Type of Intervention > > One to One Session > OneToOne > > > Group Session > GroupSession > > > School Campaign > SchoolCampaign > > > Church Rally > ChurchRally > > > Edutainment Sessions > Edutainment > > > Launch > Launch > > > Sensitisation Workshop > SensitisationWorkshop > > > > > > Total number of males reached. > > > Total number of females reached. label> > > > > Total number of people reached. > > > Check validity. > > > > > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en

What do you mean different? Does it seem like a time zone problem?

ยทยทยท On Wed, Mar 21, 2012 at 07:27, christopher serumola wrote: > Thanks Yaw, > > Your advice helped me solve the problem. But now another question, > when i capture data on the smartphone and submit to a locally setup > odk aggregate server, the time values are not correctly recorded in > the database(Postgresql). For example there is where i input time > spent but the values that actually get recorded in the database are > different from those i entered. Any ideas? > > On Mar 6, 8:32 am, Yaw Anokwa wrote: >> Christopher, >> >> Constraints should work on previous values, but I guess they don't. Try this... >> >> >> >> > relevant="/SMC/InterventionDetails/CalcTotalReach > 1 and >> selected(/SMC/InterventionDetails/InterventionType,'OneToOne')" >> required="true()" readonly="true()"/> >> >> I've made the ValidateReach relevant only when the total is > 1 and >> when OneToOne selected. Because the prompt is required and readonly >> and the default value is blank, once it's relevant, it will never go >> past that prompt. You could use a constraint on a constant to do >> something similar if you want to use use a jr:constraintMsg. >> >> Yaw >> >> >> >> On Mon, Mar 5, 2012 at 12:16, christopherserumola wrote: >> > i have developed a form for data collection but i am having serious >> > challenges when it comes to validating input data i.e i'm trying to >> > create a constraint that will prevent the data collector from moving >> > to the next question if a particular selection was made(One to One >> > Session) in a previous question AND the sum of input values in other >> > previous questions is greater than 1. I have tried several options but >> > without success. Please help, the form is as shown below. >> >> > <?xml version="1.0"?> >> > > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http:// >> > openrosa.org/javarosa"> >> > >> > validation test >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> >> > >> > > > type="string" required="true()"/> >> > > > required="true()" constraint=". >= 0" jr:constraintMsg="Males >> > reached can only be 0 or more!"/> >> > > > type="int" required="true()" constraint=". >= 0" >> > jr:constraintMsg="Females reached can only be 0 or more!"/> >> > > > type="int" calculate="../MalesReached+../FemalesReached" >> > required="true()" readonly="true()"/> >> > > > type="int" constraint="/SMC/InterventionDetails/CalcTotalReach = 1" >> > relevant="selected(/SMC/InterventionDetails/InterventionType, >> > 'OneToOne')" readonly="true()"/> >> >> > >> > >> > >> >> > >> > >> > Type of Intervention >> > >> > One to One Session >> > OneToOne >> > >> > >> > Group Session >> > GroupSession >> > >> > >> > School Campaign >> > SchoolCampaign >> > >> > >> > Church Rally >> > ChurchRally >> > >> > >> > Edutainment Sessions >> > Edutainment >> > >> > >> > Launch >> > Launch >> > >> > >> > Sensitisation Workshop >> > SensitisationWorkshop >> > >> >> > >> >> > >> > Total number of males reached. >> > >> > >> > Total number of females reached.> > label> >> > >> >> > >> > Total number of people reached. >> > >> > >> > Check validity. >> > >> >> > >> > >> >> > -- >> > Post: opendatakit@googlegroups.com >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> > Options:http://groups.google.com/group/opendatakit?hl=en- Hide quoted text - >> >> - Show quoted text -

Christopher,

ODK Collect stores time with timezone information. For example,

2011-08-05T20:59:02.899-07
2009-05-15T00:01:00.000-07
23:00:00.000-07
2010-06-15

If you look at the raw XML on your phone, I bet you see the proper time zone.

Mitch/Waylon know better, but I believe ODK Aggregate displays the
date in UTC. If timezone support is a must have, please file a feature
request at http://code.google.com/p/opendatakit/issues/list.

Yaw

ยทยทยท On Wed, Apr 4, 2012 at 00:26, christopher serumola wrote: > Yes, i think its a timezone problem. Where can i change it? The phone > is set to GMT+2:00(Botswana) which is correct. > > On Mar 23, 8:12 pm, Yaw Anokwa wrote: >> What do you mean different? Does it seem like a time zone problem? >> >> >> >> On Wed, Mar 21, 2012 at 07:27, christopherserumola wrote: >> > Thanks Yaw, >> >> > Your advice helped me solve the problem. But now another question, >> > when i capture data on the smartphone and submit to a locally setup >> > odk aggregate server, the time values are not correctly recorded in >> > the database(Postgresql). For example there is where i input time >> > spent but the values that actually get recorded in the database are >> > different from those i entered. Any ideas? >> >> > On Mar 6, 8:32 am, Yaw Anokwa wrote: >> >> Christopher, >> >> >> Constraints should work on previous values, but I guess they don't. Try this... >> >> >> >> >> >> > >> relevant="/SMC/InterventionDetails/CalcTotalReach > 1 and >> >> selected(/SMC/InterventionDetails/InterventionType,'OneToOne')" >> >> required="true()" readonly="true()"/> >> >> >> I've made the ValidateReach relevant only when the total is > 1 and >> >> when OneToOne selected. Because the prompt is required and readonly >> >> and the default value is blank, once it's relevant, it will never go >> >> past that prompt. You could use a constraint on a constant to do >> >> something similar if you want to use use a jr:constraintMsg. >> >> >> Yaw >> >> >> On Mon, Mar 5, 2012 at 12:16, christopherserumola wrote: >> >> > i have developed a form for data collection but i am having serious >> >> > challenges when it comes to validating input data i.e i'm trying to >> >> > create a constraint that will prevent the data collector from moving >> >> > to the next question if a particular selection was made(One to One >> >> > Session) in a previous question AND the sum of input values in other >> >> > previous questions is greater than 1. I have tried several options but >> >> > without success. Please help, the form is as shown below. >> >> >> > <?xml version="1.0"?> >> >> > > >> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http:// >> >> > openrosa.org/javarosa"> >> >> > >> >> > validation test >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> >> > >> >> > > >> > type="string" required="true()"/> >> >> > > >> > required="true()" constraint=". >= 0" jr:constraintMsg="Males >> >> > reached can only be 0 or more!"/> >> >> > > >> > type="int" required="true()" constraint=". >= 0" >> >> > jr:constraintMsg="Females reached can only be 0 or more!"/> >> >> > > >> > type="int" calculate="../MalesReached+../FemalesReached" >> >> > required="true()" readonly="true()"/> >> >> > > >> > type="int" constraint="/SMC/InterventionDetails/CalcTotalReach = 1" >> >> > relevant="selected(/SMC/InterventionDetails/InterventionType, >> >> > 'OneToOne')" readonly="true()"/> >> >> >> > >> >> > >> >> > >> >> >> > >> >> > >> >> > Type of Intervention >> >> > >> >> > One to One Session >> >> > OneToOne >> >> > >> >> > >> >> > Group Session >> >> > GroupSession >> >> > >> >> > >> >> > School Campaign >> >> > SchoolCampaign >> >> > >> >> > >> >> > Church Rally >> >> > ChurchRally >> >> > >> >> > >> >> > Edutainment Sessions >> >> > Edutainment >> >> > >> >> > >> >> > Launch >> >> > Launch >> >> > >> >> > >> >> > Sensitisation Workshop >> >> > SensitisationWorkshop >> >> > >> >> >> > >> >> >> > >> >> > Total number of males reached. >> >> > >> >> > >> >> > Total number of females reached.> >> > label> >> >> > >> >> >> > >> >> > Total number of people reached. >> >> > >> >> > >> >> > Check validity. >> >> > >> >> >> > >> >> > >> >> >> > -- >> >> > Post: opendatakit@googlegroups.com >> >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >> > Options:http://groups.google.com/group/opendatakit?hl=en-Hide quoted text - >> >> >> - Show quoted text -- Hide quoted text - >> >> - Show quoted text -

Incoming times or datetimes are converted to UTC (GMT) because we store the
values as TIMESTAMP WITHOUT TIME ZONE in PostgreSQL and as DATETIME in
MySQL.

Incoming dates are assumed to already be UTC dates since they don't have an
associated timezone (as Yaw shows below) and we cannot do any adjustment.

There is no way to choose the timezone within ODK Aggregate. It displays
everything as UTC (GMT).

Mitch

ยทยทยท On Wed, Apr 4, 2012 at 4:12 PM, Yaw Anokwa wrote:

Christopher,

ODK Collect stores time with timezone information. For example,

2011-08-05T20:59:02.899-07
2009-05-15T00:01:00.000-07
23:00:00.000-07
2010-06-15

If you look at the raw XML on your phone, I bet you see the proper time
zone.

Mitch/Waylon know better, but I believe ODK Aggregate displays the
date in UTC. If timezone support is a must have, please file a feature
request at http://code.google.com/p/opendatakit/issues/list.

Yaw

On Wed, Apr 4, 2012 at 00:26, christopher serumola serumolac@gmail.com wrote:

Yes, i think its a timezone problem. Where can i change it? The phone
is set to GMT+2:00(Botswana) which is correct.

On Mar 23, 8:12 pm, Yaw Anokwa yano...@gmail.com wrote:

What do you mean different? Does it seem like a time zone problem?

On Wed, Mar 21, 2012 at 07:27, christopherserumolaserumo...@gmail.com wrote:

Thanks Yaw,

Your advice helped me solve the problem. But now another question,
when i capture data on the smartphone and submit to a locally setup
odk aggregate server, the time values are not correctly recorded in
the database(Postgresql). For example there is where i input time
spent but the values that actually get recorded in the database are
different from those i entered. Any ideas?

On Mar 6, 8:32 am, Yaw Anokwa yano...@gmail.com wrote:

Christopher,

Constraints should work on previous values, but I guess they don't.
Try this...

I've made the ValidateReach relevant only when the total is > 1 and
when OneToOne selected. Because the prompt is required and readonly
and the default value is blank, once it's relevant, it will never go
past that prompt. You could use a constraint on a constant to do
something similar if you want to use use a jr:constraintMsg.

Yaw

On Mon, Mar 5, 2012 at 12:16, christopherserumola< serumo...@gmail.com> wrote:

i have developed a form for data collection but i am having serious
challenges when it comes to validating input data i.e i'm trying to
create a constraint that will prevent the data collector from
moving

to the next question if a particular selection was made(One to One
Session) in a previous question AND the sum of input values in
other

previous questions is greater than 1. I have tried several options
but

without success. Please help, the form is as shown below.

<?xml version="1.0"?>

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://
www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://
openrosa.org/javarosa">
<h:head>
<h:title>validation test</h:title>



 <InterventionDetails>
         <InterventionType/>
         <MalesReached/>
         <FemalesReached/>
         <CalcTotalReach/>
         <ValidateReach/>
 </InterventionDetails>
>> >> > >> >> >> > >> >> > > >> > type="string" required="true()"/> >> >> > > >> > required="true()" constraint=". >= 0" jr:constraintMsg="Males >> >> > reached can only be 0 or more!"/> >> >> > > >> > type="int" required="true()" constraint=". >= 0" >> >> > jr:constraintMsg="Females reached can only be 0 or more!"/> >> >> > > >> > type="int" calculate="../MalesReached+../FemalesReached" >> >> > required="true()" readonly="true()"/> >> >> > > >> > type="int" constraint="/SMC/InterventionDetails/CalcTotalReach = 1" >> >> > relevant="selected(/SMC/InterventionDetails/InterventionType, >> >> > 'OneToOne')" readonly="true()"/> >> >> >> > >> >> > >> >> > >> >> >> > >> >> > >> >> > Type of Intervention >> >> > >> >> > One to One Session >> >> > OneToOne >> >> > >> >> > >> >> > Group Session >> >> > GroupSession >> >> > >> >> > >> >> > School Campaign >> >> > SchoolCampaign >> >> > >> >> > >> >> > Church Rally >> >> > ChurchRally >> >> > >> >> > >> >> > Edutainment Sessions >> >> > Edutainment >> >> > >> >> > >> >> > Launch >> >> > Launch >> >> > >> >> > >> >> > Sensitisation Workshop >> >> > SensitisationWorkshop >> >> > >> >> >> > >> >> >> > >> >> > Total number of males reached. >> >> > >> >> > >> >> > Total number of females reached.> >> > label> >> >> > >> >> >> > >> >> > Total number of people reached. >> >> > >> >> > >> >> > Check validity. >> >> > >> >> >> > >> >> > >> >> >> > -- >> >> > Post: opendatakit@googlegroups.com >> >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >> > Options:http://groups.google.com/group/opendatakit?hl=en-Hidequoted text - >> >> >> - Show quoted text -- Hide quoted text - >> >> - Show quoted text -

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

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

The time widget is for storing the time (10:15pm), not the amount of
time (10 minutes, 15 seconds). If you want to store an amount of time,
use the integer data type.

The reason there is a (2 hour) difference beween what you capture and
what Aggregate stores is because times in Aggregate are stored as UCT.
As Mitch explained earlier at
https://groups.google.com/group/opendatakit/msg/94dd96cf85b53df9, it's
a timezone issue.

ยทยทยท On Mon, Apr 23, 2012 at 05:47, christopher serumola wrote: > Thanks. But what i mean is that when i use the odk time widget on the phone > to record the amount of time taken(not using start and end preload params) > e.g time taken is 10:15(i.e 10 minutes and 15 seconds) odk aggregate records > it on the postgresql database as 8:15(i.e 2 minutes less than what was > captured). I have tried many times using different amounts of time but > always encounter the 2 minutes difference. What could be the cause of this. > > > On Thu, Apr 5, 2012 at 1:12 AM, Yaw Anokwa wrote: >> >> Christopher, >> >> ODK Collect stores time with timezone information. For example, >> >> 2011-08-05T20:59:02.899-07 >> 2009-05-15T00:01:00.000-07 >> 23:00:00.000-07 >> 2010-06-15 >> >> If you look at the raw XML on your phone, I bet you see the proper time >> zone. >> >> Mitch/Waylon know better, but I believe ODK Aggregate displays the >> date in UTC. If timezone support is a must have, please file a feature >> request at http://code.google.com/p/opendatakit/issues/list. >> >> Yaw >> >> On Wed, Apr 4, 2012 at 00:26, christopher serumola wrote: >> > Yes, i think its a timezone problem. Where can i change it? The phone >> > is set to GMT+2:00(Botswana) which is correct. >> > >> > On Mar 23, 8:12 pm, Yaw Anokwa wrote: >> >> What do you mean different? Does it seem like a time zone problem? >> >> >> >> >> >> >> >> On Wed, Mar 21, 2012 at 07:27, christopherserumola wrote: >> >> > Thanks Yaw, >> >> >> >> > Your advice helped me solve the problem. But now another question, >> >> > when i capture data on the smartphone and submit to a locally setup >> >> > odk aggregate server, the time values are not correctly recorded in >> >> > the database(Postgresql). For example there is where i input time >> >> > spent but the values that actually get recorded in the database are >> >> > different from those i entered. Any ideas? >> >> >> >> > On Mar 6, 8:32 am, Yaw Anokwa wrote: >> >> >> Christopher, >> >> >> >> >> Constraints should work on previous values, but I guess they don't. >> >> >> Try this... >> >> >> >> >> >> >> >> >> >> > >> >> relevant="/SMC/InterventionDetails/CalcTotalReach > 1 and >> >> >> selected(/SMC/InterventionDetails/InterventionType,'OneToOne')" >> >> >> required="true()" readonly="true()"/> >> >> >> >> >> I've made the ValidateReach relevant only when the total is > 1 and >> >> >> when OneToOne selected. Because the prompt is required and readonly >> >> >> and the default value is blank, once it's relevant, it will never go >> >> >> past that prompt. You could use a constraint on a constant to do >> >> >> something similar if you want to use use a jr:constraintMsg. >> >> >> >> >> Yaw >> >> >> >> >> On Mon, Mar 5, 2012 at 12:16, christopherserumola wrote: >> >> >> > i have developed a form for data collection but i am having >> >> >> > serious >> >> >> > challenges when it comes to validating input data i.e i'm trying >> >> >> > to >> >> >> > create a constraint that will prevent the data collector from >> >> >> > moving >> >> >> > to the next question if a particular selection was made(One to One >> >> >> > Session) in a previous question AND the sum of input values in >> >> >> > other >> >> >> > previous questions is greater than 1. I have tried several options >> >> >> > but >> >> >> > without success. Please help, the form is as shown below. >> >> >> >> >> > <?xml version="1.0"?> >> >> >> > > >> >> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http:// >> >> >> > openrosa.org/javarosa"> >> >> >> > >> >> >> > validation test >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> >> >> > >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/InterventionType" >> >> >> > type="string" required="true()"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/MalesReached" type="int" >> >> >> > required="true()" constraint=". >= 0" jr:constraintMsg="Males >> >> >> > reached can only be 0 or more!"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/FemalesReached" >> >> >> > type="int" required="true()" constraint=". >= 0" >> >> >> > jr:constraintMsg="Females reached can only be 0 or more!"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/CalcTotalReach" >> >> >> > type="int" calculate="../MalesReached+../FemalesReached" >> >> >> > required="true()" readonly="true()"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/ValidateReach" >> >> >> > type="int" constraint="/SMC/InterventionDetails/CalcTotalReach = >> >> >> > 1" >> >> >> > relevant="selected(/SMC/InterventionDetails/InterventionType, >> >> >> > 'OneToOne')" readonly="true()"/> >> >> >> >> >> > >> >> >> > >> >> >> > >> >> >> >> >> > >> >> >> > > >> >> > ref="/SMC/InterventionDetails/InterventionType"> >> >> >> > Type of >> >> >> > Intervention >> >> >> > >> >> >> > One to One >> >> >> > Session >> >> >> > >> >> >> > OneToOne >> >> >> > >> >> >> > >> >> >> > Group >> >> >> > Session >> >> >> > >> >> >> > GroupSession >> >> >> > >> >> >> > >> >> >> > School >> >> >> > Campaign >> >> >> > >> >> >> > SchoolCampaign >> >> >> > >> >> >> > >> >> >> > Church >> >> >> > Rally >> >> >> > >> >> >> > ChurchRally >> >> >> > >> >> >> > >> >> >> > Edutainment >> >> >> > Sessions >> >> >> > >> >> >> > Edutainment >> >> >> > >> >> >> > >> >> >> > >> >> >> > Launch >> >> >> > >> >> >> > Launch >> >> >> > >> >> >> > >> >> >> > >> >> >> > Sensitisation Workshop >> >> >> > >> >> >> > SensitisationWorkshop >> >> >> > >> >> >> >> >> > >> >> >> >> >> > > >> >> > ref="/SMC/InterventionDetails/MalesReached"> >> >> >> > Total number of males >> >> >> > reached. >> >> >> > >> >> >> > > >> >> > ref="/SMC/InterventionDetails/FemalesReached"> >> >> >> > Total number of females reached.> >> >> > label> >> >> >> > >> >> >> >> >> > > >> >> > ref="/SMC/InterventionDetails/CalcTotalReach"> >> >> >> > Total number of people >> >> >> > reached. >> >> >> > >> >> >> > > >> >> > ref="/SMC/InterventionDetails/ValidateReach"> >> >> >> > Check validity. >> >> >> > >> >> >> >> >> > >> >> >> > >> >> >> >> >> > -- >> >> >> > Post: opendatakit@googlegroups.com >> >> >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >> >> > Options:http://groups.google.com/group/opendatakit?hl=en-Hide >> >> >> > quoted text - >> >> >> >> >> - Show quoted text -- Hide quoted text - >> >> >> >> - Show quoted text - > >

How hard would it be to store times with timezones?

ยทยทยท On Wed, Apr 4, 2012 at 16:56, Mitch S wrote: > Incoming times or datetimes are converted to UTC (GMT) because we store the > values as TIMESTAMP WITHOUT TIME ZONE in PostgreSQL and as DATETIME in > MySQL. > > Incoming dates are assumed to already be UTC dates since they don't have an > associated timezone (as Yaw shows below) and we cannot do any adjustment. > > There is no way to choose the timezone within ODK Aggregate. It displays > everything as UTC (GMT). > > Mitch > > On Wed, Apr 4, 2012 at 4:12 PM, Yaw Anokwa wrote: >> >> Christopher, >> >> ODK Collect stores time with timezone information. For example, >> >> 2011-08-05T20:59:02.899-07 >> 2009-05-15T00:01:00.000-07 >> 23:00:00.000-07 >> 2010-06-15 >> >> If you look at the raw XML on your phone, I bet you see the proper time >> zone. >> >> Mitch/Waylon know better, but I believe ODK Aggregate displays the >> date in UTC. If timezone support is a must have, please file a feature >> request at http://code.google.com/p/opendatakit/issues/list. >> >> Yaw >> >> On Wed, Apr 4, 2012 at 00:26, christopher serumola wrote: >> > Yes, i think its a timezone problem. Where can i change it? The phone >> > is set to GMT+2:00(Botswana) which is correct. >> > >> > On Mar 23, 8:12 pm, Yaw Anokwa wrote: >> >> What do you mean different? Does it seem like a time zone problem? >> >> >> >> >> >> >> >> On Wed, Mar 21, 2012 at 07:27, christopherserumola wrote: >> >> > Thanks Yaw, >> >> >> >> > Your advice helped me solve the problem. But now another question, >> >> > when i capture data on the smartphone and submit to a locally setup >> >> > odk aggregate server, the time values are not correctly recorded in >> >> > the database(Postgresql). For example there is where i input time >> >> > spent but the values that actually get recorded in the database are >> >> > different from those i entered. Any ideas? >> >> >> >> > On Mar 6, 8:32 am, Yaw Anokwa wrote: >> >> >> Christopher, >> >> >> >> >> Constraints should work on previous values, but I guess they don't. >> >> >> Try this... >> >> >> >> >> >> >> >> >> >> > >> >> relevant="/SMC/InterventionDetails/CalcTotalReach > 1 and >> >> >> selected(/SMC/InterventionDetails/InterventionType,'OneToOne')" >> >> >> required="true()" readonly="true()"/> >> >> >> >> >> I've made the ValidateReach relevant only when the total is > 1 and >> >> >> when OneToOne selected. Because the prompt is required and readonly >> >> >> and the default value is blank, once it's relevant, it will never go >> >> >> past that prompt. You could use a constraint on a constant to do >> >> >> something similar if you want to use use a jr:constraintMsg. >> >> >> >> >> Yaw >> >> >> >> >> On Mon, Mar 5, 2012 at 12:16, christopherserumola wrote: >> >> >> > i have developed a form for data collection but i am having >> >> >> > serious >> >> >> > challenges when it comes to validating input data i.e i'm trying >> >> >> > to >> >> >> > create a constraint that will prevent the data collector from >> >> >> > moving >> >> >> > to the next question if a particular selection was made(One to One >> >> >> > Session) in a previous question AND the sum of input values in >> >> >> > other >> >> >> > previous questions is greater than 1. I have tried several options >> >> >> > but >> >> >> > without success. Please help, the form is as shown below. >> >> >> >> >> > <?xml version="1.0"?> >> >> >> > > >> >> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http:// >> >> >> > openrosa.org/javarosa"> >> >> >> > >> >> >> > validation test >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> >> >> > >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/InterventionType" >> >> >> > type="string" required="true()"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/MalesReached" type="int" >> >> >> > required="true()" constraint=". >= 0" jr:constraintMsg="Males >> >> >> > reached can only be 0 or more!"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/FemalesReached" >> >> >> > type="int" required="true()" constraint=". >= 0" >> >> >> > jr:constraintMsg="Females reached can only be 0 or more!"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/CalcTotalReach" >> >> >> > type="int" calculate="../MalesReached+../FemalesReached" >> >> >> > required="true()" readonly="true()"/> >> >> >> > > >> >> > nodeset="/SMC/InterventionDetails/ValidateReach" >> >> >> > type="int" constraint="/SMC/InterventionDetails/CalcTotalReach = >> >> >> > 1" >> >> >> > relevant="selected(/SMC/InterventionDetails/InterventionType, >> >> >> > 'OneToOne')" readonly="true()"/> >> >> >> >> >> > >> >> >> > >> >> >> > >> >> >> >> >> > >> >> >> > > >> >> > ref="/SMC/InterventionDetails/InterventionType"> >> >> >> > Type of >> >> >> > Intervention >> >> >> > >> >> >> > One to One >> >> >> > Session >> >> >> > >> >> >> > OneToOne >> >> >> > >> >> >> > >> >> >> > Group >> >> >> > Session >> >> >> > >> >> >> > GroupSession >> >> >> > >> >> >> > >> >> >> > School >> >> >> > Campaign >> >> >> > >> >> >> > SchoolCampaign >> >> >> > >> >> >> > >> >> >> > Church >> >> >> > Rally >> >> >> > >> >> >> > ChurchRally >> >> >> > >> >> >> > >> >> >> > Edutainment >> >> >> > Sessions >> >> >> > >> >> >> > Edutainment >> >> >> > >> >> >> > >> >> >> > >> >> >> > Launch >> >> >> > >> >> >> > Launch >> >> >> > >> >> >> > >> >> >> > >> >> >> > Sensitisation Workshop >> >> >> > >> >> >> > SensitisationWorkshop >> >> >> > >> >> >> >> >> > >> >> >> >> >> > > >> >> > ref="/SMC/InterventionDetails/MalesReached"> >> >> >> > Total number of males >> >> >> > reached. >> >> >> > >> >> >> > > >> >> > ref="/SMC/InterventionDetails/FemalesReached"> >> >> >> > Total number of females reached.> >> >> > label> >> >> >> > >> >> >> >> >> > > >> >> > ref="/SMC/InterventionDetails/CalcTotalReach"> >> >> >> > Total number of people >> >> >> > reached. >> >> >> > >> >> >> > > >> >> > ref="/SMC/InterventionDetails/ValidateReach"> >> >> >> > Check validity. >> >> >> > >> >> >> >> >> > >> >> >> > >> >> >> >> >> > -- >> >> >> > Post: opendatakit@googlegroups.com >> >> >> > Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> >> >> > Options:http://groups.google.com/group/opendatakit?hl=en-Hide >> >> >> > quoted text - >> >> >> >> >> - Show quoted text -- Hide quoted text - >> >> >> >> - Show quoted text - >> >> -- >> Post: opendatakit@googlegroups.com >> Unsubscribe: opendatakit+unsubscribe@googlegroups.com >> Options: http://groups.google.com/group/opendatakit?hl=en > > > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitchellsundt@gmail.com > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en
1 Like

There are two ways to go:

(1) Change Aggregate to show dates in a specified timezone (e.g., have a
timezone choice on the Site Admin / Preferences tab). Use that designated
timezone for all exported csv and kml data, and all published data to
Google Spreadsheets or Fusion Tables.

This is roughly the path Aggregate is heading down now. Since Google's App
Engine hosts are all configured with GMT time, we sort of standardized on
preserving that end-to-end.

The change would be confined to the formatting layer, and would be
straightforward to do.

(2) Actually preserve the timezones of the incoming data (a systemic
change).

This would change Build/XLSForm and Collect to emit metadata that
communicates the timezone of a filled-in submission as a preload metadata
element (e.g., in the OpenRosa block) so that date types (which lack
timezone information) could be properly timezoned. If that were present,
we could then preserve timezones for all datatypes into the datastore layer.

The problematic datastore is then MySQL. Google and PostgreSQL already
provide storage types that can preserve timezones. For MySQL, it probably
makes sense to store a timezoned datetime as two columns -- the UTC
datetime and the timezone. Complicated but a fairly constrained change
within the MySQL datastore layer.

This would be an Aggregate 1.1 feature, along with string-valued version
and full OpenRosa 1.0 compliance.

Mitch

ยทยทยท On Wed, Apr 4, 2012 at 4:58 PM, Yaw Anokwa wrote:

How hard would it be to store times with timezones?

On Wed, Apr 4, 2012 at 16:56, Mitch S mitchellsundt@gmail.com wrote:

Incoming times or datetimes are converted to UTC (GMT) because we store
the
values as TIMESTAMP WITHOUT TIME ZONE in PostgreSQL and as DATETIME in
MySQL.

Incoming dates are assumed to already be UTC dates since they don't have
an
associated timezone (as Yaw shows below) and we cannot do any adjustment.

There is no way to choose the timezone within ODK Aggregate. It displays
everything as UTC (GMT).

Mitch

On Wed, Apr 4, 2012 at 4:12 PM, Yaw Anokwa yanokwa@gmail.com wrote:

Christopher,

ODK Collect stores time with timezone information. For example,

2011-08-05T20:59:02.899-07
2009-05-15T00:01:00.000-07
23:00:00.000-07
2010-06-15

If you look at the raw XML on your phone, I bet you see the proper time
zone.

Mitch/Waylon know better, but I believe ODK Aggregate displays the
date in UTC. If timezone support is a must have, please file a feature
request at http://code.google.com/p/opendatakit/issues/list.

Yaw

On Wed, Apr 4, 2012 at 00:26, christopher serumola <serumolac@gmail.com wrote:

Yes, i think its a timezone problem. Where can i change it? The phone
is set to GMT+2:00(Botswana) which is correct.

On Mar 23, 8:12 pm, Yaw Anokwa yano...@gmail.com wrote:

What do you mean different? Does it seem like a time zone problem?

On Wed, Mar 21, 2012 at 07:27, christopherserumola< serumo...@gmail.com> wrote:

Thanks Yaw,

Your advice helped me solve the problem. But now another question,
when i capture data on the smartphone and submit to a locally setup
odk aggregate server, the time values are not correctly recorded in
the database(Postgresql). For example there is where i input time
spent but the values that actually get recorded in the database are
different from those i entered. Any ideas?

On Mar 6, 8:32 am, Yaw Anokwa yano...@gmail.com wrote:

Christopher,

Constraints should work on previous values, but I guess they
don't.

Try this...

I've made the ValidateReach relevant only when the total is > 1
and

when OneToOne selected. Because the prompt is required and
readonly

and the default value is blank, once it's relevant, it will never
go

past that prompt. You could use a constraint on a constant to do
something similar if you want to use use a jr:constraintMsg.

Yaw

On Mon, Mar 5, 2012 at 12:16, christopherserumolaserumo...@gmail.com wrote:

i have developed a form for data collection but i am having
serious
challenges when it comes to validating input data i.e i'm trying
to
create a constraint that will prevent the data collector from
moving
to the next question if a particular selection was made(One to
One

Session) in a previous question AND the sum of input values in
other
previous questions is greater than 1. I have tried several
options

but
without success. Please help, the form is as shown below.

<?xml version="1.0"?>

<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://
www.w3.org/1999/xhtml" xmlns:ev="
http://www.w3.org/2001/xml-events"

xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://
openrosa.org/javarosa">
<h:head>
<h:title>validation test</h:title>


<!-- submitted data and defaults
go

here -->

 <InterventionDetails>

         <InterventionType/>

         <MalesReached/>

         <FemalesReached/>

         <CalcTotalReach/>

         <ValidateReach/>

 </InterventionDetails>
                                           <!-- Bindings -->
                                           <bind

nodeset="/SMC/InterventionDetails/InterventionType"
type="string" required="true()"/>



                           </model>
   </h:head>
   <h:body>
                           <!-- User interface -->
                           <select1

ref="/SMC/InterventionDetails/InterventionType">
Type of
Intervention

One to One
Session

OneToOne


Group
Session

GroupSession


School
Campaign

SchoolCampaign


Church
Rally

ChurchRally

Edutainment

Sessions

Edutainment

Launch

Launch

Sensitisation Workshop

SensitisationWorkshop

                           </select1>
                           <input

ref="/SMC/InterventionDetails/MalesReached">
Total number of males
reached.


Total number of females reached.</
label>

                           <input

ref="/SMC/InterventionDetails/CalcTotalReach">
Total number of people
reached.


Check validity.

   </h:body>

</h:html>

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

  • Show quoted text -- Hide quoted text -
  • Show quoted text -

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

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

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

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

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