Skip to content

Commit 402b8eb

Browse files
ncduy0303cysjonathan
authored andcommitted
fix(TabbedViewQuestions): fix stepper spacing for student view with non-skippable questions
1 parent cd64e98 commit 402b8eb

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/TabbedViewQuestions.tsx

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Dispatch, FC, SetStateAction } from 'react';
2-
import { Paper, Step, StepButton, StepLabel, Stepper } from '@mui/material';
2+
import { Paper, Step, StepButton, Stepper } from '@mui/material';
33

44
import { workflowStates } from 'course/assessment/submission/constants';
55
import { getAssessment } from 'course/assessment/submission/selectors/assessments';
@@ -30,8 +30,6 @@ const TabbedViewQuestions: FC<Props> = (props) => {
3030

3131
const published = workflowState === workflowStates.Published;
3232

33-
const currentQuestionId = questionIds[stepIndex];
34-
3533
const shouldRenderActiveStepper = (index: number): boolean => {
3634
return (
3735
!autograded || published || skippable || graderView || index <= maxStep
@@ -49,29 +47,22 @@ const TabbedViewQuestions: FC<Props> = (props) => {
4947
nonLinear
5048
>
5149
{questionIds.map((id, index) => {
52-
if (shouldRenderActiveStepper(index)) {
53-
return (
54-
<Step
55-
key={currentQuestionId}
56-
active={!autograded || index <= maxStep}
57-
>
58-
<StepButton
59-
className="p-4"
60-
icon={
61-
<StepperButton
62-
questionId={id}
63-
questionIndex={index}
64-
stepIndex={stepIndex}
65-
/>
66-
}
67-
onClick={() => setStepIndex(index)}
68-
/>
69-
</Step>
70-
);
71-
}
50+
const isDisabled = !shouldRenderActiveStepper(index);
7251
return (
73-
<Step key={id}>
74-
<StepLabel />
52+
<Step key={id} active={!autograded || index <= maxStep}>
53+
<StepButton
54+
className="p-4"
55+
disabled={isDisabled}
56+
icon={
57+
<StepperButton
58+
disabled={isDisabled}
59+
questionId={id}
60+
questionIndex={index}
61+
stepIndex={stepIndex}
62+
/>
63+
}
64+
onClick={() => setStepIndex(index)}
65+
/>
7566
</Step>
7667
);
7768
})}

client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/button/StepperButton.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FC } from 'react';
22
import { SvgIcon } from '@mui/material';
33
import { blue, green, lightBlue, red } from '@mui/material/colors';
4+
import { grey } from 'theme/colors';
45

56
import { getExplanations } from 'course/assessment/submission/selectors/explanations';
67
import { useAppSelector } from 'lib/hooks/store';
@@ -9,16 +10,19 @@ interface Props {
910
questionId: number;
1011
questionIndex: number;
1112
stepIndex: number;
13+
disabled?: boolean;
1214
}
1315

1416
const StepperButton: FC<Props> = (props) => {
15-
const { questionId, questionIndex, stepIndex } = props;
17+
const { questionId, questionIndex, stepIndex, disabled = false } = props;
1618

1719
const explanations = useAppSelector(getExplanations);
1820

1921
let stepButtonColor = '';
2022
const isCurrentQuestion = questionIndex === stepIndex;
21-
if (explanations[questionId]?.correct) {
23+
if (disabled) {
24+
stepButtonColor = grey[400];
25+
} else if (explanations[questionId]?.correct) {
2226
stepButtonColor = isCurrentQuestion ? green[700] : green[300];
2327
} else if (explanations[questionId]?.correct === false) {
2428
stepButtonColor = isCurrentQuestion ? red[700] : red[300];

0 commit comments

Comments
 (0)