Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/commons/workspace/WorkspaceActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
CLEAR_REPL_INPUT,
CLEAR_REPL_OUTPUT,
CLEAR_REPL_OUTPUT_LAST,
DECREMENT_REQUEST_COUNTER,
DISABLE_TOKEN_COUNTER,
EditorTabState,
ENABLE_TOKEN_COUNTER,
Expand All @@ -35,6 +36,7 @@ import {
EVAL_REPL,
EVAL_TESTCASE,
GradingColumnVisibility,
INCREMENT_REQUEST_COUNTER,
MOVE_CURSOR,
NAV_DECLARATION,
PLAYGROUND_EXTERNAL_SELECT,
Expand Down Expand Up @@ -67,7 +69,6 @@ import {
UPDATE_GRADING_COLUMN_VISIBILITY,
UPDATE_HAS_UNSAVED_CHANGES,
UPDATE_REPL_VALUE,
UPDATE_REQUEST_COUNTER,
UPDATE_STEPSTOTAL,
UPDATE_SUBLANGUAGE,
UPDATE_SUBMISSIONS_TABLE_FILTERS,
Expand Down Expand Up @@ -396,10 +397,13 @@ export const setIsEditorReadonly = createAction(
})
);

export const updateRequestCounter = createAction(
UPDATE_REQUEST_COUNTER,
(requestCount: number) => ({ payload: { requestCount } })
);
export const increaseRequestCounter = createAction(INCREMENT_REQUEST_COUNTER, () => ({
payload: {}
}));

export const decreaseRequestCounter = createAction(DECREMENT_REQUEST_COUNTER, () => ({
payload: {}
}));

export const updateSubmissionsTableFilters = createAction(
UPDATE_SUBMISSIONS_TABLE_FILTERS,
Expand Down
15 changes: 12 additions & 3 deletions src/commons/workspace/WorkspaceReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ import {
import {
ADD_EDITOR_TAB,
CHANGE_EXTERNAL_LIBRARY,
DECREMENT_REQUEST_COUNTER,
DISABLE_TOKEN_COUNTER,
EditorTabState,
ENABLE_TOKEN_COUNTER,
END_CLEAR_CONTEXT,
EVAL_EDITOR,
EVAL_REPL,
INCREMENT_REQUEST_COUNTER,
MOVE_CURSOR,
REMOVE_EDITOR_TAB,
REMOVE_EDITOR_TAB_FOR_FILE,
Expand All @@ -79,7 +81,6 @@ import {
UPDATE_GRADING_COLUMN_VISIBILITY,
UPDATE_HAS_UNSAVED_CHANGES,
UPDATE_REPL_VALUE,
UPDATE_REQUEST_COUNTER,
UPDATE_STEPSTOTAL,
UPDATE_SUBLANGUAGE,
UPDATE_SUBMISSIONS_TABLE_FILTERS,
Expand Down Expand Up @@ -659,12 +660,20 @@ const oldWorkspaceReducer: Reducer<WorkspaceManagerState> = (
currentQuestion: action.payload.questionId
}
};
case UPDATE_REQUEST_COUNTER:
case INCREMENT_REQUEST_COUNTER:
return {
...state,
grading: {
...state.grading,
requestCounter: action.payload.requestCount
requestCounter: state.grading.requestCounter + 1
}
};
case DECREMENT_REQUEST_COUNTER:
return {
...state,
grading: {
...state.grading,
requestCounter: Math.max(0, state.grading.requestCounter - 1)
}
};
case SET_FOLDER_MODE:
Expand Down
3 changes: 2 additions & 1 deletion src/commons/workspace/WorkspaceTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export const CLEAR_REPL_OUTPUT_LAST = 'CLEAR_REPL_OUTPUT_LAST';
export const END_CLEAR_CONTEXT = 'END_CLEAR_CONTEXT';
export const ENABLE_TOKEN_COUNTER = 'ENABLE_TOKEN_COUNTER';
export const DISABLE_TOKEN_COUNTER = 'DISABLE_TOKEN_COUNTER';
export const DECREMENT_REQUEST_COUNTER = 'DECREMENT_REQUEST_COUNTER';
export const EVAL_EDITOR = 'EVAL_EDITOR';
export const EVAL_REPL = 'EVAL_REPL';
export const PROMPT_AUTOCOMPLETE = 'PROMPT_AUTOCOMPLETE';
export const EVAL_SILENT = 'EVAL_SILENT';
export const EVAL_TESTCASE = 'EVAL_TESTCASE';
export const EVAL_EDITOR_AND_TESTCASES = 'EVAL_EDITOR_AND_TESTCASES';
export const INCREMENT_REQUEST_COUNTER = 'INCREMENT_REQUEST_COUNTER';
export const MOVE_CURSOR = 'MOVE_CURSOR';
export const NAV_DECLARATION = 'NAV_DECLARATION';
export const PLAYGROUND_EXTERNAL_SELECT = 'PLAYGROUND_EXTERNAL_SELECT ';
Expand All @@ -40,7 +42,6 @@ export const TOGGLE_EDITOR_AUTORUN = 'TOGGLE_EDITOR_AUTORUN';
export const TOGGLE_USING_SUBST = 'TOGGLE_USING_SUBST';
export const TOGGLE_USING_CSE = 'TOGGLE_USING_CSE';
export const TOGGLE_UPDATE_CSE = 'TOGGLE_UPDATE_CSE';
export const UPDATE_REQUEST_COUNTER = 'UPDATE_REQUEST_COUNTER';
export const UPDATE_SUBMISSIONS_TABLE_FILTERS = 'UPDATE_SUBMISSIONS_TABLE_FILTERS';
export const UPDATE_GRADING_COLUMN_VISIBILITY = 'UPDATE_GRADING_COLUMN_VISIBILITY';
export const UPDATE_CURRENT_ASSESSMENT_ID = 'UPDATE_CURRENT_ASSESSMENT_ID';
Expand Down
12 changes: 8 additions & 4 deletions src/pages/academy/grading/Grading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fetchGradingOverviews } from 'src/commons/application/actions/SessionAc
import { Role } from 'src/commons/application/ApplicationTypes';
import SimpleDropdown from 'src/commons/SimpleDropdown';
import { useSession, useTypedSelector } from 'src/commons/utils/Hooks';
import { updateRequestCounter } from 'src/commons/workspace/WorkspaceActions';
import { decreaseRequestCounter, increaseRequestCounter } from 'src/commons/workspace/WorkspaceActions';
import { numberRegExp } from 'src/features/academy/AcademyTypes';
import {
exportGradingCSV,
Expand Down Expand Up @@ -55,8 +55,7 @@ const Grading: React.FC = () => {

const updateGradingOverviewsCallback = useCallback(
(page: number, filterParams: Object) => {
console.log("+1 parent");
dispatch(updateRequestCounter(requestCounter + 1));
dispatch(increaseRequestCounter());
dispatch(
fetchGradingOverviews(
showAllGroups,
Expand All @@ -70,7 +69,12 @@ const Grading: React.FC = () => {
);

useEffect(() => {
dispatch(updateRequestCounter(Math.max(0, requestCounter - 1)));
console.log(requestCounter);
}, [requestCounter]);

useEffect(() => {
console.log("minus 11");
dispatch(decreaseRequestCounter());
}, [gradingOverviews]);

// If submissionId or questionId is defined but not numeric, redirect back to the Grading overviews page
Expand Down
Loading