Another step towards Javascriptinput-style script loading
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
### version of textline.html which does dynamic math
|
||||
###
|
||||
<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 state == 'unsubmitted':
|
||||
<div class="unanswered" id="status_${id}">
|
||||
% elif state == 'correct':
|
||||
@@ -15,27 +19,26 @@
|
||||
<div style="display:none;" name="${hidden}" inputid="input_${id}" />
|
||||
% endif
|
||||
|
||||
<input type="text" name="input_${id}" id="input_${id}" value="${value}" class="math" size="${size if size else ''}"
|
||||
% if hidden:
|
||||
style="display:none;"
|
||||
% endif
|
||||
/>
|
||||
<div class="script_placeholder" data-src="/static/js/mathjax_preprocessor_for_6002x.js"/>
|
||||
<p class="status">
|
||||
% if state == 'unsubmitted':
|
||||
unanswered
|
||||
% elif state == 'correct':
|
||||
correct
|
||||
% elif state == 'incorrect':
|
||||
incorrect
|
||||
% elif state == 'incomplete':
|
||||
incomplete
|
||||
% endif
|
||||
</p>
|
||||
<input type="text" name="input_${id}" id="input_${id}" value="${value}" class="math" size="${size if size else ''}"
|
||||
% if hidden:
|
||||
style="display:none;"
|
||||
% endif
|
||||
/>
|
||||
<p class="status">
|
||||
% if state == 'unsubmitted':
|
||||
unanswered
|
||||
% elif state == 'correct':
|
||||
correct
|
||||
% elif state == 'incorrect':
|
||||
incorrect
|
||||
% elif state == 'incomplete':
|
||||
incomplete
|
||||
% endif
|
||||
</p>
|
||||
|
||||
<p id="answer_${id}" class="answer"></p>
|
||||
<p id="answer_${id}" class="answer"></p>
|
||||
|
||||
<div id="display_${id}" class="equation">`{::}`</div>
|
||||
<div id="display_${id}" class="equation">`{::}`</div>
|
||||
|
||||
</div>
|
||||
<textarea style="display:none" id="input_${id}_dynamath" name="input_${id}_dynamath"> </textarea>
|
||||
|
||||
@@ -297,12 +297,17 @@ class @Problem
|
||||
|
||||
refreshMath: (event, element) =>
|
||||
element = event.target unless element
|
||||
target = "display_#{element.id.replace(/^input_/, '')}"
|
||||
elid = element.id.replace(/^input_/,'')
|
||||
|
||||
target = "display_" + elid
|
||||
|
||||
preprocessor_tag = "inputtype_" + elid
|
||||
mathjax_preprocessor = @inputtypeDisplays[preprocessor_tag]
|
||||
|
||||
if jax = MathJax.Hub.getAllJax(target)[0]
|
||||
eqn = $(element).val()
|
||||
if @mathjax_preprocessor
|
||||
eqn = @mathjax_preprocessor(eqn)
|
||||
if mathjax_preprocessor
|
||||
eqn = mathjax_preprocessor(eqn)
|
||||
|
||||
MathJax.Hub.Queue ['Text', jax, eqn],
|
||||
[@updateMathML, jax, element]
|
||||
@@ -324,9 +329,13 @@ class @Problem
|
||||
inputtypeSetupMethods:
|
||||
|
||||
textinputdynamath: (element) =>
|
||||
preprocessorClass = window['MathjaxPreprocessorFor6002x']
|
||||
data = $(element).find('.textinputdynamath_data')
|
||||
|
||||
preprocessorClassName = data.data('preprocessor')
|
||||
preprocessorClass = window[preprocessorClassName]
|
||||
|
||||
preprocessor = new preprocessorClass()
|
||||
alert preprocessor.fn
|
||||
return preprocessor.fn
|
||||
|
||||
javascriptinput: (element) =>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user