Skip to content

Commit

Permalink
fix: Show correct active step status in assignment view when the page…
Browse files Browse the repository at this point in the history
… is loaded.
  • Loading branch information
mpetojevic committed Oct 28, 2024
1 parent dd3f93a commit 0ade5bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/components/assignment/assignment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const AssignmentComponent = () => {
} = useQuery<number>({
queryKey: ['subLeft'],
queryFn: async () => {
refetchSubmissions();
await refetchSubmissions();
const response = await getSubmissionCount(lectureId, assignmentId);
const remainingSubmissions =
assignment.max_submissions - response.submission_count;
Expand Down Expand Up @@ -154,7 +154,7 @@ export const AssignmentComponent = () => {
setActiveStatus(active_step);
});
}
}, [lecture, assignment]);
}, [lecture, assignment, submissions]);

if (
isLoadingAssignment ||
Expand Down Expand Up @@ -190,7 +190,7 @@ export const AssignmentComponent = () => {
enqueueSnackbar('Successfully Reset Assignment', {
variant: 'success'
});
refetchFiles();
await refetchFiles();
} catch (e) {
if (e instanceof Error) {
enqueueSnackbar('Error Reset Assignment: ' + e.message, {
Expand All @@ -214,9 +214,10 @@ export const AssignmentComponent = () => {
async () => {
await submitAssignment(lecture, assignment, true).then(
() => {
refetchSubleft();
const active_step = calculateActiveStep(submissions);
setActiveStatus(active_step);
refetchSubleft().then(() => {
const active_step = calculateActiveStep(submissions);
setActiveStatus(active_step);
});
enqueueSnackbar('Successfully Submitted Assignment', {
variant: 'success'
});
Expand Down
7 changes: 4 additions & 3 deletions src/components/assignment/submission-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export const SubmissionList = (props: ISubmissionListProps) => {
startIcon={<DeleteIcon />}
size="small"
onClick={() => {
const warningMessage = props.subLeft === 0 && props.submissions.length === 1
const warningMessage =
props.subLeft === 0 && props.submissions.length === 1
? '<strong>This is your last submission left. If you delete it, you won’t be able to submit again and you will be graded with 0 points.<strong></strong>'
: '';
showDialog(
Expand All @@ -146,10 +147,10 @@ export const SubmissionList = (props: ISubmissionListProps) => {
props.assignment.id,
value.id
);
queryClient.invalidateQueries({
await queryClient.invalidateQueries({
queryKey: ['submissions']
});
queryClient.invalidateQueries({
await queryClient.invalidateQueries({
queryKey: ['submissionsAssignmentStudent']
});
enqueueSnackbar('Successfully Deleted Submission', {
Expand Down

0 comments on commit 0ade5bd

Please sign in to comment.