Skip to content

Commit 6c1e290

Browse files
fix: update attempts on UI after reset (#215)
1 parent bc8168b commit 6c1e290

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/grading/components/GradingLearnerContent.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('GradingLearnerContent', () => {
7676
mockUseRescoreSubmission.mockReturnValue({ mutate: mockMutateRescore } as any);
7777
mockUsePendingTasks.mockReturnValue({ refetch: mockRefetch } as any);
7878
(useLearner as jest.Mock).mockReturnValue({ data: { username: 'testuser', email: 'testuser@example.com', progressUrl: '/progress' }, isLoading: false, error: null });
79-
(useProblemDetails as jest.Mock).mockReturnValue({ data: { currentScore: { score: 0, total: null }, attempts: { current: 1, total: 1 } }, isLoading: false, error: null });
79+
(useProblemDetails as jest.Mock).mockReturnValue({ data: { currentScore: { score: 0, total: null }, attempts: { current: 1, total: 1 } }, isLoading: false, error: null, refetch: jest.fn() });
8080
});
8181

8282
it('renders correctly for single learner mode', () => {

src/grading/components/GradingLearnerContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const GradingLearnerContent = ({ toolType, onShowTasks }: GradingLearnerContentP
2727
const problemFieldRef = useRef<{ reset: () => void }>(null);
2828
const [showCurrentStatus, setShowCurrentStatus] = useState(false);
2929
const [confirmationModalData, setConfirmationModalData] = useState<{ message: string, confirmButtonLabel: string, action?: () => void }>({ message: '', confirmButtonLabel: '', action: undefined });
30-
const { data: problemData = { currentScore: { score: 0, total: null }, attempts: { current: null, total: 0 } }, isError: isProblemDataError } = useProblemDetails(courseId, blockId, usernameOrEmail);
30+
const { data: problemData = { currentScore: { score: 0, total: null }, attempts: { current: null, total: 0 } }, isError: isProblemDataError, refetch: refetchProblemData } = useProblemDetails(courseId, blockId, usernameOrEmail);
3131
const { data: learnerData = { username: '', progressUrl: '' } } = useLearner(courseId, usernameOrEmail);
3232
const { showModal, showToast } = useAlert();
3333

@@ -53,6 +53,7 @@ const GradingLearnerContent = ({ toolType, onShowTasks }: GradingLearnerContentP
5353
resetAttempts({ learner: usernameOrEmail, problem: blockId }, {
5454
onSuccess: () => {
5555
resetConfirmationModalData();
56+
refetchProblemData();
5657
showToast(intl.formatMessage(messages.resetAttemptsSuccess, { student: usernameOrEmail || intl.formatMessage(messages.allLearners), blockId }));
5758
},
5859
onError: manageOnError

0 commit comments

Comments
 (0)