Skip to main content

std-quiz

Level: Molecule | Entity: QuizItem | Persistence: runtime

3 states, 4 events, 5 transitions

Live Preview

orbital QuizItemOrbital {
entity QuizItem [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
question : string
answer : string
optionA : string
optionB : string
optionC : string
optionD : string
difficulty : string
currentIndex : number
totalQuestions : number
}
trait QuizItemQuiz -> QuizItem [interaction] {
initial: question
state question {
INIT -> question
(fetch QuizItem)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "help-circle", size: "lg" }, { type: "typography", content: "Quiz", variant: "h2" }] }, { type: "divider" }, { type: "card", children: [{ type: "stack", direction: "vertical", gap: "md", align: "center", children: [{ type: "icon", name: "help-circle", size: "lg" }, { type: "typography", variant: "h3", content: ["object/get", ["array/first", "@entity"], "name"] }] }] }, { type: "simple-grid", columns: 2, children: [{ type: "button", label: ["object/get", ["array/first", "@entity"], "optionA"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "A" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionB"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "B" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionC"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "C" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionD"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "D" } }] }, { type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "signal", size: "sm" }, { type: "typography", variant: "caption", color: "muted", content: "Difficulty:" }, { type: "badge", label: ["object/get", ["array/first", "@entity"], "difficulty"] }] }, { type: "stack", direction: "horizontal", gap: "xs", align: "center", children: [{ type: "typography", variant: "caption", color: "muted", content: "Question" }, { type: "typography", variant: "caption", content: ["+", ["object/get", ["array/first", "@entity"], "currentIndex"], 1] }, { type: "typography", variant: "caption", color: "muted", content: "of" }, { type: "typography", variant: "caption", content: ["object/get", ["array/first", "@entity"], "totalQuestions"] }] }] }] })
ANSWER -> answer-revealed
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "help-circle", size: "lg" }, { type: "typography", content: "Answer Revealed", variant: "h2" }] }, { type: "divider" }, { type: "card", children: [{ type: "stack", direction: "vertical", gap: "md", children: [{ type: "typography", variant: "caption", color: "muted", content: "Question" }, { type: "typography", variant: "body", content: ["object/get", ["array/first", "@entity"], "name"] }, { type: "divider" }, { type: "typography", variant: "caption", color: "muted", content: "Answer" }, { type: "typography", variant: "h3", content: ["object/get", ["array/first", "@entity"], "description"] }] }] }, { type: "alert", variant: "info", message: "Review the answer above." }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Next Question", event: "NEXT", variant: "primary", icon: "arrow-right" }] }] })
}
state answer-revealed {
NEXT -> question
(set @entity.currentIndex (+ @entity.currentIndex 1))
(fetch QuizItem)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "help-circle", size: "lg" }, { type: "typography", content: "Quiz", variant: "h2" }] }, { type: "divider" }, { type: "card", children: [{ type: "stack", direction: "vertical", gap: "md", align: "center", children: [{ type: "icon", name: "help-circle", size: "lg" }, { type: "typography", variant: "h3", content: ["object/get", ["array/first", "@entity"], "name"] }] }] }, { type: "simple-grid", columns: 2, children: [{ type: "button", label: ["object/get", ["array/first", "@entity"], "optionA"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "A" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionB"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "B" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionC"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "C" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionD"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "D" } }] }, { type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "signal", size: "sm" }, { type: "typography", variant: "caption", color: "muted", content: "Difficulty:" }, { type: "badge", label: ["object/get", ["array/first", "@entity"], "difficulty"] }] }, { type: "stack", direction: "horizontal", gap: "xs", align: "center", children: [{ type: "typography", variant: "caption", color: "muted", content: "Question" }, { type: "typography", variant: "caption", content: ["+", ["object/get", ["array/first", "@entity"], "currentIndex"], 1] }, { type: "typography", variant: "caption", color: "muted", content: "of" }, { type: "typography", variant: "caption", content: ["object/get", ["array/first", "@entity"], "totalQuestions"] }] }] }] })
RESTART -> complete
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "icon", name: "check-circle", size: "lg" }, { type: "typography", content: "Quiz Complete!", variant: "h2" }, { type: "alert", variant: "success", message: "You have completed all questions." }, { type: "button", label: "Restart", event: "RESTART", variant: "primary", icon: "rotate-ccw" }] })
}
state complete {
RESTART -> question
(fetch QuizItem)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "help-circle", size: "lg" }, { type: "typography", content: "Quiz", variant: "h2" }] }, { type: "divider" }, { type: "card", children: [{ type: "stack", direction: "vertical", gap: "md", align: "center", children: [{ type: "icon", name: "help-circle", size: "lg" }, { type: "typography", variant: "h3", content: ["object/get", ["array/first", "@entity"], "name"] }] }] }, { type: "simple-grid", columns: 2, children: [{ type: "button", label: ["object/get", ["array/first", "@entity"], "optionA"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "A" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionB"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "B" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionC"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "C" } }, { type: "button", label: ["object/get", ["array/first", "@entity"], "optionD"], event: "ANSWER", variant: "secondary", actionPayload: { answer: "D" } }] }, { type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "signal", size: "sm" }, { type: "typography", variant: "caption", color: "muted", content: "Difficulty:" }, { type: "badge", label: ["object/get", ["array/first", "@entity"], "difficulty"] }] }, { type: "stack", direction: "horizontal", gap: "xs", align: "center", children: [{ type: "typography", variant: "caption", color: "muted", content: "Question" }, { type: "typography", variant: "caption", content: ["+", ["object/get", ["array/first", "@entity"], "currentIndex"], 1] }, { type: "typography", variant: "caption", color: "muted", content: "of" }, { type: "typography", variant: "caption", content: ["object/get", ["array/first", "@entity"], "totalQuestions"] }] }] }] })
}
}
page "/quizitems/quiz" -> QuizItemQuiz
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-
questionstring""
answerstring""
optionAstring""
optionBstring""
optionCstring""
optionDstring""
difficultystring"medium"
currentIndexnumber0
totalQuestionsnumber3

States

StateType
questionInitial
answer-revealed-
complete-

Events

EventPayload
INIT-
ANSWERanswer: string
NEXT-
RESTART-

Transitions

FromEventToEffects
questionINITquestion2 effects
questionANSWERanswer-revealed1 effect
answer-revealedNEXTquestion3 effects
answer-revealedRESTARTcomplete1 effect
completeRESTARTquestion2 effects