Skip to content

Commit

Permalink
fix: patch bugs found during bash (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
alangsto authored Feb 7, 2024
1 parent 37c550a commit 96dd8c8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ export {

export { default as reducer } from './slice';

export {
expireExamAttempt,
} from './slice';

export { default as Emitter } from './emitter';
8 changes: 5 additions & 3 deletions src/instructions/timed_exam/StartTimedExamInstructions.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { Button } from '@edx/paragon';
import { startTimedExam } from '../../data';

const StartTimedExamInstructions = () => {
const { exam, startTimedExam } = useSelector(state => state.specialExams);
const { exam } = useSelector(state => state.specialExams);
const dispatch = useDispatch();
const examDuration = exam.total_time;

return (
Expand Down Expand Up @@ -37,7 +39,7 @@ const StartTimedExamInstructions = () => {
<Button
data-testid="start-exam-button"
variant="outline-primary"
onClick={startTimedExam}
onClick={() => dispatch(startTimedExam())}

Check warning on line 42 in src/instructions/timed_exam/StartTimedExamInstructions.jsx

View check run for this annotation

Codecov / codecov/patch

src/instructions/timed_exam/StartTimedExamInstructions.jsx#L42

Added line #L42 was not covered by tests
>
<FormattedMessage
id="exam.startExamInstructions.startExamButtonText"
Expand Down
8 changes: 4 additions & 4 deletions src/timer/ExamTimerBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CountDownTimer from './CountDownTimer';
import { ExamStatus, IS_STARTED_STATUS } from '../constants';
import TimerProvider from './TimerProvider';
import {
Emitter, expireExamAttempt, stopExam, submitExam,
Emitter, expireExam, stopExam, submitExam,
} from '../data';
import {
TIMER_IS_CRITICALLY_LOW,
Expand Down Expand Up @@ -46,17 +46,17 @@ const ExamTimerBlock = injectIntl(({ intl }) => {
useEffect(() => {
Emitter.once(TIMER_IS_LOW, onLowTime);
Emitter.once(TIMER_IS_CRITICALLY_LOW, onCriticalLowTime);
Emitter.once(TIMER_LIMIT_REACHED, () => dispatch(expireExamAttempt));
Emitter.once(TIMER_LIMIT_REACHED, () => dispatch(expireExam()));
Emitter.once(TIMER_REACHED_NULL, onTimeReachedNull);

return () => {
Emitter.off(TIMER_IS_LOW, onLowTime);
Emitter.off(TIMER_IS_CRITICALLY_LOW, onCriticalLowTime);
Emitter.off(TIMER_LIMIT_REACHED, () => dispatch(expireExamAttempt));
Emitter.off(TIMER_LIMIT_REACHED, () => dispatch(expireExam()));
Emitter.off(TIMER_REACHED_NULL, onTimeReachedNull);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [dispatch]);

return (
<TimerProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/timer/TimerProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const TimerProvider = ({
liveInterval = null;
}
};
}, [timeRemaining]);
}, [timeRemaining, dispatch]);

return (
// eslint-disable-next-line react/jsx-no-constructed-context-values
Expand Down

0 comments on commit 96dd8c8

Please sign in to comment.