Skip to content

Commit

Permalink
DSL demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Dec 21, 2024
1 parent 80ae765 commit 89f4b39
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions samples/src/jvmMain/kotlin/ivy/learn/dsl/LessonDslDemo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package ivy.learn.dsl

import ivy.learn.TextStyle

fun main() {

}

fun exampleLesson() = lessonContent {
intro()
whyQuestion()
whyExplanation()
arraysInternals()
internalsQuestion()
openQuestion("open") {
question = "What is 2 + 2? (enter exact answer)"
correctAnswer = "4"
}
}

private fun LessonContentScope.intro() {
text("intro") {
text = "Arrays"
style = TextStyle.Heading
}
text("intro_text") {
text = "The most fundamental data structure"
}
}

private fun LessonContentScope.whyQuestion() {
question("why_q") {
question = "Why arrays are so important?"
clarification = "Think about their properties."
answer(
text = "Lorem ipsum",
correct = true,
explanation = "Lorem ipsum"
)
answer(
text = "Lorem ipsum 2",
explanation = "test"
)
}
}

private fun LessonContentScope.whyExplanation() {
text("why_explain") {
text = "Lorem ipsum"
style = TextStyle.BodySpacingLarge
}
}

private fun LessonContentScope.arraysInternals() {
image("internals_img") {
imageUrl = "url"
}
text("internals") {
text = "lorem ipsum"
style = TextStyle.BodySpacingMedium
}
}

private fun LessonContentScope.internalsQuestion() {
question("internals_q") {
question = "Why Lorem ipsum?"
answer(
text = "Abc",
correct = true,
explanation = "..."
)
answer(
text = "Def",
correct = true,
explanation = "..."
)
answer(
text = "42",
explanation = "..."
)
answer(
text = "3.14",
explanation = "..."
)
}
}

0 comments on commit 89f4b39

Please sign in to comment.