Commit 79174259 by Victor Shnayder

Address Ike's comments.

- change a few comments / strings
- move extract_choices into the ChoiceGroup class
parent b78fb8df
...@@ -265,6 +265,8 @@ class OptionInput(InputTypeBase): ...@@ -265,6 +265,8 @@ class OptionInput(InputTypeBase):
Example: Example:
<optioninput options="('Up','Down')" correct="Up"/><text>The location of the sky</text> <optioninput options="('Up','Down')" correct="Up"/><text>The location of the sky</text>
# TODO: allow ordering to be randomized
""" """
template = "optioninput.html" template = "optioninput.html"
...@@ -288,7 +290,6 @@ class OptionInput(InputTypeBase): ...@@ -288,7 +290,6 @@ class OptionInput(InputTypeBase):
# make list of (option_id, option_description), with description=id # make list of (option_id, option_description), with description=id
return [(t, t) for t in tokens] return [(t, t) for t in tokens]
@classmethod @classmethod
def get_attributes(cls): def get_attributes(cls):
""" """
...@@ -344,14 +345,15 @@ class ChoiceGroup(InputTypeBase): ...@@ -344,14 +345,15 @@ class ChoiceGroup(InputTypeBase):
else: else:
raise Exception("ChoiceGroup: unexpected tag {0}".format(self.tag)) raise Exception("ChoiceGroup: unexpected tag {0}".format(self.tag))
self.choices = extract_choices(self.xml) self.choices = self.extract_choices(self.xml)
def _extra_context(self): def _extra_context(self):
return {'input_type': self.html_input_type, return {'input_type': self.html_input_type,
'choices': self.choices, 'choices': self.choices,
'name_array_suffix': self.suffix} 'name_array_suffix': self.suffix}
def extract_choices(element): @staticmethod
def extract_choices(element):
''' '''
Extracts choices for a few input types, such as ChoiceGroup, RadioGroup and Extracts choices for a few input types, such as ChoiceGroup, RadioGroup and
CheckboxGroup. CheckboxGroup.
...@@ -424,6 +426,9 @@ registry.register(JavascriptInput) ...@@ -424,6 +426,9 @@ registry.register(JavascriptInput)
class TextLine(InputTypeBase): class TextLine(InputTypeBase):
""" """
A text line input. Can do math preview if "math"="1" is specified. A text line input. Can do math preview if "math"="1" is specified.
If the hidden attribute is specified, the textline is hidden and the input id is stored in a div with name equal
to the value of the hidden attribute. This is used e.g. for embedding simulations turned into questions.
""" """
template = "textline.html" template = "textline.html"
...@@ -438,8 +443,7 @@ class TextLine(InputTypeBase): ...@@ -438,8 +443,7 @@ class TextLine(InputTypeBase):
return [ return [
Attribute('size', None), Attribute('size', None),
# if specified, then textline is hidden and input id is stored
# in div with name=self.hidden. (TODO: is this functionality used by anyone?)
Attribute('hidden', False), Attribute('hidden', False),
Attribute('inline', False), Attribute('inline', False),
...@@ -537,7 +541,7 @@ class CodeInput(InputTypeBase): ...@@ -537,7 +541,7 @@ class CodeInput(InputTypeBase):
] ]
# pulled out for testing # pulled out for testing
submitted_msg = ("Your file(s) have been submitted; as soon as your submission is" submitted_msg = ("Submitted. As soon as your submission is"
" graded, this message will be replaced with the grader's feedback.") " graded, this message will be replaced with the grader's feedback.")
@classmethod @classmethod
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment