test_that("Testing CreateItemBody DirectedPair", { dp <- new("DirectedPair", rows = c("Lion", "Flower", "Mushrooms"), rows_identifiers = c("ID_1", "ID_2", "ID_3"), cols = c("Animal", "Plant", "Fungi"), cols_identifiers = c("IDT_1", "IDT_2", "IDT_3"), answers_identifiers = c("ID_3 IDT_3", "ID_1 IDT_1", "ID_2 IDT_2"), points = 5, title = "directed_pair", orientation = "horizontal", prompt = "Associated left elements with the right category" ) # The example was based on OPAL question type "Match Interaction" because # qti does not provide it example <- ' Associated left elements with the right category Lion Flower Mushrooms Animal Plant Fungi ' sut <- xml2::read_xml(toString(createItemBody(dp))) expected <- xml2::read_xml(example) expect_equal(sut, expected) }) test_that("Testing createResponseDeclaration() method in DirectedPair class where its slots answer_score and points are undefined", { dp <- new("DirectedPair", rows = c("Lion", "Flower", "Mushrooms"), rows_identifiers = c("ID_1", "ID_2", "ID_3"), cols = c("Animal", "Plant", "Fungi"), cols_identifiers = c("IDT_1", "IDT_2", "IDT_3"), answers_identifiers = c("ID_3 IDT_3", "ID_1 IDT_1", "ID_2 IDT_2"), title = "directed_pair", prompt = "Associated left elements with the right category" ) # The example was based on OPAL question type "Match Interaction" because # qti does not provide it example <- ' ID_3 IDT_3 ID_1 IDT_1 ID_2 IDT_2 ' sut <- xml2::read_xml(toString(createResponseDeclaration(dp))) expected <- xml2::read_xml(example) expect_equal(sut, expected) }) test_that("Testing OutcomeDeclaration DirectedPair", { dp <- new("DirectedPair", rows = c("Lion", "Flower", "Mushrooms"), rows_identifiers = c("ID_1", "ID_2", "ID_3"), cols = c("Animal", "Plant", "Fungi"), cols_identifiers = c("IDT_1", "IDT_2", "IDT_3"), answers_identifiers = c("ID_3 IDT_3", "ID_1 IDT_1", "ID_2 IDT_2"), points = 5, title = "directed_pair", prompt = "Associated left elements with the right category" ) # The example was based on OPAL question type "Match Interaction" because # qti does not provide it example <- ' 0 5 0 ' responseDe <- as.character(htmltools::tag("additionalTag", list(createOutcomeDeclaration(dp)))) sut <- xml2::read_xml(responseDe) expected <- xml2::read_xml(example) expect_equal(sut, expected) }) test_that("Testing the constructor for DirectedPair class", { sut <- directedPair(content = list("

\"Directed pairs\" task

"), rows = c("alfa", "beta", "gamma"), rows_identifiers = c("a", "b", "g"), cols = c("A", "B", "G;"), cols_identifiers = c("as", "bs", "gs"), answers_identifiers = c("a as", "b bs", 'g gs')) xml_sut <- create_assessment_item(sut) expect_no_error(xml2::read_xml(as.character(xml_sut))) expect_s4_class(sut, "DirectedPair") })