From 90596382c04b80d9d033d6ae4a2ae3190636ec88 Mon Sep 17 00:00:00 2001 From: rgomeztao Date: Fri, 5 May 2023 17:25:04 +0200 Subject: [PATCH 1/5] feat: implement async fix --- src/qtiCommonRenderer/renderers/Math.js | 11 ++++++++++- .../renderers/interactions/AssociateInteraction.js | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qtiCommonRenderer/renderers/Math.js b/src/qtiCommonRenderer/renderers/Math.js index 31ec4671..58d8dbf3 100644 --- a/src/qtiCommonRenderer/renderers/Math.js +++ b/src/qtiCommonRenderer/renderers/Math.js @@ -38,6 +38,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) { @@ -48,7 +54,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(); } diff --git a/src/qtiCommonRenderer/renderers/interactions/AssociateInteraction.js b/src/qtiCommonRenderer/renderers/interactions/AssociateInteraction.js index dca5d950..8c75b6db 100644 --- a/src/qtiCommonRenderer/renderers/interactions/AssociateInteraction.js +++ b/src/qtiCommonRenderer/renderers/interactions/AssociateInteraction.js @@ -735,7 +735,6 @@ const render = function(interaction) { renderEmptyPairs(interaction); sizeAdapter.adaptSize($('.result-area .target, .choice-area .qti-choice', $container)); - resolve(); }); }; From 379a3b213566e107e85dd9fd89609167298dc521 Mon Sep 17 00:00:00 2001 From: rgomeztao Date: Mon, 8 May 2023 09:59:57 +0200 Subject: [PATCH 2/5] chore: fixes prettier --- src/qtiCommonRenderer/renderers/Math.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qtiCommonRenderer/renderers/Math.js b/src/qtiCommonRenderer/renderers/Math.js index 58d8dbf3..4c330b48 100644 --- a/src/qtiCommonRenderer/renderers/Math.js +++ b/src/qtiCommonRenderer/renderers/Math.js @@ -38,12 +38,12 @@ export default { template: tpl, getContainer: containerHelper.get, render: function render(math) { - $("body").on("mathjaxRendered", function(event, reference) { - if($(reference).find('math').length !== 0) { + $('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) { @@ -55,7 +55,7 @@ export default { if ($self.length) { MathJax.Hub.Queue(['Typeset', MathJax.Hub, $self[0]]); MathJax.Hub.Queue(function () { - $("body").trigger("mathjaxRendered", [$self[0]]); + $('body').trigger('mathjaxRendered', [$self[0]]); resolve(); }); } else { From dfffbcf11fc4909d7231bbc002fae502d3f4d2a8 Mon Sep 17 00:00:00 2001 From: rgomeztao Date: Mon, 8 May 2023 10:10:28 +0200 Subject: [PATCH 3/5] chore: fixes eslint issues --- src/qtiCommonRenderer/renderers/Math.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qtiCommonRenderer/renderers/Math.js b/src/qtiCommonRenderer/renderers/Math.js index 4c330b48..7258edd9 100644 --- a/src/qtiCommonRenderer/renderers/Math.js +++ b/src/qtiCommonRenderer/renderers/Math.js @@ -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 From 401f031d64d434cb5e299747a0257c03fb732509 Mon Sep 17 00:00:00 2001 From: rgomeztao Date: Thu, 11 May 2023 11:35:01 +0200 Subject: [PATCH 4/5] chore: adds version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dfc81381..254fae4c 100644 --- a/package.json +++ b/package.json @@ -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": [ From 2f752865af938dfa53ebc7983139f68aa4bdab1f Mon Sep 17 00:00:00 2001 From: rgomeztao Date: Thu, 11 May 2023 11:40:26 +0200 Subject: [PATCH 5/5] fix: updates version bump --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 89787640..c7547456 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@oat-sa/tao-item-runner-qti", - "version": "1.9.3", + "version": "1.9.4", "lockfileVersion": 1, "requires": true, "dependencies": {