test_that("generate_xml", { file <- system.file("extdata", "questions.csv", package = "moodef") qc <- question_category(category = 'Initial test', adapt_images = TRUE) |> define_questions_from_csv(file = file) xml <- qc |> generate_xml() qc2 <- qc |> generate_xml_file(file = tempfile(fileext = '.xml')) file <- system.file("extdata", "questions_image.csv", package = "moodef") df <- read_question_csv(file = file) df[1, 'image'] <- system.file("extdata", "divide.png", package = "moodef") df[2, 'image'] <- system.file("extdata", "ops.png", package = "moodef") qc3 <- question_category(category = 'Initial test', adapt_images = TRUE) |> define_questions_from_data_frame(df) xml3 <- qc3 |> generate_xml() expect_equal(qc, qc2) expect_equal( xml, structure( "\n\n \n $course$/top/Initial test \n \n \n \n \n q_001_multichoice_what_are_the_basic_arithmetic_operations \n\n \n \n

What are the basic arithmetic operations?

]]>
\n \n
\n \n1.0000000\n0.5\n0\n\ntrue\ntrue\nabc\n0\n Correct. \n \n Incorrect. \n\n Addition, subtraction, multiplication and division.\n Correct. \n\n\n Addition and subtraction.\n Incorrect. \n\n\n Addition, subtraction, multiplication, division and square root.\n Incorrect. \n\n
\n\n q_002_matching_match_each_operation_with_its_symbol \n\n \n \n

Match each operation with its symbol.

]]>
\n \n
\n \n1.0000000\n0.3333333\n0\n\ntrue\n\n Correct.\n\n\n Partially correct.\n\n\n Incorrect.\n\n\n\n Addition

]]>
\n \n +\n \n
\n\n Subtraction

]]>
\n \n -\n \n
\n\n Multiplication

]]>
\n \n *\n \n
\n
\n\n q_003_truefalse_the_square_root_is_a_basic_arithmetic_op \n\n \n \n

The square root is a basic arithmetic operation.

]]>
\n \n
\n \n1.0000000\n1.0000000\n0\n\n\n false\n \n \n \n\n\n true\n \n \n \n\n
\n\n q_004_shortanswer_what_basic_operation_does_it_have_as_a \n\n \n \n

What basic operation does it have as a + symbol?

]]>
\n \n
\n \n1.0000000\n0.3333333\n0\n\n0\n\n Addition\n \n \n \n\n
\n\n q_005_ddwtos_the_symbol_for_addition_is_1_the_sy \n\n \n \n

The symbol for addition is [[1]], the symbol for subtraction is [[2]].

]]>
\n \n
\n \n1\n0.3333333\n0\n\n1\n\n Correct.\n\n\n Partially correct.\n\n\n Incorrect.\n\n\n\n +\n 1\n\n\n -\n 1\n\n
\n\n q_006_gapselect_the_symbol_for_addition_is_1_the_sy \n\n \n \n

The symbol for addition is [[1]], the symbol for subtraction is [[2]].

]]>
\n \n
\n \n1\n0.3333333\n0\n\n1\n\n Correct.\n\n\n Partially correct.\n\n\n Incorrect.\n\n\n\n +\n 1\n\n\n -\n 1\n\n
\n\n q_007_ordering_h_sort_the_result_from_smallest_to_largest \n\n \n \n

Sort the result from smallest to largest.

]]>
\n \n
\n \n1\n0.3333333\n0\n\nHORIZONTAL\nALL\n0\nABSOLUTE_POSITION\nSHOW\nnone\n\n Correct.\n\n\n Partially correct.\n\n\n Incorrect.\n\n1\n\n 6/2\n\n\n 6-2\n\n\n 6+2\n\n\n 6*2\n\n \n \n \n \n \n \n
\n\n q_008_ordering_v_sort_the_result_from_smallest_to_largest \n\n \n \n

Sort the result from smallest to largest.

]]>
\n \n
\n \n1\n0.3333333\n0\n\nVERTICAL\nALL\n0\nABSOLUTE_POSITION\nSHOW\nnone\n\n Correct.\n\n\n Partially correct.\n\n\n Incorrect.\n\n1\n\n 6/2\n\n\n 6-2\n\n\n 6+2\n\n\n 6*2\n\n \n \n \n \n \n \n
\n\n q_009_numerical_what_is_the_result_of_sqrt_4 \n\n \n \n

What is the result of SQRT(4)?

]]>
\n \n
\n \n1\n0.3333333\n0\n\n\n 2\n \n \n \n 0\n\n\n -2\n \n \n \n 0\n\n 0\n 0.1000000\n 3\n 0\n
\n\n q_010_numerical_what_is_the_result_of_4_3 \n\n \n \n

What is the result of 4/3?

]]>
\n \n
\n \n1\n0.3333333\n0\n\n\n 1.33\n \n \n \n 0.03\n\n 0\n 0.1000000\n 3\n 0\n
\n\n q_011_essay_describe_the_addition_operation \n\n \n \n

Describe the addition operation.

]]>
\n \n
\n \n1\n0\n0\n\neditor\n1\n10\n\n\n0\n0\n0\n\n\n \n\n\n \n\n
\n
", class = c("glue", "character") ) ) # expect_equal(nchar(xml3), 174824) })