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
12 changes: 8 additions & 4 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 */; };
F64B1B5B25C300E800A2BB39 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F64B1B5A25C300E800A2BB39 /* GoogleService-Info.plist */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -42,6 +43,7 @@
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>"; };
E7DE9A4430C3A45320910A5E /* Pods_Assignment_Two.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Assignment_Two.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F64B1B5A25C300E800A2BB39 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../Downloads/GoogleService-Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -124,6 +126,7 @@
8EF8F77A2597C7DE000850BF /* Assignment_TwoApp.swift */,
8E35409825B90F1B007B7029 /* RKTaskDelegate.swift */,
8E0A956825B677950025461E /* RKTaskSamples.swift */,
F64B1B5A25C300E800A2BB39 /* 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 */,
F64B1B5B25C300E800A2BB39 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -408,15 +412,15 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Assignment Two/Preview Content\"";
DEVELOPMENT_TEAM = CQRZ4E7K9U;
DEVELOPMENT_TEAM = 8QL2EG96Y4;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "Assignment Two/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.Assignment-Two";
PRODUCT_BUNDLE_IDENTIFIER = "com.chami.cardinalkit-derm";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Assignment Two/Supporting Files/Assignment Two-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -434,15 +438,15 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Assignment Two/Preview Content\"";
DEVELOPMENT_TEAM = CQRZ4E7K9U;
DEVELOPMENT_TEAM = 8QL2EG96Y4;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "Assignment Two/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "edu.stanford.cs342.Assignment-Two";
PRODUCT_BUNDLE_IDENTIFIER = "com.chami.cardinalkit-derm";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Assignment Two/Supporting Files/Assignment Two-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
4 changes: 2 additions & 2 deletions Assignment Two/Assignment_TwoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct Assignment_TwoApp: App {
// (2) open the Auth section
// (3) On the Sign-in Methods page, enable the Anonymous sign-in method.

FirebaseApp.configure()
Auth.auth().signInAnonymously()
FirebaseApp.configure()
Auth.auth().signInAnonymously()

}

Expand Down
137 changes: 132 additions & 5 deletions Assignment Two/RKTaskSamples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,54 @@

import ResearchKit

/**
This file contains some sample `ResearchKit` tasks
that you can modify and use throughout your project!
*/

//struct RKTaskSamples {
//
// /**
// Sample task template!
// */
// static let sampleSurveyTask: ORKOrderedTask = {
// var steps = [ORKStep]()
//
// let booleanAnswer = ORKBooleanAnswerFormat(yesString: "YES!", noString: "Not now") // let for constants that are not changing
// let booleanStep = ORKQuestionStep(identifier: "AreYouReady-Boolean", title: "Before we get started...", question: "Are you ready to take the test?", answer: booleanAnswer)
//
// steps += [booleanStep]
//
// // Formats
// let dateAnswerFormat = ORKDateAnswerFormat(style: .date)
// let numberAnswerFormat = ORKNumericAnswerFormat(style: .integer, unit: nil, minimum: 18 as NSNumber, maximum: 100 as NSNumber)
//
// // Date Form Item
// let dateFromItem = ORKFormItem(identifier: "RegistrationForm-DateQuestion", text: "When did you have surgery?", answerFormat: dateAnswerFormat)
//
// // Age Form Item
// let ageFromItem = ORKFormItem(identifier: "RegistrationForm-Age", text: "How old are you?", answerFormat: numberAnswerFormat)
//
// let formStep = ORKFormStep(identifier: "RegistrationForm", title: "About you", text: "Please take a moment to answer some (very) quick questions!")
//
// formStep.formItems = [dateFromItem, ageFromItem]
// steps += [formStep]
//
// let summaryStep = ORKCompletionStep(identifier: "SummaryStep")
// summaryStep.title = "thank you"
// summaryStep.text = "All done!"
// steps += [summaryStep]
//
// // create navigable rule
// let resultBooleanSelector = ORKResultSelector(resultIdentifier: booleanStep.identifier)
// let predicate = ORKResultPredicate.predicateForBooleanQuestionResult(with: resultBooleanSelector, expectedAnswer: false)
//
// // navigable lets you skip questions, children of ORKOrderedTask
// let task = ORKNavigableOrderedTask(identifier: "SurveyTask-Assessment", steps: steps)
// // if get a false on the boolean step, do the summary step
// let navigableRule = ORKPredicateStepNavigationRule(resultPredicatesAndDestinationStepIdentifiers: [(resultPredicate: predicate, destinationStepIdentifier: summaryStep.identifier)])
// task.setNavigationRule(navigableRule, forTriggerStepIdentifier: booleanStep.identifier)
// return task
// }()
//}


struct RKTaskSamples {

/**
Expand All @@ -24,7 +68,90 @@ struct RKTaskSamples {
CS342 -- ASSIGNMENT 2
Add steps to the array above to create a survey!
*/
// Formats
let answerFormatEmail = ORKAnswerFormat.emailAnswerFormat()
let stringAnswerFormat = ORKTextAnswerFormat()
let dateAnswerFormat = ORKDateAnswerFormat(style: .date)
let numberAnswerFormat = ORKNumericAnswerFormat(style: .integer, unit: nil, minimum: 18 as NSNumber, maximum: 100 as NSNumber)

// Question 1 is getting name, email, and age
let AboutYouFormItem = ORKFormItem(sectionTitle: "Personal information")
let firstNameFormItem = ORKFormItem(identifier: "RegistrationForm-FirstName", text: "First Name", answerFormat: stringAnswerFormat)
let lastNameFormItem = ORKFormItem(identifier: "RegistrationForm-LastName", text: "Last Name", answerFormat: stringAnswerFormat)
let ageFromItem = ORKFormItem(identifier: "RegistrationForm-Age", text: "Age", answerFormat: numberAnswerFormat)
let emailFormItem = ORKFormItem(identifier: "RegistrationForm-Email", text: "Email", answerFormat: answerFormatEmail)
// registration form
let formStep = ORKFormStep(identifier: "RegistrationForm", title: "About you", text: "Before we get started, tell us a little bit about yourself")
formStep.formItems = [AboutYouFormItem, firstNameFormItem, lastNameFormItem, ageFromItem, emailFormItem]
steps += [formStep]

// Question 2 is asking about skin type (oily, combination, dry)
let skinTypes = [
ORKTextChoice(text: "Oily", value: 0 as NSNumber),
ORKTextChoice(text: "Combination", value: 1 as NSNumber),
ORKTextChoice(text: "Dry", value: 2 as NSNumber)
]
let skinTypeAnswerFormat: ORKTextChoiceAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .singleChoice, textChoices: skinTypes)
let skinTypeQuestionStep = ORKQuestionStep(identifier: "SkinTypeQuestionStep", title: "Skin Type", question: "How would you describe your skin?", answer: skinTypeAnswerFormat)
steps += [skinTypeQuestionStep]

// Question 3 is aking about main concern (clogged pores, control breakouts, acne scars)
let skinIssues = [
ORKTextChoice(text: "Control breakouts", value: 0 as NSNumber),
ORKTextChoice(text: "Clean clogged pores", value: 1 as NSNumber),
ORKTextChoice(text: "Reduce acne scars", value: 2 as NSNumber),
ORKTextChoice(text: "Fade dark spots", value: 3 as NSNumber),
ORKTextChoice(text: "Fight wrinkles", value: 4 as NSNumber),
ORKTextChoice(text: "Reduce fine lines", value: 5 as NSNumber),
]
let skinConcernAnswerFormat: ORKTextChoiceAnswerFormat = ORKAnswerFormat.choiceAnswerFormat(with: .multipleChoice, textChoices: skinIssues)
let skinIssuesQuestionStep = ORKQuestionStep(identifier: "SkinIssuesQuestionStep", title: "Goals", question: "What would you like to improve about your skin?", answer: skinConcernAnswerFormat)
steps += [skinIssuesQuestionStep]

// Question 4 is asking about allergies
let booleanAnswer = ORKBooleanAnswerFormat(yesString: "Yes", noString: "No")
let booleanStep = ORKQuestionStep(identifier: "Allergies-Boolean", title: "Allergies", question: "Do you have any allergies?", answer: booleanAnswer)
booleanStep.isOptional = false
steps += [booleanStep]

// if yes then we ask the user to enter them in a text box
let allergiesAnswerFormat = ORKTextAnswerFormat(maximumLength: 200)
allergiesAnswerFormat.multipleLines = true
let allergiesQuestionStep = ORKQuestionStep(identifier: "AllergiesQuestionStep", title: "Allergies", question: "Please describe your allergies.", answer: allergiesAnswerFormat)
steps += [allergiesQuestionStep]

// Question 5 is asking to upload a photo
let instructionStep = ORKInstructionStep(identifier: "imageCaptureInstructionStep")
instructionStep.title = NSLocalizedString("Time to take a selfie", comment: "")
instructionStep.text = "Please take a photo of yourself, position your face as indicated and make sure you have good lighting."
let handSolidImage = UIImage(named: "Portrait")!
instructionStep.image = handSolidImage.withRenderingMode(.alwaysTemplate)
instructionStep.isOptional = false
let imageCaptureStep = ORKImageCaptureStep(identifier: "imageCaptureStep")
imageCaptureStep.title = NSLocalizedString("Image Capture", comment: "")
imageCaptureStep.isOptional = true
imageCaptureStep.accessibilityInstructions = NSLocalizedString("Your instructions for capturing the image", comment: "")
imageCaptureStep.accessibilityHint = NSLocalizedString("Captures the image visible in the preview", comment: "")

imageCaptureStep.templateImage = UIImage(named: "Portrait")!

imageCaptureStep.templateImageInsets = UIEdgeInsets(top: 0.05, left: 0.05, bottom: 0.05, right: 0.05)
steps += [instructionStep, imageCaptureStep]

// Summary step
let summaryStep = ORKCompletionStep(identifier: "SummaryStep")
summaryStep.title = "All done!"
summaryStep.text = "Our AI will review this information and create a customized skincare routine for you!"
steps += [summaryStep]

// create navigable rule for allergy question
let resultBooleanSelector = ORKResultSelector(resultIdentifier: booleanStep.identifier)
let predicate = ORKResultPredicate.predicateForBooleanQuestionResult(with: resultBooleanSelector, expectedAnswer: false)
let navigableRule = ORKPredicateStepNavigationRule(resultPredicatesAndDestinationStepIdentifiers: [(resultPredicate: predicate, destinationStepIdentifier: instructionStep.identifier)])

return ORKOrderedTask(identifier: "SurveyTask-Assessment", steps: steps)
// create task grouping all steps
let task = ORKNavigableOrderedTask(identifier: "SurveyTask-Assessment", steps: steps)
task.setNavigationRule(navigableRule, forTriggerStepIdentifier: booleanStep.identifier)
return task
}()
}
3 changes: 2 additions & 1 deletion Assignment Two/Views/SurveyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
import ResearchKit

struct SurveyView: View {

// Start survey button
@State var taskController: CKTaskViewController? = nil
@State var surveyOptional: ORKOrderedTask? = nil {
didSet {
Expand All @@ -37,6 +37,7 @@ struct SurveyView: View {
*/

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