Skip to content

Commit

Permalink
Merge pull request #369 from oat-sa/backport/AUT-3093/math-expression…
Browse files Browse the repository at this point in the history
…-fix

Backport/aut 3093/math expression fix
  • Loading branch information
rgomeztao authored May 11, 2023
2 parents 9cc1da1 + 2f75286 commit 56f7da4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-item-runner-qti",
"version": "1.9.3",
"version": "1.9.4",
"displayName": "TAO Item Runner QTI",
"description": "TAO QTI Item Runner modules",
"files": [
Expand Down
12 changes: 11 additions & 1 deletion src/qtiCommonRenderer/renderers/Math.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import tpl from 'taoQtiItem/qtiCommonRenderer/tpl/math';
import containerHelper from 'taoQtiItem/qtiCommonRenderer/helpers/container';
import MathJax from 'mathJax';
import $ from 'jquery';

// Do not wait between rendering each individual math element
// http://docs.mathjax.org/en/latest/api/hub.html
Expand All @@ -38,6 +39,12 @@ export default {
template: tpl,
getContainer: containerHelper.get,
render: function render(math) {
$('body').on('mathjaxRendered', function (event, reference) {
if ($(reference).find('math').length !== 0) {
$(reference).closest('.qti-choice').addClass('flexible-choice-width');
}
});

return new Promise(function (resolve) {
const $self = containerHelper.get(math);
if (typeof MathJax !== 'undefined' && MathJax) {
Expand All @@ -48,7 +55,10 @@ export default {
//defer execution fix some rendering issue in chrome
if ($self.length) {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, $self[0]]);
MathJax.Hub.Queue(resolve);
MathJax.Hub.Queue(function () {
$('body').trigger('mathjaxRendered', [$self[0]]);
resolve();
});
} else {
resolve();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ const render = function(interaction) {
renderEmptyPairs(interaction);

sizeAdapter.adaptSize($('.result-area .target, .choice-area .qti-choice', $container));

resolve();
});
};
Expand Down

0 comments on commit 56f7da4

Please sign in to comment.