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)
quiz( question( "What is 'tidy data'?", answer(paste0(""), correct = TRUE), answer(paste0("")), allow_retry = TRUE, random_answer_order = TRUE) )
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) ))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.