Commit 5fe7b761 authored by wycers's avatar wycers
Browse files

submission list

parent ee7ea45f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
		"@types/gravatar": "^1.8.6",
		"@types/lodash": "^4.14.202",
		"@types/node": "^20.11.24",
		"@types/nprogress": "^0.2.3",
		"@types/prismjs": "^1.26.3",
		"@typescript-eslint/eslint-plugin": "^7.0.0",
		"@typescript-eslint/parser": "^7.0.0",
@@ -96,6 +97,7 @@
		"monaco-editor": "^0.47.0",
		"mysql2": "^3.9.2",
		"nanoid": "^5.0.6",
		"nprogress": "^0.2.0",
		"oslo": "^1.1.3",
		"qiniu": "^7.11.1",
		"svelte-radix": "^1.0.3",
+14 −0
Original line number Diff line number Diff line
@@ -104,6 +104,9 @@ dependencies:
  nanoid:
    specifier: ^5.0.6
    version: 5.0.6
  nprogress:
    specifier: ^0.2.0
    version: 0.2.0
  oslo:
    specifier: ^1.1.3
    version: 1.1.3
@@ -157,6 +160,9 @@ devDependencies:
  '@types/node':
    specifier: ^20.11.24
    version: 20.11.24
  '@types/nprogress':
    specifier: ^0.2.3
    version: 0.2.3
  '@types/prismjs':
    specifier: ^1.26.3
    version: 1.26.3
@@ -2561,6 +2567,10 @@ packages:
    dependencies:
      undici-types: 5.26.5

  /@types/nprogress@0.2.3:
    resolution: {integrity: sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA==}
    dev: true

  /@types/prismjs@1.26.3:
    resolution: {integrity: sha512-A0D0aTXvjlqJ5ZILMz3rNfDBOx9hHxLZYv2by47Sm/pqW35zzjusrZTryatjN/Rf8Us2gZrJD+KeHbUSTux1Cw==}

@@ -5257,6 +5267,10 @@ packages:
      path-key: 4.0.0
    dev: true

  /nprogress@0.2.0:
    resolution: {integrity: sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==}
    dev: false

  /object-assign@4.1.1:
    resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
    engines: {node: '>=0.10.0'}
+0 −1
Original line number Diff line number Diff line
<script lang="ts">
	import { goto } from '$app/navigation';
	import AssignmentCard from '$lib/components/assignment/card/AssignmentCard.svelte';
	import { Button } from '$lib/components/ui/button';
	import type { PageData } from './$types';

+13 −3
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ import { redirect } from '@sveltejs/kit';
import type { PageParentData, PageServerLoad } from './$types';
import { getAssignmentsByClassId } from '$lib/server/db/assignment';
import _ from 'lodash';
import { db } from '$lib/server/db';

export const load = (async ({ parent }) => {
	const data: PageParentData = await parent();
@@ -11,7 +12,16 @@ export const load = (async ({ parent }) => {
		redirect(302, '/login');
	}

	const assignments = await getAssignmentsByClassId(currentClass.id);

	return { assignments };
	const submissions = await db.submission.findMany({
		where: {
			problem: {
				classId: currentClass.id
			}
		}
	});
	return {
		submissions
	};
}) satisfies PageServerLoad;

export const prerender = true;
 No newline at end of file
+64 −18
Original line number Diff line number Diff line
<script lang="ts">
	import { goto } from '$app/navigation';
	import AssignmentCard from '$lib/components/assignment/card/AssignmentCard.svelte';
	import { Button } from '$lib/components/ui/button';
	import type { PageData } from './$types';

	import { createTable, DataBodyRow, Render, Subscribe } from 'svelte-headless-table';

	import { readable } from 'svelte/store';
	import * as Table from '$lib/components/ui/table';
	import _ from 'lodash';

	export let data: PageData;
	const table = createTable(readable(data.submissions));
	const columns = table.createColumns([
		table.column({
			accessor: 'id',
			header: 'ID'
		}),
		table.column({
			accessor: 'name',
			header: 'Name'
		}),
		table.column({
			accessor: ({ id }) => id,
			header: ''
		})
	]);

	const { headerRows, pageRows, tableAttrs, tableBodyAttrs } = table.createViewModel(columns);
	$: role = data.currentClass.role;
</script>

<div class="h-full px-4 py-6 lg:px-8">
	<div class="flex items-center justify-between space-y-2">
		<h2 class="text-3xl font-bold tracking-tight">Assignments</h2>
		{#if role !== 'STUDENT'}
			<div class="flex items-center space-x-2">
				<!-- <DatePickerWithRange /> -->
				<Button size="sm" on:click={() => {
					goto("./assignment/new")
				}}>
					<!-- <Download class="mr-2 h-4 w-4" /> -->
					Create
				</Button>
			</div>
		{/if}
		<h2 class="text-3xl font-bold tracking-tight">Submissions</h2>
	</div>
	<div class="py-6 space-y-4">
		{#each data.assignments as assignment}
			<AssignmentCard  assignment={{ ...assignment }} />
	<div class="space-y-4 py-6">
		<div class="rounded-md border">
			<Table.Root {...$tableAttrs}>
				<Table.Header>
					{#each $headerRows as headerRow}
						<Subscribe rowAttrs={headerRow.attrs()}>
							<Table.Row>
								{#each headerRow.cells as cell (cell.id)}
									<Subscribe attrs={cell.attrs()} let:attrs props={cell.props()}>
										<Table.Head {...attrs}>
											<Render of={cell.render()} />
										</Table.Head>
									</Subscribe>
								{/each}
							</Table.Row>
						</Subscribe>
					{/each}
				</Table.Header>
				<Table.Body {...$tableBodyAttrs}>
					{#each $pageRows as row (row.id)}
						<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
							<Table.Row
								{...rowAttrs}
								on:click={() => {
									goto(`/submission/${row instanceof DataBodyRow ? row.original.id : ''}`);
								}}
							>
								{#each row.cells as cell (cell.id)}
									<Subscribe attrs={cell.attrs()} let:attrs>
										<Table.Cell {...attrs}>
											<Render of={cell.render()} />
										</Table.Cell>
									</Subscribe>
								{/each}
							</Table.Row>
						</Subscribe>
					{/each}
				</Table.Body>
			</Table.Root>
		</div>
	</div>
</div>
Loading