Skip to content

Commit b242bd0

Browse files
committed
disable edits after finalization
1 parent cb0f0f1 commit b242bd0

File tree

1 file changed

+9
-7
lines changed
  • packages/quizms/src/web/teacher/table

1 file changed

+9
-7
lines changed

packages/quizms/src/web/teacher/table/index.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ function Table() {
136136
}
137137

138138
const colDefs = useMemo(
139-
() => columnDefinition(contest, variants, canViewScore(contest, participation)),
140-
[contest, variants, participation],
139+
() => columnDefinition(contest, variants, canViewScore(contest, participation), frozen),
140+
[contest, variants, participation, frozen],
141141
);
142142

143143
const onCellEditRequest = async (ev: CellEditRequestEvent) => {
@@ -216,6 +216,7 @@ function columnDefinition(
216216
contest: Contest,
217217
variants: Record<string, Variant>,
218218
canViewScore: boolean,
219+
frozen: boolean,
219220
): ColDef[] {
220221
const widths = {
221222
xs: 100,
@@ -240,7 +241,7 @@ function columnDefinition(
240241
cellDataType: field.type,
241242
width: widths[field.size ?? "md"],
242243
equals: field.type === "date" ? isEqualDate : undefined,
243-
editable: contest.allowStudentEdit,
244+
editable: contest.allowStudentEdit && !frozen,
244245
...defaultOptions,
245246
tooltipValueGetter: ({ data }: ITooltipParams<Student>) => {
246247
return isStudentIncomplete(data!, contest, variants);
@@ -268,7 +269,7 @@ function columnDefinition(
268269
field: "variant",
269270
headerName: "Variante",
270271
width: 100,
271-
editable: true,
272+
editable: !frozen,
272273
...defaultOptions,
273274
hide: !contest.hasVariants,
274275
},
@@ -302,7 +303,8 @@ function columnDefinition(
302303
return displayAnswer(data.answers[id], variants[data.variant].schema[id].kind) ?? "";
303304
},
304305
tooltipValueGetter: ({ data }) => data.answers?.[id],
305-
editable: ({ data }) => contest.allowAnswerEdit && !data.absent && !data.disabled,
306+
editable: ({ data }) =>
307+
contest.allowAnswerEdit && !data.absent && !data.disabled && !frozen,
306308
resizable: true,
307309
};
308310
}),
@@ -320,7 +322,7 @@ function columnDefinition(
320322
cellDataType: "boolean",
321323
width: 120,
322324
valueGetter: ({ data }) => data.absent ?? false,
323-
editable: true,
325+
editable: !frozen,
324326
...defaultOptions,
325327
sortable: false,
326328
hide: !contest.allowAnswerEdit,
@@ -353,7 +355,7 @@ function columnDefinition(
353355
cellDataType: "boolean",
354356
width: 120,
355357
valueGetter: ({ data }) => data.disabled ?? false,
356-
editable: true,
358+
editable: !frozen,
357359
...defaultOptions,
358360
sortable: false,
359361
hide: !contest.allowStudentDelete,

0 commit comments

Comments
 (0)