From 68fb5e5bc72a1582d9f108c056c4461f93428c95 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 18 Sep 2023 08:16:56 +0100 Subject: [PATCH] Updated a problem with the rendering of the Solutions --- src/components/Solutions/FillBlanks.tsx | 13 +++-- src/components/Solutions/MatchSentences.tsx | 31 ++++++----- src/components/Solutions/MultipleChoice.tsx | 2 +- src/components/Solutions/TrueFalse.tsx | 61 +++++++++++---------- 4 files changed, 56 insertions(+), 51 deletions(-) diff --git a/src/components/Solutions/FillBlanks.tsx b/src/components/Solutions/FillBlanks.tsx index 598c770c..77c7aa40 100644 --- a/src/components/Solutions/FillBlanks.tsx +++ b/src/components/Solutions/FillBlanks.tsx @@ -85,12 +85,13 @@ export default function FillBlanksSolutions({id, type, prompt, solutions, text, ))} - {text.split("\\n").map((line, index) => ( -

- {renderLines(line)} -
-

- ))} + {userSolutions && + text.split("\\n").map((line, index) => ( +

+ {renderLines(line)} +
+

+ ))}
diff --git a/src/components/Solutions/MatchSentences.tsx b/src/components/Solutions/MatchSentences.tsx index d0582c99..c2537202 100644 --- a/src/components/Solutions/MatchSentences.tsx +++ b/src/components/Solutions/MatchSentences.tsx @@ -74,21 +74,22 @@ export default function MatchSentencesSolutions({
))}
- {sentences.map((sentence, index) => ( - x.question === sentence.id) - ? "#CC5454" - : userSolutions.find((x) => x.question === sentence.id)?.option === sentence.solution - ? "#7872BF" - : "#CC5454" - } - showHead={false} - /> - ))} + {userSolutions && + sentences.map((sentence, index) => ( + x.question === sentence.id) + ? "#CC5454" + : userSolutions.find((x) => x.question === sentence.id)?.option === sentence.solution + ? "#7872BF" + : "#CC5454" + } + showHead={false} + /> + ))}
diff --git a/src/components/Solutions/MultipleChoice.tsx b/src/components/Solutions/MultipleChoice.tsx index 308a4654..5ef32351 100644 --- a/src/components/Solutions/MultipleChoice.tsx +++ b/src/components/Solutions/MultipleChoice.tsx @@ -88,7 +88,7 @@ export default function MultipleChoice({id, type, prompt, questions, userSolutio
{prompt} - {questionIndex < questions.length && ( + {userSolutions && questionIndex < questions.length && ( questions[questionIndex].id === x.question)?.option} diff --git a/src/components/Solutions/TrueFalse.tsx b/src/components/Solutions/TrueFalse.tsx index 4e65991d..a80df152 100644 --- a/src/components/Solutions/TrueFalse.tsx +++ b/src/components/Solutions/TrueFalse.tsx @@ -64,37 +64,40 @@ export default function TrueFalseSolution({prompt, type, id, questions, userSolu
You can click a selected option again to deselect it.
- {questions.map((question, index) => { - const userSolution = userSolutions.find((x) => x.id === question.id.toString()); + {userSolutions && + questions.map((question, index) => { + const userSolution = userSolutions.find((x) => x.id === question.id.toString()); - return ( -
- - {index + 1}. {question.prompt} - -
- - - + return ( +
+ + {index + 1}. {question.prompt} + +
+ + + +
-
- ); - })} + ); + })}