Is it possible to create a conditional constraint? Example
For question 2:
If (question 1 = "Some Choice 1") constraint=". < 10"
If (question 1 = "Some Choice 2") constraint=". < 25"
Is it possible to create a conditional constraint? Example
For question 2:
If (question 1 = "Some Choice 1") constraint=". < 10"
If (question 1 = "Some Choice 2") constraint=". < 25"
yes, but we need to update the javarosa-libraries in collect 1.1.7
before you can use it.
i expect this will happen before the final release. if you need it
today, you have to build the core yourself. the thread at
https://groups.google.com/d/msg/javarosa-developers/eEAyytjIeS4/NUxYgTb1UowJ
should help.
the syntax is
Hi there!
I am still trying to figure out if it is possible to create a conditional constraint, and if yes, how? I want toi achieve the exact same thing -
For question 2:
If (question 1 = "Choice 1") constraint=". < 10"
If (question 1 != "Choice 1") constraint=". < 25"
The method by Yaw does not work me. Any help is really appreciated.
Thanks.
Try
((previous question = choice 1) and (. < 10)) or ((previous question = choice 2) and (. < 25))
Note that this assumes that you only have two choices that are possible when you ask the current question. If there are other choices you won't be a will to pass this constraint. So you may need to add additional conditions for what happens with those other choices
On Aug 2, 2013, at 11:25 PM, "basant7@gmail.com" basant7@gmail.com wrote:
Hi there!
I am still trying to figure out if it is possible to create a conditional constraint, and if yes, how? I want toi achieve the exact same thing -
For question 2:
If (question 1 = "Choice 1") constraint=". < 10"
If (question 1 != "Choice 1") constraint=". < 25"The method by Yaw does not work me. Any help is really appreciated.
Thanks.
On Friday, January 11, 2013 12:38:19 AM UTC+5:30, lmacdona....@gmail.com wrote:
On Wednesday, October 12, 2011 6:16:00 PM UTC-4, Yaw Anokwa wrote:
yes, but we need to update the javarosa-libraries in collect 1.1.7
before you can use it.i expect this will happen before the final release. if you need it
today, you have to build the core yourself. the thread at
https://groups.google.com/d/msg/javarosa-developers/eEAyytjIeS4/NUxYgTb1UowJ
should help.the syntax is
On Wed, Oct 12, 2011 at 09:46, jpknoll jpknoll@gmail.com wrote:
Is it possible to create a conditional constraint? Example
For question 2:
If (question 1 = "Some Choice 1") constraint=". < 10"
If (question 1 = "Some Choice 2") constraint=". < 25"--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=enGreat tip. I thought of Yaw's solution as well and tried it. However, I found that this doesn't behave exactly as expected.
While filling out a form, a wrong answer returns the error message that it should. This is true for all possible wrong answers, the first time I put them into a survey. But when I changed a wrong answer to a different type of wrong answer, which should trigger a different error message, then the same error message is returned.
Please see the documentation of the features available in the underlying
XML form description here: http://opendatakit.org/help/form-design/
and particularly the documentation here:
for the available functions for doing this.
The documentation for XLSForm is much more limited (
http://opendatakit.org/help/form-design/xlsform/ ) but the sample form
contains some good examples of formulas (
http://opendatakit.org/wp-content/uploads/2013/06/sample_xlsform.xls )
Try
((previous question = choice 1) and (. < 10)) or ((previous question =
choice 2) and (. < 25))Note that this assumes that you only have two choices that are possible
when you ask the current question. If there are other choices you won't be
a will to pass this constraint. So you may need to add additional
conditions for what happens with those other choices
Luke
On Aug 2, 2013, at 11:25 PM, "basant7@gmail.com" basant7@gmail.com wrote:
Hi there!
I am still trying to figure out if it is possible to create a
conditional constraint, and if yes, how? I want toi achieve the exact same
thing -For question 2:
If (question 1 = "Choice 1") constraint=". < 10"
If (question 1 != "Choice 1") constraint=". < 25"The method by Yaw does not work me. Any help is really appreciated.
Thanks.
On Friday, January 11, 2013 12:38:19 AM UTC+5:30, lmacdona....@gmail.comwrote:
On Wednesday, October 12, 2011 6:16:00 PM UTC-4, Yaw Anokwa wrote:
yes, but we need to update the javarosa-libraries in collect 1.1.7
before you can use it.i expect this will happen before the final release. if you need it
today, you have to build the core yourself. the thread athttps://groups.google.com/d/msg/javarosa-developers/eEAyytjIeS4/NUxYgTb1UowJ
should help.
the syntax is
On Wed, Oct 12, 2011 at 09:46, jpknoll jpknoll@gmail.com wrote:
Is it possible to create a conditional constraint? Example
For question 2:
If (question 1 = "Some Choice 1") constraint=". < 10"
If (question 1 = "Some Choice 2") constraint=". < 25"--
Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=enGreat tip. I thought of Yaw's solution as well and tried it. However,
I found that this doesn't behave exactly as expected.While filling out a form, a wrong answer returns the error message that
it should. This is true for all possible wrong answers, the first time I
put them into a survey. But when I changed a wrong answer to a different
type of wrong answer, which should trigger a different error message, then
the same error message is returned.--
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.
--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com
Hi, I am reviving this because I have not been able to find a reliable solution yet.
My scenario is quite similar to @jpknoll's but I have more than 2 choices that should affect the constraint in the subsequent question. i.e.
For question 2:
If (question 1 = "Some Choice 1") constraint=". < 10"
If (question 1 = "Some Choice 2") constraint=". < 25"
.
.
If (question 1 = "Some Choice n") constraint=". < x"
What is the correct XLSForm syntax to achieve this?
Have you tried the previously posted solution?:
((${previous question} = 'choice 1') and (. < 10)) or ((${previous question} = 'choice 2') and (. < 25)) or ...
This should work if you just add whatever additional 'or' clauses needed.
Thank you, the solution you shared worked for my scenario: more than two viable options in the previous questions each creating a different constraint on the question to be constrained.
Yes, I had tried the solution but since the author mentioned that the constraint wouldn't work if you have more than two choices in the previous question, (yet that is my exact scenario), I was unable to expand it to accommodate my needs.
Once again, Thank you
Glad is working for you. It’s worth noting that, at the end of the day, these constraints are just XPath expressions, and as such can be arbitrarily complex and contains references to as many different results as you like. If the expression returns true then the ‘constraint’ (whatever that may imply) is met, otherwise it’s not.