diff --git a/prisma/migrations/20250616020439_add_random/migration.sql b/prisma/migrations/20250616020439_add_random/migration.sql new file mode 100644 index 0000000..59728f5 --- /dev/null +++ b/prisma/migrations/20250616020439_add_random/migration.sql @@ -0,0 +1,13 @@ +/* + Warnings: + + - Added the required column `type` to the `Problem` table without a default value. This is not possible if the table is not empty. + +*/ +-- CreateEnum +CREATE TYPE "Type" AS ENUM ('NS', 'INT', 'FLOAT', 'CHAR', 'INTARRAY', 'FLOATARRAY', 'STRING', 'MATRIX'); + +-- AlterTable +ALTER TABLE "Problem" ADD COLUMN "isRandom" BOOLEAN NOT NULL DEFAULT false, +ADD COLUMN "lengthOfArray" INTEGER[], +ADD COLUMN "type" "Type" NOT NULL; diff --git a/prisma/migrations/20250616021548_rename_type/migration.sql b/prisma/migrations/20250616021548_rename_type/migration.sql new file mode 100644 index 0000000..f44282f --- /dev/null +++ b/prisma/migrations/20250616021548_rename_type/migration.sql @@ -0,0 +1,16 @@ +/* + Warnings: + + - You are about to drop the column `type` on the `Problem` table. All the data in the column will be lost. + - Added the required column `answerType` to the `Problem` table without a default value. This is not possible if the table is not empty. + +*/ +-- CreateEnum +CREATE TYPE "AnswerType" AS ENUM ('NS', 'INT', 'FLOAT', 'CHAR', 'INTARRAY', 'FLOATARRAY', 'STRING', 'MATRIX'); + +-- AlterTable +ALTER TABLE "Problem" DROP COLUMN "type", +ADD COLUMN "answerType" "AnswerType" NOT NULL; + +-- DropEnum +DROP TYPE "Type"; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 6a14175..b82be14 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -34,6 +34,17 @@ enum Protocol { wss } +enum AnswerType { + NS // Not Suitable + INT // Single Integer + FLOAT // Single Float + CHAR // Single Character + INTARRAY // Integer Array + FLOATARRAY // Float Array + STRING // Single String + MATRIX // Arrays +} + enum Status { PD // PENDING QD // QUEUED @@ -76,22 +87,22 @@ model User { } model Problem { - id String @id @default(cuid()) - displayId Int @unique - difficulty Difficulty @default(EASY) - isPublished Boolean @default(false) - trim Boolean @default(false) - timeLimit Int @default(1000) - memoryLimit Int @default(134217728) - - + id String @id @default(cuid()) + displayId Int @unique + difficulty Difficulty @default(EASY) + isPublished Boolean @default(false) + trim Boolean @default(false) + timeLimit Int @default(1000) + memoryLimit Int @default(134217728) + isRandom Boolean @default(false) + answerType AnswerType + lengthOfArray Int[] localizations ProblemLocalization[] templates Template[] testcases Testcase[] submissions Submission[] - userId String? user User? @relation(fields: [userId], references: [id], onDelete: SetNull) diff --git a/prisma/seed.ts b/prisma/seed.ts index 99148b4..6617018 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -42,6 +42,8 @@ const problemData: Prisma.ProblemCreateInput[] = [ difficulty: "EASY", isPublished: true, trim: true, + answerType: "INTARRAY", + lengthOfArray: [2, 3, 4, 5, 6], localizations: { create: [ { @@ -736,6 +738,8 @@ int main() { difficulty: "MEDIUM", isPublished: true, trim: true, + answerType: "INTARRAY", + lengthOfArray: [1, 2, 3], localizations: { create: [ { @@ -1264,6 +1268,8 @@ int main() { difficulty: "HARD", isPublished: true, trim: true, + answerType: "INTARRAY", + lengthOfArray: [1, 2, 3, 4, 5], localizations: { create: [ { diff --git a/src/app/actions/random.ts b/src/app/actions/random.ts new file mode 100644 index 0000000..c4f514e --- /dev/null +++ b/src/app/actions/random.ts @@ -0,0 +1,3 @@ +"use server" + +function judgeRandom(){}