Skip to content

Establish a custom enhanced text format #97

Description

@e-caste

This is because we want to support:

  • on the frontend:
    • formatted text (MarkDown style)
    • formulas (LaTeX style)
    • base64 images
    • the predefined answers that MoodleXML supports (multichoice, truefalse, shortanswer, matching, cloze, essay, numerical, description)
  • on the backend:
    • storing formatted text (MarkDown style)
    • converting from the various MoodleXML supported formats to our enhanced MarkDown
    • formulas (LaTeX style)
    • base64 images
    • the predefined answers that MoodleXML supports (multichoice, truefalse, shortanswer, matching, cloze, essay, numerical, description)

The Moodle XML format docs are here: https://docs.moodle.org/400/en/Moodle_XML_format
Some notes:

  1. "Format" selects the Formatting options for the question text. The options are html (the default), moodle_auto_format, plain_text and markdown. The choice effects the way in which the text will be displayed.

So we need to support html, moodle_auto_format (what is it specifically?), plain_text and markdown.

  1. 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]
    If you export questions from a Moodle 1.9 server, the exported file might contain only the relative URL to the image hosted in the 1.9 server, while exported questions from Moodle 2.x and 3.x servers might contain the actual image encoded in base 64. This explains why some question bank import-export operations include all the images and some others don't.

So this means that when we have included images, we include them as base64 inside our text as the frontend already supports this, but if we only have a relative URL without the base server URL we will be unable to import the image.

  1. Depending on the type of the question, some specific tags are expected:
  • for multichoice > In addition, an MC question has the following tags: single (values: true/false), shuffleanswers (values: 1/0), correctfeedback, partiallycorrectfeedback, incorrectfeedback, answernumbering (allowed values: 'none', 'abc', 'ABCD' or '123' -- The <single> tag is used to distinguish single response (radio button) and multiple response (checkbox) variants.)
  • for truefalse > 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.
  • for shortanswer > The short answer question type supports alternative correct responses, each with its own weighting and feedback. The Moodle XML format uses one tag for each of the alternative correct answers. The <usecase> tag toggles case-sensitivity with the values 1/0.
  • for matching > 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.
  • for numerical > 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).
  • for essay > 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).
  • for cloze > It is supported, and depends on a special format for the <questiontext> tag.
  • for description > This response type has no further tags other than those contained in the question header (such as <questiontext>).
  • for random_matching(?) > 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.

When new questions are uploaded, they should be converted from MoodleXML to our custom format.
When a new question or answer or reply is entered directly from the text editor, it should already be in our custom format from the frontend and it should be stored unchanged.

Example text:

### Title
**bold text**  
_italic text_  
~~strikethrough text~~  
[link](https://example.com)  
> quote

`monospaced code`  
![image from a link](https://weee-open.github.io/skeeelled/img/logoSkeeelledLight.svg)  
<some identifier for base64>image content</some identifier for base64>

- dotted
- list

1. numbered
2. list

- [ ] check
- [ ] boxes

$\int{x^2}$

Screenshot 2022-04-20 at 19 09 32

Screenshot 2022-04-20 at 19 10 10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BackendBackend relatedFrontendFrontend relatedenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions