Commit ce1e14e3 authored by wycers's avatar wycers
Browse files

create assignment

parent 3ed229cc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
	},
	"type": "module",
	"dependencies": {
		"@internationalized/date": "^3.5.2",
		"@lucia-auth/adapter-prisma": "^4.0.0",
		"@milkdown/core": "^7.3.5",
		"@milkdown/ctx": "^7.3.5",
@@ -73,11 +74,13 @@
		"@tiptap/starter-kit": "^2.2.4",
		"clsx": "^2.1.0",
		"cmdk-sv": "^0.0.15",
		"formsnap": "^0.5.1",
		"github-markdown-css": "^5.5.1",
		"gravatar": "^1.8.2",
		"highlight.js": "^11.9.0",
		"katex": "^0.16.9",
		"lodash": "^4.17.21",
		"moment": "^2.30.1",
		"mysql2": "^3.9.2",
		"oslo": "^1.1.3",
		"prisma": "^5.10.2",
+24 −100

File changed.

Preview size limit exceeded, changes collapsed.

+45 −0
Original line number Diff line number Diff line
/*
  Warnings:

  - You are about to drop the column `entryId` on the `Submission` table. All the data in the column will be lost.
  - You are about to drop the `AssignmentEntry` table. If the table is not empty, all the data it contains will be lost.
  - Added the required column `problemId` to the `Submission` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE `AssignmentEntry` DROP FOREIGN KEY `AssignmentEntry_assignmentId_fkey`;

-- DropForeignKey
ALTER TABLE `Submission` DROP FOREIGN KEY `Submission_entryId_fkey`;

-- AlterTable
ALTER TABLE `Submission` DROP COLUMN `entryId`,
    ADD COLUMN `problemId` INTEGER NOT NULL;

-- DropTable
DROP TABLE `AssignmentEntry`;

-- CreateTable
CREATE TABLE `Problem` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `name` VARCHAR(191) NOT NULL,
    `index` INTEGER NOT NULL,
    `assignmentId` INTEGER NOT NULL,
    `penalty` INTEGER NULL,
    `penaltyAfter` INTEGER NULL,
    `title` VARCHAR(191) NOT NULL,
    `start` DATETIME(3) NOT NULL,
    `end` DATETIME(3) NOT NULL,
    `description` VARCHAR(191) NOT NULL,
    `judgementArgs` JSON NULL,

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

-- AddForeignKey
ALTER TABLE `Problem` ADD CONSTRAINT `Problem_assignmentId_fkey` FOREIGN KEY (`assignmentId`) REFERENCES `Assignment`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Submission` ADD CONSTRAINT `Submission_problemId_fkey` FOREIGN KEY (`problemId`) REFERENCES `Problem`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
+4 −4
Original line number Diff line number Diff line
@@ -165,12 +165,12 @@ model Assignment {
  class   Class @relation(fields: [classId], references: [id])
  classId Int

  entries AssignmentEntry[]
  problems Problem[]

  @@unique([classId, name])
}

model AssignmentEntry {
model Problem {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
@@ -199,8 +199,8 @@ model Submission {

  name String

  entry   AssignmentEntry @relation(fields: [entryId], references: [id])
  entryId Int
  problem   Problem @relation(fields: [problemId], references: [id])
  problemId Int

  submitter   User @relation(fields: [submitterId], references: [id])
  submitterId Int
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ export const handle: Handle = async ({ event, resolve }) => {
		include: { user: true }
	});
	if (!luciaUser) {
		console.log('no lucia user');
		redirect(302, '/login');
	}

Loading