【问题标题】:How to create multiple choice answer format using Research Kit? [closed]如何使用研究工具包创建多项选择答案格式? [关闭]
【发布时间】:2015-12-04 05:43:41
【问题描述】:

如何使用研究工具包创建多项选择答案格式。我知道我必须使用ORKTextChoiceAnswerFormat,但找不到一些代码。任何机构都可以帮忙吗?

【问题讨论】:

    标签: ios objective-c researchkit


    【解决方案1】:
    // 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];
    

    【讨论】:

      猜你喜欢
      • 2015-06-19
      • 1970-01-01
      • 2013-09-24
      • 1970-01-01
      • 2013-09-19
      • 2021-07-04
      • 1970-01-01
      • 2015-09-17
      相关资源
      最近更新 更多