From d8b22ff12fa384b5b871f667bd7a8cc48a811ea8 Mon Sep 17 00:00:00 2001 From: ichuang Date: Wed, 4 Jul 2012 14:13:13 -0400 Subject: [PATCH] add hidden attribute to textline and textbox inputtypes, for javascript problems --- common/lib/capa/inputtypes.py | 8 ++++++-- common/lib/capa/templates/textbox.html | 9 ++++++++- common/lib/capa/templates/textinput.html | 6 ++++++ common/lib/capa/templates/textinput_dynamath.html | 9 ++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/common/lib/capa/inputtypes.py b/common/lib/capa/inputtypes.py index a23b5c418c..54445af769 100644 --- a/common/lib/capa/inputtypes.py +++ b/common/lib/capa/inputtypes.py @@ -182,7 +182,8 @@ def textline(element, value, status, render_template, msg=""): raise Exception(msg) count = int(eid.split('_')[-2])-1 # HACK size = element.get('size') - context = {'id':eid, 'value':value, 'state':status, 'count':count, 'size': size, 'msg': msg} + hidden = element.get('hidden','') # if specified, then textline is hidden and id is stored in div of name given by hidden + context = {'id':eid, 'value':value, 'state':status, 'count':count, 'size': size, 'msg': msg, 'hidden': hidden} html = render_template("textinput.html", context) return etree.XML(html) @@ -203,8 +204,9 @@ def textline_dynamath(element, value, status, render_template, msg=''): eid=element.get('id') count = int(eid.split('_')[-2])-1 # HACK size = element.get('size') + hidden = element.get('hidden','') # if specified, then textline is hidden and id is stored in div of name given by hidden context = {'id':eid, 'value':value, 'state':status, 'count':count, 'size': size, - 'msg':msg, + 'msg':msg, 'hidden' : hidden, } html = render_template("textinput_dynamath.html", context) return etree.XML(html) @@ -224,11 +226,13 @@ def textbox(element, value, status, render_template, msg=''): rows = element.get('rows') or '30' cols = element.get('cols') or '80' mode = element.get('mode') or 'python' # mode for CodeMirror, eg "python" or "xml" + hidden = element.get('hidden','') # if specified, then textline is hidden and id is stored in div of name given by hidden linenumbers = element.get('linenumbers') # for CodeMirror if not value: value = element.text # if no student input yet, then use the default input given by the problem context = {'id':eid, 'value':value, 'state':status, 'count':count, 'size': size, 'msg':msg, 'mode':mode, 'linenumbers':linenumbers, 'rows':rows, 'cols':cols, + 'hidden' : hidden, } html = render_template("textbox.html", context) try: diff --git a/common/lib/capa/templates/textbox.html b/common/lib/capa/templates/textbox.html index 0dc0a9f88c..dbdb597cf9 100644 --- a/common/lib/capa/templates/textbox.html +++ b/common/lib/capa/templates/textbox.html @@ -1,5 +1,9 @@
- + @@ -12,6 +16,9 @@ % elif state == 'incomplete': % endif + % if hidden: +
+ % endif
(${state})
diff --git a/common/lib/capa/templates/textinput.html b/common/lib/capa/templates/textinput.html index 0ba27c6938..7f2f563b81 100644 --- a/common/lib/capa/templates/textinput.html +++ b/common/lib/capa/templates/textinput.html @@ -8,11 +8,17 @@ % elif state == 'incomplete':
% endif + % if hidden: +
+ % endif

diff --git a/common/lib/capa/templates/textinput_dynamath.html b/common/lib/capa/templates/textinput_dynamath.html index 2fc44c9d3e..9009deb682 100644 --- a/common/lib/capa/templates/textinput_dynamath.html +++ b/common/lib/capa/templates/textinput_dynamath.html @@ -10,9 +10,16 @@

% elif state == 'incomplete':
+ % endif + % if hidden: +
% endif - +

% if state == 'unsubmitted':