store

package
v0.0.0-...-84b44bb Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package store defines models and global methods to operate these models

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrivsToStr

func PrivsToStr(privs []Privilege) []string

PrivsToStr converts privileges slice to string slice to simplify embedding

Types

type Class

type Class struct {
	ClassDescription
	Course  Course
	Group   Group
	Teacher Teacher
}

Class describes a general class with its references to groups, courses, teachers etc.

type ClassDescription

type ClassDescription struct {
	ID       string        `json:"id"`
	Title    string        `json:"title"`
	Location Location      `json:"location"`
	Start    time.Time     `json:"start"`
	Duration time.Duration `json:"duration"`
	Repeats  int           `json:"repeats"`
}

ClassDescription describes a basic lesson of the Course, e.g. a couple

type Course

type Course struct {
	ID              string             `json:"id"`                         // a hash derived from all others fields
	Name            string             `json:"name"`                       // the name of the course
	Program         EducationalProgram `json:"program,omitempty"`          // bachelor, master or graduate
	Formats         []CourseFormat     `json:"formats,omitempty"`          // a set of preferable course formats
	Groups          []Group            `json:"groups,omitempty"`           // a study groups, e.g. "BS19-04"
	Assistants      []Teacher          `json:"assistants,omitempty"`       // teacher assistants of the course
	PrimaryLector   Teacher            `json:"primary_lector"`             // e.g. who leads the lectures
	AssistantLector Teacher            `json:"assistant_lector,omitempty"` // e.g. who leads the tutorials, might be empty
	StudyYear       StudyYear          `json:"study_year"`

	Classes []ClassDescription `json:"classes,omitempty"` // classes of the course, i.e. the course schedule
}

Course describes a basic semester course, e.g. "Operational systems"

type CourseFormat

type CourseFormat string

CourseFormat describes a parts (couples, lessons) of the Course

const (
	Lecture  CourseFormat = "lecture"
	Tutorial CourseFormat = "tutorial"
	Lab      CourseFormat = "lab"
)

Basic course formats

type EducationalProgram

type EducationalProgram string

EducationalProgram describes a study level of students

const (
	Bachelor EducationalProgram = "bachelor"
	Master   EducationalProgram = "master"
)

Basic educational levels

type Group

type Group struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"` // name of this group, e.g. "BS19-04"
	StudyYear StudyYear `json:"study_year"`
}

Group describes a basic students group, e.g. "BS19-04"

func (*Group) PrepareUntrusted

func (g *Group) PrepareUntrusted()

PrepareUntrusted sets zero values to all immutable for user fields

type Location

type Location string

Location describes a room or auditory where the ClassDescription is held

type Privilege

type Privilege string

Privilege describes a user's privilege to perform some action

const (
	PrivAddUsers  Privilege = "add_users"
	PrivReadUsers Privilege = "read_users"
	PrivEditUsers Privilege = "edit_users"
	PrivListUsers Privilege = "list_users"
)

Default user privileges

func StrToPrivs

func StrToPrivs(s []string) []Privilege

StrToPrivs converts string slice to privileges to simplify embedding

type StudyYear

type StudyYear struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

StudyYear describes a particular study year like "BS - Year 1 (Computer Science)"

type Teacher

type Teacher struct {
	Preferences TeacherPreferences `json:"preferences,omitempty"`
	TeacherDetails
}

Teacher describes a basic teacher with its own name and surname

func (*Teacher) Empty

func (t *Teacher) Empty() bool

Empty returns true if there is no teacher data

func (*Teacher) PrepareUntrusted

func (t *Teacher) PrepareUntrusted()

PrepareUntrusted sets zero values for all fields that are immutable for user

type TeacherDetails

type TeacherDetails struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Surname string `json:"surname"`

	Email string `json:"email"`

	Degree string `json:"degree"`
	About  string `json:"about"`
}

TeacherDetails describes a data that relates to one particular teacher to exclude the recursion problems

type TeacherPreferences

type TeacherPreferences struct {
	TimeSlots []TimeSlot       `json:"time_slots"` // preferable time slots for teaching
	Staff     []TeacherDetails `json:"staff"`      // preferable teaching staff
	Locations []Location       `json:"rooms"`      // preferable rooms for teaching
}

TeacherPreferences describes teacher's preferences in generating the schedule. When setting the teacher preferences, in Staff all fields will be ignored except the IDs

func (TeacherPreferences) Empty

func (p TeacherPreferences) Empty() bool

Empty checks whether the preferences are empty or not

type TimeSlot

type TimeSlot struct {
	ID       string            `json:"id"`       // id of this time slot
	Weekday  time.Weekday      `json:"weekday"`  // a weekday of time slot
	Start    timetype.Clock    `json:"start"`    // start time of time slot
	Duration timetype.Duration `json:"duration"` // duration of a time slot
}

TimeSlot describes a particular period of time in a week

type User

type User struct {
	ID         string      `json:"id"`
	Email      string      `json:"email"`
	Privileges []Privilege `json:"privileges"`
}

User describes a basic user

func (User) HasPrivilege

func (u User) HasPrivilege(priv string) bool

HasPrivilege checks whether user has the defined privilege

Directories

Path Synopsis
Package pgh provides some wrappers and helpers for github.com/jackc/pgx methods
Package pgh provides some wrappers and helpers for github.com/jackc/pgx methods
Package service wraps user interfaces with common logic unrelated to any particular user implementation.
Package service wraps user interfaces with common logic unrelated to any particular user implementation.
Package uni defines interface for university organization database repository and provides some implementations of this interface
Package uni defines interface for university organization database repository and provides some implementations of this interface
Package user provides implementations for Interface for the database user repository.
Package user provides implementations for Interface for the database user repository.

Jump to

Keyboard shortcuts

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