displaying output value of repeat group position

34 views
Skip to first unread message

lameez

unread,
Nov 30, 2017, 9:24:10 AM11/30/17
to commcare-users
Hi,

I've tried making sense of CommCare's guidelines on the position function of repeat questions, but I'm getting lost. 

Our survey asks farmers about the number of fields planted with maize. Then for each field, we ask for location and distance. At its basic level, this structure has worked. But there are a few things more I'd like to achieve with these repeat group questions.

1. Show enumerators which field # they are entering data for i.e. where they are in the repeat group loop. 
  • The repeat group (after the repeat count question) starts with a label question asking enumerators to fill in data for each of the farmer's fields. 
  • I would like to change this so that it states "Please fill in data for Field 1", with the number changing automatically for each loop of the repeat group.
A) Do I just add <output value="position(..) +1" /> directly to the repeat group label question text? 

B) Or do I first create a hidden value outside the repeat group with <output value="position(..) +1" /> entered into the default value box, and then reference this hidden value in the label question text?

C) If I do B, should I then make several repeat group questions referencing each field # separately (basically defeating the purpose of a repeat group), or will the output value referenced in label update field # automatically as it moves through each position?


2.  Display output value of field location & distance for specific field outside repeat group
  • Enumerators are required to randomly select a field (using a dice app) which they will visit with the farmer at the end of the survey
  • I would like to show them the location and distance of the randomly selected field
This is how I think it could work:

Step 1 - Create hidden value questions for the location and distance (separately) of each field up to set maximum number of fields (in this case its 5 fields, so 10 hidden value questions)

Step 2 - Enter the output values for location and distance in the default value box for each field

Step 3 - Have enumerator enter the selected field number (e.g. field #2) in a separate question (id: random_field)

Step 4 - Add a label question that shows location and distance of selected field using output from hidden values with a display condition using the output of random field selected:

This field's location is <output / hidden value for field #2 location>
This field is <output / hidden value for field #2 distance> .
Please ask the farmer to take you to this field.

A) Is this the correct way to display the output value of a repeat group question for a specific position?

B) What do I enter as the default value in the hidden value questions (in Step 2)?

C) What do I enter in the label question showing the location and distance of specific field selected (in Step 4)?


3. Changing initial input value for repeat count question (number of fields)
  • I know there's a workaround for this and if I understand it correctly it should be structured as below
  • Would this work?
-- Repeat count (# of fields)
   -- Repeat group question label (possibly with output value for field position as in Q1 above)
       -- Group question with display condition position(..) < /data/repeat_count
          -- Repeat question 1
          -- Repeat question 2 etc.

Thanks for the help!

Lameez

PS> If there's a CommCare staffer reading this, it would be so great if CommCare could start providing videos for these more complicated / advanced features showing how its done step-by-step. So much easier to understand than reading technical documentation.









Reply all
Reply to author
Forward
0 new messages