Skip to content

Commit 1566237

Browse files
authored
chore: peer grade load next fix (#136)
* chore: use grade next step fix * chore: show peer grade status alert correctly
1 parent 7762d5c commit 1566237

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

src/components/ModalActions/hooks/useModalActionConfig.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { stepNames, stepStates } from 'constants/index';
22

3-
import { useGlobalState } from 'hooks/app';
3+
import { useGlobalState, useStepInfo } from 'hooks/app';
44
import { useHasSubmitted } from 'hooks/assessment';
55
import { useViewStep } from 'hooks/routing';
66
import {
@@ -18,6 +18,7 @@ const useModalActionConfig = ({ options }) => {
1818
const hasSubmitted = useHasSubmitted();
1919
const finishedStateActions = useFinishedStateActions();
2020
const inProgressActions = useInProgressActions({ options });
21+
const stepInfo = useStepInfo();
2122

2223
const loadNextAction = useLoadNextAction();
2324
const startStepAction = useStartStepAction();
@@ -31,7 +32,7 @@ const useModalActionConfig = ({ options }) => {
3132
// finished state
3233
if (hasSubmitted) {
3334
if (globalState.activeStepState === stepStates.waitingForPeerGrades) {
34-
return { primary: loadNextAction, secondary: exitAction };
35+
return { primary: stepInfo.peer?.isWaitingForSubmissions ? null : loadNextAction, secondary: exitAction };
3536
}
3637
if (globalState.activeStepState !== stepStates.inProgress) {
3738
return { primary: exitAction };

src/components/StatusAlert/hooks/useSuccessAlerts.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useViewStep } from 'hooks/routing';
2-
import { useGlobalState } from 'hooks/app';
2+
import { useGlobalState, useStepInfo } from 'hooks/app';
33
import { useHasSubmitted } from 'hooks/assessment';
44
import { useStartStepAction, useLoadNextAction } from 'hooks/actions';
55

@@ -16,6 +16,7 @@ const useSuccessAlerts = ({ step }) => {
1616
const hasSubmitted = useHasSubmitted();
1717
const startStepAction = useStartStepAction();
1818
const loadNextAction = useLoadNextAction();
19+
const stepInfo = useStepInfo();
1920
const exitAlert = useCreateExitAlert({ step });
2021
const createAlert = useCreateAlert({ step });
2122

@@ -32,13 +33,14 @@ const useSuccessAlerts = ({ step }) => {
3233
} else if (viewStep === stepNames.peer) {
3334
successAlert.actions = [loadNextAction.action];
3435
}
35-
} else if (activeStepState === stepStates.waitingForPeerGrades) {
36+
} else if (activeStepState === stepStates.waitingForPeerGrades && !stepInfo.peer.isWaitingForSubmissions) {
3637
successAlert.actions = [loadNextAction.action];
3738
}
38-
out.push(createAlert(successAlert));
3939

4040
if (activeStepState !== stepStates.inProgress) {
4141
out.push(exitAlert(activeStepState));
42+
} else {
43+
out.push(createAlert(successAlert));
4244
}
4345
if (activeStepName === stepNames.staff) {
4446
out.push(exitAlert(stepNames.staff));

src/components/StatusAlert/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const StatusAlert = ({
1717
step,
1818
}) => {
1919
const isPageDataLoading = useIsPageDataLoading();
20-
const alerts = useStatusAlertData({ hasSubmitted, step });
20+
const alerts = useStatusAlertData({ step });
2121
const customWrapper = ({ children }) => (
2222
<div className="w-100 h-100">
2323
{children}

src/components/StepProgressIndicator/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const StepProgressIndicator = ({ step }) => {
5353
: needed;
5454
const showAction = hasSubmitted
5555
&& !(step === stepNames.peer && stepInfo[step].isWaitingForSubmissions)
56-
&& (needed !== done);
56+
&& !(step === stepNames.studentTraining && needed === done);
5757

5858
return (
5959
<div className={className}>

src/hooks/actions/useLoadNextAction.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import {
44
usePageDataStatus,
55
useRefreshPageData,
66
useActiveStepName,
7+
useStepInfo,
78
} from 'hooks/app';
89
import { useResetAssessment } from 'hooks/assessment';
910
import { useViewStep } from 'hooks/routing';
10-
import {
11-
MutationStatus,
12-
stepNames,
13-
} from 'constants/index';
11+
import { MutationStatus, stepNames } from 'constants/index';
1412

1513
import messages, { loadNextSteps } from './messages';
1614

@@ -22,8 +20,15 @@ export default () => {
2220
const pageDataStatus = usePageDataStatus().status;
2321
const viewStep = useViewStep();
2422
const activeStep = useActiveStepName();
23+
const stepInfo = useStepInfo();
2524
const step = viewStep === stepNames.xblock ? activeStep : viewStep;
26-
if (![stepNames.studentTraining, stepNames.peer].includes(step)) {
25+
if (
26+
!(
27+
step === stepNames.studentTraining
28+
|| (step === stepNames.peer)
29+
|| (step === stepNames.peer && !stepInfo.peer?.isWaitingForSubmissions)
30+
)
31+
) {
2732
return null;
2833
}
2934
const label = (message) => `${formatMessage(message)} ${formatMessage(loadNextSteps[step])}`;

src/views/XBlockView/Actions/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const SubmissionActions = () => {
3232
[stepNames.studentTraining, stepNames.peer].includes(activeStepName)
3333
&& stepState !== stepStates.waiting
3434
&& stepInfo.numberOfAssessmentsCompleted > 0
35+
&& !stepInfo.isWaitingForSubmissions
3536
) {
3637
const onClick = () => openModal({ view: activeStepName, title: activeStepName });
3738
return (

0 commit comments

Comments
 (0)