ODK2.0: Resetting values in IF block to empty based on conditional logic automatically in ODK Survey

Hello ODK Developers,

I have the attached ODK Survey form which have 3 questions in which two of
them depend on the answer of the first question. I put the two questions
under IF block and whenever I answered "No" for the first question the two
questions in the IF block will be escaped. But the problem arises when I
answered for the first question “Yes” and fill out some data for the two
questions in the IF block and get back to the first question and answered
“No” again. The two questions will still have their data maintained and
saved in the database. Is it possible to automatically reset the values of
the two questions in the IF block to empty if the answer for the first
question is "No"?

Many thanks,

Pomi

form.xlsx (15.4 KB)

Yes. see attached.

A straightforward solution is to add an else clause and use the assign
operators to set the 'what' and 'when' fields to null.

However, if a user navigates strangely through your form (e.g. selects a
yes_no value, but goes backward, then uses the contents menu to jump to
another question), there is a possibility that the fields will not be
cleared because the if...else...end if might have been skipped.

To prevent that from happening, you can force the assign to occur on the
screen with the yes_no question. Use the begin screen ... end screen and
place the logic for clearing the value within that screen.

The moment the user selects one of the yes_no questions, the screen is
redrawn (to display the user's new choice), causing the statements to be
executed to clear the values.

This is a bit harsh should the user toggle the value -- it forcibly clears
the 'what' and 'when' values at that time, rather than waiting for the user
to commit to the change by moving forward.

An alternative would be to put this assign logic onto a different screen
with a question that is required only when these values should be cleared.

form_modified.xlsx (15.6 KB)

··· On Thu, Sep 3, 2015 at 11:06 PM, Pomi Daniel wrote:

Hello ODK Developers,

I have the attached ODK Survey form which have 3 questions in which two of
them depend on the answer of the first question. I put the two questions
under IF block and whenever I answered "No" for the first question the two
questions in the IF block will be escaped. But the problem arises when I
answered for the first question “Yes” and fill out some data for the two
questions in the IF block and get back to the first question and answered
“No” again. The two questions will still have their data maintained and
saved in the database. Is it possible to automatically reset the values of
the two questions in the IF block to empty if the answer for the first
question is "No"?

Many thanks,

Pomi

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

I'd like to add just a few more points. The keyword "when" is reserved and
will need to change. Also, a model worksheet can be helpful in a survey
like this to clarify prompt types and names. I've modified Mitch's example
with these changes.

Clarice

testForm.xlsx (13.5 KB)

··· On Fri, Sep 4, 2015 at 9:33 AM, Mitch Sundt wrote:

Yes. see attached.

A straightforward solution is to add an else clause and use the assign
operators to set the 'what' and 'when' fields to null.

However, if a user navigates strangely through your form (e.g. selects a
yes_no value, but goes backward, then uses the contents menu to jump to
another question), there is a possibility that the fields will not be
cleared because the if...else...end if might have been skipped.

To prevent that from happening, you can force the assign to occur on the
screen with the yes_no question. Use the begin screen ... end screen and
place the logic for clearing the value within that screen.

The moment the user selects one of the yes_no questions, the screen is
redrawn (to display the user's new choice), causing the statements to be
executed to clear the values.

This is a bit harsh should the user toggle the value -- it forcibly clears
the 'what' and 'when' values at that time, rather than waiting for the user
to commit to the change by moving forward.

An alternative would be to put this assign logic onto a different screen
with a question that is required only when these values should be cleared.

On Thu, Sep 3, 2015 at 11:06 PM, Pomi Daniel pomi144@gmail.com wrote:

Hello ODK Developers,

I have the attached ODK Survey form which have 3 questions in which two
of them depend on the answer of the first question. I put the two questions
under IF block and whenever I answered "No" for the first question the two
questions in the IF block will be escaped. But the problem arises when I
answered for the first question “Yes” and fill out some data for the two
questions in the IF block and get back to the first question and answered
“No” again. The two questions will still have their data maintained and
saved in the database. Is it possible to automatically reset the values of
the two questions in the IF block to empty if the answer for the first
question is "No"?

Many thanks,

Pomi

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Many thanks Mitch and Clarice. This answers my question.

··· On Friday, September 4, 2015 at 9:02:13 PM UTC+3, clarice larson wrote: > > I'd like to add just a few more points. The keyword "when" is reserved > and will need to change. Also, a model worksheet can be helpful in a > survey like this to clarify prompt types and names. I've modified Mitch's > example with these changes. > > Clarice > > On Fri, Sep 4, 2015 at 9:33 AM, Mitch Sundt <mitche...@gmail.com > wrote: > >> Yes. see attached. >> >> A straightforward solution is to add an else clause and use the assign >> operators to set the 'what' and 'when' fields to null. >> >> However, if a user navigates strangely through your form (e.g. selects a >> yes_no value, but goes backward, then uses the contents menu to jump to >> another question), there is a possibility that the fields will not be >> cleared because the if...else...end if might have been skipped. >> >> To prevent that from happening, you can force the assign to occur on the >> screen with the yes_no question. Use the begin screen ... end screen and >> place the logic for clearing the value within that screen. >> >> The moment the user selects one of the yes_no questions, the screen is >> redrawn (to display the user's new choice), causing the statements to be >> executed to clear the values. >> >> This is a bit harsh should the user toggle the value -- it forcibly >> clears the 'what' and 'when' values at that time, rather than waiting for >> the user to commit to the change by moving forward. >> >> An alternative would be to put this assign logic onto a different screen >> with a question that is required only when these values should be cleared. >> >> >> >> On Thu, Sep 3, 2015 at 11:06 PM, Pomi Daniel <pom...@gmail.com > wrote: >> >>> Hello ODK Developers, >>> >>> I have the attached ODK Survey form which have 3 questions in which two >>> of them depend on the answer of the first question. I put the two questions >>> under IF block and whenever I answered "No" for the first question the two >>> questions in the IF block will be escaped. But the problem arises when I >>> answered for the first question “Yes” and fill out some data for the two >>> questions in the IF block and get back to the first question and answered >>> “No” again. The two questions will still have their data maintained and >>> saved in the database. Is it possible to automatically reset the values of >>> the two questions in the IF block to empty if the answer for the first >>> question is "No"? >>> >>> >>> Many thanks, >>> >>> >>> Pomi >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "ODK Developers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to opendatakit-developers+unsubscribe@googlegroups.com >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Mitch Sundt >> Software Engineer >> University of Washington >> mitche...@gmail.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "ODK Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to opendatakit-developers+unsubscribe@googlegroups.com >> . >> For more options, visit https://groups.google.com/d/optout. >> > >