You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was hoping to get some help in understanding a ResearchKit concept.
Navigable Task Question
I was looking at different things one can do with Research Kit and came across the Navigable Task based on the various answer responses; for example, ORKPredicateStepNavigationRule. The first information for ORKPredicateStepNavigationRule I found though uses a method in which each individual question for an ORKTextChoice is its own steps += [], as opposed to the code I have below called Choices1 where the steps are contained within a single form (as seen with the ORKTextChoice):
//Choices1
static let choiceIdentifier = "choice"
static let choiceFormIdentifier = "choice.form"
static let ChoiceQuestion1Step = "checkin.form.choicequestion1"
static let ChoiceQuestionStep = "checkin.form.Choice"
static func Choices1() -> ORKTask {
let Choices = [
ORKTextChoice(text: "None", value: 0 as NSNumber),
ORKTextChoice(text: "Slight", value: 1 as NSNumber),
ORKTextChoice(text: "Mild", value: 2 as NSNumber),
ORKTextChoice(text: "Severe", value: 3 as NSNumber),
]
let choiceAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(
with: .singleChoice,
textChoices: Choices
)
let choiceStep = ORKFormItem(
identifier: ChoiceQuestion1Step,
text: "Text question goes here",
answerFormat: choiceAnswerFormat
)
choiceStep.isOptional = false
let formStep = ORKFormStep(
identifier: choiceFormIdentifier,
title: "Choice Question",
text: "Instructions for questions"
)
formStep.formItems = [choiceStep]
formStep.isOptional = false
let choiceTask = ORKOrderedTask(
identifier: choiceIdentifier,
steps: [formStep]
)
return choiceTask
}
What I am trying to understand is in the absence of having steps += for each individual question (not as a form), is it possible to use the ORKPredicateStepNavigationRule within the above Choices1 form and depending on the question response to an ORKTextChoice in the Choices1 the user will be redirected to another form (Choices2 below)?
For example, looking at the modified code below, you see that I have added Choices2 as an additional form to the original code from above. What I am looking to do is make it so when a person where to select ORKTextChoice(text: "None", value: 0 as NSNumber), they will be sent automatically to the Choices2 form and could fill out an additional series of questions.
//Choices1
static let choiceIdentifier = "choice"
static let choiceFormIdentifier = "choice.form"
static let ChoiceQuestion1Step = "checkin.form.choicequestion1"
static let ChoiceQuestionStep = "checkin.form.Choice"
static func Choices1() -> ORKTask {
let Choices = [
ORKTextChoice(text: "None", value: 0 as NSNumber),
ORKTextChoice(text: "Slight", value: 1 as NSNumber),
ORKTextChoice(text: "Mild", value: 2 as NSNumber),
ORKTextChoice(text: "Severe", value: 3 as NSNumber),
]
let choiceAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(
with: .singleChoice,
textChoices: Choices
)
let choiceStep = ORKFormItem(
identifier: ChoiceQuestion1Step,
text: "Text question goes here",
answerFormat: choiceAnswerFormat
)
choiceStep.isOptional = false
let formStep = ORKFormStep(
identifier: choiceFormIdentifier,
title: "Choice Question",
text: "Instructions for questions"
)
formStep.formItems = [choiceStep]
formStep.isOptional = false
let choiceTask = ORKOrderedTask(
identifier: choiceIdentifier,
steps: [formStep]
)
return choiceTask
}
// Choices2
static let choice2Identifier = "choice2"
static let choice2FormIdentifier = "choice2.form"
static let Choice2Question1Step = "checkin.form.choice2question1"
static let Choice2QuestionStep = "checkin.form.Choice2"
static func Choices2() -> ORKTask {
let Choices2 = [
ORKTextChoice(text: "None", value: 0 as NSNumber),
ORKTextChoice(text: "Slight", value: 1 as NSNumber),
ORKTextChoice(text: "Mild", value: 2 as NSNumber),
ORKTextChoice(text: "Severe", value: 3 as NSNumber),
]
let choiceAnswerFormat2 = ORKAnswerFormat.choiceAnswerFormat(
with: .singleChoice,
textChoices: Choices2
)
let choice2Step = ORKFormItem(
identifier: Choice2Question1Step,
text: "Text question goes here",
answerFormat: choiceAnswerFormat2
)
choice2Step.isOptional = false
let form2Step = ORKFormStep(
identifier: choice2FormIdentifier,
title: "Choice Question",
text: "Instructions for questions"
)
form2Step.formItems = [choices2Step]
form2Step.isOptional = false
let choice2Task = ORKOrderedTask(
identifier: choice2Identifier,
steps: [form2Step]
)
return choiceTask
}
I thought that doing something like this inside of the Choices1 code would work, but doesn't seem to be:
let choicePredicate = ORKResultPredicate.predicateForBooleanQuestionResult(with: ORKResultSelector(resultIdentifier: ChoiceQuestion1Step), expectedAnswer: (0 != 0))
let predicatedNavigationRule = ORKPredicateStepNavigationRule(resultPredicates: [choicePredicate], destinationStepIdentifiers: [choice2Task])
task.setNavigationRule(predicatedNavigationRule, forTriggerStepIdentifier: ChoiceQuestion1Step)
I have a feeling that because I am working with two forms and if I put the ORKResultPredicate.predicateForBooleanQuestionResult inside Choices1, for whatever reason cannot see the form of Choices2.
Am I close and on the right track? Can someone help me better understand how this works, please? I hope this makes sense, please let me know if you need any clarification - I'd be grateful for any direction!
Thank you!
The text was updated successfully, but these errors were encountered:
Hello everyone!
I was hoping to get some help in understanding a ResearchKit concept.
Navigable Task Question
I was looking at different things one can do with Research Kit and came across the Navigable Task based on the various answer responses; for example,
ORKPredicateStepNavigationRule.
The first information forORKPredicateStepNavigationRule
I found though uses a method in which each individual question for anORKTextChoice
is its ownsteps += []
, as opposed to the code I have below calledChoices1
where the steps are contained within a single form (as seen with theORKTextChoice
):What I am trying to understand is in the absence of having
steps +=
for each individual question (not as a form), is it possible to use theORKPredicateStepNavigationRule
within the aboveChoices1
form and depending on the question response to anORKTextChoice
in theChoices1
the user will be redirected to another form (Choices2
below)?For example, looking at the modified code below, you see that I have added
Choices2
as an additional form to the original code from above. What I am looking to do is make it so when a person where to selectORKTextChoice(text: "None", value: 0 as NSNumber)
, they will be sent automatically to theChoices2
form and could fill out an additional series of questions.I thought that doing something like this inside of the
Choices1
code would work, but doesn't seem to be:I have a feeling that because I am working with two forms and if I put the
ORKResultPredicate.predicateForBooleanQuestionResult
insideChoices1
, for whatever reason cannot see the form ofChoices2
.Am I close and on the right track? Can someone help me better understand how this works, please? I hope this makes sense, please let me know if you need any clarification - I'd be grateful for any direction!
Thank you!
The text was updated successfully, but these errors were encountered: