Formato Moodle XML

De MoodleDocs


El formato XML Format es un formato específico de Moodle, para importar y exportar preguntas a emplear con el Módulo de examen. El formato ha sido desarrollado dentro de la comunidad de Moodle, pero puede ser soportado por otros programas en mayor o menor grado.

Unas palabras acerca de validez (y CDATA)

El revisor de XML asume que el archivo XML está bien formado y no detecta ni reporta errores. Si el archivo no está bien formado, Usted muy probablemente obtendrá errores inesperados. Si Usted está escribiendo a mano el archivo XML, se le recomienda encarecidamente que lo pase a traves de algún tipo de verificador XML antes de importarlo a Moodle. Una foma simple de hacer esto es abrir el archivo XML usando Firefox o Internet Explorer.

Tenga en cuenta particularmente que los fragmentos HTML incrustados deberían de estar dentro de secciones CDATA. Ejemplo CDATA:

<questiontext format="html">
      <text><![CDATA[
             Ahora yo puedo incluir cualquier HTML que yo
desee. Sin el CDATA, las marcas (tags) HTML romperían el XML!! ]]> </text> </questiontext>

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Estructura general del archivo XML

El archivo está rodeado por marcas (tags) como sigue. Es importante asegurarse de que la marca xml solamente sea realmente la primera línea del archivo. Una primera línea vacía, o marcas adicionales en la primera línea, confundirán al revisor XML de Moodle.

<?xml version="1.0" ?> <quiz>

.
.
.

</quiz>

translator note icon.png Nota del traductor: La palabra ingles quiz significa examen y la palabra question significa 'pregunta


Dentro de las marcas <quiz> hay varias marcas <question>. Una de estas marcas <question> puede ser una pregunta de mentiritas con un tipo de category para especificar una categoría para la importación/exportación.

<question type="category">

   <category>
       <text>$course$/XXXX</text>
   </category>

</question>

En donde XXXX is the new category name. If the category exists, the question(s) will be added to the existing course; otherwise a new category will be created. This only works if you have "Get category from file" checked.

Multiple categories can be specified in the same file. Just add another dummy 'category' question each time you would like to establish a new category and the questions that follow it will be placed there.

El archivo debe estar codificado en UTF-8

Moodle XML import and export are balanced in functionality, so if you need to understand the format you can simply create some questions and export them to see what it looks like.

Marcas (Tags) comunes para todos los tipos de preguntas

Una pregunta se escribe como sigue:

<question type="multichoice|truefalse|shortanswer|matching|cloze|essay|numerical|description">

    <name>
        <text>Nombre de la pregunta</text>
    </name>
    <questiontext format="html">
        <text>¿Cual es la respuesta a esta pregunta?</text>
    </questiontext>
    .
    .
    .

</question>

"Format" selecciona los formatos de texto para el texto de la pregunta. Las opciones son html (valor por defecto), moodle_auto_format, plain_text y markdown. La elección afecta la manera en la cual se mostrará el texto.

Further tags, which usually include at least one <answer> tag, follow in the space marked with dots as child nodes to the <question> tag. The response-related tags are listed further down on this page. Various (optional?) tags are possible.

  • penalty
  • generalfeedback
  • defaultgrade
  • hidden

The <image> tag contains the url of any included image. Nested within the <image> tag may be an <image_base64> tag which contains the actual image data encoded in base64 [1].

Nota: Si Usted exporta preguntas desde un servidor Moodle 1.9, las preguntas podrían contener solamente la URL relativa hacia las imágenes alojadas en el servidor 1.9, mientras que las preguntas exportadas desde un servidor Moodle 2.x y 3.x contendrían la imagen en sí codificada en base 64. Esto explica el porqué algunas operaciones de importar-exportar preguntas del banco de preguntas incluyen a todas las imágenes mientras que otras no.


In the following question type examples the common parts of the question are not shown to improve clarity. It's a good idea to export some examples yourself to see a full example.

Opción múltiple

LAs preguntas de Opción Múltiple tienen una marca <answer> para cada opción. Cada opción puede acarrear retroalimentación y ponderación del puntaje (al usar el atributo de fracción). Además, una pregunta de Opción Múltiple tiene las siguientes marcas (tags):

  • single (values: true/false)
  • shuffleanswers (values: 1/0)
  • correctfeedback
  • partiallycorrectfeedback
  • incorrectfeedback
  • answernumbering (allowed values: 'none', 'abc', 'ABCD' or '123')

La marca <single> es usada para distinguir variantes de respuesta única (botón de selección) y respuesta múltiple (casila de selección).

<question type="multichoice">

<answer fraction="100">
    <text>La respuesta correcta</text>
   <feedback><text>¡Correcto!</text></feedback>
</answer>
<answer fraction="0">
    <text>Un distractor</text>
   <feedback><text>¡Ooops!</text></feedback>
</answer>
<answer fraction="0">
    <text>Otro distractor</text>
   <feedback><text>¡Ooops!</text></feedback>
</answer>
<shuffleanswers>1</shuffleanswers>
<single>true</single>
<answernumbering>abc</answernumbering>

Falso/verdadero

Two answer tags are given, one which is true, and one which is false. The fraction attribute of the answer tag identifies which option is correct (100) and which is false (0). Feedback is supported. The following example shows the format when true is the correct answer and false is wrong.

<question type="truefalse">
<answer fraction="100">
   <text>true</text>
   <feedback><text>Correct!</text></feedback>
</answer>
<answer fraction="0">
   <text>false</text>
   <feedback><text>Ooops!</text></feedback>
</answer>

Respuesta corta

The short answer question type supports alternative correct responses, each with its own weighting and feedback. The Moodle XML format uses one <answer> tag for each of the alternative correct answers.

The <usecase> tag toggles case-sensitivity with the values 1/0.

<question type="shortanswer">
<answer fraction="100">
    <text>The correct answer</text>
    <feedback><text>Correct!</text></feedback>
</answer>
<question type="shortanswer">
<answer fraction="100">
    <text>The correct answer</text>
    <feedback><text>Correct!</text></feedback>
</answer>
<answer fraction="100">
    <text>An alternative answer</text>
    <feedback><text>Correct!</text></feedback>
</answer>

Respuesta numérica

The following is a simplified version of the Moodle XML format for numerical responses.

<question type="numerical">
<answer fraction="100">
    <text>23</text>
    <feedback><text>Feedback</text></feedback>
</answer>

Moodle also supports a <tolerance> tag (how accurate must the number be?) and one or more <unit> tags. Unit tags have names and multipliers. E.g. if the main answer is in kilometres, an additional answer could be the equivalent in metres with a multiplier of 1000.

Note: prior to 1.7.2 the fraction was expressed as a value between 0 and 1 in a <fraction> element and the answer value was not enclosed in <text> tags. This format of the numerical question type is deprecated but will still be correctly imported if found (for now).

Relación de columnas (emparejamiento)

Pair matching responses use the <shuffleanswers> tag to determine whether the order of the items should be randomized. Each pair is contained inside a <subquestion> tag. The first item of each pair is contained with a <text> tag, while the second has an <answer> tag around it as well. Feedback and score weighting is not supported by Moodle for this response type.

<question type="matching">
<subquestion>
    <text>This is the 1st item in the 1st pair.</text>
    <answer>
        <text>This is the 2nd item in the 1st pair.</text>
    </answer>
</subquestion>
<subquestion>
    <text>This is the 1st item in the 2nd pair.</text>
    <answer>
        <text>This is the 2nd item in the 2nd pair.</text>
    </answer>
</subquestion>
<shuffleanswers>true</shuffleanswers>

Ensayo

Un ejemplo de una pregunta del tipo de ensayo...

 <question type="essay">
   <answer fraction="0">
       <text></text>
   </answer>
 </question>

There isn't an answer and there isn't a grade in this case.

Note: prior to 1.7.2 the fraction was expressed as a value between 0 and 1 in a <fraction> element and the answer value was not enclosed in <text> tags. This format of the essay question type is deprecated but will still be correctly imported if found (for now).

Otros tipos de preguntas

Cloze (preguntas incrustadas)

It is supported, and depends on a special format for the <questiontext> tag.

Tipo de respuesta descripción

This response type has no further tags other than those contained in the question header (such as <questiontext>).

Relación de columnas (emparejamiento) aleatorias

Moodle has a question type which consists of taking short answer questions in the same quiz and displaying them as a pair matching exercise. However Moodle is neither able to export nor import this question type.

Formatos de texto

Moodle XML files should explicity specify the text format (html, moodle_auto_format, plain_text and markdown - these correspond to the constants , FORMAT_HTML, FORMAT_MOODLE, etc used in the Moodle code) for each piece of content. Note that, by default, the format should be specified on the parent of the <text> element. This is slightly odd, but a remnant of history.

If the format is not specified for the questiontext, then html is the default. If the format is not specified on any other part of the question, then the format of the questiontext is the default.

(This default changed around November 2011. Before that, the default was moodle_auto_format whenever the format was not specified.)

Utilerías útiles

  • Online Moodle XML converter Convert from existing text files glossaries and quizzes to Moodle XML format. Also can convert from Moodle XMl to text.
  • Word Template for generating Moodle XML.
  • MoodleXMLBuilder converts commonly-used test generator output into Moodle XML. MoodleXMLBuilder currently supports converting tests and question banks created in Blackboard, ExamView, TestGen, and EZTest. Images are fully supported within all question fields where images are allowed within the Moodle quiz module.
  • MoXMLE - A Java based application MoXMLE is a Java based application that converts a Simple TXT file into a Moodle XML format.

Vea también