From 94fbd3a6d1ff58ad03c42ae0a7cc11d5a0795764 Mon Sep 17 00:00:00 2001 From: vtourraine Date: Wed, 6 Jan 2016 16:47:29 +0100 Subject: [PATCH] Add includeAssistiveDeviceForm parameter to timed walk task Make timed walk assistive device form items non-optional --- ResearchKit/Common/ORKOrderedTask.h | 17 ++++++++++------- ResearchKit/Common/ORKOrderedTask.m | 6 +++++- Testing/ORKTest/ORKTest/MainViewController.m | 1 + samples/ORKCatalog/ORKCatalog/TaskListRow.swift | 2 +- .../ORKCatalog/Tasks/TaskListRow.swift | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ResearchKit/Common/ORKOrderedTask.h b/ResearchKit/Common/ORKOrderedTask.h index 769e9445..3b7456c8 100644 --- a/ResearchKit/Common/ORKOrderedTask.h +++ b/ResearchKit/Common/ORKOrderedTask.h @@ -452,13 +452,15 @@ typedef NS_OPTIONS(NSUInteger, ORKPredefinedTaskOption) { Data collected by the task is in the form of an `ORKTimedWalkResult` object. - @param identifier The task identifier to use for this task, appropriate to the study. - @param intendedUseDescription A localized string describing the intended use of the data - collected. If the value of this parameter is `nil`, the default - localized text is displayed. - @param distanceInMeters The timed walk distance in meters. - @param timeLimit The time limit to complete the trials. - @param options Options that affect the features of the predefined task. + @param identifier The task identifier to use for this task, appropriate to the study. + @param intendedUseDescription A localized string describing the intended use of the data + collected. If the value of this parameter is `nil`, the default + localized text is displayed. + @param distanceInMeters The timed walk distance in meters. + @param timeLimit The time limit to complete the trials. + @param includeAssistiveDeviceForm A Boolean value that indicates whether to inlude the form step + about the usage of an assistive device. + @param options Options that affect the features of the predefined task. @return An active Timed Walk task that can be presented with an `ORKTaskViewController` object. */ @@ -466,6 +468,7 @@ typedef NS_OPTIONS(NSUInteger, ORKPredefinedTaskOption) { intendedUseDescription:(nullable NSString *)intendedUseDescription distanceInMeters:(double)distanceInMeters timeLimit:(NSTimeInterval)timeLimit + includeAssistiveDeviceForm:(BOOL)includeAssistiveDeviceForm options:(ORKPredefinedTaskOption)options; /** diff --git a/ResearchKit/Common/ORKOrderedTask.m b/ResearchKit/Common/ORKOrderedTask.m index 8b78a2a0..40e9d9d1 100644 --- a/ResearchKit/Common/ORKOrderedTask.m +++ b/ResearchKit/Common/ORKOrderedTask.m @@ -992,6 +992,7 @@ void ORKStepArrayAddStep(NSMutableArray *array, ORKStep *step) { intendedUseDescription:(nullable NSString *)intendedUseDescription distanceInMeters:(double)distanceInMeters timeLimit:(NSTimeInterval)timeLimit + includeAssistiveDeviceForm:(BOOL)includeAssistiveDeviceForm options:(ORKPredefinedTaskOption)options { NSMutableArray *steps = [NSMutableArray array]; @@ -1013,7 +1014,7 @@ void ORKStepArrayAddStep(NSMutableArray *array, ORKStep *step) { } } - { + if (includeAssistiveDeviceForm) { ORKFormStep *step = [[ORKFormStep alloc] initWithIdentifier:ORKTimedWalkFormStepIdentifier title:ORKLocalizedString(@"TIMED_WALK_FORM_TITLE", nil) text:ORKLocalizedString(@"TIMED_WALK_FORM_TEXT", nil)]; @@ -1022,6 +1023,7 @@ void ORKStepArrayAddStep(NSMutableArray *array, ORKStep *step) { ORKFormItem *formItem1 = [[ORKFormItem alloc] initWithIdentifier:ORKTimedWalkFormAFOStepIdentifier text:ORKLocalizedString(@"TIMED_WALK_QUESTION_TEXT", nil) answerFormat:answerFormat1]; + formItem1.optional = NO; NSArray *textChoices = @[ORKLocalizedString(@"TIMED_WALK_QUESTION_2_CHOICE", nil), ORKLocalizedString(@"TIMED_WALK_QUESTION_2_CHOICE_2", nil), @@ -1034,6 +1036,8 @@ void ORKStepArrayAddStep(NSMutableArray *array, ORKStep *step) { text:ORKLocalizedString(@"TIMED_WALK_QUESTION_2_TITLE", nil) answerFormat:answerFormat2]; formItem2.placeholder = ORKLocalizedString(@"TIMED_WALK_QUESTION_2_TEXT", nil); + formItem2.optional = NO; + step.formItems = @[formItem1, formItem2]; step.optional = NO; diff --git a/Testing/ORKTest/ORKTest/MainViewController.m b/Testing/ORKTest/ORKTest/MainViewController.m index 9ad2c0d5..1a60bec3 100644 --- a/Testing/ORKTest/ORKTest/MainViewController.m +++ b/Testing/ORKTest/ORKTest/MainViewController.m @@ -531,6 +531,7 @@ static const CGFloat HeaderSideLayoutMargin = 16.0; intendedUseDescription:nil distanceInMeters:100 timeLimit:180 + includeAssistiveDeviceForm:YES options:ORKPredefinedTaskOptionNone]; } else if ([identifier isEqualToString:HolePegTestTaskIdentifier]) { return [ORKNavigableOrderedTask holePegTestTaskWithIdentifier:HolePegTestTaskIdentifier diff --git a/samples/ORKCatalog/ORKCatalog/TaskListRow.swift b/samples/ORKCatalog/ORKCatalog/TaskListRow.swift index e12a0072..a9b24c25 100644 --- a/samples/ORKCatalog/ORKCatalog/TaskListRow.swift +++ b/samples/ORKCatalog/ORKCatalog/TaskListRow.swift @@ -646,7 +646,7 @@ enum TaskListRow: Int, Printable { /// This task presents the Timed Walk pre-defined active task. private var timedWalkTask: ORKTask { - return ORKOrderedTask.timedWalkTaskWithIdentifier(String(Identifier.TimedWalkTask), intendedUseDescription: exampleDescription, distanceInMeters: 100.0, timeLimit: 180.0, options: []) + return ORKOrderedTask.timedWalkTaskWithIdentifier(String(Identifier.TimedWalkTask), intendedUseDescription: exampleDescription, distanceInMeters: 100.0, timeLimit: 180.0, includeAssistiveDeviceForm: true, options: []) } /// This task presents the Hole Peg Test pre-defined active task. diff --git a/samples/ORKCatalog/ORKCatalog/Tasks/TaskListRow.swift b/samples/ORKCatalog/ORKCatalog/Tasks/TaskListRow.swift index 4ca58b49..d929790c 100644 --- a/samples/ORKCatalog/ORKCatalog/Tasks/TaskListRow.swift +++ b/samples/ORKCatalog/ORKCatalog/Tasks/TaskListRow.swift @@ -1157,7 +1157,7 @@ enum TaskListRow: Int, CustomStringConvertible { /// This task presents the Timed Walk pre-defined active task. private var timedWalkTask: ORKTask { - return ORKOrderedTask.timedWalkTaskWithIdentifier(String(Identifier.TimedWalkTask), intendedUseDescription: exampleDescription, distanceInMeters: 100.0, timeLimit: 180.0, options: []) + return ORKOrderedTask.timedWalkTaskWithIdentifier(String(Identifier.TimedWalkTask), intendedUseDescription: exampleDescription, distanceInMeters: 100.0, timeLimit: 180.0, includeAssistiveDeviceForm: true, options: []) } /// This task presents the Tone Audiometry pre-defined active task.