From cb45b4aa7e484b8d1085cdd7ffac8cb9b7b5bf8f Mon Sep 17 00:00:00 2001 From: gease Date: Sat, 21 May 2022 18:34:29 +0200 Subject: [PATCH] #173 Replace alert with SnackError for quiz. --- js/src/components/ParagraphsWithQuiz.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/src/components/ParagraphsWithQuiz.js b/js/src/components/ParagraphsWithQuiz.js index db82b5be..24a6e3db 100644 --- a/js/src/components/ParagraphsWithQuiz.js +++ b/js/src/components/ParagraphsWithQuiz.js @@ -6,6 +6,7 @@ import QuizSubmit from '@anu/components/QuizSubmit'; import paragraphMappings from '@anu/utilities/paragraphMappings'; import Box from '@material-ui/core/Box'; import QuizAlert from '@anu/components/QuizAlert'; +import SnackAlert from "@anu/components/SnackAlert"; // TODO - should be a pure function component with hooks. class ParagraphsWithQuiz extends React.Component { @@ -18,6 +19,7 @@ class ParagraphsWithQuiz extends React.Component { correctValuesCount: !isNaN(props.correctValuesCount) ? props.correctValuesCount : -1, isSubmitting: false, openDialog: false, + alertOpen: false, readyToSubmit: !props.isSingleSubmission, isSingleSubmission: props.isSingleSubmission, }; @@ -96,7 +98,7 @@ class ParagraphsWithQuiz extends React.Component { }); this.props.submitQuiz(true); } else { - alert(Drupal.t('Quiz submission failed. Please try again.', {}, { context: 'ANU LMS' })); + this.setState({alertOpen: true}); console.error(response.status, await response.text()); } } catch (error) { @@ -186,6 +188,15 @@ class ParagraphsWithQuiz extends React.Component { isQuiz /> )} + this.setState({ alertOpen: false })} + severity='warning' + variant="filled" + spaced + duration={5000} + /> );