library(CKteachR)
library(learnr)
library(submitr) 
library(googlesheets4) 
library(gradethis) 
knitr::opts_chunk$set(echo = FALSE)
learnr::tutorial_options(
  exercise.timelimit = 60, 
  exercise.checker = gradethis::grade_learnr) 
submitr::login_controls()
# setup google sheets
# read the 'service account token setup' https://gargle.r-lib.org/articles/get-api-credentials.html#service-account-token-1
# read https://github.com/juampynr/google-spreadsheet-reader
# for each new sheet remember to share with googledrive-docs@mph-teaching.iam.gserviceaccount.com


options(tutorial.storage = "none")

out <-
  setup_progress_monitoring(
    rstudioapi::getActiveProject(),
    "test",
    "15oXGGq0fgFL7kN3ZCcouhJhnIY_wJCDj3tPu6nyug-g",
    "1YLZkrgLJJ0sGVXtkie30gpHdudzth-3dRUkUR_pQH0I",
    "UoL.MPH.datalab@gmail.com"
  )

submitr::shiny_logic(input, output, session, out$vfun, out$storage_actions)

Fixed-response questions

learnr::question("Which planet do we live on?",
         answer("Mars", correct = FALSE),
         answer("Earth", correct = TRUE,  message = "Good job Earthling!"),
         answer("Saturn",  correct = FALSE),
         allow_retry = TRUE,
         random_answer_order = TRUE
)

Hours in 2020

Use the box below to calculate how many hours 2020 has.


**Hint:** Remember 2020 is a leap year (if you haven't noticed yet :-)) and it has 366 days. Each day has 24 hours. Therefore `366 * 24` should be the correct answer.
gradethis::grade_result(
  fail_if( ~ .result != 8784, "Result should have been 366 * 24 = 8784"),
  pass_if(~ TRUE, "Well done!"),
  glue_correct = "{.message}"
)

Multiple selections in multiple choice

learnr::question("Which of these are countries? (Select ALL that apply)",
         answer("California", correct = FALSE),
         answer("France", correct = TRUE, message = "Good job Earthling!"),  
         answer("China",  correct = TRUE),
         random_answer_order = TRUE,
         allow_retry = TRUE,
         options = list(foobar = "Flag")
)


ChristK/CKteachR documentation built on Dec. 31, 2020, 10:59 a.m.