From ea7856c8341eca26089e61f9ba40d30b3cf57ed7 Mon Sep 17 00:00:00 2001 From: Shreya Bhandari Date: Sat, 7 Sep 2024 02:15:06 -0700 Subject: [PATCH] input required --- src/components/problem-layout/HintTextbox.js | 9 +++++++++ src/components/problem-layout/ProblemCard.js | 7 ++++++- src/components/problem-layout/ToastNotifyCorrectness.js | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/components/problem-layout/HintTextbox.js b/src/components/problem-layout/HintTextbox.js index da8fa3fb1da..095f90643bd 100644 --- a/src/components/problem-layout/HintTextbox.js +++ b/src/components/problem-layout/HintTextbox.js @@ -12,6 +12,9 @@ import { stagingProp } from "../../util/addStagingProperty"; import { toastNotifyCorrectness } from "./ToastNotifyCorrectness"; import { joinList } from "../../util/formListString"; import withTranslation from "../../util/withTranslation.js" +import { + toastNotifyEmpty +} from "./ToastNotifyCorrectness"; class HintTextbox extends React.Component { static contextType = ThemeContext; @@ -47,6 +50,12 @@ class HintTextbox extends React.Component { variabilization: chooseVariables(this.props.hintVars, this.props.seed), questionText: this.hint.text }); + + if (parsed == '') { + toastNotifyEmpty() + return; + } + this.props.submitHint(parsed, this.hint, correctAnswer, this.props.hintNum); const isCorrect = !!correctAnswer diff --git a/src/components/problem-layout/ProblemCard.js b/src/components/problem-layout/ProblemCard.js index 84d1e58ed3e..a46d3e585df 100644 --- a/src/components/problem-layout/ProblemCard.js +++ b/src/components/problem-layout/ProblemCard.js @@ -29,7 +29,7 @@ import { stagingProp } from "../../util/addStagingProperty"; import ErrorBoundary from "../ErrorBoundary"; import { toastNotifyCompletion, - toastNotifyCorrectness, + toastNotifyCorrectness, toastNotifyEmpty } from "./ToastNotifyCorrectness"; import { joinList } from "../../util/formListString"; import axios from "axios"; @@ -211,6 +211,11 @@ class ProblemCard extends React.Component { const { seed, problemVars, problemID, courseName, answerMade, lesson } = this.props; + if (inputVal == '') { + toastNotifyEmpty() + return; + } + const [parsed, correctAnswer, reason] = checkAnswer({ attempt: inputVal, actual: stepAnswer, diff --git a/src/components/problem-layout/ToastNotifyCorrectness.js b/src/components/problem-layout/ToastNotifyCorrectness.js index 62155b581fe..6b21ac3841f 100644 --- a/src/components/problem-layout/ToastNotifyCorrectness.js +++ b/src/components/problem-layout/ToastNotifyCorrectness.js @@ -28,3 +28,9 @@ export function toastNotifyCompletion(translate) { autoClose: 3000 }) } + +export function toastNotifyEmpty() { + toast.info("Please input an answer.", { + autoClose: 3000 + }) +}