Using results from Shiny as response in learnr

I have a collection of simple shiny apps for teaching that use marks set with the mouse as responses.


  • In basic statistic, mark median and quartiles in a dot or rag plot
  • In intermediate course, draw a regression line through a dot plot. Surprise, these are always to steep! A good point to discuss that regression is not "the best looking line"
  • In a course for medical researcher, draw a contour in an image or a critical decision point in a plot.

I would like to integrate these into the learn framework. Could anyone point me to an example as a starter?

Ok, looks my question was too stupid or too complex, so let me try again with a simplified version. See comments in example below. Save code as an Rmd-file to run it.

title: "How to use Shiny  responses in learnr"
output: learnr::tutorial
runtime: shiny_prerendered

```{r context="setup", include=FALSE}

# Not used.....
custom_checker = function(label, user_code, check_code, envir_result, evaluate_result, last_value, stage, ...) {
  if (stage == "code_check") 
    return(list("Not this", correct = FALSE))
tutorial_options(exercise.checker = custom_checker)

## Topic 1

### Using Shiny

I know that I can do THIS with `learnr` standard tools (see next page), but let's take it as a simple example for a custom Shiny question.

There is an [example in the Shiny documentation](, which explains how shiny components are shown, but not how they are used.

This [link on community]( is interesting, but also does not show how to use 

```{r,  context="render", echo=FALSE}
radioButtons("choose", "Select <<good>> as correct",
             c("bad", "ugly", "good"))

Button 'Next topic' should only be visible when answer is correct

```{r, context="server"}

observeEvent(input$choose, {

## Topic 2

### The usual way

```{r good-bad, echo = FALSE}
  "Pick good",
  answer("good", correct = TRUE),
  allow_retry = TRUE,
  random_answer_order = TRUE

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.