Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.RData
.Ruserdata
.DS_Store
/.quarto/
/.quarto/
**/*.quarto_ipynb
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
File renamed without changes.
15 changes: 15 additions & 0 deletions _extensions/r-wasm/live/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
title: Quarto Live
author: George Stagg
version: 0.1.3-dev
quarto-required: ">=1.4.0"
contributes:
filters:
- live.lua
formats:
common:
ojs-engine: true
filters:
- live.lua
html: default
revealjs: default
dashboard: default
40 changes: 40 additions & 0 deletions _extensions/r-wasm/live/_gradethis.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
```{webr}
#| edit: false
#| output: false
webr::install("gradethis", quiet = TRUE)
library(gradethis)
options(webr.exercise.checker = function(
label, user_code, solution_code, check_code, envir_result, evaluate_result,
envir_prep, last_value, engine, stage, ...
) {
if (is.null(check_code)) {
# No grading code, so just skip grading
invisible(NULL)
} else if (is.null(label)) {
list(
correct = FALSE,
type = "warning",
message = "All exercises must have a label."
)
} else if (is.null(solution_code)) {
list(
correct = FALSE,
type = "warning",
message = htmltools::tags$div(
htmltools::tags$p("A problem occurred grading this exercise."),
htmltools::tags$p(
"No solution code was found. Note that grading exercises using the ",
htmltools::tags$code("gradethis"),
"package requires a model solution to be included in the document."
)
)
)
} else {
gradethis::gradethis_exercise_checker(
label = label, solution_code = solution_code, user_code = user_code,
check_code = check_code, envir_result = envir_result,
evaluate_result = evaluate_result, envir_prep = envir_prep,
last_value = last_value, stage = stage, engine = engine)
}
})
```
32 changes: 32 additions & 0 deletions _extensions/r-wasm/live/_knitr.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
```{r echo=FALSE}
# Setup knitr for handling {webr} and {pyodide} blocks
# TODO: With quarto-dev/quarto-cli#10169, we can implement this in a filter
# We'll handle `include: false` in Lua, always include cell in knitr output
knitr::opts_hooks$set(include = function(options) {
if (options$engine == "webr" || options$engine == "pyodide") {
options$include <- TRUE
}
options
})
# Passthrough engine for webr
knitr::knit_engines$set(webr = function(options) {
knitr:::one_string(c(
"```{webr}",
options$yaml.code,
options$code,
"```"
))
})
# Passthrough engine for pyodide
knitr::knit_engines$set(pyodide = function(options) {
knitr:::one_string(c(
"```{pyodide}",
options$yaml.code,
options$code,
"```"
))
})
```
Loading
Loading