Skip to content

Commit

Permalink
systemseed#173 Replace alert with SnackError for quiz.
Browse files Browse the repository at this point in the history
  • Loading branch information
gease committed Jun 27, 2022
1 parent ca4d976 commit cb45b4a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/src/components/ParagraphsWithQuiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -186,6 +188,15 @@ class ParagraphsWithQuiz extends React.Component {
isQuiz
/>
)}
<SnackAlert
show={this.state.alertOpen}
message={Drupal.t('Quiz submission failed. Please try again.', {}, { context: 'ANU LMS' })}
onClose={() => this.setState({ alertOpen: false })}
severity='warning'
variant="filled"
spaced
duration={5000}
/>
</LessonGrid>
</>
);
Expand Down

0 comments on commit cb45b4a

Please sign in to comment.