-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5701598
commit 0d4a6a9
Showing
8 changed files
with
739 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ivy.learn | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlin.jvm.JvmInline | ||
|
||
@Serializable | ||
data class Course( | ||
override val id: CourseId, | ||
val name: String, | ||
val tagline: String, | ||
val image: ImageUrl, | ||
val lessons: List<LessonId>, | ||
) : Identifiable<CourseId> | ||
|
||
@Serializable | ||
@JvmInline | ||
value class CourseId(override val value: String) : Id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ivy.learn | ||
|
||
interface Identifiable<AId : Id> { | ||
val id: AId | ||
} | ||
|
||
interface Id { | ||
val value: String | ||
} |
172 changes: 172 additions & 0 deletions
172
learn-dsl/src/commonMain/kotlin/ivy/learn/LessonModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package ivy.learn | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlin.jvm.JvmInline | ||
|
||
@Serializable | ||
data class Lesson( | ||
override val id: LessonId, | ||
val name: String, | ||
val tagline: String, | ||
val image: ImageUrl, | ||
val content: LessonContent, | ||
val completed: Boolean, | ||
) : Identifiable<LessonId> | ||
|
||
@Serializable | ||
data class LessonContent( | ||
val rootItem: LessonItemId, | ||
val items: Map<LessonItemId, LessonItem>, | ||
) | ||
|
||
@Serializable | ||
@JvmInline | ||
value class LessonId(override val value: String) : Id | ||
|
||
@Serializable | ||
sealed interface LessonItem { | ||
val id: LessonItemId | ||
} | ||
|
||
@Serializable | ||
@JvmInline | ||
value class LessonItemId(val value: String) | ||
|
||
/** | ||
* Item that doesn't branch the tree. | ||
*/ | ||
interface LinearItem { | ||
val next: LessonItemId? | ||
} | ||
|
||
@Serializable | ||
@SerialName("TextItem") | ||
data class TextItem( | ||
override val id: LessonItemId, | ||
val text: String, | ||
val style: TextStyle, | ||
override val next: LessonItemId?, | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
enum class TextStyle { | ||
Heading, | ||
Body, | ||
BodySpacingMedium, | ||
BodySpacingLarge | ||
} | ||
|
||
@Serializable | ||
@SerialName("QuestionItem") | ||
data class QuestionItem( | ||
override val id: LessonItemId, | ||
val question: String, | ||
val clarification: String?, | ||
val answers: List<Answer>, | ||
val correct: Set<AnswerId>, | ||
override val next: LessonItemId?, | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
data class Answer( | ||
val id: AnswerId, | ||
val text: String, | ||
val explanation: String?, | ||
) | ||
|
||
@Serializable | ||
@JvmInline | ||
value class AnswerId(val value: String) | ||
|
||
@Serializable | ||
@SerialName("OpenQuestionItem") | ||
data class OpenQuestionItem( | ||
override val id: LessonItemId, | ||
val question: String, | ||
val correctAnswer: String, | ||
override val next: LessonItemId?, | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
@SerialName("LinkItem") | ||
data class LinkItem( | ||
override val id: LessonItemId, | ||
val text: String, | ||
val url: String, | ||
override val next: LessonItemId?, | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
@SerialName("LessonNavigationItem") | ||
data class LessonNavigationItem( | ||
override val id: LessonItemId, | ||
val text: String, | ||
val onClick: LessonItemId, | ||
override val next: LessonItemId?, | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
@SerialName("LottieAnimationItem") | ||
data class LottieAnimationItem( | ||
override val id: LessonItemId, | ||
val lottie: LottieAnimation, | ||
override val next: LessonItemId?, | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
@JvmInline | ||
value class LottieAnimation(val url: String) | ||
|
||
@Serializable | ||
@SerialName("ImageItem") | ||
data class ImageItem( | ||
override val id: LessonItemId, | ||
val image: ImageUrl, | ||
override val next: LessonItemId?, | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
@JvmInline | ||
value class ImageUrl(val url: String) | ||
|
||
@Serializable | ||
@SerialName("ChoiceItem") | ||
data class ChoiceItem( | ||
override val id: LessonItemId, | ||
val question: String, | ||
val options: List<ChoiceOption>, | ||
) : LessonItem | ||
|
||
@Serializable | ||
data class ChoiceOption( | ||
val id: ChoiceOptionId, | ||
val text: String, | ||
val next: LessonItemId, | ||
) | ||
|
||
@Serializable | ||
@JvmInline | ||
value class ChoiceOptionId(val value: String) | ||
|
||
@Serializable | ||
@SerialName("MysteryItem") | ||
data class MysteryItem( | ||
override val id: LessonItemId, | ||
val text: String, | ||
val hidden: LessonItemId, | ||
override val next: LessonItemId? | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
@SerialName("SoundItem") | ||
data class SoundItem( | ||
override val id: LessonItemId, | ||
val text: String, | ||
val sound: SoundUrl, | ||
override val next: LessonItemId? | ||
) : LessonItem, LinearItem | ||
|
||
@Serializable | ||
@JvmInline | ||
value class SoundUrl(val url: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ivy.learn | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlin.jvm.JvmInline | ||
|
||
@Serializable | ||
data class Topic( | ||
override val id: TopicId, | ||
val name: String, | ||
val courses: List<CourseId> | ||
) : Identifiable<TopicId> | ||
|
||
@JvmInline | ||
@Serializable | ||
value class TopicId(override val value: String) : Id |
Oops, something went wrong.