Changes

Jump to navigation Jump to search
Line 79: Line 79:     
Currently, (14 May 2009) the API supports parsing the GIFT file format well enough to import Multiple Choice and True/False questions, along with complete implementations for basic functionality of the corresponding question objects.  No support for partial credit answers is currently implemented, nor are other question types working correctly (though most can be parsed to some extent).  Export to CSV works as intended, though it is intentionally simple.  Documentation on usage and integration of the API into an activity is in the doc/ directory of [[http://git.sugarlabs.org/projects/question-support-api the repository]]. A simple, but complete usage example, using a console interface is available in tests/complete_test.py.
 
Currently, (14 May 2009) the API supports parsing the GIFT file format well enough to import Multiple Choice and True/False questions, along with complete implementations for basic functionality of the corresponding question objects.  No support for partial credit answers is currently implemented, nor are other question types working correctly (though most can be parsed to some extent).  Export to CSV works as intended, though it is intentionally simple.  Documentation on usage and integration of the API into an activity is in the doc/ directory of [[http://git.sugarlabs.org/projects/question-support-api the repository]]. A simple, but complete usage example, using a console interface is available in tests/complete_test.py.
 +
 +
===Current implementation===
 +
1. Ensure that PyParser and PEAK-Rules are installed
 +
2. Include the quizdata module
 +
    import quizdata
 +
3. Select plain text output
 +
    from quizdata.text import plain_text
 +
4. Select desired question types
 +
    from quizdata.question import MultipleChoiceQuestion, MissingWordQuestion
 +
5. Import when function to assist with question sorting
 +
    from peak.rules import when
 +
6. Handle questions (this section should be rewritten as needed for your activity
 +
    # this is the base case for any question type we don't handle otherwise.
 +
    def do_question(q):
 +
        print "Unhandled question type.", type(q)
 +
    # for multiple choice questions (incl. subclasses) we do this...
 +
    @when(do_question, (MultipleChoiceQuestion,))
 +
    def do_multi_questions(q):
 +
        print plain_text(q.text)
 +
        for a in zip('0123456789', q.answers):
 +
            print "%5s: %s" % a
 +
        answer = int(raw_input())
 +
        q.answer = q.answers[answer]
 +
        print q.correct
 +
    # for missing word-style questions, which aren't implemented correctly yet, and
 +
    # are a subclass of multiple choice questions... we make sure to ignore them
 +
    # with a more specific rule.
 +
    @when(do_question, (MissingWordQuestion,))
 +
    def do_mw_question(q): # XXX: inheritance is annoying here...
 +
        print "Unhandled question type. (MissingWordQuestion)"
 +
7. Open questions
 +
    questions = quizdata.open("file://%s?format=gift" % path.join(base_path, 'tests', 'multi_choice.txt'))
 +
    for q in questions:
 +
        do_question(q)
    
===Education Standards===
 
===Education Standards===
23

edits

Navigation menu