I am trying to create a form that will ask a series of questions and then at the end will ask the user if the questions should be repeated again for a new entity. If the user answers ‘yes’ then the questions should be repeated and a new instance of the answers should be recorded (and at the end the user should be asked again if they want the questions to be repeated again). If the user answers no, then the form should complete without repeating any more questions.
To do this, I was hoping to use the repeat
block and the dynamic repeat_count
logic similar to what was described here. Unfortunately, I cannot seem to get this functionality to work with the CHT.
I tried using the exact data from the linked example and I got some obscure XPath error. For some reason it did not seem to like references to the
${plant}
repeat block name. This needs some more investigation, and perhaps a discussion in a separate thread.
type | name | label | calculation | repeat_count |
---|---|---|---|---|
calculate | count | 1 + sum(${more_plants_count}) | ||
begin_repeat | plant | Plant | ${count} | |
text | species | Species | ||
integer | estimated_size | Estimated size | ||
select_one yes_no | more_plants | Are there more plants in this area? | ||
calculate | more_plants_count | if(${more_plants} = ‘yes’, 1, 0) | ||
end_repeat |
With this config, my form will ask for the information about one plant species and then will end the repeat block regardless of what my answer is to the more_plants
question.
Can anyone see something wrong with my logic or suggest an alternate way to achieve this functionality? Is this a known gap in the CHT functionality? Thank you!