I'm using the xlsform system to write an ODK survey, and am struggling to
work out how to do the following - any help would be very gratefully
received.
I have two single-select questions using the same choices list. I am
trying to make it the case that the second question will default to the
choice selected for the first question.
For example, if they select 'kilos' for the first question from a list of
possible units of measurement, then the second question will also default
to 'kilos'. But if they select 'grams', the second question will default to
'grams' instead.
Has anyone got a suggestion at what to put in the 'default' column to make
this work?
As far as I know, this is not possible with ODK Collect. If anyone knows
how to do this, please respond to the list, and I will add it to the
documentation.
···
On Thu, Sep 26, 2013 at 3:11 AM, TLG wrote:
Hi,
I'm using the xlsform system to write an ODK survey, and am struggling to
work out how to do the following - any help would be very gratefully
received.
I have two single-select questions using the same choices list. I am
trying to make it the case that the second question will default to the
choice selected for the first question.
For example, if they select 'kilos' for the first question from a list of
possible units of measurement, then the second question will also default
to 'kilos'. But if they select 'grams', the second question will default to
'grams' instead.
Has anyone got a suggestion at what to put in the 'default' column to make
this work?
I know this is an old thread, however still relevent as the issue remain the same.
The root of the problem is, I think, in Java Rosa itself: the default value inside the XML is set in
Desired_default_value
.
Whatever we do, this default value is NOT in a part of the form that is to be dynamically evaluated, therefore any sort of:
${variable_to_use_as_default}
will be seen as just text, not an expression to be evaluated. In order for that to work, we would need to have the default being set in binding, so expressions can be resolved, not directly inside the tags.
Since the Xforms is just based, & converts to, whatever the XML does, then of course in Xforms this won't work either.
There definitely are times when it would be desirable to have a default to be dynamically set, that being said... I guess it's always possible to have it display as a note, but sometimes people don't pay attention after they've been using the form for a while....
This is as close as I could get. It doesn't really do what is needed,
but the technique might be useful for others....
Attached is a form with two selects. Whatever you pick for the first
select will also be the default value for the second select. The catch
here is that the two selects will always be linked. That is, while you
can change the value of the second select, when you save the form,
it'll write over that choice with the value of the first select.
Personally, I think it's a lot cleaner if the form has the user choose
one unit for the entire form, or have them choose a unit for each
measurement.
As far as I know, this is not possible with ODK Collect. If anyone knows how
to do this, please respond to the list, and I will add it to the
documentation.
I'm using the xlsform system to write an ODK survey, and am struggling to
work out how to do the following - any help would be very gratefully
received.
I have two single-select questions using the same choices list. I am
trying to make it the case that the second question will default to the
choice selected for the first question.
For example, if they select 'kilos' for the first question from a list of
possible units of measurement, then the second question will also default to
'kilos'. But if they select 'grams', the second question will default to
'grams' instead.
Has anyone got a suggestion at what to put in the 'default' column to make
this work?
I know this is an old thread, however still relevent as the issue remain the same.
The root of the problem is, I think, in Java Rosa itself: the default value inside the XML is set in
Desired_default_value
.
Whatever we do, this default value is NOT in a part of the form that is to be dynamically evaluated, therefore any sort of:
${variable_to_use_as_default}
will be seen as just text, not an expression to be evaluated. In order for that to work, we would need to have the default being set in binding, so expressions can be resolved, not directly inside the tags.
Since the Xforms is just based, & converts to, whatever the XML does, then of course in Xforms this won't work either.
There definitely are times when it would be desirable to have a default to be dynamically set, that being said... I guess it's always possible to have it display as a note, but sometimes people don't pay attention after they've been using the form for a while....
Just providing some feedback on this topic: Yaw's constraint method for
setting default values based on a previous response appears to work fine,
even with select multi type questions (thanks for the tip, Yaw). There are,
however, a couple of caveats: 1) this doesn't appear to work if you are
using XLSForm and entering ${some_previous_question} in the constraint
column... not sure why though, the syntax seems to be correct in the output
XML file; and 2) this doesn't appear to work in Enketo.
Cheers,
-Ed
···
On Thursday, September 26, 2013 7:35:09 PM UTC-5, Yaw Anokwa wrote:
>
> Mitch,
>
> This is as close as I could get. It doesn't really do what is needed,
> but the technique might be useful for others....
>
> Attached is a form with two selects. Whatever you pick for the first
> select will also be the default value for the second select. The catch
> here is that the two selects will always be linked. That is, while you
> can change the value of the second select, when you save the form,
> it'll write over that choice with the value of the first select.
>
> Personally, I think it's a lot cleaner if the form has the user choose
> one unit for the entire form, or have them choose a unit for each
> measurement.
>
> Yaw
> --
> Need ODK services? http://nafundi.com provides form design,
> professional support, custom reporting, and software development for
> ODK.
>
> On Thu, Sep 26, 2013 at 9:17 AM, Mitch Sundt <mitche...@gmail.com> wrote:
> > As far as I know, this is not possible with ODK Collect. If anyone knows
> how
> > to do this, please respond to the list, and I will add it to the
> > documentation.
> >
> >
> > On Thu, Sep 26, 2013 at 3:11 AM, TLG <theago...@gmail.com > wrote:
> >>
> >> Hi,
> >>
> >> I'm using the xlsform system to write an ODK survey, and am struggling
> to
> >> work out how to do the following - any help would be very gratefully
> >> received.
> >>
> >> I have two single-select questions using the same choices list. I am
> >> trying to make it the case that the second question will default to the
> >> choice selected for the first question.
> >>
> >> For example, if they select 'kilos' for the first question from a list
> of
> >> possible units of measurement, then the second question will also
> default to
> >> 'kilos'. But if they select 'grams', the second question will default
> to
> >> 'grams' instead.
> >>
> >>
> >> Has anyone got a suggestion at what to put in the 'default' column to
> make
> >> this work?
> >>
> >>
> >>
> >> Many thanks
> >>
> >>
> >> TLG
> >>
> >> --
> >> --
> >> Post: opend...@googlegroups.com
> >> Unsubscribe: opendatakit...@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...@googlegroups.com .
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> >
> > --
> > Mitch Sundt
> > Software Engineer
> > University of Washington
> > mitche...@gmail.com
> >
> > --
> > --
> > Post: opend...@googlegroups.com
> > Unsubscribe: opendatakit...@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...@googlegroups.com .
> > For more options, visit https://groups.google.com/groups/opt_out.
>
Just to catch up on this, so it's still not possible to add a default value to single-select widgets based on previous answers?
I tried something rather simple like but it wouldn't work.
if(/data/is_boss=1,/data/respondent_sex)
If the respondent himself / herself is the boss of a company (is_boss) then the previously selected gender (respondent_sex) is the default value for the gender of the boss (boss_sex).
In your specific example, instead of attempting to pre-fillboss_sex with a default respondent_sex when is_boss is true, why don't you simply hide showing the boss_sex select question in this case, because its redundant - you already know the answer - and instead compute the answer with something like:
Thank you @Xiphware for your prompt response.But while changing the first choice during edit it will not change the second list, it remain with the first selection. Any fix?
Thanks
Correct. The second select can only be ‘initialized’ once by this means, so subsequently changing the first to a different value won’t do anything.
You might want to rethink your form logic, bearing in mind that, in reality, there isn’t really a specific ‘order’ to questions... So, for example, if I set Q1, then explicitly changed the selected default in Q2 to something else, then went back and changed Q1, what would be your expected result?
Hi Xiphware,
I have tried to apply your example to my case but the answer for the second gets selected even before my selection and that is also the wrong one.I think that could be due to the if condition.Is there any way out?. Attached the scenario i am trying.selectdefault_ex.xls (26.5 KB)
Thanks
Thank you Xiphaware. As you have seen in the example, I want the final questions to be filled automatically based on the previous response. In the attached file I want a8 and a9 automatically to be filled based on the responses on a7a, a7b and a7sum.selectdefault_sample.xls (29 KB)