db

package
v0.0.0-...-df0601d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: EUPL-1.2 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("object already exists")
	ErrNotFound      = errors.New("no such object")
)

Functions

func Init

func Init()

func InsertAssignment

func InsertAssignment(a Assignment) error

func InsertSubject

func InsertSubject(s Subject) error

func InsertSubmission

func InsertSubmission(s *Submission) error

func InsertTeacher

func InsertTeacher(t *Teacher) error

func InsertUser

func InsertUser(u *User) error

func IsTeacher

func IsTeacher(username, subjectId string) bool

func NewSubmissionId

func NewSubmissionId() string

func UpdateSubmission

func UpdateSubmission(s *Submission) error

func UpdateUser

func UpdateUser(u *User) error

Types

type Assignment

type Assignment struct {
	Id        string
	SubjectId string `bson:"subject_id"`

	Name           string
	Image          string
	Timeout        time.Duration
	SubmissionPath string `bson:"submission_path"`

	SoftDeadline time.Time `bson:"soft_deadline"`
	HardDeadline time.Time `bson:"hard_deadline"`
	DailyPenalty int       `bson:"daily_penalty"`

	MaxScoreByTests   int `bson:"max_score_by_tests"`
	MaxScoreByTeacher int `bson:"max_score_by_teacher"`
}

Assignment holds data related to an assignment.

func GetAllAssignments

func GetAllAssignments(subjectId string) []Assignment

func GetAssignment

func GetAssignment(subjectId, id string) (*Assignment, error)

func GetAssignmentOrPanic

func GetAssignmentOrPanic(subjectId, id string) *Assignment

type Subject

type Subject struct {
	Id   string
	Name string
}

Subject holds data related to a subject.

func GetAllSubjects

func GetAllSubjects() []Subject

func GetSubject

func GetSubject(id string) (*Subject, error)

func GetSubjectOrPanic

func GetSubjectOrPanic(id string) *Subject

type Submission

type Submission struct {
	Id           string
	AssignmentId string `bson:"assignment_id"`
	SubjectId    string `bson:"subject_id"`

	OwnerUsername string `bson:"owner_username"`

	Status           string // TODO: make this a constant or an enum.
	Timestamp        time.Time
	UploadedFile     []byte `bson:"uploaded_file",json:"-"`
	UploadedFileName string `bson:"uploaded_file_name",json:"-"`
	Logs             []byte
	Metadata         map[string]string

	ScoreByTests int `bson:"score_by_tests"`

	GradedByTeacher bool   `bson:"graded_by_teacher"`
	GraderUsername  string `bson:"grader_username"`
	ScoreByTeacher  int    `bson:"score_by_teacher"`
	Feedback        string
}

Submission holds data related to a submission.

func GetActiveSubmissions

func GetActiveSubmissions(subjectId, assignmentId string) []Submission

func GetAllSubmissions

func GetAllSubmissions(subjectId, assignmentId string) []Submission

func GetSubmission

func GetSubmission(subjectId, assignmentId, id string) (*Submission, error)

func GetSubmissionOrPanic

func GetSubmissionOrPanic(subjectId, assignmentId, id string) *Submission

func GetSubmissionsOfUser

func GetSubmissionsOfUser(subjectId, assignmentId, ownerUsername string) []Submission

type Teacher

type Teacher struct {
	Username  string
	SubjectId string `bson:"subject_id"`
}

Teacher describes the teacher of a User on a Subject.

type User

type User struct {
	Username string
	Password string
	IsAdmin  bool `bson:"is_admin"`
}

User holds data related to an user.

func GetAdmins

func GetAdmins() []User

func GetAllTeachersOfSubject

func GetAllTeachersOfSubject(subjectId string) []User

func GetUser

func GetUser(username string) (*User, error)

func GetUserAuth

func GetUserAuth(username, password string) (*User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL