Skip to content
Snippets Groups Projects
Commit 49be9303 authored by srosse's avatar srosse
Browse files

OO-2842: add MathJax to the offline results reports

parent 118f3073
No related branches found
No related tags found
No related merge requests found
......@@ -344,6 +344,16 @@ public class VelocityRenderDecorator implements Closeable {
return sb;
}
public StringOutput mathJaxCdnFullUrl() {
StringOutput sb = new StringOutput(100);
if(WebappHelper.getMathJaxCdn().startsWith("http")) {
sb.append(WebappHelper.getMathJaxCdn());
} else {
sb.append("https:").append(WebappHelper.getMathJaxCdn());
}
return sb;
}
public StringOutput contextPath() {
StringOutput sb = new StringOutput(100);
sb.append(Settings.getServerContextPath());
......
<!DOCTYPE HTML>
<html>
<head>
<title>$rootTitle</title>
<link rel='stylesheet' href='../../../css/offline/qti/theme.css' />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
</head>
<body class="o_page_margins">
<div id="o_main">$r.render("results")</div>
</body>
</html>
\ No newline at end of file
......@@ -53,6 +53,7 @@ import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.render.URLBuilder;
import org.olat.core.gui.render.velocity.VelocityHelper;
import org.olat.core.gui.render.velocity.VelocityRenderDecorator;
import org.olat.core.gui.translator.Translator;
import org.olat.core.gui.util.WindowControlMocker;
import org.olat.core.id.Identity;
......@@ -306,9 +307,10 @@ public class QTI21ResultsExportMediaResource implements MediaResource {
mainVC.contextPut("rootTitle", translator.translate("table.grading"));
mainVC.put("results", results);
//render VelocityContainer to StringOutPut
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
Renderer renderer = Renderer.getInstance(mainVC, translator, ubu, new RenderResult(), new EmptyGlobalSettings());
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(renderer, mainVC, sb);
mainVC.contextPut("r", vrdec);
renderer.render(sb, mainVC, null);
return sb.toString();
}
......
<!DOCTYPE HTML>
<html>
<head>
......@@ -23,6 +24,45 @@
function setFlexiFormDirtyByListener(e){
//
}
function o_mathjax() {
jQuery.ajax("${r.mathJaxCdnFullUrl()}MathJax.js?config=TeX-AMS-MML_HTMLorMML", {
cache: true,
dataType: "script",
success: function() {
MathJax.Hub.Config({
extensions: ["jsMath2jax.js"],
messageStyle: 'none',
showProcessingMessages: false,
showMathMenu: false,
menuSettings: { },
jsMath2jax: {
preview: "none"
},
tex2jax: {
ignoreClass: "math"
},
"HTML-CSS": {
EqnChunk: 5, EqnChunkFactor: 1, EqnChunkDelay: 100
},
"fast-preview": {
disabled: true
}
});
}
});
}
var BFormatter = {
// format on load
formatLatexFormulas : function(domId) {}
};
jQuery(function() {
if ((window.unsafeWindow == null ? window : unsafeWindow).MathJax == null) {
var count = jQuery('div.math,span.math,math,div.mathEntryInteraction').length;
if (count > 0) {
o_mathjax();
}
}
});
/* ]]> */
</script>
</head>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment