How to create multiple choice answer format using Research Kit? [closed]

妖精的绣舞 提交于 2019-11-29 09:01:38
// bool Question 1
ORKBooleanAnswerFormat *boolFormat = [ORKBooleanAnswerFormat new];
ORKQuestionStep *booleanStep1 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierQ1"];
booleanStep1.title = @"Are you feeling ill?";
booleanStep1.answerFormat = boolFormat;
booleanStep1.optional = NO;


// choice Question1
ORKTextChoiceAnswerFormat *choice =  [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@[@"Cough",@"Sore throat",@"Runny or stuffy nose"]];
ORKQuestionStep *multipleStep = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierC1"];
multipleStep.title = @"Do you feel any symptoms given below?";
multipleStep.answerFormat = choice;
multipleStep.optional = NO;


// bool Question 2
ORKQuestionStep *booleanStep2 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierQ2"];
booleanStep2.title = @"Do you feel problem in your eye?";
booleanStep2.answerFormat = boolFormat;
booleanStep2.optional = NO;

// choice Question2
ORKTextChoiceAnswerFormat *choice2 =  [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@[@"Eye Redness",@"Eye Itching",@"Discharge (usually watery or mucous-like)",@"Feels like there is sand in the eye.",@"Crusting over of the eyelid."]];
ORKQuestionStep *multipleStep2 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierC2"];
multipleStep2.title = @"Do you feel any symptoms given below?";
multipleStep2.answerFormat = choice2;
multipleStep2.optional = NO;

// bool Question 3
ORKQuestionStep *booleanStep3 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierQ3"];
booleanStep3.title = @"Do you feel problem in your stomach?";
booleanStep3.answerFormat = boolFormat;
booleanStep3.optional = NO;


// choice Question3
ORKTextChoiceAnswerFormat *choice3 =  [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@[@"Diarrhea",@"Abdominal Pain",@"Nausea",@"Vomiting"]];
ORKQuestionStep *multipleStep3 = [[ORKQuestionStep alloc] initWithIdentifier:@"identifierC3"];
multipleStep3.title = @"Do you feel any symptoms given below?";
multipleStep3.answerFormat = choice3;
multipleStep3.optional = NO;


 // Present the task view controller.
ORKOrderedTask *task =
[[ORKOrderedTask alloc] initWithIdentifier:@"identifier8" steps:@[booleanStep1,multipleStep,booleanStep2,multipleStep2,booleanStep3,multipleStep3]];
ORKTaskViewController *taskViewController =
[[ORKTaskViewController alloc] initWithTask:task taskRunUUID:nil];
taskViewController.delegate = self;
[self presentViewController:taskViewController animated:YES completion:nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!