Jump to content

User:Miriya52/week10

From mediawiki.org

Refer to project glossary for acronyms and definitions.
Week 10: February 6 - 10

Objectives

[edit]
  • Parse basic question
  • Parse more types and more complicated questions
  • Validation checks to reject illegal inputs

Summary

[edit]
  • Successfully parses basic well-formed question. See test_element() unittest.
  • In progress for development of validation checks with schema, adding true/false type, and reading a file into the structures.

Progress Update

[edit]

Adding validation check to GIFT parser

[edit]

For the XML format, a schema is defined to verify well-formedness and validity of an input. I am looking into how to integrate this for the GIFT parser.

GIFT basic question:

//comment
::Question title
::Question{
=A correct answer
~Wrong answer1
~Wrong answer2
~Wrong answer3
}

simple elements defined as:
<xs:element name="xxx" type="yyy"/>
where xxx is the name of the element and yyy is the data type of the element.

Proposed XSD schema

[edit]

<xs:schema>
        <xs:sequence>
               <xs:element name="questionTitle" type="xs:string"/>
               <xs:element name="question" type="xs:string"/>
               <xs:complexType>
                     <xs:element name="correctResponse" type="xs:string"/>
                    <xs:element name="wrongResponse" type="xs:string" maxOccurs="unbounded"/>
               <xs:complexType>
        <xs:sequence>
</xs:schema>

Unless defined as a "sequence" or "group", the sequence of elements doesn't matter. Sequence is "questionTitle", "question", then *Responses are in order; however inside the *Response elements complexType, it should be able to occur in any sequence. Need to see if this definition works.

Eventually, I want to include feedback in the responses as follows:

<xs:schema>
        <xs:element name="questionTitle" type="xs:string"/>
        <xs:element name="question" type="xs:string"/>
        <xs:element name="correctResponse">
                 <xs:complexType>
                         <xs:sequence>
                                <xs:element name="value" type="xs:string"/>
                                <xs:element name="feedback" type="xs:string"/>
                         </xs:sequence>
                 </xs:complexType>
        </xs:element name="correctResponse">
        <xs:element name="wrongResponse" maxOccurs="unbounded">
                 <xs:complexType>
                         <xs:sequence>
                                <xs:element name="value" type="xs:string"/>
                                <xs:element name="feedback" type="xs:string"/>
                         </xs:sequence>
                 </xs:complexType>
        </xs:element name="wrongResponse">
</xs:schema>

Adding True/False type

[edit]

I am working on parsing true/false. See test_true_false().

::Q1:: 1+1=2 {T}

That is a valid Moodle GIFT format. The issue is that until the parser gets to last brackets '{T}', it's not apparent that it is a true/false vs multiple choice. In multiple choice, = is that tag for a correct response. So I think the parser logic needs to be modified to take in the whole question, and then identify what type of question it is. That would be a different parser logic than the pyslet XML parser which an rely on tags.

Reading in a Document

[edit]

I am working on reading in readFile.txt. See unittest test_document(); ignore the assert tests for now, the first element should be "Question title". However, when I call Document.read(), it does read the file, but ends up with only one element in the tree "Wrong answer3".

Plan for next week

[edit]
  • Redesign parser to buffer the whole question, and then parse to the different child elements
  • Keep debugging!