Shared/Models/Question.swift (1973B)
1import Foundation
2
3
4
5struct Question: Hashable, Sendable {
6
7
8 var id: String
9 var prompt: String
10 var kind: QuestionKind
11
12 var options: [String] = []
13 var placeholder: String?
14
15 var narrativeRule: NarrativeRule?
16
17 var askOn: SurveyKinds
18
19
20 var order: Int
21
22
23 var showsInTimeline = true
24 var archivedAt: Date?
25 var modifiedAt: Date
26}
27
28enum QuestionKind: String, Codable, Sendable, CaseIterable {
29 case yesNo
30 case choice
31 case tokens
32 case people
33 case location
34 case number
35 case note
36}
37
38
39
40struct SurveyKinds: OptionSet, Hashable, Sendable {
41 let rawValue: Int16
42
43 static let random = SurveyKinds(rawValue: 1 << 0)
44 static let wake = SurveyKinds(rawValue: 1 << 1)
45 static let bedtime = SurveyKinds(rawValue: 1 << 2)
46
47 static let all: SurveyKinds = [.random, .wake, .bedtime]
48
49
50 init(surveyFor kind: ReportKind) {
51 switch kind {
52 case .random, .manual: self = .random
53 case .wake: self = .wake
54 case .bedtime: self = .bedtime
55 }
56 }
57
58 init(rawValue: Int16) {
59 self.rawValue = rawValue
60 }
61}