Commit 62d5c13e authored by wycers's avatar wycers
Browse files

grades

parent 561324d0
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
/*
  Warnings:

  - You are about to drop the column `updatedAt` on the `Submission` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE `Submission` DROP COLUMN `updatedAt`;

-- CreateTable
CREATE TABLE `GradeEntry` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `classId` INTEGER NOT NULL,
    `name` VARCHAR(191) NOT NULL,
    `title` VARCHAR(191) NOT NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `GradeGroup` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL,
    `title` VARCHAR(191) NOT NULL,
    `index` INTEGER NOT NULL,
    `porportion` INTEGER NOT NULL,
    `strategy` ENUM('MAX', 'MIN', 'LAST') NOT NULL DEFAULT 'MAX',
    `gradeEntryId` INTEGER NOT NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `GradeRecord` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `studentId` INTEGER NOT NULL,
    `grade` INTEGER NOT NULL,
    `source` JSON NOT NULL,
    `gradeGroupId` INTEGER NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `GradeEntry` ADD CONSTRAINT `GradeEntry_classId_fkey` FOREIGN KEY (`classId`) REFERENCES `Class`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `GradeGroup` ADD CONSTRAINT `GradeGroup_gradeEntryId_fkey` FOREIGN KEY (`gradeEntryId`) REFERENCES `GradeEntry`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `GradeRecord` ADD CONSTRAINT `GradeRecord_studentId_fkey` FOREIGN KEY (`studentId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `GradeRecord` ADD CONSTRAINT `GradeRecord_gradeGroupId_fkey` FOREIGN KEY (`gradeGroupId`) REFERENCES `GradeGroup`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+15 −0
Original line number Diff line number Diff line
/*
  Warnings:

  - You are about to drop the column `submissionId` on the `File` table. All the data in the column will be lost.
  - Added the required column `volumeId` to the `Submission` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE `File` DROP FOREIGN KEY `File_submissionId_fkey`;

-- AlterTable
ALTER TABLE `File` DROP COLUMN `submissionId`;

-- AlterTable
ALTER TABLE `Submission` ADD COLUMN `volumeId` VARCHAR(191) NOT NULL;
+31 −0
Original line number Diff line number Diff line
/*
  Warnings:

  - You are about to drop the column `gradeEntryId` on the `GradeGroup` table. All the data in the column will be lost.
  - You are about to drop the column `porportion` on the `GradeGroup` table. All the data in the column will be lost.
  - You are about to drop the column `gradeGroupId` on the `GradeRecord` table. All the data in the column will be lost.
  - Added the required column `entryId` to the `GradeGroup` table without a default value. This is not possible if the table is not empty.
  - Added the required column `proportion` to the `GradeGroup` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE `GradeGroup` DROP FOREIGN KEY `GradeGroup_gradeEntryId_fkey`;

-- DropForeignKey
ALTER TABLE `GradeRecord` DROP FOREIGN KEY `GradeRecord_gradeGroupId_fkey`;

-- AlterTable
ALTER TABLE `GradeGroup` DROP COLUMN `gradeEntryId`,
    DROP COLUMN `porportion`,
    ADD COLUMN `entryId` INTEGER NOT NULL,
    ADD COLUMN `proportion` INTEGER NOT NULL;

-- AlterTable
ALTER TABLE `GradeRecord` DROP COLUMN `gradeGroupId`,
    ADD COLUMN `groupId` INTEGER NULL;

-- AddForeignKey
ALTER TABLE `GradeGroup` ADD CONSTRAINT `GradeGroup_entryId_fkey` FOREIGN KEY (`entryId`) REFERENCES `GradeEntry`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `GradeRecord` ADD CONSTRAINT `GradeRecord_groupId_fkey` FOREIGN KEY (`groupId`) REFERENCES `GradeGroup`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+57 −10
Original line number Diff line number Diff line
@@ -43,7 +43,8 @@ model User {

  classes      ClassesOnUsers[]
  submissions  Submission[]
  SubmissionFeedback SubmissionFeedback[]
  feedbacks    SubmissionFeedback[]
  gradeRecords GradeRecord[]

  luciaUser LuciaUser[]
}
@@ -91,6 +92,7 @@ model Class {
  users        ClassesOnUsers[]
  assignments  Assignment[]
  problems     Problem[]
  gradeEntries GradeEntry[]

  @@unique([semesterId, courseId])
}
@@ -134,9 +136,6 @@ model File {
  filename String
  size     Int
  type     StorageType @default(QINIU)

  submission   Submission? @relation(fields: [submissionId], references: [id])
  submissionId Int?
}

enum StorageType {
@@ -204,7 +203,7 @@ model Submission {
  submitter   User @relation(fields: [submitterId], references: [id])
  submitterId Int

  files File[]
  volumeId String

  // feedback
  feedback SubmissionFeedback?
@@ -230,6 +229,54 @@ model SubmissionFeedback {
  submissionId Int        @unique
}

model GradeEntry {
  id Int @id @default(autoincrement())

  class   Class @relation(fields: [classId], references: [id])
  classId Int

  name  String
  title String

  groups GradeGroup[]
}

model GradeGroup {
  id Int @id @default(autoincrement())

  name  String
  title String

  index      Int
  proportion Int
  strategy   GradeGroupStrategy @default(MAX)

  records GradeRecord[]

  entry   GradeEntry @relation(fields: [entryId], references: [id])
  entryId Int
}

enum GradeGroupStrategy {
  MAX
  MIN
  LAST
}

model GradeRecord {
  id Int @id @default(autoincrement())

  student   User @relation(fields: [studentId], references: [id])
  studentId Int

  grade Int

  source Json

  group   GradeGroup? @relation(fields: [groupId], references: [id])
  groupId Int?
}

model Judgement {
  id       Int                 @id @default(autoincrement())
  status   JudgementStatus
+29 −12
Original line number Diff line number Diff line
@@ -25,8 +25,9 @@
	import { buttonVariants } from '$lib/components/ui/button';
	import * as Dialog from '$lib/components/ui/dialog';
	import * as Card from '$lib/components/ui/card';
	import * as Avatar from '$lib/components/ui/avatar';
	import { cn } from '$lib/utils';
	import { FileText, Upload } from 'svelte-radix';
	import { EyeNone, FileText, Upload } from 'svelte-radix';
	import MonacoEditor from '../monaco/MonacoEditor.svelte';
	import * as Select from '$lib/components/ui/select';
	let className: string | undefined | null = undefined;
@@ -38,6 +39,8 @@
	import _ from 'lodash';
	import { upload } from '$lib/shared/file';
	import { goto } from '$app/navigation';
	import Separator from '$lib/components/ui/separator/separator.svelte';
	import moment from 'moment';

	export let data: SuperValidated<Infer<SubmissionFormSchema>>;
	const form = superForm(data, {
@@ -60,6 +63,8 @@
		}
	});

	export let submissions: Array<{ time: Date; result: string; id: number }> = [];

	const { form: formData, enhance, delayed, timeout } = form;
	$: selectedLanguage = {
		label: dict[$formData.language].filename,
@@ -198,23 +203,35 @@
				<p class="text-sm text-muted-foreground">Email digest, mentions & all activity.</p>
			</div>
		</div> -->
		<div
		<!-- <div
			class="-mx-1 flex items-center space-x-4 rounded-md p-2 transition-all hover:bg-accent hover:text-accent-foreground"
		>
			<FileText class="mt-px h-5 w-5" />
			<div class="space-y-1">
				<p class="text-sm font-medium leading-none">History</p>
				<!-- <p class="text-sm text-muted-foreground">Only mentions and comments.</p> -->
				<p class="text-sm text-muted-foreground">Only mentions and comments.</p>
			</div>
		</div> -->
		<div class="mx-3 my-1">
			<Separator></Separator>
		</div>
		<!-- <div
		<!-- <p class="text-sm font-medium leading-none">History</p> -->
		{#each submissions as submission, index}
			<a
				class="-mx-2 flex items-center space-x-4 rounded-md p-2 transition-all hover:bg-accent hover:text-accent-foreground"
				href={`/submission/${submission.id}`}
			>
			<EyeNone class="mt-px h-5 w-5" />
				<!-- <EyeNone class="mt-px h-5 w-5" /> -->
				<Avatar.Root>
					<Avatar.Fallback>#{index + 1}</Avatar.Fallback>
				</Avatar.Root>
				<div class="space-y-1">
				<p class="text-sm font-medium leading-none">Ignoring</p>
				<p class="text-sm text-muted-foreground">Turn off all notifications.</p>
					<p class="text-sm font-medium leading-none">{submission.result}</p>
					<p class="text-sm text-muted-foreground">{moment(submission.time).format('ll HH:mm')}</p>
				</div>
		</div> -->
			</a>
		{:else}
			<p class="text-sm text-muted-foreground">No submissions now.</p>
		{/each}
	</Card.Content>
</Card.Root>
Loading