Pulling responses in the previous question to be used as a value set in the follow up questions

Dear colleagues, I’m having challenging programming this part in kobo. I have provided a modified part of the questionnaire. Your assistance will be appreciated.

  1. How familiar are you with each of the following letters in the context of sustainable development? Please select a response for each LETTER.
    COLUMNS
  1. Very familiar
  2. Somewhat familiar
  3. Not very familiar
  4. I have never heard of it

ROWS [RANDOMIZE]
1). A
2). B
3). C
4). D
5). E

IF RESPONDENT IS NOT SOMEWHAT FAMILIAR OR VERY FAMILIAR WITH ANY OF THE LETTERS IN Q20, END THE INTERVIEW.

  1. Using a 10-point scale where ‘1’ means “does not describe at all” and ‘10’ means “describes completely,” please rate each statement on how well it describes each of the following LETTERS.

LETTER SELECTION FOR Q25
IF VERY/SOMEWHAT FAMILIAR WITH UNDP IN Q20, SELECT THAT AS ONE LETTER.
CHOOSE REMAINING LETTERS (UP TO 3 TOTAL) IF VERY OR SOMEWHAT FAMILIAR WITH IN Q20 ON A LEAST FILL BASIS. DO NOT CHOOSE ANY LETTERS NOT “VERY OR SOMEWHAT FAMILIAR” WITH IN Q20.
RANDOMIZE WHICH LETTER OF THE THREE IS ASSIGNED TO LETTER 1, 2, 3.

PROGRAMMING NOTE: RATE ALL LETTERS ON A GIVEN ATTRIBUTE BEFORE MOVING TO NEXT ATTRIBUTE.

LETTERS

  1. LETTER 1
  2. LETTER 2
  3. LETTER 3
    ATTRIBUTES (RANDOMIZE)
  4. Brings stakeholders together
  5. Can mobilize quickly in times of crisis (e.g., natural disasters, war)
  6. Communicates its goals and accomplishments effectively
  7. Delivers long-term, sustainable solutions
  8. Has a clear focus
  9. Has a long track record of success
  10. Has experts on the global priorities that are important to me/my LETTER
  11. Has proved its worth as a partner
  12. Has strong problem-solving skills when confronting evolving global priorities
  13. Helps create secure, productive and just communities
  14. Improves the lives of the most vulnerable
  15. Is an LETTER I trust
  16. Is collaborative
  17. Is effective in achieving results
  18. Is endorsed by people and LETTERS that I trust
  19. Uses new technologies to solve complex problems
  20. Operates in the country(ies)/region(s) that I care about
  21. Understands the big picture to solve interconnected issues
  22. Uses/collaborates with local counterparts to address community priorities
  1. Which, if any, of the following LETTERS do you/your LETTER consider to be a partner of choice to work on critical sustainable development challenges? Please check all that apply. MULTIPLE RESPONSE
    INSERT LETTERS VERY OR SOMEWHAT FAMILIAR WITH IN Q20. MAINTAIN LETTER ORDER FROM Q20. INCLUDE “NONE OF THE ABOVE”

Its not entirely clear from your form definition what you are trying to accomplish, but from the subject title - “Pulling responses in the previous question to be used as a value set in the follow up questions” - this sounds very much like what is called a cascading select.

Cascading select questions are sets of questions whose options depend on the response to a previous question.

Please review the above best-practices doc and perhaps post a followup if there is additional information you need.

1 Like

Okay. Here is an example, suppose in q20 I say I very familiar with letter A, somewhat family with letter B, not very familiar with letter C and D, and I have never heard of letter E. This means q25, asking about the attributes(for each letter), should ONLY apply to letters A and B (the letters I’m very and somewhat familiar with). So these two letters A and B to be automatically selected in q25 and q26. I’m not sure how to go about programming this, even with the article on cascading. I hope it is much clearer now. Thank you.

Sorry for the delay in responding; this was a bit trickier than I first imagined.

As I understand it, you are presenting a predetermined list of letters - say A, B, C, D, E - to the user, and for each letter asking them to rank their ‘familiarity’ with that letter, on a range of “Very familiar” vs “Somewhat familiar” vs “Not very familiar” vs “Never heard of it”. Then, presenting only those letters that the user indicated either ‘Very’ or “Somewhat familiar” for a subsequent selection.

So the first task is to present the list of all the letters, using a repeat group whose number of iterations matches the number of letters/options. For this you can use a trick where the number of repeat iterations is a count of the number of ‘nodes’ in the XForms instance containing the letters choice list:

repeat_count = count(instance('letters')/root/item)

[in order to ensure the letters are correctly populated into the resulting XForm I’m using them in a hidden select_multiple question. Otherwise, if you have a choice list defined in your XLSForm but which isnt actually used directly by any questions, then the choice-list basically gets removed as an optimism by pyxform incorrectly thinking it’s superfluous…]

Then within the repeat group you can display each of the letters and ask the user for their familiarity with each. You have to use a few more XForm tricks to get at the name and label of each letter option, based on what iteration (ie pos) of the loop you happen to be in:

pos = position(..)
letter_name = instance('letters')/root/item[position()=${pos}]/name
letter_label = jr:choice-name(${letter_name}, '${hidden_select}')

At the end of the repeat you can accumulate all the letters from the repeat where the user has specified a familiarity of at least “Somewhat familiar” (ie criteria >= 2). These letters are put into a space-separated string (you’ll see why in a second…) using the join() function. This string basically now contains a list of all the letters that the user has indicated they are familiar with.

final_selection = join(' ', ${all_letters}[criteria >= 2]/letter_name)

choice_filter = selected(${final_selection},name)

Finally, you can then use this list as specfically-designed choice-filter against all the original letters to display only letters that the user is familiar with. In my example this ‘familiar list’ is used in a followup select_multiple question, but it could just as easily be used for a select_one or something else.

SelectFromRepeat.xlsx (16.0 KB)

Important: this form behaves as expected when run under Collect; however it seems to misbehave when run under Enketo. Specifically, although all the calculations remain valid - particularly the all-important join() that accumulates the familiar letters out of the repeat - it seems this calculation is not correctly triggered in Enketo for re-evaluation whenever the user answers a new criteria question. Possibly this is due to the slightly different logic that Enketo follows for determining when to perform recalculations when things change.

Anyway, I haven’t been able to get this working correctly for Enketo [I tried, hence the delay in responding…]. But please have a go with it under Collect and see if you can adapt it to your needs.

1 Like

Thank you very much. I saw what you are talking about here. The challenge is the expected respondents are coming from diverse institutions. And we are not sure if they will using the web or collect (whether they will be using android devices or not) for responding to the survey. Hence, we need the Enketo to work as it does under Collect.