Add random function to help create a series of test.

Add the answerType key to restrict the type of answer.
Add the lengthOfArray key to rule the length of array or matrix. While if a single number just put null.
Add new content of seed.ts like above all.
This commit is contained in:
dioxide 2025-06-16 14:06:49 +08:00
parent 7f79b901b7
commit 3aa0a52b9e
5 changed files with 59 additions and 10 deletions

View File

@ -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;

View File

@ -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";

View File

@ -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)

View File

@ -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: [
{

View File

@ -0,0 +1,3 @@
"use server"
function judgeRandom(){}