by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Anna Liao
    @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
    @jayvdb
    can you print out a 'tree' of a parsed QTI document ?
    Anna Liao
    @anna-liao
    Hmm, I guess I could try that
    I could just run the QTI sample and see what it looks like
    John Vandenberg
    @jayvdb
    so we can see which classes are used at which levels of the tree of an QTI object
    Anna Liao
    @anna-liao
    ok, I will look into it
    Anna Liao
    @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="http://www.imsglobal.org/xsd/imsqti_v2p2 " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/ xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd"><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="http://www.imsglobal.org/question/qti_v2p2/r ptemplates/match_correct"/></assessmentItem>']

    len(dlines)
    2
    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')
    d.read()
    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
    @jayvdb
    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')
    >>> d.read()
    (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
    @anna-liao
    I ran it in a console, not in a unittest
    sure, i will check the type
    Anna Liao
    @anna-liao

    dir(d)
    ['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']

    d.dict
    {'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}

    d.root.get_value()
    Traceback (most recent call last):
    File "<input>", line 1, in <module>
    d.root.get_value()
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2335, in get_value
    return join_characters(self.generate_value(ignore_elements))
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2305, in generate_value
    raise XMLMixedContentError(str(self))
    pyslet.xml.structures.XMLMixedContentError:

    <assessmentItem adaptive="false" identifier="choice" timeDependent="false" title="Unattended Luggage" xml ns="http://www.imsglobal.org/xsd/imsqti_v2p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:s chemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v 2p2.xsd"><responseDeclaration baseType="identifier" cardinality="single" identifier="RESPONSE"><correctRe sponse><value>ChoiceA</value></correctResponse></responseDeclaration> <outcomeDeclaration baseType="float " cardinality="single" identifier="SCORE"><defaultValue><value>0</value></defaultValue></outcomeDeclarati on> <itemBody><p>Look at the text in the picture.</p> <p><img alt="NEVER LEAVE LUGGAGE UNATTENDED" src="i mages/sign.png"/></p> <choiceInteraction maxChoices="1" responseIdentifier="RESPONSE" shuffle="false"><pr ompt>What does it say?</prompt> <simpleChoice identifier="ChoiceA">You must stay with your luggage at all
    times.</simpleChoice> <simpleChoice identifier="ChoiceB">Do not let someone else look after your luggage
    .</simpleChoice> <simpleChoice identifier="ChoiceC">Remember your luggage when you leave.</simpleChoice><
    /choiceInteraction></itemBody> <responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/r ptemplates/match_correct"/></assessmentItem>doc

    children = list(d.get_children())
    len(children)
    1
    children
    [<pyslet.xml.structures.Element object at 0x106095240>]
    children[0].xmlname
    'assessmentItem'
    children[0].get_value()
    Traceback (most recent call last):
    File "<input>", line 1, in <module>
    children[0].get_value()
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2335, in get_value
    return join_characters(self.generate_value(ignore_elements))
    File "/Users/annaliao/repos/pyslet/pyslet/xml/structures.py", line 2305, in generate_value
    raise XMLMixedContentError(str(self))
    pyslet.xml.structures.XMLMixedContentError:

    <assessmentItem adaptive="false" identifier="choice" timeDependent="false" title="Unattended Luggage" xml ns="http://www.imsglobal.org/xsd/imsqti_v2p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:s chemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v 2p2.xsd"><responseDeclaration baseType="identifier" cardinality="single" identifier="RESPONSE"><correctRe sponse><value>ChoiceA</value></correctResponse></responseDeclaration> <outcomeDeclaration baseType="float " cardinality="single" identifier="SCORE"><defaultValue><value>0</value></defaultValue></outcomeDeclarati on> <itemBody><p>Look at the text in the picture.</p> <p><img alt="NEVER LEAVE LUGGAGE UNATTENDED" src="i mages/sign.png"/></p> <choiceInteraction maxChoices="1" responseIdentifier="RESPONSE" shuffle="false"><pr ompt>What does it say?</prompt> <simpleChoice identifier="ChoiceA">You must stay with your luggage at all
    times.</simpleChoice> <simpleChoice identifier="ChoiceB">Do not let someone else look after your luggage
    .</simpleChoice> <simpleChoice identifier="ChoiceC">Remember your luggage when you leave.</simpleChoice><
    /choiceInteraction></itemBody> <responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/r ptemplates/match_correct"/></assessmentItem>

    So that looks about right
    or consistent with when I make the same calls on my document
    len(children) is 1
    children[0].xmlname is only the first element name
    and getting the value of that child is just all the elements lumped together
    thanks for the suggestions
    Anna Liao
    @anna-liao
    Once again, I'm running into issues with the bytes/str incompatibility in CI, but not in manual tox: https://travis-ci.org/anna-liao/pyslet/builds/202693838
    Do you have suggestions on how to resolve that issue in CI? You had mentioned previously that it is a py2/py3 issue
    It affects being able to use the base_uri, which is used when reading files
    Just to clarify, the unittests for that commit passes in manual tox.
    John Vandenberg
    @jayvdb
    Nod. Ill provide a fix for your str/bytes problems when i get home this afternoon.
    Anna Liao
    @anna-liao
    thanks!
    Anna Liao
    @anna-liao
    Hello, I am wondering if I can get some feedback and guidance on wrapping up this project. It will help me to set a timeline to the completion of this internship. I am planning on moving on to another project in March, so looking to finish my work on this project in March. Thanks.
    Anna Liao
    @anna-liao
    Hello, just a note that I won't be available most of next week as I am moving and have some other personal obligations. I'm happy to continue on this project the following week. Hope you have a good weekend.
    M. Volz
    @mvolz
    Cheers
    M. Volz
    @mvolz
    Hi Anna, we need your final report by March 6th, although not if we are extended the project- I'm not sure if we ever definitively decided on that? What do you think- do you need more time?