read_qti: Read Assessment Items in QTI XML

View source: R/read_qti.R

read_qtiR Documentation

Read Assessment Items in QTI XML

Description

These functions read QTI XML from character strings or files. Only the single and multiple choice item types are currently supported.

Usage

read_qti(x, ...)

Arguments

x

String or connection to QTI XML file.

...

further arguments passed to or from other functions.

Value

read_qti returns an object of class “qti_item”, which contains the following elements, if present in x:

id

item id, extracted from the identifier attribute

title

item title, extracted from the title attribute

type

item type, currently “single” for single choice

prompt

text for the item stem

options

list of text for options

key

vector of correct/incorrect as 0/1 for options

xml

raw XML contents, stored as an object of class “xml_document”

Examples


# Read from character string
item <- read_qti(
  "<assessmentItem identifier='1584'
    title='Excellent Example Item'>
    <responseDeclaration identifier='RESPONSE' cardinality='single'
      baseType='identifier'>
      <correctResponse>
        <value>ChoiceB</value>
      </correctResponse>
    </responseDeclaration>
    <outcomeDeclaration identifier='SCORE' cardinality='single'
      baseType='float'>
      <defaultValue><value>0</value></defaultValue>
    </outcomeDeclaration>
    <itemBody>
      <prompt>
        <p>Is this a really good question?</p>
      </prompt>
      <choiceInteraction responseIdentifier='RESPONSE' shuffle='false'
        maxChoices='1'>
        <simpleChoice identifier='ChoiceA'>Yes</simpleChoice>
        <simpleChoice identifier='ChoiceB'>No</simpleChoice>
        <simpleChoice identifier='ChoiceC'>Maybe</simpleChoice>
      </choiceInteraction>
    </itemBody>
  </assessmentItem>"
)
item


talbano/qti documentation built on Jan. 25, 2023, 4:02 a.m.