From 747105e3280ca8253417a2fdab3401b41de3b3f7 Mon Sep 17 00:00:00 2001 From: Isaac Chuang Date: Fri, 11 May 2012 17:05:14 -0400 Subject: [PATCH] More minor cleanups --- djangoapps/courseware/capa/inputtypes.py | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/djangoapps/courseware/capa/inputtypes.py b/djangoapps/courseware/capa/inputtypes.py index 460ff7a5eb..bb3ecd209f 100644 --- a/djangoapps/courseware/capa/inputtypes.py +++ b/djangoapps/courseware/capa/inputtypes.py @@ -1,11 +1,34 @@ +# +# File: courseware/capa/inputtypes.py +# + +''' +Module containing the problem elements which render into input objects + +- textline +- textbox (change this to textarea?) +- schemmatic + +These are matched by *.html files templates/*.html which are mako templates with the actual html. + +''' + + from lxml.etree import Element from lxml import etree from mitxmako.shortcuts import render_to_string +#----------------------------------------------------------------------------- #takes the xml tree as 'element', the student's previous answer as 'value', and the graded status as 'state' def choicegroup(element, value, state): + ''' + Radio button inputs: multiple choice or true/false + + TODO: allow order of choices to be randomized, following lon-capa spec. Use "location" attribute, + ie random, top, bottom. + ''' eid=element.get('id') if element.get('type') == "MultipleChoice": type="radio" @@ -16,7 +39,7 @@ def choicegroup(element, value, state): choices={} for choice in element: assert choice.tag =="choice", "only tags should be immediate children of a " - choices[choice.get("name")] = etree.tostring(choice[0]) + choices[choice.get("name")] = etree.tostring(choice[0]) # TODO: what if choice[0] has math tags in it? context={'id':eid, 'value':value, 'state':state, 'type':type, 'choices':choices} html=render_to_string("choicegroup.html", context) return etree.XML(html)