Difference between revisions of "Relevance Condition to Multiple Fields"
Kbjarkefur (talk | contribs) |
|||
Line 1: | Line 1: | ||
== Best Practice == | == Best Practice == | ||
There are ways to apply the same relevance code to multiple fields without copying a code. Copying the same code to a couple of fields could be OK depending on personal preference, but copying to 5 or more fields should always be avoided as it increases the likelihood of making programming mistakes. | |||
A questionnaire coded like this will be much easier to be updated during the development phase or during the field work where there is little time as many other tasks are keeping the project team pre-occupied. | It is recommended to use a begin group field to apply the same relevance code to all the field inside the group. Then, the code relevance is indicated '''only''' for the begin group field and there is no need to repeat it for all the fields concerned by this code relevance. A questionnaire coded like this will be much easier to be updated during the development phase or during the field work where there is little time as many other tasks are keeping the project team pre-occupied. | ||
In general, using begin groups field in a programming form avoids the repetition of codes and makes the whole survey easy to read and to understand. | |||
== Code example == | == Code example == |
Revision as of 16:08, 25 January 2018
Best Practice
There are ways to apply the same relevance code to multiple fields without copying a code. Copying the same code to a couple of fields could be OK depending on personal preference, but copying to 5 or more fields should always be avoided as it increases the likelihood of making programming mistakes.
It is recommended to use a begin group field to apply the same relevance code to all the field inside the group. Then, the code relevance is indicated only for the begin group field and there is no need to repeat it for all the fields concerned by this code relevance. A questionnaire coded like this will be much easier to be updated during the development phase or during the field work where there is little time as many other tasks are keeping the project team pre-occupied.
In general, using begin groups field in a programming form avoids the repetition of codes and makes the whole survey easy to read and to understand.
Code example
Here is a code example that shows how a group is used so that the relevance condition does not have to be applied to each field inside the group.
Note that there is no problem to have a field to be required that is not always shown. Required mean that if the field is displayed then data needs to be recorded for this field before the enumerator is allowed to swipe pass this question.
Back to Parent
This article is part of the topic SurveyCTO Coding Practices