rstudio / learnr

Interactive Tutorials with R Markdown
https://pkgs.rstudio.com/learnr
Apache License 2.0
704 stars 236 forks source link

The 'message' field of feedback must be a character vector or an htmltools tag or tagList #787

Closed 19barsav closed 1 year ago

19barsav commented 1 year ago

This error pops up no matter what I try to check for. I have my exercise as a Hello, World! program, and I am trying to make sure that that is what the student prints. I changed the exercise to be 1+1 like the example, and I still get the error.


Print out "Hello, World!" to your console!

```{r fprog, exercise = TRUE}
**Hint:** To print something to your console, just type the variable name!
**Hint:** variableName <- "Hello, World!"
grade_this({
  if (identical(.result, mean(1:10))) {
    pass()
  }
  fail()
})


I rewrote grade_this to use grade_result, and I've tried pass-if. I also tried my own custom message, and letting it default. Nothing seems to change the error. 
gadenbuie commented 1 year ago

Hi @19barsav, this certainly sounds frustrating. Unfortunately, there isn't quite enough information in your issue to reproduce or diagnose the problem. Could you include the source code of a small (and complete) tutorial that creates the error you're seeing? You can copy and paste the code below into a comment in this issue and then paste your tutorial .Rmd code into the template in the middle.

````markdown

...replace this text with your tutorial.Rmd source...


It would also be helpful to include the package versions you're using. The easiest way to get these is to run `devtools::session_info()` and then copy and paste the results into a code block in your issue.
19barsav commented 1 year ago

Hi! Yes, I can do that!


---
title: "R Introduction"
output:
  learnr::tutorial:
    progressive: true
    allow_skip: true
runtime: shiny_prerendered
description: >
  A basic introduction to R and the tidyverse!
---

```{r setup, include=FALSE}
library(learnr)
library(tidyverse)
library(nycflights13)
library(Lahman)
gradethis::gradethis_setup()
tutorial_options(
  exercise.timelimit = 60,
  # A simple checker function that just returns the message in the check chunk
  exercise.checker = function(check_code, ...) {
    list(
      message = eval(parse(text = check_code)),
      correct = logical(0),
      type = "info",
      location = "append"
    )
  }
)
knitr::opts_chunk$set(error = TRUE)

First Program!

Print out "Hello, World!" to your console!

**Hint:** To print something to your console, just type the variable name!
**Hint:** variableName <- "Hello, World!"
grade_this({
  if (identical(.result, mean(1:10))) {
    pass()
  }
  fail()
})
````markdown

 Session info ────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.1.1 (2021-08-10)
 os       Red Hat Enterprise Linux Server 7.9 (Maipo)
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       UTC
 date     2023-05-22
 rstudio  2021.09.0+351.pro6 Ghost Orchid (server)
 pandoc   2.14.0.3 @ /usr/lib/rstudio-server/bin/pandoc/ (via rmarkdown)

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────
 package      * version     date (UTC) lib source
 cachem         1.0.8       2023-05-01 [1] RSPM (R 4.1.0)
 callr          3.7.3       2022-11-02 [1] RSPM (R 4.1.0)
 cli            3.6.1       2023-03-23 [1] RSPM (R 4.1.0)
 colorspace     2.1-0       2023-01-23 [1] RSPM (R 4.1.0)
 crayon         1.5.2       2022-09-29 [1] RSPM (R 4.1.0)
 devtools       2.4.5       2022-10-11 [1] RSPM (R 4.1.0)
 digest         0.6.31      2022-12-11 [1] RSPM (R 4.1.0)
 dplyr        * 1.1.0       2023-01-29 [1] RSPM (R 4.1.0)
 ellipsis       0.3.2       2021-04-29 [1] RSPM (R 4.1.0)
 evaluate       0.21        2023-05-05 [1] RSPM (R 4.1.0)
 fansi          1.0.4       2023-01-22 [1] RSPM (R 4.1.0)
 fastmap        1.1.1       2023-02-24 [1] RSPM (R 4.1.0)
 forcats      * 1.0.0       2023-01-29 [1] RSPM (R 4.1.0)
 fs             1.6.2       2023-04-25 [1] RSPM (R 4.1.0)
 generics       0.1.3       2022-07-05 [1] RSPM (R 4.1.0)
 ggplot2      * 3.4.1       2023-02-10 [1] RSPM (R 4.1.0)
 glue           1.6.2       2022-02-24 [1] RSPM (R 4.1.0)
 gradethis    * 0.2.13      2023-05-19 [1] Github (rstudio-education/gradethis@cab4b64)
 gtable         0.3.3       2023-03-21 [1] RSPM (R 4.1.0)
 hms            1.1.2       2022-08-19 [1] RSPM (R 4.1.0)
 htmltools      0.5.5       2023-03-23 [1] RSPM (R 4.1.0)
 htmlwidgets    1.6.2       2023-03-17 [1] RSPM (R 4.1.0)
 httpuv         1.6.11      2023-05-11 [1] RSPM (R 4.1.0)
 jsonlite       1.8.4       2022-12-06 [1] RSPM (R 4.1.0)
 knitr          1.42        2023-01-25 [1] RSPM (R 4.1.0)
 Lahman       * 11.0-0      2023-05-04 [1] RSPM (R 4.1.0)
 later          1.3.1       2023-05-02 [1] RSPM (R 4.1.0)
 learnr       * 0.11.3.9000 2023-05-19 [1] Github (rstudio/learnr@9e18b55)
 lifecycle      1.0.3       2022-10-07 [1] RSPM (R 4.1.0)
 lubridate    * 1.9.2       2023-02-10 [1] RSPM (R 4.1.0)
 magrittr       2.0.3       2022-03-30 [1] RSPM (R 4.1.0)
 memoise        2.0.1       2021-11-26 [1] RSPM (R 4.1.0)
 mime           0.12        2021-09-28 [1] RSPM (R 4.1.0)
 miniUI         0.1.1.1     2018-05-18 [1] RSPM (R 4.1.0)
 munsell        0.5.0       2018-06-12 [1] RSPM (R 4.1.0)
 nycflights13 * 1.0.2       2021-04-12 [1] RSPM (R 4.1.0)
 pillar         1.9.0       2023-03-22 [1] RSPM (R 4.1.0)
 pkgbuild       1.4.0       2022-11-27 [1] RSPM (R 4.1.0)
 pkgconfig      2.0.3       2019-09-22 [1] RSPM (R 4.1.0)
 pkgload        1.3.2       2022-11-16 [1] RSPM (R 4.1.0)
 prettyunits    1.1.1       2020-01-24 [1] RSPM (R 4.1.0)
 processx       3.8.0       2022-10-26 [1] RSPM (R 4.1.0)
 profvis        0.3.7       2020-11-02 [1] RSPM (R 4.1.0)
 promises       1.2.0.1     2021-02-11 [1] RSPM (R 4.1.0)
 ps             1.7.2       2022-10-26 [1] RSPM (R 4.1.0)
 purrr        * 1.0.1       2023-01-10 [1] RSPM (R 4.1.0)
 R6             2.5.1       2021-08-19 [1] RSPM (R 4.1.0)
 Rcpp           1.0.10      2023-01-22 [1] RSPM (R 4.1.0)
 readr        * 2.1.4       2023-02-10 [1] RSPM (R 4.1.0)
 remotes        2.4.2       2021-11-30 [1] RSPM (R 4.1.0)
 rlang          1.1.1       2023-04-28 [1] RSPM (R 4.1.0)
 rmarkdown      2.21        2023-03-26 [1] RSPM (R 4.1.0)
 rprojroot      2.0.3       2022-04-02 [1] RSPM (R 4.1.0)
 rstudioapi     0.14        2022-08-22 [1] RSPM (R 4.1.0)
 scales         1.2.1       2022-08-20 [1] RSPM (R 4.1.0)
 sessioninfo    1.2.2       2021-12-06 [1] RSPM (R 4.1.0)
 shiny          1.7.4       2022-12-15 [1] RSPM (R 4.1.0)
 stringi        1.7.12      2023-01-11 [1] RSPM (R 4.1.0)
 stringr      * 1.5.0       2022-12-02 [1] RSPM (R 4.1.0)
 tibble       * 3.2.1       2023-03-20 [1] RSPM (R 4.1.0)
 tidyr        * 1.3.0       2023-01-24 [1] RSPM (R 4.1.0)
 tidyselect     1.2.0       2022-10-10 [1] RSPM (R 4.1.0)
 tidyverse    * 2.0.0       2023-02-22 [1] RSPM (R 4.1.0)
 timechange     0.2.0       2023-01-11 [1] RSPM (R 4.1.0)
 tzdb           0.3.0       2022-03-28 [1] RSPM (R 4.1.0)
 urlchecker     1.0.1       2021-11-30 [1] RSPM (R 4.1.0)
 usethis        2.1.6       2022-05-25 [1] RSPM (R 4.1.0)
 utf8           1.2.3       2023-01-31 [1] RSPM (R 4.1.0)
 vctrs          0.6.2       2023-04-19 [1] RSPM (R 4.1.0)
 withr          2.5.0       2022-03-03 [1] RSPM (R 4.1.0)
 xfun           0.39        2023-04-20 [1] RSPM (R 4.1.0)
 xtable         1.8-4       2019-04-21 [1] RSPM (R 4.1.0)
 yaml           2.3.7       2023-01-23 [1] RSPM (R 4.1.0)

It may 100% be a user error - I've just tried everything I can think of and I looked at the source code to see if I could pinpoint the issue, but I didn't understand it, either.

gadenbuie commented 1 year ago

Oh! It looks like you were using one of the built-in examples to get started. It's unfortunate, but those tutorials include some code that isn't really designed for the normal learnr + gradethis use case. In particular remove these lines marked below:

tutorial_options(
  exercise.timelimit = 60,
- # A simple checker function that just returns the message in the check chunk
- exercise.checker = function(check_code, ...) {
-   list(
-     message = eval(parse(text = check_code)),
-     correct = logical(0),
-     type = "info",
-     location = "append"
-   )
- }
)

Those lines shouldn't be part of the template if you use the "Create new R Markdown document" action in the RStudio IDE and then find "Interactive Tutorial" in the From Template menu.

19barsav commented 1 year ago

You are the BEST!!