Skip to content
This repository was archived by the owner on Dec 22, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Assignment Two.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
8EF8F77D2597C7DE000850BF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EF8F77C2597C7DE000850BF /* ContentView.swift */; };
8EF8F77F2597C7E1000850BF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8EF8F77E2597C7E1000850BF /* Assets.xcassets */; };
8EF8F7822597C7E1000850BF /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8EF8F7812597C7E1000850BF /* Preview Assets.xcassets */; };
E20FD4C925C0F50900101AC5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = E20FD4C825C0F50900101AC5 /* GoogleService-Info.plist */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -41,6 +42,7 @@
8EF8F77E2597C7E1000850BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
8EF8F7812597C7E1000850BF /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
8EF8F7832597C7E1000850BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E20FD4C825C0F50900101AC5 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
E7DE9A4430C3A45320910A5E /* Pods_Assignment_Two.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Assignment_Two.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -124,6 +126,7 @@
8EF8F77A2597C7DE000850BF /* Assignment_TwoApp.swift */,
8E35409825B90F1B007B7029 /* RKTaskDelegate.swift */,
8E0A956825B677950025461E /* RKTaskSamples.swift */,
E20FD4C825C0F50900101AC5 /* GoogleService-Info.plist */,
);
path = "Assignment Two";
sourceTree = "<group>";
Expand Down Expand Up @@ -215,6 +218,7 @@
files = (
8EF8F7822597C7E1000850BF /* Preview Assets.xcassets in Resources */,
8EF8F77F2597C7E1000850BF /* Assets.xcassets in Resources */,
E20FD4C925C0F50900101AC5 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -416,7 +420,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.Assignment-Two";
PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.demo-firebase";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Assignment Two/Supporting Files/Assignment Two-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -442,7 +446,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.Assignment-Two";
PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.demo-firebase";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Assignment Two/Supporting Files/Assignment Two-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
1 change: 1 addition & 0 deletions Assignment Two/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- This should be your Firebase GoogleService-Info.plist file for your particular instance! -->
65 changes: 63 additions & 2 deletions Assignment Two/RKTaskSamples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Copyright © 2019 Stanford University.
// All rights reserved.
//

import ResearchKit

/**
Expand All @@ -25,6 +24,68 @@ struct RKTaskSamples {
Add steps to the array above to create a survey!
*/

return ORKOrderedTask(identifier: "SurveyTask-Assessment", steps: steps)
let booleanAnswer = ORKBooleanAnswerFormat(yesString: "YES!", noString: "Not now")
let booleanStep = ORKQuestionStep(identifier: "AreYouReady-Boolean", title: "Before we get started...", question: "Are you ready to start the test?", answer: booleanAnswer)

steps += [booleanStep]

let dateAnswerFormat = ORKDateAnswerFormat(style: .date)
let numberAnswerFormat = ORKNumericAnswerFormat(style: .integer, unit: nil, minimum: 0 as NSNumber, maximum: 100 as NSNumber)

let ageFormItem = ORKFormItem(identifier: "RegistrationForm-Age", text: "How old are you?", answerFormat: numberAnswerFormat, optional: true)
let dateFormItem = ORKFormItem(identifier: "RegistrationForm-DateQuestion", text: "When did you have surgery?", answerFormat: dateAnswerFormat)

let formStep = ORKFormStep(identifier: "RegistrationForm", title: "About you", text: "Please take a moment to answer some (very) quick questions!")
formStep.formItems = [dateFormItem, ageFormItem]
steps += [formStep]

let summaryStep = ORKCompletionStep(identifier: "SummaryStep")
summaryStep.title = "Thank you."
summaryStep.text = "All done!"
steps += [summaryStep]

let task = ORKNavigableOrderedTask(identifier: "SurveyTask-Assessment", steps: steps)

let resultBooleanSelector = ORKResultSelector(resultIdentifier: booleanStep.identifier)
let predicate = ORKResultPredicate.predicateForBooleanQuestionResult(with: resultBooleanSelector, expectedAnswer: false)
let navigableRule = ORKPredicateStepNavigationRule(resultPredicatesAndDestinationStepIdentifiers: [(predicate, summaryStep.identifier)])
task.setNavigationRule(navigableRule, forTriggerStepIdentifier: booleanStep.identifier)

return task
}()

/**
Sample task template!
*/
static let sampleTappingTask: ORKOrderedTask = {
var steps = [ORKStep]()

/*
CS342 -- ASSIGNMENT 2
Add steps to the array above to create a survey!
*/

let booleanAnswer = ORKBooleanAnswerFormat(yesString: "YES!", noString: "Not now")
let booleanStep = ORKQuestionStep(identifier: "AreYouReady-Boolean", title: "Before we get started...", question: "Are you ready to start the test?", answer: booleanAnswer)

steps += [booleanStep]

// add an active task here
let tappingTask = ORKOrderedTask.twoFingerTappingIntervalTask(withIdentifier: "TappingTask", intendedUseDescription: "Finger tapping is a universal way to communicate.", duration: 5, handOptions: .right, options: ORKPredefinedTaskOption())
steps += tappingTask.steps

let summaryStep = ORKCompletionStep(identifier: "SummaryStep")
summaryStep.title = "Thank you."
summaryStep.text = "All done!"
steps += [summaryStep]

let task = ORKNavigableOrderedTask(identifier: "SurveyTappingTask-Assessment", steps: steps)

let resultBooleanSelector = ORKResultSelector(resultIdentifier: booleanStep.identifier)
let predicate = ORKResultPredicate.predicateForBooleanQuestionResult(with: resultBooleanSelector, expectedAnswer: false)
let navigableRule = ORKPredicateStepNavigationRule(resultPredicatesAndDestinationStepIdentifiers: [(predicate, summaryStep.identifier)])
task.setNavigationRule(navigableRule, forTriggerStepIdentifier: booleanStep.identifier)

return task
}()
}
9 changes: 8 additions & 1 deletion Assignment Two/Views/SurveyView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

//
// SurveyView.swift
// Assignment Two
Expand All @@ -6,7 +7,6 @@
// Copyright © 2019 Stanford University.
// All rights reserved.
//

import SwiftUI
import ResearchKit

Expand Down Expand Up @@ -37,10 +37,17 @@ struct SurveyView: View {
*/

// surveyOptional = /* my ORKOrderedTask */
surveyOptional = RKTaskSamples.sampleSurveyTask
}) {
RoundedTextView("Start Survey", backgroundColor: .red)
}

Button(action: {
surveyOptional = RKTaskSamples.sampleTappingTask
}) {
RoundedTextView("Start Tapping!", backgroundColor: .red)
}

Spacer()
}
.frame(maxWidth: .infinity)
Expand Down