@@ -795,6 +795,36 @@ export class CoreQuestionHelperProvider {
795795 onAbort ?. emit ( ) ;
796796 }
797797
798+ /**
799+ * Returns correct icon based on the LMS version.
800+ * In LMS 4.4 and older, fa-check means correct. In 4.5+, fa-check means partially correct.
801+ *
802+ * @param withPrefix Whether to include the prefix in the icon name.
803+ * @returns Icon name.
804+ */
805+ getCorrectIcon ( withPrefix = true ) : string {
806+ const icon = CoreSites . getRequiredCurrentSite ( ) . isVersionGreaterEqualThan ( '4.5' )
807+ ? 'check-double'
808+ : 'check' ;
809+
810+ return withPrefix ? `fas-${ icon } ` : icon ;
811+ }
812+
813+ /**
814+ * Returns partially correct icon based on the LMS version.
815+ * In LMS 4.4 and older, fa-check means correct. In 4.5+, fa-check means partially correct.
816+ *
817+ * @param withPrefix Whether to include the prefix in the icon name.
818+ * @returns Icon name.
819+ */
820+ getPartiallyCorrectIcon ( withPrefix = true ) : string {
821+ const icon = CoreSites . getRequiredCurrentSite ( ) . isVersionGreaterEqualThan ( '4.5' )
822+ ? 'check'
823+ : 'square-check' ;
824+
825+ return withPrefix ? `fas-${ icon } ` : icon ;
826+ }
827+
798828 /**
799829 * Treat correctness icons, replacing them with local icons and setting click events to show the feedback if needed.
800830 *
@@ -806,24 +836,22 @@ export class CoreQuestionHelperProvider {
806836 let iconName : string | undefined ;
807837 let color : string | undefined ;
808838
839+ const correctIcon = this . getCorrectIcon ( false ) ;
840+ const partiallyCorrectIcon = this . getCorrectIcon ( false ) ;
809841 if ( 'src' in icon ) {
810842 if ( ( icon as HTMLImageElement ) . src . indexOf ( 'correct' ) >= 0 ) {
811- iconName = 'check' ;
843+ iconName = correctIcon ;
812844 color = CoreIonicColorNames . SUCCESS ;
813845 } else if ( ( icon as HTMLImageElement ) . src . indexOf ( 'incorrect' ) >= 0 ) {
814846 iconName = 'xmark' ;
815847 color = CoreIonicColorNames . DANGER ;
816848 }
817849 } else {
818- // In LMS 4.4 and older, fa-check means correct. In 4.5+, fa-check means partially correct.
819- if (
820- icon . classList . contains ( 'fa-check-square' ) ||
821- ( icon . classList . contains ( 'fa-check' ) && icon . classList . contains ( 'text-warning' ) )
822- ) {
823- iconName = 'check' ;
850+ if ( icon . classList . contains ( `fa-${ partiallyCorrectIcon } ` ) ) {
851+ iconName = partiallyCorrectIcon ;
824852 color = CoreIonicColorNames . WARNING ;
825- } else if ( icon . classList . contains ( ' fa-check-double' ) || icon . classList . contains ( 'fa-check' ) ) {
826- iconName = 'check-double' ;
853+ } else if ( icon . classList . contains ( ` fa-${ correctIcon } ` ) ) {
854+ iconName = correctIcon ;
827855 color = CoreIonicColorNames . SUCCESS ;
828856 } else if ( icon . classList . contains ( 'fa-xmark' ) || icon . classList . contains ( 'fa-remove' ) ) {
829857 iconName = 'xmark' ;
0 commit comments