Commit b61af28a authored by Yechang's avatar Yechang
Browse files

feat(grade): update problem's grade group

parent 7ee01eac
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -10,11 +10,12 @@ type CreateProblemSchema = {
	testdata: string;
	start: string | Date;
	end: string | Date;
	judgementArgs: string | number | boolean | JsonObject | JsonArray;
	judgementArgs: string | number | boolean | JsonObject | JsonArray,
};

type UpdateProblemSchema = {
	id: number;
	gradeGroupId?: number | null;
} & CreateProblemSchema;

export const getProblem = async (id: number) => {
@@ -33,7 +34,7 @@ export const createProblem = async ({ ...data }: CreateProblemSchema) => {
export const updateProblem = async ({ id, ...data }: UpdateProblemSchema) => {
	const problem = await db.problem.update({
		where: { id },
		data: { ...data }
		data: { ...data },
	});

	return problem;
+11 −1
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@
		end: z
			.string()
			.datetime()
			.refine((date) => (date === undefined ? false : true), 'Please select a valid date.')
			.refine((date) => (date === undefined ? false : true), 'Please select a valid date.'),
		gradeGroupId: z.number().nullish()
	});

	export type ProblemFormSchema = typeof problemFromSchema;
@@ -63,6 +64,7 @@
	import MonacoEditor from '$lib/components/monaco/MonacoEditor.svelte';
	import { upload } from '$lib/shared/file';
	import { Progress } from '$lib/components/ui/progress';
	import NumberInput from '$lib/components/ui/input/numberInput.svelte';

	export let data: SuperValidated<Infer<ProblemFormSchema>>;

@@ -152,6 +154,14 @@
		</Form.Control>
		<Form.FieldErrors />
	</Form.Field>
	<Form.Field name="gradeGroupId" {form}>
		<Form.Control let:attrs>
			<Form.Label>Grade Group ID</Form.Label>
			<NumberInput {...attrs} bind:value={$formData.gradeGroupId} placeholder="Grade Group ID" />
		</Form.Control>
		<Form.Description>valid submissions will create a grade record in the group</Form.Description>
		<Form.FieldErrors />
	</Form.Field>
	<Form.Field {form} name="description">
		<Form.Control let:attrs>
			<Form.Label>Description</Form.Label>
+1 −1

File changed.

Contains only whitespace changes.