Skip to content

Commit

Permalink
Check for null before using option.no
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtan2000 committed Sep 17, 2024
1 parent f08f936 commit 1ce2f7a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/(main)/quiz/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ const QuizPage: React.FC = () => {
{currentQuestion.options && currentQuestion.options.map((option) => (
<div key={option.no} className="cardOption">
<label className="option-label">
<div style={{ display: 'flex', alignItems: 'center' }}>{`mcq-${option.no}`}
<div style={{ display: 'flex', alignItems: 'center' }}>`{option.no}`
{option.no !== null && `mcq-${option.no}`}
<input
type="radio"
name={`mcq-${currentQuestion.id}`}
Expand Down Expand Up @@ -466,7 +467,8 @@ const QuizPage: React.FC = () => {
) : (
<Button
label="Submit"
onClick={() => {submitAttempt(quiz.id, currentQuestion.id, selectedOptions[currentQuestion.id]);
onClick={() => {
submitAttempt(quiz.id, currentQuestion.id, selectedOptions[currentQuestion.id]);
handleSubmitAnswer()
}}
disabled={isAnswerSubmitted}
Expand Down

0 comments on commit 1ce2f7a

Please sign in to comment.