Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# sample-forms
# Sample Forms

This project is __*infrequently maintained*__
A repository of example xforms for use in ODK Collect and ODK Web Forms.

It contains example ODK Collect forms.
## Relevant links

There are many new features now available for which we do not have example forms.
- [ODK](https://getodk.org/)
- [Documentation](https://docs.getodk.org/)
- [User forum](https://forum.getodk.org/)

User documentation is [here](https://opendatakit.org/help/)

The Google group for user questions is: [opendatakit@](https://groups.google.com/forum/#!forum/opendatakit)
33 changes: 33 additions & 0 deletions xml-examples/computations/1-calculate-simple.xform.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Calculate (simple)</h:title>
<model>
<instance>
<root id="calculate-simple">
<first-question>1</first-question>
<second-question/>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/first-question"/>
<bind nodeset="/root/second-question" calculate="/root/first-question * 2"/>
<bind nodeset="/root/meta/instanceID" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/root/first-question">
<label>1. Default value is 1</label>
</input>
<input ref="/root/second-question">
<label>2. Calculates #1 × 2</label>
</input>
</h:body>
</h:html>
33 changes: 33 additions & 0 deletions xml-examples/computations/2-relevant-simple.xform.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Relevant (simple)</h:title>
<model>
<instance>
<root id="relevant-simple">
<first-question>1</first-question>
<second-question>default if relevant</second-question>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/first-question"/>
<bind nodeset="/root/second-question" relevant="/root/first-question &gt; 2"/>
<bind nodeset="/root/meta/instanceID" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/root/first-question">
<label>1. Default value is 1</label>
</input>
<input ref="/root/second-question">
<label>2. Relevant if #1 is greater than 2</label>
</input>
</h:body>
</h:html>
38 changes: 38 additions & 0 deletions xml-examples/computations/3-relevant-calculate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Relevant and calculate</h:title>
<model>
<instance>
<root id="relevant-calculate">
<first-question>0</first-question>
<second-question>no</second-question>
<third-question/>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/first-question"/>
<bind nodeset="/root/second-question" />
<bind nodeset="/root/third-question" calculate="/root/first-question * 3" relevant="selected(/root/second-question, 'yes')"/>
<bind nodeset="/root/meta/instanceID" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/root/first-question">
<label>1. Enter a number</label>
</input>
<input ref="/root/second-question">
<label>2. Enter "yes" to make #3 relevant</label>
</input>
<input ref="/root/third-question">
<label>3. Calculation of #1 × 3, relevant if #2 is "yes"</label>
</input>
</h:body>
</h:html>
33 changes: 33 additions & 0 deletions xml-examples/computations/4-calculate-required.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Calculate and required</h:title>
<model>
<instance>
<root id="calculate-required">
<first-question>10</first-question>
<second-question/>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/first-question"/>
<bind nodeset="/root/second-question" calculate="/root/first-question * 2" required="/root/first-question &gt; 1"/>
<bind nodeset="/root/meta/instanceID" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/root/first-question">
<label>1. Default value is 10</label>
</input>
<input ref="/root/second-question">
<label>2. Required if #1 is greater than 1, calculates #1 × 2</label>
</input>
</h:body>
</h:html>
38 changes: 38 additions & 0 deletions xml-examples/computations/5-relevant-readonly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Relevant and readonly</h:title>
<model>
<instance>
<root id="relevant-readonly">
<first-question>1</first-question>
<second-question>2</second-question>
<third-question>3</third-question>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/first-question"/>
<bind nodeset="/root/second-question" relevant="/root/first-question &lt; 2" readonly="true()" />
<bind nodeset="/root/third-question" relevant="/root/first-question &gt; 2" readonly="/root/first-question &lt; 4" />
<bind nodeset="/root/meta/instanceID" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/root/first-question">
<label>1. Default value is 1</label>
</input>
<input ref="/root/second-question">
<label>2. Relevant if #1 is less than 2, always read-only</label>
</input>
<input ref="/root/third-question">
<label>3. Relevant if #1 is greater than 2, read-only if #1 is less than 4</label>
</input>
</h:body>
</h:html>
51 changes: 51 additions & 0 deletions xml-examples/computations/6-relevant-calculate-group.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Relevant, calculate, group</h:title>
<model>
<instance>
<root id="relevant-calculate-group">
<first-question />
<second-question />
<grp>
<grouped-a />
<grouped-b />
</grp>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/first-question" />
<bind nodeset="/root/second-question" />
<bind nodeset="/root/grp" relevant="selected(/root/first-question, 'y')" />
<bind nodeset="/root/grp/grouped-a" calculate="concat('second = ', /root/second-question)" readonly="true()" />
<bind nodeset="/root/grp/grouped-b" />
<bind nodeset="/root/meta/instanceID" type="string" />
</model>
</h:head>
<h:body>
<input ref="/root/first-question">
<label>1. Set to "y" to make group relevant</label>
</input>
<input ref="/root/second-question">
<label>2. Enter some text</label>
</input>
<group ref="/root/grp">
<label>3. Group</label>

<input ref="/root/grp/grouped-a">
<label>3.1. Grouped a, calculated from #2, readonly</label>
</input>

<input ref="/root/grp/grouped-b">
<label>3.2. Grouped b</label>
</input>
</group>
</h:body>
</h:html>
70 changes: 70 additions & 0 deletions xml-examples/computations/7-readonly-group.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Readonly, group</h:title>
<model>
<instance>
<root id="relevant-calculate-group">
<outer-1>outer-1 default</outer-1>
<grp1>
<a>grp1 a default</a>
<b>grp1 b default</b>
</grp1>
<outer-2>outer-2 default</outer-2>
<grp2>
<a>grp2 a default</a>
<b>grp2 b default</b>
</grp2>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/outer-1" />
<bind nodeset="/root/grp1/a" />
<bind nodeset="/root/grp1/b" readonly="/root/grp1/a = 'grp1 a default'" />
<bind nodeset="/root/outer-2" readonly="true()" />
<bind nodeset="/root/grp2" readonly="/root/grp1/a != 'grp1 a default'" />
<bind nodeset="/root/grp2/a" />
<bind nodeset="/root/grp2/b" readonly="/root/outer-1 = 'outer-1 default'" />
</model>
</h:head>
<h:body>
<input ref="/root/outer-1">
<label>1. First root level question</label>
</input>

<group ref="/root/grp1">
<label>2. Group 1</label>

<input ref="/root/grp1/a">
<label>2.1. Group 1 - a</label>
</input>

<input ref="/root/grp1/b">
<label>2.2. Group 1 - b, readonly if #2.1 is its default value</label>
</input>
</group>

<input ref="/root/outer-2">
<label>3. Second root level question, readonly</label>
</input>

<group ref="/root/grp2">
<label>4. Group 2, readonly if #2.1 is NOT its default value</label>

<input ref="/root/grp2/a">
<label>4.1. Group 2 - a, readonly if parent group is</label>
</input>

<input ref="/root/grp2/b">
<label>4.2. Group 2 - b, readonly if its group is, or if #1 is its default value</label>
</input>
</group>
</h:body>
</h:html>
50 changes: 50 additions & 0 deletions xml-examples/computations/8-outputs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Outputs</h:title>
<model>
<instance>
<root id="outputs">
<a />
<b />
<d>10</d>
<e />
<c>default value of c</c>
<meta>
<instanceID/>
</meta>
</root>
</instance>
<bind nodeset="/root/a" />
<bind nodeset="/root/b" calculate="now()" />
<bind nodeset="/root/c" />
<bind nodeset="/root/d" />
<bind nodeset="/root/e" calculate="/root/d * 2" />
</model>
</h:head>
<h:body>
<input ref="/root/a">
<label>
1. Whoops, accidentally built part of output functionality!
now() calculated by /root/b: <output value="/root/b" />
</label>
</input>
<input ref="/root/d">
<label>/root/d</label>
</input>
<input ref="/root/e">
<label>/root/e</label>
</input>
<input ref="/root/c">
<label>
2. Wonder if calculate also works...
d: <output value="/root/d" />, e (d * 2): <output value="/root/e" />
</label>
</input>
</h:body>
</h:html>
Loading