Skip to content
Snippets Groups Projects
Commit 1d4f992c authored by Linus Keiser's avatar Linus Keiser :speech_balloon:
Browse files

--wip--

parent 43a665b1
No related branches found
No related tags found
No related merge requests found
Pipeline #591921 failed
Showing
with 317 additions and 203 deletions
......@@ -57,7 +57,6 @@ DEFINE FIELD final ON evaluation TYPE bool DEFAULT false PERMISSIONS FULL;
-- NOTE: making this an edge between evaluation->submission seems overkill
-- NOTE: but maybe make this a record reference? (https://surrealdb.com/docs/surrealql/datamodel/references)
-- DEFINE FIELD annotations ON evaluation TYPE array<record<annotation>> DEFAULT [] PERMISSIONS FULL;
-- DEFINE FIELD annotations ON evaluation TYPE array<record<annotation>> DEFAULT [] PERMISSIONS FULL;
DEFINE FIELD maxScore ON evaluation READONLY VALUE out.out.full_score PERMISSIONS FULL;
DEFINE FIELD postDeltaScore ON evaluation READONLY VALUE <future> {
......@@ -102,12 +101,36 @@ DEFINE INDEX one_per_submission ON evaluation FIELDS out UNIQUE;
-- ------------------------------
DEFINE TABLE annotation TYPE RELATION IN tutor | reviewer OUT evaluation SCHEMALESS PERMISSIONS NONE;
DEFINE FIELD type ON annotation TYPE "document" | "line" | "range" PERMISSIONS FULL;
DEFINE FIELD content ON annotation TYPE string PERMISSIONS FULL;
-- DEFINE FIELD meta.author ON annotation TYPE record<tutor> PERMISSIONS FULL;
DEFINE FIELD meta.scoreDelta ON annotation TYPE option<float> PERMISSIONS FULL;
-- TODO: figure out how to split this into union specific fields
-- 'line'
DEFINE FIELD line ON annotation TYPE option<number> PERMISSIONS FULL;
-- 'range'
DEFINE FIELD range.start.line ON annotation TYPE option<number> PERMISSIONS FULL;
DEFINE FIELD range.start.column ON annotation TYPE option<number> PERMISSIONS FULL;
DEFINE FIELD range.start.offset ON annotation TYPE option<number> PERMISSIONS FULL;
DEFINE FIELD range.end.line ON annotation TYPE option<number> PERMISSIONS FULL;
DEFINE FIELD range.end.column ON annotation TYPE option<number> PERMISSIONS FULL;
DEFINE FIELD range.end.offset ON annotation TYPE option<number> PERMISSIONS FULL;
-- 'document' | 'line' | 'range'
DEFINE FIELD visual.color ON annotation TYPE option<string> PERMISSIONS FULL;
-- 'line' | 'range'
DEFINE FIELD visual.zIndex ON annotation TYPE option<number> PERMISSIONS FULL;
-- 'range'
DEFINE FIELD visual.underline ON annotation TYPE option<'solid' | 'dashed' | 'dotted'> PERMISSIONS FULL;
DEFINE FIELD time.created_at ON annotation TYPE datetime DEFAULT time::now() PERMISSIONS FULL;
DEFINE FIELD time.updated_at ON annotation TYPE datetime VALUE time::now() PERMISSIONS FULL;
......@@ -184,23 +207,21 @@ DEFINE FIELD tests[*].name ON submission TYPE string READONLY PERMISSIONS FULL;
-- DEFINE FIELD updated_at ON submission TYPE datetime VALUE time::now() READONLY;
-- NOTE: this could also be part of the value at stage, e.g. {"ongoing_evaluation", preliminary_score: ...}
DEFINE FIELD score on submission VALUE <future> {
LET $eval = @<-evaluation;
IF $eval == NONE OR $eval.is_empty() { RETURN NONE};
RETURN $eval.first().score;
};
DEFINE FIELD stage ON submission VALUE <future> {
LET $eval = @<-evaluation;
IF $eval == NONE OR $eval.is_empty() { RETURN "pending_evaluation" };
DEFINE FIELD score on submission VALUE <future> {<-evaluation[$].score};
LET $review = $eval.first()<-review;
DEFINE FIELD stage ON submission READONLY VALUE <future> {
LET $eval = <-evaluation[$];
IF $review == NONE OR $review.is_empty() { RETURN "ongoing_evaluation" };
RETURN IF $review.first().approved { "approved" } ELSE { "pending_approval" };
} READONLY;
RETURN IF !$eval
{ 'pending_evaluation' }
ELSE IF !$eval<-review[$]
{ 'ongoing_evaluation' }
ELSE IF $eval<-review[$].approved
{ 'reviewed' }
ELSE
{ 'prending_approval' }
;
} PERMISSIONS FULL;
-- ------------------------------
......
// ====================
// DO NOT EDIT THIS FILE!
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from "zod";
import { recordId } from "../recordSchema.js"
// the create schema for table annotation
export const annotationInputSchemaGen = z.object({
content: z.string(),
in: recordId(),
line: z.number().optional(),
meta: z.object({
scoreDelta: z.number().optional()
}).optional(),
out: recordId('evaluation'),
range: z.object({
end: z.object({
column: z.number().optional(),
line: z.number().optional(),
offset: z.number().optional()
}).optional(),
start: z.object({
column: z.number().optional(),
line: z.number().optional(),
offset: z.number().optional()
}).optional()
}),
time: z.object({
created_at: z.string().datetime().optional(),
updated_at: z.string().datetime()
}),
type: z.unknown(),
visual: z.object({
color: z.string().optional(),
underline: z.unknown().optional(),
zIndex: z.number().optional()
}).optional()
}).passthrough();
// the select schema for table annotation
export const annotationOutputSchemaGen = z.object({
content: z.string(),
in: recordId(),
line: z.number().optional(),
meta: z.object({
scoreDelta: z.number().optional()
}).optional(),
out: recordId('evaluation'),
range: z.object({
end: z.object({
column: z.number().optional(),
line: z.number().optional(),
offset: z.number().optional()
}).optional(),
start: z.object({
column: z.number().optional(),
line: z.number().optional(),
offset: z.number().optional()
}).optional()
}),
time: z.object({
created_at: z.string().datetime(),
updated_at: z.string().datetime()
}),
type: z.unknown(),
visual: z.object({
color: z.string().optional(),
underline: z.unknown().optional(),
zIndex: z.number().optional()
}).optional()
}).passthrough();
......@@ -3,29 +3,25 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { recordId } from '../recordSchema.js';
import { z } from "zod";
import { recordId } from "../recordSchema.js"
// the create schema for table assignment
export const assignmentInputSchemaGen = z
.object({
description: z.string(),
full_score: z.number(),
module: recordId('module'),
name: z.string(),
programming_language: z.string(),
solution: z.string()
})
.passthrough();
export const assignmentInputSchemaGen = z.object({
description: z.string(),
full_score: z.number(),
module: recordId('module'),
name: z.string(),
programming_language: z.string(),
solution: z.string()
}).passthrough();
// the select schema for table assignment
export const assignmentOutputSchemaGen = z
.object({
description: z.string(),
full_score: z.number(),
module: recordId('module'),
name: z.string(),
programming_language: z.string(),
solution: z.string()
})
.passthrough();
export const assignmentOutputSchemaGen = z.object({
description: z.string(),
full_score: z.number(),
module: recordId('module'),
name: z.string(),
programming_language: z.string(),
solution: z.string()
}).passthrough();
......@@ -3,27 +3,24 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { recordId } from '../recordSchema.js';
import { z } from "zod";
import { recordId } from "../recordSchema.js"
// the create schema for table evaluation
export const evaluationInputSchemaGen = z
.object({
annotations: z.object({}).array(),
final: z.boolean().optional(),
in: recordId('tutor'),
out: recordId('submission'),
score: z.number().optional()
})
.passthrough();
export const evaluationInputSchemaGen = z.object({
final: z.boolean().optional(),
in: recordId('tutor'),
maxScore: z.unknown(),
out: recordId('submission'),
score: z.number().optional()
}).passthrough();
// the select schema for table evaluation
export const evaluationOutputSchemaGen = z
.object({
annotations: z.object({}).array(),
final: z.boolean(),
in: recordId('tutor'),
out: recordId('submission'),
score: z.number().optional()
})
.passthrough();
export const evaluationOutputSchemaGen = z.object({
final: z.boolean(),
in: recordId('tutor'),
maxScore: z.unknown(),
out: recordId('submission'),
postDeltaScore: z.unknown(),
score: z.number().optional()
}).passthrough();
......@@ -3,10 +3,15 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { z } from "zod";
// the create schema for table exercise_group
export const exerciseGroupInputSchemaGen = z.object({}).passthrough();
export const exerciseGroupInputSchemaGen = z.object({
}).passthrough();
// the select schema for table exercise_group
export const exerciseGroupOutputSchemaGen = z.object({}).passthrough();
export const exerciseGroupOutputSchemaGen = z.object({
}).passthrough();
......@@ -3,21 +3,17 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { recordId } from '../recordSchema.js';
import { z } from "zod";
import { recordId } from "../recordSchema.js"
// the create schema for table has_account
export const hasAccountInputSchemaGen = z
.object({
in: recordId(),
out: recordId('user')
})
.passthrough();
export const hasAccountInputSchemaGen = z.object({
in: recordId(),
out: recordId('user')
}).passthrough();
// the select schema for table has_account
export const hasAccountOutputSchemaGen = z
.object({
in: recordId(),
out: recordId('user')
})
.passthrough();
export const hasAccountOutputSchemaGen = z.object({
in: recordId(),
out: recordId('user')
}).passthrough();
export * from './annotation/annotationSchemaGen.js';
export * from './assignment/assignmentSchemaGen.js';
export * from './evaluation/evaluationSchemaGen.js';
export * from './exerciseGroup/exerciseGroupSchemaGen.js';
......@@ -9,4 +10,4 @@ export * from './reviewer/reviewerSchemaGen.js';
export * from './student/studentSchemaGen.js';
export * from './submission/submissionSchemaGen.js';
export * from './tutor/tutorSchemaGen.js';
export * from './user/userSchemaGen.js';
export * from './user/userSchemaGen.js';
\ No newline at end of file
......@@ -3,17 +3,17 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { recordId } from '../recordSchema.js';
import { z } from "zod";
import { recordId } from "../recordSchema.js"
// the create schema for table member_of
export const memberOfInputSchemaGen = z.object({
in: recordId('student'),
out: recordId('exercise_group')
in: recordId('student'),
out: recordId('exercise_group')
});
// the select schema for table member_of
export const memberOfOutputSchemaGen = z.object({
in: recordId('student'),
out: recordId('exercise_group')
in: recordId('student'),
out: recordId('exercise_group')
});
......@@ -3,24 +3,21 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { z } from "zod";
// the create schema for table module
export const moduleInputSchemaGen = z
.object({
pass_score: z.number(),
reference: z.string(),
total_score: z.number(),
ungraded: z.boolean().optional()
})
.passthrough();
export const moduleInputSchemaGen = z.object({
pass_score: z.number(),
reference: z.string(),
total_score: z.number(),
ungraded: z.boolean().optional()
}).passthrough();
// the select schema for table module
export const moduleOutputSchemaGen = z
.object({
pass_score: z.number(),
reference: z.string(),
total_score: z.number(),
ungraded: z.boolean()
})
.passthrough();
export const moduleOutputSchemaGen = z.object({
pass_score: z.number(),
reference: z.string(),
total_score: z.number(),
ungraded: z.boolean()
}).passthrough();
......@@ -3,23 +3,19 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { recordId } from '../recordSchema.js';
import { z } from "zod";
import { recordId } from "../recordSchema.js"
// the create schema for table review
export const reviewInputSchemaGen = z
.object({
approved: z.boolean(),
in: recordId('reviewer'),
out: recordId('evaluation')
})
.passthrough();
export const reviewInputSchemaGen = z.object({
approved: z.boolean(),
in: recordId('reviewer'),
out: recordId('evaluation')
}).passthrough();
// the select schema for table review
export const reviewOutputSchemaGen = z
.object({
approved: z.boolean(),
in: recordId('reviewer'),
out: recordId('evaluation')
})
.passthrough();
export const reviewOutputSchemaGen = z.object({
approved: z.boolean(),
in: recordId('reviewer'),
out: recordId('evaluation')
}).passthrough();
......@@ -3,10 +3,15 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { z } from "zod";
// the create schema for table reviewer
export const reviewerInputSchemaGen = z.object({}).passthrough();
export const reviewerInputSchemaGen = z.object({
}).passthrough();
// the select schema for table reviewer
export const reviewerOutputSchemaGen = z.object({}).passthrough();
export const reviewerOutputSchemaGen = z.object({
}).passthrough();
......@@ -3,18 +3,15 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { z } from "zod";
// the create schema for table student
export const studentInputSchemaGen = z
.object({
alias: z.string()
})
.passthrough();
export const studentInputSchemaGen = z.object({
alias: z.string()
}).passthrough();
// the select schema for table student
export const studentOutputSchemaGen = z
.object({
alias: z.string()
})
.passthrough();
export const studentOutputSchemaGen = z.object({
alias: z.string()
}).passthrough();
......@@ -3,41 +3,33 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { recordId } from '../recordSchema.js';
import { z } from "zod";
import { recordId } from "../recordSchema.js"
// the create schema for table submission
export const submissionInputSchemaGen = z
.object({
code: z.string(),
in: recordId(),
out: recordId('assignment'),
source_code: z.string().optional(),
tests: z
.object({
annotation: z.string().optional(),
label: z.string(),
name: z.string()
})
.array()
})
.passthrough();
export const submissionInputSchemaGen = z.object({
code: z.string(),
in: recordId(),
out: recordId('assignment'),
source_code: z.string().optional(),
tests: z.object({
annotation: z.string().optional(),
label: z.string(),
name: z.string()
}).array()
}).passthrough();
// the select schema for table submission
export const submissionOutputSchemaGen = z
.object({
code: z.string(),
in: recordId(),
out: recordId('assignment'),
score: z.unknown(),
source_code: z.string().optional(),
stage: z.unknown(),
tests: z
.object({
annotation: z.string().optional(),
label: z.string(),
name: z.string()
})
.array()
})
.passthrough();
export const submissionOutputSchemaGen = z.object({
code: z.string(),
in: recordId(),
out: recordId('assignment'),
score: z.unknown(),
source_code: z.string().optional(),
stage: z.unknown(),
tests: z.object({
annotation: z.string().optional(),
label: z.string(),
name: z.string()
}).array()
}).passthrough();
......@@ -3,10 +3,15 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { z } from "zod";
// the create schema for table tutor
export const tutorInputSchemaGen = z.object({}).passthrough();
export const tutorInputSchemaGen = z.object({
}).passthrough();
// the select schema for table tutor
export const tutorOutputSchemaGen = z.object({}).passthrough();
export const tutorOutputSchemaGen = z.object({
}).passthrough();
......@@ -3,26 +3,27 @@
// This file is autogenerated and will be overwritten during generation!
// ====================
import { z } from 'zod';
import { z } from "zod";
// the create schema for table user
export const userInputSchemaGen = z.object({
activation_expires: z.string().datetime().optional(),
activation_token: z.string().optional(),
email: z.string().email(),
enabled: z.boolean(),
name: z.string(),
password_hash: z.string().optional(),
roles: z.unknown().array()
activation_expires: z.string().datetime().optional(),
activation_token: z.string().optional(),
email: z.string().email(),
enabled: z.boolean(),
name: z.string(),
password_hash: z.string().optional(),
roles: z.unknown().array()
});
// the select schema for table user
export const userOutputSchemaGen = z.object({
activation_expires: z.string().datetime(),
activation_token: z.string(),
email: z.string().email(),
enabled: z.boolean(),
name: z.string(),
password_hash: z.string(),
roles: z.unknown().array()
activation_expires: z.string().datetime(),
activation_token: z.string(),
email: z.string().email(),
enabled: z.boolean(),
name: z.string(),
password_hash: z.string(),
roles: z.unknown().array()
});
/* Place your custom changes here */
import { z } from "zod";
import { annotationInputSchemaGen, annotationOutputSchemaGen } from "../../_generated/index.js";
import { recordId } from "../../_generated/recordSchema.js";
// payload schema for creating a new annotation entity
export const annotationCreateSchema = annotationInputSchemaGen.merge(z.object({
id: recordId("annotation").optional()
// add your custom fields here, which are not part of SurrealDB table schema
// they are not overwritten by the next run
}))
// payload schema for fetching a annotation entity
export const annotationSchema = annotationOutputSchemaGen.merge(z.object({
id: recordId("annotation"),
// add your custom fields here, which are not part of SurrealDB table schema
// they are not overwritten by the next run
}))
/* Place your custom changes here */
import { z } from "zod";
import { type RecordId} from "surrealdb";
import { annotationCreateSchema, annotationSchema } from "./annotationSchema.js";
// the create type for table annotation
export type AnnotationCreate = z.input<typeof annotationCreateSchema>
// the select type for table annotation
export type Annotation = z.output<typeof annotationSchema> & {id: RecordId<string>}
\ No newline at end of file
export * from './annotationSchema.js';
export * from './annotationTypes.js';
\ No newline at end of file
/* Place your custom changes here */
import { z } from 'zod';
import { z } from "zod";
import { assignmentInputSchemaGen, assignmentOutputSchemaGen } from '../../_generated/index.js';
import { recordId } from '../../_generated/recordSchema.js';
import { assignmentInputSchemaGen, assignmentOutputSchemaGen } from "../../_generated/index.js";
import { recordId } from "../../_generated/recordSchema.js";
// payload schema for creating a new assignment entity
export const assignmentCreateSchema = assignmentInputSchemaGen.merge(
z.object({
id: recordId('assignment').optional()
// add your custom fields here, which are not part of SurrealDB table schema
// they are not overwritten by the next run
})
);
export const assignmentCreateSchema = assignmentInputSchemaGen.merge(z.object({
id: recordId("assignment").optional()
// add your custom fields here, which are not part of SurrealDB table schema
// they are not overwritten by the next run
}))
// payload schema for fetching a assignment entity
export const assignmentSchema = assignmentOutputSchemaGen.merge(
z.object({
id: recordId('assignment')
// add your custom fields here, which are not part of SurrealDB table schema
// they are not overwritten by the next run
})
);
export const assignmentSchema = assignmentOutputSchemaGen.merge(z.object({
id: recordId("assignment"),
// add your custom fields here, which are not part of SurrealDB table schema
// they are not overwritten by the next run
}))
/* Place your custom changes here */
import { z } from 'zod';
import { type RecordId } from 'surrealdb';
import { z } from "zod";
import { type RecordId} from "surrealdb";
import { assignmentCreateSchema, assignmentSchema } from './assignmentSchema.js';
import { assignmentCreateSchema, assignmentSchema } from "./assignmentSchema.js";
// the create type for table assignment
export type AssignmentCreate = z.input<typeof assignmentCreateSchema>;
export type AssignmentCreate = z.input<typeof assignmentCreateSchema>
// the select type for table assignment
export type Assignment = z.output<typeof assignmentSchema> & { id: RecordId<string> };
export type Assignment = z.output<typeof assignmentSchema> & {id: RecordId<string>}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment