Allow textinputdynamath to specify its Mathjax preprocessor per-problem

This commit is contained in:
kimth
2012-09-10 19:42:40 -04:00
parent 971fe53dec
commit bd72fbdfd8
3 changed files with 22 additions and 7 deletions

View File

@@ -326,8 +326,16 @@ def textline_dynamath(element, value, status, render_template, msg=''):
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
# Preprocessor to insert between raw input and Mathjax
preprocessor = {'class_name': element.get('preprocessorClassName',''),
'script_src': element.get('preprocessorSrc','')}
if '' in preprocessor.values():
preprocessor = None
context = {'id': eid, 'value': value, 'state': status, 'count': count, 'size': size,
'msg': msg, 'hidden': hidden,
'preprocessor': preprocessor,
}
html = render_template("textinput_dynamath.html", context)
return etree.XML(html)

View File

@@ -3,8 +3,10 @@
###
<section class="text-input-dynamath textinputdynamath capa_inputtype" id="inputtype_${id}">
<div class="textinputdynamath_data" data-preprocessor="MathjaxPreprocessorFor6002x"/>
<div class="script_placeholder" data-src="/static/js/mathjax_preprocessor_for_6002x.js"/>
% if preprocessor is not None:
<div class="textinputdynamath_data" data-preprocessor="${preprocessor['class_name']}"/>
<div class="script_placeholder" data-src="${preprocessor['script_src']}"/>
% endif
% if state == 'unsubmitted':
<div class="unanswered" id="status_${id}">