From c1c050a6b6fee7dfc92c8d6df7e9e304e6d5f31a Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Tue, 19 Feb 2013 17:35:40 -0500 Subject: [PATCH] WIP on an inputtype for heroesX annotation - has a text area for saved but (currently) ungraded comments - has a set of tags with weights --- common/lib/capa/capa/inputtypes.py | 55 +++++++++++++++++-- common/lib/capa/capa/responsetypes.py | 3 +- .../capa/capa/templates/annotationinput.html | 37 +++++++++++++ common/static/js/capa/annotationinput.js | 11 ++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 common/lib/capa/capa/templates/annotationinput.html create mode 100644 common/static/js/capa/annotationinput.js diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 951104501a..d825bdbf88 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -909,15 +909,15 @@ registry.register(DesignProtein2dInput) class EditAGeneInput(InputTypeBase): """ An input type for editing a gene. Integrates with the genex java applet. - + Example: - + """ - + template = "editageneinput.html" tags = ['editageneinput'] - + @classmethod def get_attributes(cls): """ @@ -927,15 +927,58 @@ class EditAGeneInput(InputTypeBase): Attribute('height'), Attribute('dna_sequence') ] - + def _extra_context(self): """ """ context = { 'applet_loader': '/static/js/capa/edit-a-gene.js', } - + return context registry.register(EditAGeneInput) +#--------------------------------------------------------------------- + +class AnnotationInput(InputTypeBase): + """ + Input type for annotations / tags: students can enter some notes or other text + (currently ungraded), and then choose from a set of tags, which are graded. + + Example: + + + Dr Seuss uses colors! How? + Write down some notes: + Now pick the right color + + + + + + + + The location of the sky + + # TODO: allow ordering to be randomized + """ + + template = "annotationinput.html" + tags = ['annotationinput'] + + def setup(self): + # Pull out all the things from the xml + self.text = 'text' + self.comment_prompt = 'comment_prompt' + self.tag_prompt = 'tag_prompt' + self.options = [(0, 'blue'), (1, 'green'), (2, 'red')] + + def _extra_context(self): + return {'text': self.text, + 'comment_prompt': self.comment_prompt, + 'tag_prompt': self.tag_prompt, + 'options': self.options} + +registry.register(AnnotationInput) + diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index a1a4e6b65e..529b409a96 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -882,7 +882,8 @@ def sympy_check2(): allowed_inputfields = ['textline', 'textbox', 'crystallography', 'chemicalequationinput', 'vsepr_input', 'drag_and_drop_input', 'editamoleculeinput', - 'designprotein2dinput', 'editageneinput'] + 'designprotein2dinput', 'editageneinput', + 'annotationinput'] def setup_response(self): xml = self.xml diff --git a/common/lib/capa/capa/templates/annotationinput.html b/common/lib/capa/capa/templates/annotationinput.html new file mode 100644 index 0000000000..d1a7370733 --- /dev/null +++ b/common/lib/capa/capa/templates/annotationinput.html @@ -0,0 +1,37 @@ +
+TODO: make the textline hidden once it all works +
+ +

Text: ${text}

+ +

Comment prompt: ${comment_prompt}

+ +