test_that("xml_question generates correct XML structure with all inputs", {
# Inputs
type <- "multichoice"
name <- "Sample Question"
questiontext <- ''
question_body <- '4'
question_tags <- 'math'
# Expected output
expected_output <- structure(
"\n\n Sample Question\n \n 4\n math\n",
class = c("glue", "character")
)
# Run the function
result <- xml_question(type, name, questiontext, question_body, question_tags)
# Check if the result matches the expected output
expect_equal(result, expected_output)
})
test_that("xml_question_category generates correct XML for a valid category", {
# Input
category <- "Mathematics"
# Expected output
expected_output <- glue::glue(
'
$course$/top/{category}
'
)
# Run the function
result <- xml_question_category(category)
# Check if the result matches the expected output
expect_equal(result, expected_output)
})