Default value and skip logic

Hi everyone,

I'm been using the javarosa tutorial to write my own xml xforms and
I'm running into a little problem.

I want to use default value and skip logic to ask if the condition of
the house is good. If it's good, then done, save and exit. If it's
not, then ask an additional question if the door is broken. I want to
have the default value for the door to be not broken.

The form worked fine. However, when I viewed the data, for questions
where the condition of the house if good, the default value of the
door doesn't show. Instead, it shows "null" instead. Please let me
know if you could figure out the problem from my code below. Thank
you so much for taking the time to read my question and for helping me
out.

<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>Test</h:title>

<model>
  <instance>
    <data id="TestData">
		<HouseCondition/>
		<BrokenDoor>0</BrokenDoor>
	</data>
  </instance>
	<bind nodeset="/data/BrokenDoor" relevant="selected(/data/

HouseCondition, '0')"/>

</model>

</h:head>
<h:body>

<select1 ref="/data/HouseCondition">
	<label>Is the condition of the house good?</label>
	<item>
		<label>Yes</label>
		<value>1</value>
	</item>
	<item>
		<label>No</label>
		<value>0</value>
	</item>
</select1>
<select1 ref="/data/BrokenDoor">
	<label>Is the door broken?</label>
	<item>
		<label>Yes</label>
		<value>1</value>
	</item>
	<item>
		<label>No</label>
		<value>0</value>
	</item>
</select1>

</h:body>
</h:html>

hi du,

the javarosa library only outputs the result of the path you take
through the form. because irrelevant (by definition) nodes are never
on your path, they are never in the output. this also helps to keep data
submissions small.

one way to get around this is to use a hidden node whose value is set
based on the irrelevant node. confusing, i know, but you can see your
form with the changes at
http://dpaste.com/574018. the important bits are below.

0 0 ... ...

now in the body only ask the house and broken door question (and not
the really broken door question), and viola, you are sending the
default value...

yaw

··· On Thu, Jul 21, 2011 at 13:24, Du wrote: > Hi everyone, > > I'm been using the javarosa tutorial to write my own xml xforms and > I'm running into a little problem. > > I want to use default value and skip logic to ask if the condition of > the house is good. If it's good, then done, save and exit. If it's > not, then ask an additional question if the door is broken. I want to > have the default value for the door to be not broken. > > The form worked fine. However, when I viewed the data, for questions > where the condition of the house if good, the default value of the > door doesn't show. Instead, it shows "null" instead. Please let me > know if you could figure out the problem from my code below. Thank > you so much for taking the time to read my question and for helping me > out. > > 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"> > > Test > > > > > > 0 > > > > > > > > > > Is the condition of the house good? > > Yes > 1 > > > No > 0 > > > > Is the door broken? > > Yes > 1 > > > No > 0 > > > > > > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en >

Thank you, Yaw, for your help. Unfortunately, the data for brokendoor
still shows as "null" whenever its question is skipped. Is there a
good place to learn more about different functions like "calculate"
and "if" just so I could understand more the extra line that you
added? I've been searching the web but couldn't find a good place
that defines all the functions for me. Thank you.

Du

··· On Jul 22, 2:30 am, Yaw Anokwa wrote: > hi du, > > the javarosa library only outputs the result of the path you take > through the form. because irrelevant (by definition) nodes are never > on your path, they are never in the output. this also helps to keep data > submissions small. > > one way to get around this is to use a hidden node whose value is set > based on the irrelevant node. confusing, i know, but you can see your > form with the changes athttp://dpaste.com/574018. the important bits are below. > > > 0 > 0 > ... > relevant="selected(/data/HouseCondition, '0')"/> > > ... > > now in the body only ask the house and broken door question (and not > the really broken door question), and viola, you are sending the > default value... > > yaw > > > > > > > > On Thu, Jul 21, 2011 at 13:24, Du wrote: > > Hi everyone, > > > I'm been using the javarosa tutorial to write my own xml xforms and > > I'm running into a little problem. > > > I want to use default value and skip logic to ask if the condition of > > the house is good. If it's good, then done, save and exit. If it's > > not, then ask an additional question if the door is broken. I want to > > have the default value for the door to be not broken. > > > The form worked fine. However, when I viewed the data, for questions > > where the condition of the house if good, the default value of the > > door doesn't show. Instead, it shows "null" instead. Please let me > > know if you could figure out the problem from my code below. Thank > > you so much for taking the time to read my question and for helping me > > out. > > > > 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"> > > > > Test > > > > > > > > > > > 0 > > > > > > > > > > > > > > > > > > Is the condition of the house good? > > > > Yes > > 1 > > > > > > No > > 0 > > > > > > > > Is the door broken? > > > > Yes > > 1 > > > > > > No > > 0 > > > > > > > > > > > > -- > > Post: opendatakit@googlegroups.com > > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > > Options:http://groups.google.com/group/opendatakit?hl=en

brokendoor will show as null because it's not relevant. there is no
way around this. if you need to transfer default values in your
submission, then the method i detailed is your best option.

you can find xform design help at
http://code.google.com/p/opendatakit/wiki/XFormDesignGuidelines and
https://bitbucket.org/javarosa/javarosa/wiki/xform. we also have
sample forms at
http://code.google.com/p/opendatakit/source/browse?repo=forms.

··· On Fri, Jul 22, 2011 at 08:12, Du wrote: > Thank you, Yaw, for your help. Unfortunately, the data for brokendoor > still shows as "null" whenever its question is skipped. Is there a > good place to learn more about different functions like "calculate" > and "if" just so I could understand more the extra line that you > added? I've been searching the web but couldn't find a good place > that defines all the functions for me. Thank you. > > Du > > On Jul 22, 2:30 am, Yaw Anokwa wrote: >> hi du, >> >> the javarosa library only outputs the result of the path you take >> through the form. because irrelevant (by definition) nodes are never >> on your path, they are never in the output. this also helps to keep data >> submissions small. >> >> one way to get around this is to use a hidden node whose value is set >> based on the irrelevant node. confusing, i know, but you can see your >> form with the changes athttp://dpaste.com/574018. the important bits are below. >> >> >> 0 >> 0 >> ... >> > relevant="selected(/data/HouseCondition, '0')"/> >> >> ... >> >> now in the body only ask the house and broken door question (and not >> the really broken door question), and viola, you are sending the >> default value... >> >> yaw >> >> >> >> >> >> >> >> On Thu, Jul 21, 2011 at 13:24, Du wrote: >> > Hi everyone, >> >> > I'm been using the javarosa tutorial to write my own xml xforms and >> > I'm running into a little problem. >> >> > I want to use default value and skip logic to ask if the condition of >> > the house is good. If it's good, then done, save and exit. If it's >> > not, then ask an additional question if the door is broken. I want to >> > have the default value for the door to be not broken. >> >> > The form worked fine. However, when I viewed the data, for questions >> > where the condition of the house if good, the default value of the >> > door doesn't show. Instead, it shows "null" instead. Please let me >> > know if you could figure out the problem from my code below. Thank >> > you so much for taking the time to read my question and for helping me >> > out. >> >> > > > 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"> >> > >> > Test >> >> > >> > >> > >> > >> > 0 >> > >> > >> > >> >> > >> > >> > >> >> > >> > Is the condition of the house good? >> > >> > Yes >> > 1 >> > >> > >> > No >> > 0 >> > >> > >> > >> > Is the door broken? >> > >> > Yes >> > 1 >> > >> > >> > No >> > 0 >> > >> > >> >> > >> > >> >> > -- >> > 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 >

Oh I understand now. Thanks Yaw for your always quick response. Have
a great weekend.

··· On Jul 22, 12:42 pm, Yaw Anokwa wrote: > brokendoor will show as null because it's not relevant. there is no > way around this. if you need to transfer default values in your > submission, then the method i detailed is your best option. > > you can find xform design help athttp://code.google.com/p/opendatakit/wiki/XFormDesignGuidelinesandhttps://bitbucket.org/javarosa/javarosa/wiki/xform. we also have > sample forms athttp://code.google.com/p/opendatakit/source/browse?repo=forms. > > > > > > > > On Fri, Jul 22, 2011 at 08:12, Du wrote: > > Thank you, Yaw, for your help. Unfortunately, the data for brokendoor > > still shows as "null" whenever its question is skipped. Is there a > > good place to learn more about different functions like "calculate" > > and "if" just so I could understand more the extra line that you > > added? I've been searching the web but couldn't find a good place > > that defines all the functions for me. Thank you. > > > Du > > > On Jul 22, 2:30 am, Yaw Anokwa wrote: > >> hi du, > > >> the javarosa library only outputs the result of the path you take > >> through the form. because irrelevant (by definition) nodes are never > >> on your path, they are never in the output. this also helps to keep data > >> submissions small. > > >> one way to get around this is to use a hidden node whose value is set > >> based on the irrelevant node. confusing, i know, but you can see your > >> form with the changes athttp://dpaste.com/574018. the important bits are below. > > >> > >> 0 > >> 0 > >> ... > >> >> relevant="selected(/data/HouseCondition, '0')"/> > >> > >> ... > > >> now in the body only ask the house and broken door question (and not > >> the really broken door question), and viola, you are sending the > >> default value... > > >> yaw > > >> On Thu, Jul 21, 2011 at 13:24, Du wrote: > >> > Hi everyone, > > >> > I'm been using the javarosa tutorial to write my own xml xforms and > >> > I'm running into a little problem. > > >> > I want to use default value and skip logic to ask if the condition of > >> > the house is good. If it's good, then done, save and exit. If it's > >> > not, then ask an additional question if the door is broken. I want to > >> > have the default value for the door to be not broken. > > >> > The form worked fine. However, when I viewed the data, for questions > >> > where the condition of the house if good, the default value of the > >> > door doesn't show. Instead, it shows "null" instead. Please let me > >> > know if you could figure out the problem from my code below. Thank > >> > you so much for taking the time to read my question and for helping me > >> > out. > > >> > >> > 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"> > >> > > >> > Test > > >> > > >> > > >> > > >> > > >> > 0 > >> > > >> > > >> > > > >> > > >> > > >> > > > >> > > >> > Is the condition of the house good? > >> > > >> > Yes > >> > 1 > >> > > >> > > >> > No > >> > 0 > >> > > >> > > >> > > >> > Is the door broken? > >> > > >> > Yes > >> > 1 > >> > > >> > > >> > No > >> > 0 > >> > > >> > > > >> > > >> > > > >> > -- > >> > 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