Skip to content

Commit

Permalink
input required
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreya Bhandari committed Sep 7, 2024
1 parent e365730 commit ea7856c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/components/problem-layout/HintTextbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/components/problem-layout/ProblemCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/components/problem-layout/ToastNotifyCorrectness.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ export function toastNotifyCompletion(translate) {
autoClose: 3000
})
}

export function toastNotifyEmpty() {
toast.info("Please input an answer.", {
autoClose: 3000
})
}

0 comments on commit ea7856c

Please sign in to comment.