From e1984110b62ce4cdb7cf2516167d2022089c1663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 3 Sep 2024 11:20:56 +0200 Subject: [PATCH] MOBILE-4638 quiz: Apply new correctness icons depending on LMS version --- .../component/addon-qtype-ordering.html | 5 +- .../qtype/ordering/component/ordering.ts | 6 +++ .../classes/base-question-component.ts | 4 +- .../question/services/question-helper.ts | 46 +++++++++++++++---- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/addons/qtype/ordering/component/addon-qtype-ordering.html b/src/addons/qtype/ordering/component/addon-qtype-ordering.html index 14675811ca6..e39e23a65d7 100644 --- a/src/addons/qtype/ordering/component/addon-qtype-ordering.html +++ b/src/addons/qtype/ordering/component/addon-qtype-ordering.html @@ -19,11 +19,12 @@ @if (dragDisabled) { @if (item.correctClass === 'correct') { - + } @else if (item.correctClass === 'incorrect') { } @else if (item.correctClass.startsWith('partial')) { - + } } diff --git a/src/addons/qtype/ordering/component/ordering.ts b/src/addons/qtype/ordering/component/ordering.ts index 89e68a4f33f..3db0012016b 100644 --- a/src/addons/qtype/ordering/component/ordering.ts +++ b/src/addons/qtype/ordering/component/ordering.ts @@ -39,6 +39,9 @@ export class AddonQtypeOrderingComponent extends CoreQuestionBaseComponent= 0) { - iconName = 'check'; + iconName = correctIcon; color = CoreIonicColorNames.SUCCESS; } else if ((icon as HTMLImageElement).src.indexOf('incorrect') >= 0 ) { iconName = 'xmark'; color = CoreIonicColorNames.DANGER; } } else { - // In LMS 4.4 and older, fa-check means correct. In 4.5+, fa-check means partially correct. - if ( - icon.classList.contains('fa-check-square') || - (icon.classList.contains('fa-check') && icon.classList.contains('text-warning')) - ) { - iconName = 'check'; + if (icon.classList.contains(`fa-${partiallyCorrectIcon}`)) { + iconName = partiallyCorrectIcon; color = CoreIonicColorNames.WARNING; - } else if (icon.classList.contains('fa-check-double') || icon.classList.contains('fa-check')) { - iconName = 'check-double'; + } else if (icon.classList.contains(`fa-${correctIcon}`)) { + iconName = correctIcon; color = CoreIonicColorNames.SUCCESS; } else if (icon.classList.contains('fa-xmark') || icon.classList.contains('fa-remove')) { iconName = 'xmark';