1
+ package ivy.learn
2
+
3
+ import kotlinx.serialization.SerialName
4
+ import kotlinx.serialization.Serializable
5
+ import kotlin.jvm.JvmInline
6
+
7
+ @Serializable
8
+ data class Lesson (
9
+ override val id : LessonId ,
10
+ val name : String ,
11
+ val tagline : String ,
12
+ val image : ImageUrl ,
13
+ val content : LessonContent ,
14
+ val completed : Boolean ,
15
+ ) : Identifiable<LessonId>
16
+
17
+ @Serializable
18
+ data class LessonContent (
19
+ val rootItem : LessonItemId ,
20
+ val items : Map <LessonItemId , LessonItem >,
21
+ )
22
+
23
+ @Serializable
24
+ @JvmInline
25
+ value class LessonId (override val value : String ) : Id
26
+
27
+ @Serializable
28
+ sealed interface LessonItem {
29
+ val id: LessonItemId
30
+ }
31
+
32
+ @Serializable
33
+ @JvmInline
34
+ value class LessonItemId (val value : String )
35
+
36
+ /* *
37
+ * Item that doesn't branch the tree.
38
+ */
39
+ interface LinearItem {
40
+ val next: LessonItemId ?
41
+ }
42
+
43
+ @Serializable
44
+ @SerialName(" TextItem" )
45
+ data class TextItem (
46
+ override val id : LessonItemId ,
47
+ val text : String ,
48
+ val style : TextStyle ,
49
+ override val next : LessonItemId ? ,
50
+ ) : LessonItem, LinearItem
51
+
52
+ @Serializable
53
+ enum class TextStyle {
54
+ Heading ,
55
+ Body ,
56
+ BodySpacingMedium ,
57
+ BodySpacingLarge
58
+ }
59
+
60
+ @Serializable
61
+ @SerialName(" QuestionItem" )
62
+ data class QuestionItem (
63
+ override val id : LessonItemId ,
64
+ val question : String ,
65
+ val clarification : String? ,
66
+ val answers : List <Answer >,
67
+ val correct : Set <AnswerId >,
68
+ override val next : LessonItemId ? ,
69
+ ) : LessonItem, LinearItem
70
+
71
+ @Serializable
72
+ data class Answer (
73
+ val id : AnswerId ,
74
+ val text : String ,
75
+ val explanation : String? ,
76
+ )
77
+
78
+ @Serializable
79
+ @JvmInline
80
+ value class AnswerId (val value : String )
81
+
82
+ @Serializable
83
+ @SerialName(" OpenQuestionItem" )
84
+ data class OpenQuestionItem (
85
+ override val id : LessonItemId ,
86
+ val question : String ,
87
+ val correctAnswer : String ,
88
+ override val next : LessonItemId ? ,
89
+ ) : LessonItem, LinearItem
90
+
91
+ @Serializable
92
+ @SerialName(" LinkItem" )
93
+ data class LinkItem (
94
+ override val id : LessonItemId ,
95
+ val text : String ,
96
+ val url : String ,
97
+ override val next : LessonItemId ? ,
98
+ ) : LessonItem, LinearItem
99
+
100
+ @Serializable
101
+ @SerialName(" LessonNavigationItem" )
102
+ data class LessonNavigationItem (
103
+ override val id : LessonItemId ,
104
+ val text : String ,
105
+ val onClick : LessonItemId ,
106
+ override val next : LessonItemId ? ,
107
+ ) : LessonItem, LinearItem
108
+
109
+ @Serializable
110
+ @SerialName(" LottieAnimationItem" )
111
+ data class LottieAnimationItem (
112
+ override val id : LessonItemId ,
113
+ val lottie : LottieAnimation ,
114
+ override val next : LessonItemId ? ,
115
+ ) : LessonItem, LinearItem
116
+
117
+ @Serializable
118
+ @JvmInline
119
+ value class LottieAnimation (val url : String )
120
+
121
+ @Serializable
122
+ @SerialName(" ImageItem" )
123
+ data class ImageItem (
124
+ override val id : LessonItemId ,
125
+ val image : ImageUrl ,
126
+ override val next : LessonItemId ? ,
127
+ ) : LessonItem, LinearItem
128
+
129
+ @Serializable
130
+ @JvmInline
131
+ value class ImageUrl (val url : String )
132
+
133
+ @Serializable
134
+ @SerialName(" ChoiceItem" )
135
+ data class ChoiceItem (
136
+ override val id : LessonItemId ,
137
+ val question : String ,
138
+ val options : List <ChoiceOption >,
139
+ ) : LessonItem
140
+
141
+ @Serializable
142
+ data class ChoiceOption (
143
+ val id : ChoiceOptionId ,
144
+ val text : String ,
145
+ val next : LessonItemId ,
146
+ )
147
+
148
+ @Serializable
149
+ @JvmInline
150
+ value class ChoiceOptionId (val value : String )
151
+
152
+ @Serializable
153
+ @SerialName(" MysteryItem" )
154
+ data class MysteryItem (
155
+ override val id : LessonItemId ,
156
+ val text : String ,
157
+ val hidden : LessonItemId ,
158
+ override val next : LessonItemId ?
159
+ ) : LessonItem, LinearItem
160
+
161
+ @Serializable
162
+ @SerialName(" SoundItem" )
163
+ data class SoundItem (
164
+ override val id : LessonItemId ,
165
+ val text : String ,
166
+ val sound : SoundUrl ,
167
+ override val next : LessonItemId ?
168
+ ) : LessonItem, LinearItem
169
+
170
+ @Serializable
171
+ @JvmInline
172
+ value class SoundUrl (val url : String )
0 commit comments