ResearchKit / AppCore

Core code shared by the initial ResearchKit apps.
Other
262 stars 82 forks source link

Support multi-choice logic in APCSmartSurvey #126

Closed ghost closed 9 years ago

ghost commented 9 years ago

Issues

  1. APCSmartSurveyTask does not support skipping to the end of the survey, only skipping to another question identifier.
  2. APCSmartSurveyTask does not support conditionally skipping based on combination answers to multi-choice questions. For example, "Did you consume alcohol, medication, and / or caffeine today?". In this case we wish to skip to questions asking only about the amount of consumption of each drug taken.

    Actions

    • Add logic in APCSmartSurveyTask to end the task if the rule "end" is written in json as follows: "rules": [ { "skipTo": "end", "type": "SurveyRule" } ] },
    • Support conditional logic of multiple choices by OR'ing the integer values of selections in a reduceChoiceAnswers method. Note: Values defined in json for choices should be of type integer and expressed in binary like this:
         "enumeration": [
                           {
                           "label": "Caffeine",
                           "value": 1,
                           "type": "SurveyQuestionOption"
                           },
                           {
                           "label": "Alcohol",
                           "value": 10,
                           "type": "SurveyQuestionOption"
                           },
                           {
                           "label": "Medication",
                           "value": 100,
                           "type": "SurveyQuestionOption"
                           }
                           ],

    Tests

    • Tested by writing a json survey where "allowMultiple":true, "dataType": "integer", APCGenericSurveyTaskViewController is the taskClassName, and "skipTo":"end" is used as a rule to direct the task to end the survey.
    • Tested multiple-choice questions in Breast Cancer to ensure this change has no effect on string data type multi-choice questions.

      Notes

@insha @jwarmkessel @Erin-Mounts @peculiar @PacificCoaster