aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amd/build/display.min.js2
-rw-r--r--amd/src/display.js15
-rw-r--r--renderer.php2
3 files changed, 10 insertions, 9 deletions
diff --git a/amd/build/display.min.js b/amd/build/display.min.js
index cd5da13..482c799 100644
--- a/amd/build/display.min.js
+++ b/amd/build/display.min.js
@@ -1 +1 @@
-define(["jquery","core/config","core/notification"],function(a,b,c){return{init:function(){a(".algebra_answer").on("input paste keyup",null,null,function(){var d=a(this).attr("id"),e=d.replace(":","_"),f=a("#"+e+"_vars").html(),g=a(this).val(),h={vars:f,expr:g,sesskey:b.sesskey};a.post(b.wwwroot+"/question/type/algebra/ajax.php",h,null,"json").done(function(b){a("#"+e+"_display").html('<span class="filter_mathjaxloader_equation">'+b+"</span>"),MathJax.Hub.Queue(["Typeset",MathJax.Hub])}).fail(function(a,b,d){c.exception(d)})})}}}); \ No newline at end of file
+define(["jquery","core/config","core/notification"],function(a,b,c){return{init:function(){a(".algebra_answer").on("input paste keyup",null,null,function(){var d=a(this).attr("id"),e=d.replace(":","_"),f={vars:a("#"+e+"_vars").html(),expr:a(this).val(),sesskey:b.sesskey};a.post(b.wwwroot+"/question/type/algebra/ajax.php",f,null,"json").done(function(b){var c=a("#"+e+"_display");c.html('<span class="filter_mathjaxloader_equation">'+b+"</span>"),require(["core/event"],function(a){a.notifyFilterContentUpdated(c)})}).fail(function(a,b,d){c.exception(d)})})}}}); \ No newline at end of file
diff --git a/amd/src/display.js b/amd/src/display.js
index e2131b7..4e80356 100644
--- a/amd/src/display.js
+++ b/amd/src/display.js
@@ -5,19 +5,20 @@ define(['jquery', 'core/config', 'core/notification'], function($, config, notif
// Convert answer id to valid javascript name.
var id = $(this).attr('id');
var display = id.replace(':', '_');
- var varnames = $('#' + display + '_vars').html();
- var currentanswer = $(this).val();
var params = {
- vars: varnames,
- expr: currentanswer,
+ vars: $('#' + display + '_vars').html(),
+ expr: $(this).val(),
sesskey: config.sesskey,
};
$.post(config.wwwroot + '/question/type/algebra/ajax.php', params, null, 'json')
.done(function(data) {
// Replace TeX form in page.
- $('#' + display + '_display').html("<span class=\"filter_mathjaxloader_equation\">" + data +"</span>");
- // MathJax update.
- MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
+ var displaydiv = $('#' + display + '_display');
+ displaydiv.html("<span class=\"filter_mathjaxloader_equation\">" + data +"</span>");
+ // Notify the filters about the modified node.
+ require(['core/event'], function(event) {
+ event.notifyFilterContentUpdated(displaydiv);
+ });
})
.fail(function(jqXHR, status, error) {
notification.exception(error);
diff --git a/renderer.php b/renderer.php
index e19ae11..a368397 100644
--- a/renderer.php
+++ b/renderer.php
@@ -143,7 +143,7 @@ class qtype_algebra_renderer extends qtype_renderer {
)
);
- $display = $question->format_text("<span class=\"filter_mathjaxloader_equation\">" . $question->formated_expression($currentanswer, $vars) ."</span>",
+ $display = $question->format_text($question->formated_expression($currentanswer, $vars),
FORMAT_MOODLE ,$qa, 'question', 'questiontext', $question->id);
$result .= html_writer::tag('div', $display ,array(
'type' => 'text',