I started learning how to program surveys in XLS form a couple of days ago
and I'd really appreciate your help.
I would like to repeat a set of questions through a preloaded list of names.
Below is what I am trying to do;
···
---
type name label choice_filter repeat_count relevance calculation calculate
n_members
pulldata('list_members','n_members','district_key',${district}) calculate
name1 pulldata('list_members','name1','district_key',${district})
calculate name2
pulldata('list_members','name2','district_key',${district})
calculate name3
pulldata('list_members','name3','district_key',${district})
calculate name4
pulldata('list_members','name4','district_key',${district})
calculate name5
pulldata('list_members','name5','district_key',${district})
begin group section_1 Section 1: Member Evaluation begin repeat
section_1_repeat ${n_members} select_one yes_no q1_1 Have you ever
interacted with ${name1}?
Each district has a certain number of members (<= 5) and I would like to
loop a group of questions from name1 to name5.
So once all the questions are asked about ${name1}, I'd like to ask the
same set of questions about ${name2}.
Is there a way to change ${name1} to the next name - ${name2} - when the
repeat ends?
I want to do this within the loop (begin repeat - end repeat) because there
are more than 20 members in some districts, and I'd rather avoid writing
the same questions 20 times using relevance etc.
I think the easiest way to do this is to move the name questions
inside the loop and make ${nameN} relevant when position(..) = N. The
idea here is to make a particular name relevant based on the loop
counter.
Then make an ${all_names} calculate variable that concatenates all the
${nameN} variables. I believe this should only show a single name
because of the relevancy that comes from position.
Finally, change the questions that refer to ${name} in an output to
refer to ${all_names}. If you are still getting every name printed,
then you might have to use selected-at(${all_names}, position(..)) in
another calculate to get the right name. The caveat with selected-at
is it'll only work if there are no spaces in the name.
All this is totally untested, so no guarantees it'll work. It should
give you a reasonable head start though. Give it a try...
Yaw
···
--
Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.
I started learning how to program surveys in XLS form a couple of days ago
and I'd really appreciate your help.
I would like to repeat a set of questions through a preloaded list of names.
Below is what I am trying to do;
type name label choice_filter repeat_count relevance calculation
calculate n_members
pulldata('list_members','n_members','district_key',${district})
calculate name1
pulldata('list_members','name1','district_key',${district})
calculate name2
pulldata('list_members','name2','district_key',${district})
calculate name3
pulldata('list_members','name3','district_key',${district})
calculate name4
pulldata('list_members','name4','district_key',${district})
calculate name5
pulldata('list_members','name5','district_key',${district})
begin group section_1 Section 1: Member Evaluation
begin repeat section_1_repeat ${n_members}
select_one yes_no q1_1 Have you ever interacted with ${name1}?
Each district has a certain number of members (<= 5) and I would like to
loop a group of questions from name1 to name5.
So once all the questions are asked about ${name1}, I'd like to ask the same
set of questions about ${name2}.
Is there a way to change ${name1} to the next name - ${name2} - when the
repeat ends?
I want to do this within the loop (begin repeat - end repeat) because there
are more than 20 members in some districts, and I'd rather avoid writing the
same questions 20 times using relevance etc.