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
    Thanks, I can use some guidance on validation
    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
    @jayvdb
    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
    @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
    @jayvdb
    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
    @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