From 8b8d9efc568a08debcd0efeb04925f9287162c95 Mon Sep 17 00:00:00 2001 From: Vignesh Date: Fri, 24 Aug 2018 17:24:23 +0800 Subject: [PATCH] Fix MCQ option 0 not showing hints (#329) * Fix MCQ option 0 not displaying intent and hints Truthy check, 0 is false. T-T * Format file * Keep one mock data as option 0 * Bump version --- package.json | 2 +- src/components/workspace/MCQChooser.tsx | 6 +++--- src/mocks/assessmentAPI.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 90c9c49b05..a6021928f7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "cadet-frontend", - "version": "1.0.4", + "version": "1.0.5", "scripts-info": { "format": "Format source code", "start": "Start the Webpack development server", diff --git a/src/components/workspace/MCQChooser.tsx b/src/components/workspace/MCQChooser.tsx index 9685cdfcc4..1553683e84 100644 --- a/src/components/workspace/MCQChooser.tsx +++ b/src/components/workspace/MCQChooser.tsx @@ -60,7 +60,7 @@ class MCQChooser extends React.PureComponent { mcqOption: i }) } - const shouldDisplayMessage = this.props.mcq.solution && this.props.mcq.choices[i].hint + const shouldDisplayMessage = this.props.mcq.solution !== null && this.props.mcq.choices[i].hint if (shouldDisplayMessage) { const hintElement = if (i === this.props.mcq.solution) { @@ -86,8 +86,8 @@ class MCQChooser extends React.PureComponent { solution: number | null ): Intent => { const active = currentOption === chosenOption - const correctOptionSelected = active && solution && currentOption === solution - if (!solution) { + const correctOptionSelected = active && solution !== null && currentOption === solution + if (solution === null) { return Intent.NONE } else if (active && correctOptionSelected) { return Intent.SUCCESS diff --git a/src/mocks/assessmentAPI.ts b/src/mocks/assessmentAPI.ts index 753d2d2425..2ae61eb16d 100644 --- a/src/mocks/assessmentAPI.ts +++ b/src/mocks/assessmentAPI.ts @@ -213,7 +213,7 @@ What's your favourite dinner food? id: 2, library: mockCurveLibrary, type: 'mcq', - solution: 2 + solution: 0 }, { answer: 3,