Shared/Models/DefaultQuestions.swift (4043B)
1import Foundation
2
3
4
5
6
7
8
9enum DefaultQuestions {
10
11 static let idPrefix = "reportage-default-"
12
13
14
15
16 static let seededAt = Date(timeIntervalSince1970: 0)
17
18 static func make() -> [Question] {
19 func question(
20 _ id: String,
21 _ prompt: String,
22 _ kind: QuestionKind,
23 options: [String] = [],
24 askOn: SurveyKinds
25 ) -> Question {
26 Question(
27 id: idPrefix + id,
28 prompt: prompt,
29 kind: kind,
30 options: options,
31 askOn: askOn,
32 order: 0,
33 modifiedAt: seededAt
34 )
35 }
36
37 let questions = [
38 question(
39 "sleep-quality",
40 String(localized: "How did you sleep?", comment: "Default wake question"),
41 .choice,
42 options: [
43 String(localized: "Well", comment: "Answer to 'How did you sleep?'"),
44 String(localized: "Okay", comment: "Answer to 'How did you sleep?'"),
45 String(localized: "Poorly", comment: "Answer to 'How did you sleep?'"),
46 ],
47 askOn: .wake
48 ),
49 question(
50 "activity",
51 String(localized: "What are you doing?", comment: "Default question"),
52 .tokens,
53 askOn: .random
54 ),
55 question(
56 "location",
57 String(localized: "Where are you?", comment: "Default question"),
58 .location,
59 askOn: .random
60 ),
61 question(
62 "people",
63 String(localized: "Who are you with?", comment: "Default question"),
64 .people,
65 askOn: .random
66 ),
67 question(
68 "working",
69 String(localized: "Are you working?", comment: "Default question"),
70 .yesNo,
71 askOn: .random
72 ),
73 question(
74 "mood",
75 String(localized: "How do you feel?", comment: "Default question"),
76 .choice,
77 options: [
78 String(localized: "Great", comment: "Answer to 'How do you feel?'"),
79 String(localized: "Good", comment: "Answer to 'How do you feel?'"),
80 String(localized: "Okay", comment: "Answer to 'How do you feel?'"),
81 String(localized: "Bad", comment: "Answer to 'How do you feel?'"),
82 ],
83 askOn: .random
84 ),
85 question(
86 "coffee",
87 String(
88 localized: "How many coffees did you have today?",
89 comment: "Default bedtime question"),
90 .number,
91 askOn: .bedtime
92 ),
93 question(
94 "learned",
95 String(localized: "What did you learn today?", comment: "Default bedtime question"),
96 .note,
97 askOn: .bedtime
98 ),
99 ]
100 return questions.enumerated().map { index, question in
101 var question = question
102 question.order = index
103 question.narrativeRule = NarrativeRule.builtIn[question.id]
104 return question
105 }
106 }
107}