diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json
index 3ae980717fd..dfd72ee1447 100644
--- a/client/i18n/locales/english/translations.json
+++ b/client/i18n/locales/english/translations.json
@@ -527,8 +527,10 @@
"building-a-university": "We're Building a Free Computer Science University Degree Program 🎉",
"if-help-university": "We've already made a ton of progress. Donate now to help our charity with the road ahead.",
"preview-external-window": "Preview currently showing in external window.",
- "fill-in-the-blank": "Fill in the blank",
- "blank": "blank",
+ "fill-in-the-blank": {
+ "heading": "Fill in the blank",
+ "blank": "blank"
+ },
"quiz": {
"correct-answer": "Correct!",
"incorrect-answer": "Incorrect.",
diff --git a/client/src/templates/Challenges/components/fill-in-the-blanks.tsx b/client/src/templates/Challenges/components/fill-in-the-blanks.tsx
index e7b19a1c14c..549a0dead35 100644
--- a/client/src/templates/Challenges/components/fill-in-the-blanks.tsx
+++ b/client/src/templates/Challenges/components/fill-in-the-blanks.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
-
import { Spacer } from '@freecodecamp/ui';
+
import { parseBlanks } from '../fill-in-the-blank/parse-blanks';
import PrismFormatted from '../components/prism-formatted';
import { FillInTheBlank } from '../../../redux/prop-types';
@@ -26,10 +26,14 @@ function FillInTheBlanks({
}: FillInTheBlankProps): JSX.Element {
const { t } = useTranslation();
- const addInputClass = (index: number): string => {
- if (answersCorrect[index] === true) return 'green-underline';
- if (answersCorrect[index] === false) return 'red-underline';
- return '';
+ const getInputClass = (index: number): string => {
+ let cls = 'fill-in-the-blank-input';
+
+ if (answersCorrect[index] === false) {
+ cls += ' incorrect-blank-answer';
+ }
+
+ return cls;
};
const paragraphs = parseBlanks(sentence);
@@ -37,7 +41,7 @@ function FillInTheBlanks({
return (
<>
-
{p.map((node, j) => { const { type, value } = node; - if (type === 'text') return value; - if (type === 'blank') + if (type === 'text') { + return value; + } + + // If a blank is answered correctly, render the answer as part of the sentence. + if (type === 'blank' && answersCorrect[value] === true) { return ( - + + {blankAnswers[value]} + ); + } + + return ( + + ); })}
); })}