diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..92ec185 Binary files /dev/null and b/.DS_Store differ diff --git a/Assignment Two.xcodeproj/project.pbxproj b/Assignment Two.xcodeproj/project.pbxproj index 90fa3e5..24cd688 100644 --- a/Assignment Two.xcodeproj/project.pbxproj +++ b/Assignment Two.xcodeproj/project.pbxproj @@ -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 */; }; + DA9EF2B325C0F59300FEFD4F /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = DA9EF2B225C0F59200FEFD4F /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -41,6 +42,7 @@ 8EF8F77E2597C7E1000850BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8EF8F7812597C7E1000850BF /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 8EF8F7832597C7E1000850BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B6D8F06825C6B4B700FF31DB /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; name = "GoogleService-Info.plist"; path = "../../../../../Downloads/GoogleService-Info.plist"; sourceTree = ""; }; E7DE9A4430C3A45320910A5E /* Pods_Assignment_Two.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Assignment_Two.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -62,6 +64,7 @@ 8E3540A425B91593007B7029 /* Firebase */, 8E3540A325B9158A007B7029 /* ResearchKit */, 8EF8F77E2597C7E1000850BF /* Assets.xcassets */, + B6D8F06825C6B4B700FF31DB /* GoogleService-Info.plist */, 8EF8F7832597C7E1000850BF /* Info.plist */, 8E35409325B90E7F007B7029 /* Assignment Two-Bridging-Header.h */, ); @@ -124,6 +127,7 @@ 8EF8F77A2597C7DE000850BF /* Assignment_TwoApp.swift */, 8E35409825B90F1B007B7029 /* RKTaskDelegate.swift */, 8E0A956825B677950025461E /* RKTaskSamples.swift */, + DA9EF2B225C0F59200FEFD4F /* GoogleService-Info.plist */, ); path = "Assignment Two"; sourceTree = ""; @@ -214,7 +218,9 @@ buildActionMask = 2147483647; files = ( 8EF8F7822597C7E1000850BF /* Preview Assets.xcassets in Resources */, + DA9EF2B325C0F59300FEFD4F /* GoogleService-Info.plist in Resources */, 8EF8F77F2597C7E1000850BF /* Assets.xcassets in Resources */, + B6D8F06925C6B4B700FF31DB /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -408,7 +414,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"Assignment Two/Preview Content\""; - DEVELOPMENT_TEAM = CQRZ4E7K9U; + DEVELOPMENT_TEAM = FJCDP5WFVN; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "Assignment Two/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -416,7 +422,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.Assignment-Two"; + PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cs342.342a2ksj; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Assignment Two/Supporting Files/Assignment Two-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -434,7 +440,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"Assignment Two/Preview Content\""; - DEVELOPMENT_TEAM = CQRZ4E7K9U; + DEVELOPMENT_TEAM = FJCDP5WFVN; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "Assignment Two/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -442,7 +448,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.Assignment-Two"; + PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cs342.342a2ksj; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Assignment Two/Supporting Files/Assignment Two-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/Assignment Two/.DS_Store b/Assignment Two/.DS_Store new file mode 100644 index 0000000..b59ef75 Binary files /dev/null and b/Assignment Two/.DS_Store differ diff --git a/Assignment Two/Assignment_TwoApp.swift b/Assignment Two/Assignment_TwoApp.swift index 1e84f32..57d36e4 100644 --- a/Assignment Two/Assignment_TwoApp.swift +++ b/Assignment Two/Assignment_TwoApp.swift @@ -34,3 +34,9 @@ struct Assignment_TwoApp: App { } } } + +struct Assignment_TwoApp_Previews: PreviewProvider { + static var previews: some View { + /*@START_MENU_TOKEN@*/Text("Hello, World!")/*@END_MENU_TOKEN@*/ + } +} diff --git a/Assignment Two/GoogleService-Info.plist b/Assignment Two/GoogleService-Info.plist new file mode 100644 index 0000000..e59c9d0 --- /dev/null +++ b/Assignment Two/GoogleService-Info.plist @@ -0,0 +1,34 @@ + + + + + CLIENT_ID + 743900058552-50d418tmmuoftfhhlsg1fmmm99mmpqfc.apps.googleusercontent.com + REVERSED_CLIENT_ID + com.googleusercontent.apps.743900058552-50d418tmmuoftfhhlsg1fmmm99mmpqfc + API_KEY + AIzaSyABySwkvgZziTXsGEsh8EkSdjD-mCr69bA + GCM_SENDER_ID + 743900058552 + PLIST_VERSION + 1 + BUNDLE_ID + edu.stanford.cs342.342a2ksj + PROJECT_ID + a2-4c1e9 + STORAGE_BUCKET + a2-4c1e9.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:743900058552:ios:ed6b81cb0b31727964754d + + \ No newline at end of file diff --git a/Assignment Two/RKTaskSamples.swift b/Assignment Two/RKTaskSamples.swift index c1a92f1..b1c2a6d 100644 --- a/Assignment Two/RKTaskSamples.swift +++ b/Assignment Two/RKTaskSamples.swift @@ -13,11 +13,139 @@ import ResearchKit that you can modify and use throughout your project! */ struct RKTaskSamples { + /** + A2 Steps - Kabir + Credit to Apple's ORKCatalogSample app as a reference for the code used to create the survey below + */ + static let onboardingSurveyTask: ORKOrderedTask = { + var steps = [ORKStep]() + +// 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] + + // About you + // Age + let numberAnswerFormat = ORKNumericAnswerFormat(style: .integer, unit: nil, minimum: 0 as NSNumber, maximum: 120 as NSNumber) + let ageFormItem = ORKFormItem(identifier: "OnboardingForm-Age", text: "How old are you?", answerFormat: numberAnswerFormat, optional: false) + ageFormItem.placeholder = NSLocalizedString("Enter your age here", comment: "") + + // Gender + let genderChoiceOneText = NSLocalizedString("Male", comment: "") + let genderChoiceTwoText = NSLocalizedString("Female", comment: "") + let genderChoiceThreeText = NSLocalizedString("Non-conforming", comment: "") + let genderChoiceFourText = NSLocalizedString("Male Transgender", comment: "") + let genderChoiceFiveText = NSLocalizedString("Female Transgender", comment: "") + let genderChoiceSixText = NSLocalizedString("Other", comment: "") + let genderChoices = [ + ORKTextChoice(text: genderChoiceOneText, value: "male" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: genderChoiceTwoText, value: "female" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: genderChoiceThreeText, value: "non-conforming" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: genderChoiceFourText, value: "male-transgender" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: genderChoiceFiveText, value: "female-transgender" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoiceOther.choice(withText: genderChoiceSixText, detailText: nil, value: "other" as NSCoding & NSCopying & NSObjectProtocol, exclusive: true, textViewPlaceholderText: "Enter text here") + ] + let genderAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: genderChoices) + let genderFormItem = ORKFormItem(identifier: "OnboardingForm-Gender", text: "What is your preferred gender: ", answerFormat: genderAnswerFormat, optional: false) + + // Ethnicity + let ethnicityChoiceOneText = NSLocalizedString("White", comment: "") + let ethnicityChoiceTwoText = NSLocalizedString("Hispanic or Latino", comment: "") + let ethnicityChoiceThreeText = NSLocalizedString("Black or African American", comment: "") + let ethnicityChoiceFourText = NSLocalizedString("Native American or American Indian", comment: "") + let ethnicityChoiceFiveText = NSLocalizedString("Asian/Pacific Islander", comment: "") + let ethnicityChoiceSixText = NSLocalizedString("Other", comment: "") + let ethnicityChoices = [ + ORKTextChoice(text: ethnicityChoiceOneText, value: "white" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: ethnicityChoiceTwoText, value: "hispanic-latino" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: ethnicityChoiceThreeText, value: "black-african-american" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: ethnicityChoiceFourText, value: "native-american-american-indian" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: ethnicityChoiceFiveText, value: "asian-pacific-islander" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoiceOther.choice(withText: ethnicityChoiceSixText, detailText: nil, value: "other" as NSCoding & NSCopying & NSObjectProtocol, exclusive: true, textViewPlaceholderText: "Enter text here") + ] + let ethnicityAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: ethnicityChoices) + let ethnicityFormItem = ORKFormItem(identifier: "OnboardingForm-Ethnicity", text: "Ethnicity", answerFormat: ethnicityAnswerFormat, optional: false) + + let onboardingFormStep = ORKFormStep(identifier: "OnboardingForm", title: "About You", text: "") + onboardingFormStep.formItems = [ageFormItem, genderFormItem, ethnicityFormItem] + steps += [onboardingFormStep] + + // Medical Onboarding Questions + let dateAnswerFormat = ORKDateAnswerFormat(style: .date) + let dateFormItem = ORKFormItem(identifier: "RegistrationForm-DateQuestion", text: "When did you have the surgery?", answerFormat: dateAnswerFormat) + + let diseaseCauseChoiceOneText = NSLocalizedString("Diabetes", comment: "") + let diseaseCauseChoiceTwoText = NSLocalizedString("High Blood Pressure", comment: "") + let diseaseCauseChoiceThreeText = NSLocalizedString("Glomerulonephritis", comment: "") + let diseaseCauseChoiceFourText = NSLocalizedString("Polycystic Kidney Disease", comment: "") + let diseaseCauseChoiceFiveText = NSLocalizedString("Obstruction", comment: "") + let diseaseCauseChoiceSixText = NSLocalizedString("Unknown", comment: "") + let diseaseCauseChoiceSevenText = NSLocalizedString("I do not know", comment: "") + let diseaseCauseChoiceEightText = NSLocalizedString("Other", comment: "") + let diseaseCauseChoices = [ + ORKTextChoice(text: diseaseCauseChoiceOneText, value: "diabetes" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: diseaseCauseChoiceTwoText, value: "high-blood-pressure" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: diseaseCauseChoiceThreeText, value: "glomerulonephritis" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: diseaseCauseChoiceFourText, value: "polycystic-kidney-disease" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: diseaseCauseChoiceFiveText, value: "obstruction" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: diseaseCauseChoiceSixText, value: "unknown" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: diseaseCauseChoiceSevenText, value: "dont-know" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoiceOther.choice(withText: diseaseCauseChoiceEightText, detailText: nil, value: "other" as NSCoding & NSCopying & NSObjectProtocol, exclusive: true, textViewPlaceholderText: "Enter text here") + ] + let diseaseCauseAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: diseaseCauseChoices) + let diseaseCauseFormItem = ORKFormItem(identifier: "MedicalOnboardingForm-Cause", text: "Cause of kidney disease?", answerFormat: diseaseCauseAnswerFormat, optional: false) + + let comorbidities = ["Diabetes", "Hypertension", "Congestive Heart Failure", "COPD", "Other"] + var comorbiditiesChoices = [ORKTextChoice]() + for comorbidity in comorbidities { + let comorbiditiesChoiceText = NSLocalizedString(comorbidity, comment: "") + if comorbidity != "Other" { + let comorbiditiesChoice = ORKTextChoice(text: comorbiditiesChoiceText, value: comorbidity.lowercased().filter {!$0.isWhitespace} as NSCoding & NSCopying & NSObjectProtocol) + comorbiditiesChoices.append(comorbiditiesChoice) + } else { + let comorbiditiesChoice = ORKTextChoiceOther.choice(withText: comorbiditiesChoiceText, detailText: nil, value: comorbidity.lowercased().filter {!$0.isWhitespace} as NSCoding & NSCopying & NSObjectProtocol, exclusive: true, textViewPlaceholderText: "Enter text here") + comorbiditiesChoices.append(comorbiditiesChoice) + } + } +// let comorbiditiesChoiceOneText = NSLocalizedString("Diabetes", comment: "") +// let comorbiditiesChoiceTwoText = NSLocalizedString("Hypertension", comment: "") +// let comorbiditiesChoiceThreeText = NSLocalizedString("Congestive Heart Failure", comment: "") +// let comorbiditiesChoiceFourText = NSLocalizedString("COPD", comment: "") +// let comorbiditiesChoiceFiveText = NSLocalizedString("Other", comment: "") +// let comorbiditiesChoices = [ +// ORKTextChoice(text: comorbiditiesChoiceOneText, value: "diabetes" as NSCoding & NSCopying & NSObjectProtocol), +// ORKTextChoice(text: comorbiditiesChoiceTwoText, value: "choice_2" as NSCoding & NSCopying & NSObjectProtocol), +// ORKTextChoice(text: comorbiditiesChoiceThreeText, value: "choice_3" as NSCoding & NSCopying & NSObjectProtocol), +// ORKTextChoice(text: comorbiditiesChoiceFourText, value: "choice_4" as NSCoding & NSCopying & NSObjectProtocol), +// ORKTextChoiceOther.choice(withText: comorbiditiesChoiceFiveText, detailText: nil, value: "choice_5" as NSCoding & NSCopying & NSObjectProtocol, exclusive: true, textViewPlaceholderText: "Enter text here") +// ] + let comorbiditiesAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .multipleChoice, textChoices: comorbiditiesChoices) + let comorbiditiesFormItem = ORKFormItem(identifier: "MedicalOnboardingForm-Comorbidities", text: "What related conditions (comorbidities) do you have?", answerFormat: comorbiditiesAnswerFormat, optional: false) + + let medicalOnboardingFormStep = ORKFormStep(identifier: "MedicalOnboardingForm", title: "Kidney-Related Medical Questions", text: "") + medicalOnboardingFormStep.formItems = [dateFormItem, diseaseCauseFormItem, comorbiditiesFormItem] + steps += [medicalOnboardingFormStep] + + 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: onboardingFormStep.identifier) + let predicate = ORKResultPredicate.predicateForBooleanQuestionResult(with: resultBooleanSelector, expectedAnswer: true) + let navigableRule = ORKPredicateStepNavigationRule(resultPredicatesAndDestinationStepIdentifiers: [(predicate, summaryStep.identifier)]) + task.setNavigationRule(navigableRule, forTriggerStepIdentifier: onboardingFormStep.identifier) + + return task + }() /** Sample task template! */ - static let sampleSurveyTask: ORKOrderedTask = { + static let sf12SurveyTask: ORKOrderedTask = { var steps = [ORKStep]() /* @@ -25,6 +153,220 @@ struct RKTaskSamples { Add steps to the array above to create a survey! */ - return ORKOrderedTask(identifier: "SurveyTask-Assessment", steps: steps) + // Question 1 + let q1textChoiceOneText = NSLocalizedString("Excellent (1)", comment: "") + let q1textChoiceTwoText = NSLocalizedString("Very Good (2)", comment: "") + let q1textChoiceThreeText = NSLocalizedString("Good (3)", comment: "") + let q1textChoiceFourText = NSLocalizedString("Fair (4)", comment: "") + let q1textChoiceFiveText = NSLocalizedString("Poor (5)", comment: "") + + let q1textChoices = [ + ORKTextChoice(text: q1textChoiceOneText, value: "Excellent (1)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceTwoText, value: "Very Good (2)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceThreeText, value: "Good (3)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceFourText, value: "Fair (4)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceFiveText, value: "Poor (5)" as NSCoding & NSCopying & NSObjectProtocol) + ] + + let q1AnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: q1textChoices) + + let q1QuestionStep = ORKQuestionStep(identifier: "Q1", title: "Question 1", question: "In general, would you say your health is:", answer: q1AnswerFormat) + + q1QuestionStep.isOptional = false + steps += [q1QuestionStep] + + // Question 2 and 3 + let q2q3textChoiceOneText = NSLocalizedString("Yes, Limited A Lot (1)", comment: "") + let q2q3textChoiceTwoText = NSLocalizedString("Yes, Limited A Little (2)", comment: "") + let q2q3textChoiceThreeText = NSLocalizedString("No, Not Limited At All (3)", comment: "") + + let q2q3textChoices = [ + ORKTextChoice(text: q2q3textChoiceOneText, value: "Yes, Limited A Lot (1)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q2q3textChoiceTwoText, value: "Yes, Limited A Little (2)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q2q3textChoiceThreeText, value: "No, Not Limited At All (3)" as NSCoding & NSCopying & NSObjectProtocol) + ] + + let q2q3AnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: q2q3textChoices) + + let q2FormItem = ORKFormItem(identifier: "Q2", text: "MODERATE ACTIVITIES, such as moving a table, pushing a vacuum cleaner, bowling, or playing golf:", answerFormat: q2q3AnswerFormat) + q2FormItem.isOptional = false + + let q3FormItem = ORKFormItem(identifier: "Q3", text: "Climbing SEVERAL flights of stairs:", answerFormat: q2q3AnswerFormat) + q3FormItem.isOptional = false + + + let q2q3FormStep = ORKFormStep(identifier: "q2q3", title: "Questions 2 and 3", text: "The following two questions are about activities you might do during a typical day. Does YOUR HEALTH NOW LIMIT YOU in these activities? If so, how much?") + q2q3FormStep.formItems = [q2FormItem, q3FormItem] + q2q3FormStep.isOptional = false + steps += [q2q3FormStep] + + // Question 4 and 5 + let q4q5textChoiceOneText = NSLocalizedString("Yes (1)", comment: "") + let q4q5textChoiceTwoText = NSLocalizedString("No (2)", comment: "") + + let q4q5textChoices = [ + ORKTextChoice(text: q4q5textChoiceOneText, value: "Yes (1)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q4q5textChoiceTwoText, value: "No (2)" as NSCoding & NSCopying & NSObjectProtocol) + ] + + let q4q5AnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: q4q5textChoices) + + let q4FormItem = ORKFormItem(identifier: "Q4", text: "ACCOMPLISHED LESS than you would like:", answerFormat: q4q5AnswerFormat) + q4FormItem.isOptional = false + + let q5FormItem = ORKFormItem(identifier: "Q5", text: "Were limited in the KIND of work or other activities:", answerFormat: q4q5AnswerFormat) + q5FormItem.isOptional = false + + + let q4q5FormStep = ORKFormStep(identifier: "q4q5", title: "Questions 4 and 5", text: "During the PAST 4 WEEKS have you had any of the following problems with your work or other regular activities AS A RESULT OF YOUR PHYSICAL HEALTH?") + q4q5FormStep.formItems = [q4FormItem, q5FormItem] + q4q5FormStep.isOptional = false + steps += [q4q5FormStep] + + // Question 6 and 7 + let q6q7textChoiceOneText = NSLocalizedString("Yes (1)", comment: "") + let q6q7textChoiceTwoText = NSLocalizedString("No (2)", comment: "") + + let q6q7textChoices = [ + ORKTextChoice(text: q6q7textChoiceOneText, value: "Yes (1)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q6q7textChoiceTwoText, value: "No (2)" as NSCoding & NSCopying & NSObjectProtocol) + ] + + let q6q7AnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: q6q7textChoices) + + let q6FormItem = ORKFormItem(identifier: "Q6", text: "ACCOMPLISHED LESS than you would like:", answerFormat: q6q7AnswerFormat) + q6FormItem.isOptional = false + + let q7FormItem = ORKFormItem(identifier: "Q7", text: "Didn’t do work or other activities as CAREFULLY as usual:", answerFormat: q6q7AnswerFormat) + q7FormItem.isOptional = false + + + let q6q7FormStep = ORKFormStep(identifier: "q6q7", title: "Questions 6 and 7", text: "During the PAST 4 WEEKS, were you limited in the kind of work you do or other regular activities AS A RESULT OF ANY EMOTIONAL PROBLEMS (such as feeling depressed or anxious)?") + q6q7FormStep.formItems = [q6FormItem, q7FormItem] + q6q7FormStep.isOptional = false + steps += [q6q7FormStep] + + // Question 8 + let q8textChoiceOneText = NSLocalizedString("Not At All (1)", comment: "") + let q8textChoiceTwoText = NSLocalizedString("A Little Bit (2)", comment: "") + let q8textChoiceThreeText = NSLocalizedString("Moderately (3)", comment: "") + let q8textChoiceFourText = NSLocalizedString("Quite A Bit (4)", comment: "") + let q8textChoiceFiveText = NSLocalizedString("Extremely (5)", comment: "") + + let q8textChoices = [ + ORKTextChoice(text: q1textChoiceOneText, value: "Not At All (1)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceTwoText, value: "A Little Bit (2)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceThreeText, value: "Moderately (3)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceFourText, value: "Quite A Bit (4)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q1textChoiceFiveText, value: "Extremely (5)" as NSCoding & NSCopying & NSObjectProtocol) + ] + + let q8AnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: q8textChoices) + + let q8QuestionStep = ORKQuestionStep(identifier: "Q8", title: "Question 8", question: "During the PAST 4 WEEKS, how much did PAIN interfere with your normal work (including both work outside the home and housework)?", answer: q8AnswerFormat) + + q8QuestionStep.isOptional = false + steps += [q8QuestionStep] + + // Question 9, 10, and 11 + let q9q10q11textChoiceOneText = NSLocalizedString("All of the Time (1)", comment: "") + let q9q10q11textChoiceTwoText = NSLocalizedString("Most of the Time (2)", comment: "") + let q9q10q11textChoiceThreeText = NSLocalizedString("A Good Bit of the Time (3)", comment: "") + let q9q10q11textChoiceFourText = NSLocalizedString("Some of the Time (4)", comment: "") + let q9q10q11textChoiceFiveText = NSLocalizedString("A Little of the Time (5)", comment: "") + let q9q10q11textChoiceSixText = NSLocalizedString("None of the Time (6)", comment: "") + + let q9q10q11textChoices = [ + ORKTextChoice(text: q9q10q11textChoiceOneText, value: "All of the Time (1)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceTwoText, value: "Most of the Time (2)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceThreeText, value: "A Good Bit of the Time (3)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceFourText, value: "Some of the Time (4)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceFiveText, value: "A Little of the Time (5)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceSixText, value: "None of the Time (6)" as NSCoding & NSCopying & NSObjectProtocol) + ] + + let q9q10q11AnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: q9q10q11textChoices) + + let q9FormItem = ORKFormItem(identifier: "Q9", text: "Have you felt calm and peaceful?", answerFormat: q9q10q11AnswerFormat) + q6FormItem.isOptional = false + + let q10FormItem = ORKFormItem(identifier: "Q10", text: "Did you have a lot of energy?", answerFormat: q9q10q11AnswerFormat) + q10FormItem.isOptional = false + + let q11FormItem = ORKFormItem(identifier: "Q11", text: "Have you felt downhearted and blue?", answerFormat: q9q10q11AnswerFormat) + q11FormItem.isOptional = false + + + let q9q10q11FormStep = ORKFormStep(identifier: "q9q10q11", title: "Questions 9, 10, and 11", text: "The next three questions are about how you feel and how things have been DURING THE PAST 4 WEEKS. For each question, please give the one answer that comes closest to the way you have been feeling. How much of the time during the PAST 4 WEEKS –") + q9q10q11FormStep.formItems = [q9FormItem, q10FormItem, q11FormItem] + q9q10q11FormStep.isOptional = false + steps += [q9q10q11FormStep] + + // Question 12 + let q12textChoiceOneText = NSLocalizedString("All of the Time (1)", comment: "") + let q12textChoiceTwoText = NSLocalizedString("Most of the Time (2)", comment: "") + let q12textChoiceThreeText = NSLocalizedString("A Good Bit of the Time (3)", comment: "") + let q12textChoiceFourText = NSLocalizedString("Some of the Time (4)", comment: "") + let q12textChoiceFiveText = NSLocalizedString("A Little of the Time (5)", comment: "") + let q12textChoiceSixText = NSLocalizedString("None of the Time (6)", comment: "") + + let q12textChoices = [ + ORKTextChoice(text: q9q10q11textChoiceOneText, value: "All of the Time (1)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceTwoText, value: "Most of the Time (2)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceThreeText, value: "A Good Bit of the Time (3)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceFourText, value: "Some of the Time (4)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceFiveText, value: "A Little of the Time (5)" as NSCoding & NSCopying & NSObjectProtocol), + ORKTextChoice(text: q9q10q11textChoiceSixText, value: "None of the Time (6)" as NSCoding & NSCopying & NSObjectProtocol) + ] + + let q12AnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: q12textChoices) + + let q12QuestionStep = ORKQuestionStep(identifier: "Q12", title: "Question 12", question: "During the PAST 4 WEEKS, how much of the time has your PHYSICAL HEALTH OR EMOTIONAL PROBLEMS interfered with your social activities (like visiting with friends, relatives, etc.)? ", answer: q12AnswerFormat) + + q12QuestionStep.isOptional = false + steps += [q12QuestionStep] + + // Summary step + let summaryStep = ORKCompletionStep(identifier: "SummaryStep") + summaryStep.title = "Thank you." + summaryStep.text = "All done!" + steps += [summaryStep] + + let task = ORKNavigableOrderedTask(identifier: "SurveyTask-Assessment", steps: steps) + return task + }() + + static let gaitAndBalanceTask: ORKOrderedTask = { + var steps = [ORKStep]() + + // Gait and Balance Task + let gaitAndBalanceTask = ORKOrderedTask.shortWalk(withIdentifier: "GaitAndBalance", intendedUseDescription: "This task will require you to walk a short distance for a fixed number for steps.", numberOfStepsPerLeg: 20, restDuration: 20, options: ORKPredefinedTaskOption()) + steps += gaitAndBalanceTask.steps + + // Summary step + let summaryStep = ORKCompletionStep(identifier: "ActiveSummaryStep") + summaryStep.title = "Thank you." + summaryStep.text = "All done!" + steps += [summaryStep] + + let task = ORKNavigableOrderedTask(identifier: "SurveyActiveTasks-Assessment", steps: steps) + return task + }() + + static let timedWalkTask: ORKOrderedTask = { + var steps = [ORKStep]() + + // Timed Walk Task + let walkTask = ORKOrderedTask.timedWalk(withIdentifier: "TimedWalk", intendedUseDescription: "This task will require you to walk a short distance for a fixed amount of time.", distanceInMeters: 100.0, timeLimit: 180.0, turnAroundTimeLimit: 180.0, includeAssistiveDeviceForm: true, options: ORKPredefinedTaskOption()) + steps += walkTask.steps + + // Summary step + let summaryStep = ORKCompletionStep(identifier: "ActiveSummaryStep") + summaryStep.title = "Thank you." + summaryStep.text = "All done!" + steps += [summaryStep] + + let task = ORKNavigableOrderedTask(identifier: "SurveyActiveTasks-Assessment", steps: steps) + return task }() } diff --git a/Assignment Two/Supporting Files/.DS_Store b/Assignment Two/Supporting Files/.DS_Store new file mode 100644 index 0000000..6618df3 Binary files /dev/null and b/Assignment Two/Supporting Files/.DS_Store differ diff --git a/Assignment Two/Views/RoundedTextView.swift b/Assignment Two/Views/RoundedTextView.swift index df6950d..5e24f2b 100644 --- a/Assignment Two/Views/RoundedTextView.swift +++ b/Assignment Two/Views/RoundedTextView.swift @@ -33,3 +33,9 @@ struct RoundedTextView: View { } } + +struct RoundedTextView_Previews: PreviewProvider { + static var previews: some View { + /*@START_MENU_TOKEN@*/Text("Hello, World!")/*@END_MENU_TOKEN@*/ + } +} diff --git a/Assignment Two/Views/SurveyView.swift b/Assignment Two/Views/SurveyView.swift index bdbc6b2..93191f1 100644 --- a/Assignment Two/Views/SurveyView.swift +++ b/Assignment Two/Views/SurveyView.swift @@ -37,10 +37,30 @@ struct SurveyView: View { */ // surveyOptional = /* my ORKOrderedTask */ + surveyOptional = RKTaskSamples.sf12SurveyTask }) { - RoundedTextView("Start Survey", backgroundColor: .red) + RoundedTextView("Start SF-12 Survey", backgroundColor: .red) } + Button(action: { + + surveyOptional = RKTaskSamples.gaitAndBalanceTask + }) { + RoundedTextView("Start Gait and Balance Task", backgroundColor: .red) + } + + Button(action: { + + surveyOptional = RKTaskSamples.timedWalkTask + }) { + RoundedTextView("Start Timed Walk Task", backgroundColor: .red) + } + + Button(action: { + surveyOptional = RKTaskSamples.onboardingSurveyTask + }) { + RoundedTextView("Start Onboarding Survey", backgroundColor: .red) + } Spacer() } .frame(maxWidth: .infinity)