From 8f9d257899a25f77ac2157ca911d21327986fd6e Mon Sep 17 00:00:00 2001 From: mitchelloharawild Date: Wed, 13 Dec 2023 16:03:34 +1100 Subject: [PATCH] Remove --- question separator Resolves #29 --- R/quiz-xml.R | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/R/quiz-xml.R b/R/quiz-xml.R index 0e2fcf7..2a39ae3 100644 --- a/R/quiz-xml.R +++ b/R/quiz-xml.R @@ -17,14 +17,6 @@ moodlequiz <- function(self_contained = TRUE, pandoc_args = NULL, ...) { - pre_processor <- function(front_matter, input, runtime, knit_meta, files_dir, - output_dir, ...) { - # Fence questions with pandoc divs - rmd <- split_rmd(input) - rmd$body <- lapply(rmd$body, fence_question) - xfun::write_utf8(c(rmd$yaml, do.call(c, rmd$body)), input) - } - post_processor <- function(metadata, input_file, output_file, ...) { # Convert content within pandoc divs to quiz questions # xml <- xml2::read_xml(output_file) @@ -47,7 +39,6 @@ moodlequiz <- function(self_contained = TRUE, out <- output_format( knitr = knitr_options(), pandoc = pandoc_options(to = "html", ext = ".xml", lua_filters = filters), - pre_processor = pre_processor, post_processor = post_processor, base_format = bookdown::html_document2( highlight = NULL, @@ -60,28 +51,3 @@ moodlequiz <- function(self_contained = TRUE, out } - -fence_question <- function(x) { - opts_prefix <- "^(\\\\?\\|\\-\\s*)" - opts_loc <- grep(opts_prefix, x) - opts <- sub(opts_prefix, "", x[opts_loc]) - opts <- yaml::yaml.load(opts) - opts <- list_defaults( - opts, - name = "Unnamed", - type = "cloze", - defaultgrade = 0, - shuffleanswers = 0, - penalty = 0, - idnumber = "", - generalfeedback = "" - ) - - if(length(opts_loc) > 0) x <- x[-opts_loc] - c( - paste0(":::{.question", paste0(" ", names(opts), "='", opts, collapse = "'"), "'}"), - x, - ":::" - ) - -}