Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

#173 Replace alert with SnackError for quiz. #184

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gease why did you decide to use warning severity here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you decide to use warning severity here?
Arbitrary choice. Change to whatever you like.

As for QuizOptionsHandler, this component seems to never be rendered. At least i failed to find where it is.

@kalabro ^^

variant="filled"
spaced
duration={5000}
/>
</LessonGrid>
</>
);
Expand Down