Skip to content

Commit

Permalink
Remove --- question separator
Browse files Browse the repository at this point in the history
Resolves #29
  • Loading branch information
mitchelloharawild committed Dec 13, 2023
1 parent 470daea commit 8f9d257
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions R/quiz-xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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,
":::"
)

}

0 comments on commit 8f9d257

Please sign in to comment.