Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hints only work if I have something in the exercise box #172

Closed
KatherineCox opened this issue Jul 26, 2018 · 1 comment · Fixed by #411
Closed

Hints only work if I have something in the exercise box #172

KatherineCox opened this issue Jul 26, 2018 · 1 comment · Fixed by #411
Labels
difficulty: intermediate Enterprising community members could help effort: low < 1 day of work help wanted Solution is well-specified enough that any community member could fix priority: low Will be fixed eventually type: bug Maintainers have validated that it is a real bug in the project code
Milestone

Comments

@KatherineCox
Copy link

KatherineCox commented Jul 26, 2018

  • If I have some code in the exercise box, hints work as expected.
  • If there is no code in the exercise box, then the code (that's supposed to be a hint) is just run below the box and no hint button is displayed.
  • Adding a single newline in the exercise box is sufficient to make the hints work, but if I don't have anything, it breaks.
---
title: "Introduction to R"
output: 
  learnr::tutorial:
    progressive: true
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
tutorial_options(exercise.completion=TRUE)
knitr::opts_chunk$set(echo = FALSE)
```

## Dataframes

Use the code block below to explore the built-in `mtcars` dataframe, which contains several pieces of data about car design and performance (originally from the 1974 Motor Trend US magazine).

Something in the exercise box means the hints work
```{r dataframe-exercise, exercise=TRUE}
mtcars
```

```{r dataframe-exercise-hint-1}
mtcars$mpg
```


Nothing in the exercise code leads to broken hints:
```{r dataframe2-exercise, exercise=TRUE}
```

```{r dataframe2-exercise-hint-1}
mtcars$mpg
```

Even a single newline is sufficient to make the hints work:
```{r dataframe3-exercise, exercise=TRUE}

```

```{r dataframe3-exercise-hint-1}
mtcars$mpg
```

screen shot 2018-07-26 at 4 01 05 pm

@schloerke schloerke added difficulty: intermediate Enterprising community members could help effort: low < 1 day of work help wanted Solution is well-specified enough that any community member could fix priority: low Will be fixed eventually type: bug Maintainers have validated that it is a real bug in the project code labels Oct 31, 2019
@schloerke schloerke added this to the v0.11.0 milestone Feb 27, 2020
@schloerke
Copy link
Collaborator

@KatherineCox Yes, I believe this is related to #410. #411 should fix #172.

cliff notes: knitr interprets chunks with 0 content to have a NULL body, which looks just like a missing chunk.

Ex:

Browse[1]> get_knitr_chunk("does-not-exist")
NULL
Browse[1]> get_knitr_chunk("dataframe2-exercise")
NULL
Browse[1]> get_knitr_chunk("dataframe3-exercise")
[1] ""
attr(,"chunk_opts")
attr(,"chunk_opts")$label
[1] "dataframe3-exercise"

attr(,"chunk_opts")$exercise
[1] TRUE

get_knitr_chunk("dataframe2-exercise") should be returning some sort of result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: intermediate Enterprising community members could help effort: low < 1 day of work help wanted Solution is well-specified enough that any community member could fix priority: low Will be fixed eventually type: bug Maintainers have validated that it is a real bug in the project code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants