Skip to contents

A 'shiny' module to implement a quiz. These are the core functions to implement the quiz with a 'shiny' application.

Usage

quiz_ui(quiz)

quiz_server(quiz)

Arguments

quiz

an object of class quiz. See create_quiz()

Value

a reactive object showing the current results of the quiz

Functions

  • quiz_ui(): UI side function

  • quiz_server(): Server side function

Author

Joseph Marlo

Examples

if (FALSE) { # interactive()
quiz <- create_quiz(
  create_question(
    'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Select nulla.',
    add_choice('auctor'),
    add_choice('nulla', correct = TRUE)
  ),
  create_question(
    'Mauris congue aliquet dui, ut dapibus lorem porttitor sed. Select 600.',
    add_choice('600', correct = TRUE),
    add_choice('800')
  )
)

ui <- shiny::fluidPage(
  htmltools::div(
    style = "max-width: 700px",
    quiz_ui(quiz)
   )
 )
server <- function(input, output, session) {
 quiz_server(quiz)
}
shinyApp(ui, server)
}