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

Add support for interactive outputs #31

Open
mitchelloharawild opened this issue Jan 18, 2025 · 1 comment
Open

Add support for interactive outputs #31

mitchelloharawild opened this issue Jan 18, 2025 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@mitchelloharawild
Copy link
Collaborator

It appears to be technically possible to import js/css/etc. into a Moodle quiz question.

To accomplish this,

$for(header-includes)$
$header-includes$
$endfor$

will need to be added to the template (bringing in the external dependencies). Then (probably with pandoc lua filters) these dependencies need to be copied over to each question (ideally only to questions with that have that dependency).

A simpler alternative implementation could be changing htmltools:::knit_print.html to directly / inline print the dependencies.

I have tested (somewhat manually)

  • leaflet (tiles appear broken, and parent div doesn't contain them correctly)
  • webr (works well, but text input and submit buttons cause question submission)

A custom dependency resolver could be a useful starting point:
https://github.com/rstudio/rmarkdown/blob/204879ff62c00df6b0910c4ed6a1f8e143c551e8/R/html_dependencies.R#L292-L304


More generally, supporting external dependencies (header-includes) will improve the output with CSS features like code highlighting and improved table formatting.

@mitchelloharawild mitchelloharawild added the help wanted Extra attention is needed label Jan 18, 2025
@mitchelloharawild
Copy link
Collaborator Author

Something like this could work for inline dependencies:

inline_dependencies <- function(x) {
  x <- htmlwidgets:::knit_print.htmlwidget(x)
  deps <- htmltools::resolveDependencies(attr(x, "knit_meta"))
  
  knitr::asis_output(paste(htmltools::renderDependencies(deps), x, sep = "\n"))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant