Commit 074fde67 by ichuang

add mode and linenumbers options to textbox inputtype

parent 436a39ed
......@@ -251,8 +251,11 @@ def textbox(element, value, status, msg=''):
eid=element.get('id')
count = int(eid.split('_')[-2])-1 # HACK
size = element.get('size')
mode = element.get('mode') or 'python' # mode for CodeMirror, eg "python" or "xml"
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}
context = {'id':eid, 'value':value, 'state':status, 'count':count, 'size': size, 'msg':msg,
'mode':mode, 'linenumbers':linenumbers }
html=render_to_string("textbox.html", context)
return etree.XML(html)
......
......@@ -24,7 +24,12 @@
// work.
$(function(){
var cm = CodeMirror.fromTextArea(document.getElementById("input_${id}"),
{'mode':"python"});
{'mode':"${mode}"
% if linenumbers=='true':
, lineNumbers: true
% endif
});
// codemirror_set["${id}"] = cm; // track it for refreshes
});
</script>
<style type="text/css">
......
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