如何使用Research Kit创建多选答案格式? [英] How to create multiple choice answer format using Research Kit?

查看:136
本文介绍了如何使用Research Kit创建多选答案格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Research Kit创建多选答案格式。我知道我必须使用 ORKTextChoiceAnswerFormat 但无法找到一些代码。任何机构可以帮助?


解决方案

  // BOOL问题1个
ORKBooleanAnswerFormat * boolFormat = [ORKBooleanAnswerFormat new];
ORKQuestionStep * booleanStep1 = [[ORKQuestionStep alloc] initWithIdentifier:@identifierQ1];
booleanStep1.title = @你感觉不适吗?;
booleanStep1.answerFormat = boolFormat;
booleanStep1.optional = NO;


//选择问题1
ORKTextChoiceAnswerFormat *选择= [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@ @ 咳嗽,@ 喉咙痛,@流鼻涕或鼻塞]];
ORKQuestionStep * multipleStep = [[ORKQuestionStep alloc] initWithIdentifier:@identifierC1];
multipleStep.title = @您觉得下面有任何症状吗?;
multipleStep.answerFormat = choice;
multipleStep.optional = NO;


// bool问题2
ORKQuestionStep * booleanStep2 = [[ORKQuestionStep alloc] initWithIdentifier:@identifierQ2];
booleanStep2.title = @你觉得眼睛有问题吗?;
booleanStep2.answerFormat = boolFormat;
booleanStep2.optional = NO;

//选择问题2
ORKTextChoiceAnswerFormat *选择2 = [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@ [@ 眼睛发红,@ 眼痒,@放电(通常为水样或mucous-喜欢,@感觉眼睛里有沙子。,@眼睑结痂。]];
ORKQuestionStep * multipleStep2 = [[ORKQuestionStep alloc] initWithIdentifier:@identifierC2];
multipleStep2.title = @您觉得下面有任何症状吗?;
multipleStep2.answerFormat = choice2;
multipleStep2.optional = NO;

// bool问题3
ORKQuestionStep * booleanStep3 = [[ORKQuestionStep alloc] initWithIdentifier:@identifierQ3];
booleanStep3.title = @你觉得肚子有问题吗?;
booleanStep3.answerFormat = boolFormat;
booleanStep3.optional = NO;


//选择问题3
ORKTextChoiceAnswerFormat * choice3 = [ORKTextChoiceAnswerFormat choiceAnswerFormatWithStyle:ORKChoiceAnswerStyleMultipleChoice textChoices:@ [@Diarrhea,@Abdominal Pain,@Nausea,@ 呕吐]];
ORKQuestionStep * multipleStep3 = [[ORKQuestionStep alloc] initWithIdentifier:@identifierC3];
multipleStep3.title = @您觉得下面有任何症状吗?;
multipleStep3.answerFormat = choice3;
multipleStep3.optional = NO;


//呈现任务视图控制器。
ORKOrderedTask *任务=
[[ORKOrderedTask的alloc] initWithIdentifier:@ identifier8 步骤:@ [booleanStep1,multipleStep,booleanStep2,multipleStep2,booleanStep3,multipleStep3]];
ORKTaskViewController * taskViewController =
[[ORKTaskViewController alloc] initWithTask:task taskRunUUID:nil];
taskViewController.delegate = self;
[self presentViewController:taskViewController animated:YES completion:nil];


How to create multiple choice answer format using Research Kit. I know I have to useORKTextChoiceAnswerFormat but unable to find some code. Can any body help ?

解决方案

// 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];

这篇关于如何使用Research Kit创建多选答案格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆