library(learnr)
library(gradethis)
knitr::opts_chunk$set(echo = FALSE)
gradethis_setup(
  pass.praise = TRUE, fail.hint = FALSE, fail_code_feedback = FALSE,
  fail.encourage = TRUE, maybe_code_feedback = FALSE)

Content quiz

quiz(
  question(
    "What is 'tidy data'?", 
    answer(paste0(""), 
      correct = TRUE),
    answer(paste0("")),
    allow_retry = TRUE, random_answer_order = TRUE)
)

Coding exercise

grader <- grade_this({
  bare_code <- str_remove_all(as.character(.user_code), " ")
    # Check whether the correct data set has been used
  if (!str_detect(bare_code, "res_container<-")){
    fail("Your call should define an object named 'res_container'!")
    }
  if (!str_detect(bare_code, "rep")){
    fail("Your call should make use of the function 'rep()'!")
    }
  if (identical(.result, rep(NA, 1000))){
    pass()
    }
  fail()
})

grader(mock_this_exercise(.user_code = res_container <- rep(NA, 1000) ))


graebnerc/DataScienceExercises documentation built on April 11, 2025, 7:57 p.m.