Skip to content

Instantly share code, notes, and snippets.

@mdlama
Created September 6, 2020 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdlama/b173c4fd96478033393300928be315db to your computer and use it in GitHub Desktop.
Save mdlama/b173c4fd96478033393300928be315db to your computer and use it in GitHub Desktop.
learnr/gradethis shinyapps.io deployment issue
---
title: "Tutorial"
output: learnr::tutorial
runtime: shiny_prerendered
---
```{r setup, include=FALSE}
library(learnr)
library(gradethis)
learnr::tutorial_options(
exercise.timelimit = 15,
exercise.checker = gradethis::grade_learnr,
exercise.eval = FALSE
)
knitr::opts_chunk$set(echo = FALSE)
```
## Topic 1
### Exercise
*Here's a simple exercise with an empty code chunk provided for entering the answer.*
Write the R code required to add two plus two:
```{r two-plus-two, exercise=TRUE}
```
### Exercise with Code
*Here's an exercise with some prepopulated code as well as `exercise.lines = 5` to provide a bit more initial room to work.*
Now write a function that adds any two numbers and then call it:
```{r add-function, exercise=TRUE, exercise.lines = 5}
add <- function() {
}
```
## Topic 2
### Exercise with Hint
*Here's an exercise where the chunk is pre-evaulated via the `exercise.eval` option (so the user can see the default output we'd like them to customize). We also add a "hint" to the correct solution via the chunk immediate below labeled `print-limit-hint`.*
Modify the following code to limit the number of rows printed to 5:
```{r print-limit, exercise=TRUE, exercise.eval=TRUE}
mtcars
```
```{r print-limit-hint}
head(___)
```
### Quiz
*You can include any number of single or multiple choice questions as a quiz. Use the `question` function to define a question and the `quiz` function for grouping multiple questions together.*
Some questions to verify that you understand the purposes of various base and recommended R packages:
```{r quiz}
quiz(
question("Which package contains functions for installing other R packages?",
answer("base"),
answer("tools"),
answer("utils", correct = TRUE),
answer("codetools")
),
question("Which of the R packages listed below are used to create plots?",
answer("lattice", correct = TRUE),
answer("tools"),
answer("stats"),
answer("grid", correct = TRUE)
)
)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment