Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    Anna Liao
    I will look to change the parser then
    and then worry about validation
    Think validation should come after the parser is working for well-formed and valid types
    John Vandenberg
    I think we were planning on having another voice chat today-ish. Im back in Indonesia, and it is 11pm, but I am online for another few hours
    Anna Liao
    oh ok
    So I re-wrote the parser
    and it handles more question types
    I'm thinking about adding feedback nested in a *Response element
    But I'm not sure how to do that
    Also working on reading in a document
    Previously, I instantiate an Element and then add children to that Element
    Usually the document root is an Element
    however, adding a child to the document, is replacing the document root
    which is strange. This is why when I parse a GIFT format text from a file, it only shows the last element
    I still don't understand why it is defined as such in Pyslet
    And there is also adding validation
    John Vandenberg
    in XML, the document root is a special node which contains all the other nodes, directly or indirectly.
    it will include things like the preamble , which isnt a typical element.
    Anna Liao
    I would have thought it would make sense when adding a child element to the document root, it would be adding a child to the document root Element. However, it seems that it replaces it.
    There is just a few ways to go
    I could work on reading in a file
    work on adding more supported types
    or work on validation
    John Vandenberg
    can you print out a 'tree' of a parsed QTI document ?
    Anna Liao
    Hmm, I guess I could try that
    I could just run the QTI sample and see what it looks like
    John Vandenberg
    so we can see which classes are used at which levels of the tree of an QTI object
    Anna Liao
    ok, I will look into it
    Anna Liao
    hmm, ok, after running a QTI example through the document read
    it does look like all the elements are lumped together into one string
    it is just the header in one string and all the other elements in the other string

    dlines=[b'<?xml version="1.0" encoding="UTF-8"?>', b'<assessmentItem adaptive="false" identifier="cho ice" timeDependent="false" title="Unattended Luggage" xmlns=" " xmlns:xsi="" xsi:schemaLocation=" xsd/imsqti_v2p2"><responseDeclaration baseTy pe="identifier" cardinality="single" identifier="RESPONSE"><correctResponse><value>ChoiceA</value></c orrectResponse></responseDeclaration> <outcomeDeclaration baseType="float" cardinality="single" ident ifier="SCORE"><defaultValue><value>0</value></defaultValue></outcomeDeclaration> <itemBody><p>Look at
    the text in the picture.</p> <p><img alt="NEVER LEAVE LUGGAGE UNATTENDED" src="images/sign.png"/></p

    <choiceInteraction maxChoices="1" responseIdentifier="RESPONSE" shuffle="false"><prompt>What does i
    t say?</prompt> <simpleChoice identifier="ChoiceA">You must stay with your luggage at all times.</sim pleChoice> <simpleChoice identifier="ChoiceB">Do not let someone else look after your luggage.</simpl eChoice> <simpleChoice identifier="ChoiceC">Remember your luggage when you leave.</simpleChoice></cho iceInteraction></itemBody> <responseProcessing template=" ptemplates/match_correct"/></assessmentItem>']

    that's good then
    that's what my code does now
    it just lumps all the elements together in one string
    so it is different from how it worked with just an Element.
    d = structures.Document(base_uri='choice.xml')
    dlines = bytes(d).split(b'\n')
    ok, I guess I will leave it as is
    looks like for a document root, it just lumps all the elements into a single string. seems a bit odd
    That was taken from this unittest
    John Vandenberg
    instead of doing it in a unit test, try it in the python console. soemthing like
    $ python3
    >>> import os
    >>> import os.path
    >>> TEST_DATA_DIR = '.../data_xml20081126')
    >>> os.chdir(TEST_DATA_DIR)
    >>> from pyslet.xml import structures
    >>> d = structures.Document(base_uri='readFile.xml')
    (replacing ... in the path with the location of the data dir)
    then you can look at d in more detail
    bytes(d) doesnt tell you much -- that almost certainly re-serialises d into a bytestream
    instead, do type(d), and dir(d) to look at the d object type, and what attributes it has that can be explored
    Anna Liao
    I ran it in a console, not in a unittest
    sure, i will check the type
    Anna Liao

    ['ChildElement', 'Create', 'DiffString', 'GenerateXML', 'GetBase', 'GetChildClass', 'GetChildren', 'G
    etElementByID', 'GetElementClass', 'GetLang', 'GetSpace', 'GetUniqueID', 'Read', 'ReadFromEntity', 'R
    eadFromStream', 'RegisterElement', 'SetBase', 'SetLang', 'UnregisterElement', 'Update', 'ValidationEr
    ror', 'WriteXML', 'XMLParser', 'bytes', 'class', 'delattr', 'dict', 'dir', 'doc ', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'le'
    , 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr ', 'sizeof', 'str', 'subclasshook', 'unicode', 'weakref__', 'add_child', 'base_uri
    ', 'create', 'data', 'declaration', 'diff_string', 'dtd', 'generate_xml', 'get_base', 'get_child_clas
    s', 'get_children', 'get_element_by_id', 'get_element_class', 'get_lang', 'get_space', 'get_unique_id
    ', 'idTable', 'lang', 'parent', 'processing_instruction', 'read', 'read_from_entity', 'read_from_stre
    am', 'register_element', 'req_manager', 'root', 'set_base', 'set_lang', 'unregister_element', 'update
    ', 'validation_error', 'write_xml']

    {'parent': None, 'idTable': {}, 'root': <pyslet.xml.structures.Element object at 0x106095240>, 'req_manag
    er': None, 'dtd': <pyslet.xml.structures.XMLDTD object at 0x103f40eb8>, 'data': [], 'declaration': None,
    'base_uri': <pyslet.rfc2396.FileURL object at 0x103b3cba8>, 'lang': None}