From 78bf8d5876ac9ef6a5bf24adbb2ebac3505569cc Mon Sep 17 00:00:00 2001 From: Arthur Barrett Date: Fri, 22 Feb 2013 00:42:12 -0500 Subject: [PATCH] update annotationinput jsonv alue on tag selection or comment change --- common/lib/capa/capa/inputtypes.py | 5 ++ .../capa/capa/templates/annotationinput.html | 11 +-- common/static/js/capa/annotationinput.js | 85 +++++++++++++++++-- 3 files changed, 87 insertions(+), 14 deletions(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index c20ee1101c..4320437525 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -976,6 +976,11 @@ class AnnotationInput(InputTypeBase): self.tag_prompt = xml.findtext('./tag_prompt') self.options = self._find_options() + # Need to provide a value that JSON can parse if there is no + # student-supplied value yet. + if self.value == "": + self.value = 'null' + def _find_options(self): options = [] index = 0 diff --git a/common/lib/capa/capa/templates/annotationinput.html b/common/lib/capa/capa/templates/annotationinput.html index eb136766f6..acae36042a 100644 --- a/common/lib/capa/capa/templates/annotationinput.html +++ b/common/lib/capa/capa/templates/annotationinput.html @@ -5,17 +5,18 @@
${text}
${comment_prompt}
-