mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-30 16:01:14 -04:00
fix(curriculum): add feedback for unanswered multiple choice questions (#57707)
This commit is contained in:
@@ -425,6 +425,7 @@
|
||||
"assignments": "Assignments",
|
||||
"question": "Question",
|
||||
"questions": "Questions",
|
||||
"answered-mcq": "You have unanswered questions and/or incorrect answers.",
|
||||
"explanation": "Explanation",
|
||||
"solution-link": "Solution Link",
|
||||
"source-code-link": "Source Code Link",
|
||||
|
||||
@@ -156,6 +156,9 @@ const ShowGeneric = ({
|
||||
const [submittedMcqAnswers, setSubmittedMcqAnswers] = useState(
|
||||
questions.map<number | null>(() => null)
|
||||
);
|
||||
|
||||
const [hasAnsweredMcqCorrectly, sethasAnsweredMcqCorrectly] = useState(true);
|
||||
|
||||
const [showFeedback, setShowFeedback] = useState(false);
|
||||
|
||||
const showNextCurriculum = useFeature('fcc-10').on;
|
||||
@@ -171,7 +174,6 @@ const ShowGeneric = ({
|
||||
);
|
||||
};
|
||||
|
||||
// submit
|
||||
const handleSubmit = () => {
|
||||
const hasCompletedAssignments =
|
||||
assignments.length === 0 || allAssignmentsCompleted;
|
||||
@@ -183,6 +185,12 @@ const ShowGeneric = ({
|
||||
if (hasCompletedAssignments && mcqCorrect) {
|
||||
openCompletionModal();
|
||||
}
|
||||
|
||||
if (mcqSolutions.length > selectedMcqOptions.length || !mcqCorrect) {
|
||||
sethasAnsweredMcqCorrectly(false);
|
||||
} else {
|
||||
sethasAnsweredMcqCorrectly(true);
|
||||
}
|
||||
};
|
||||
|
||||
const sceneSubject = new SceneSubject();
|
||||
@@ -258,6 +266,10 @@ const ShowGeneric = ({
|
||||
<ChallengeExplanation explanation={explanation} />
|
||||
) : null}
|
||||
|
||||
{!hasAnsweredMcqCorrectly && (
|
||||
<p className='text-center'>{t('learn.answered-mcq')}</p>
|
||||
)}
|
||||
|
||||
<Button block={true} variant='primary' onClick={handleSubmit}>
|
||||
{blockType === BlockTypes.review
|
||||
? t('buttons.submit')
|
||||
|
||||
Reference in New Issue
Block a user