schema

package
v0.0.0-...-1b8d80d Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StudentLevel int = iota
	TutorLevel
	MajorLevel
	HeadLevel
	AdminLevel
	RootLevel

	STUDENT Role = "student"
	TUTOR   Role = "tutor"
	ROOT    Role = "root"
	//DateLayout indicates the date format
	DateLayout = "02/01/2006 15:04"
)

The different level of Roles

Variables

View Source
var (
	//ErrUnknownStudent declares the student is unknown
	ErrUnknownStudent = errors.New("Unknown student")
	//ErrUnknownConvention declares the convention is unknown
	ErrUnknownConvention = errors.New("No convention associated to this student")
	//ErrStudentExists declares the student already exists
	ErrStudentExists = errors.New("Student already exists")
	//ErrReportExists declares the report already exists
	ErrReportExists = errors.New("Report already exists")
	//ErrUnknownReport declares the report does not exist
	ErrUnknownReport = errors.New("Unknown report or student")
	//ErrInvalidGrade declares the grade is not between in 0 and 20
	ErrInvalidGrade = errors.New("The grade must be between 0 and 20 (inclusive)")
	//ErrReportConflict declares a report has not been uploaded
	ErrReportConflict = errors.New("The report has not been uploaded")
	//ErrInternshipExists declares the internship already exists
	ErrInternshipExists = errors.New("Internship already exists")
	//ErrUnknownInternship declares the internship does not exists
	ErrUnknownInternship = errors.New("Unknown internship")
	//ErrUserExists declares the user already exists
	ErrUserExists = errors.New("User already exists")
	//ErrUnknownUser declares the user is unknown
	ErrUnknownUser = errors.New("The email does not match a registered user")
	//ErrUserTutoring declares the user cannot be removed as it is tutoring students
	ErrUserTutoring = errors.New("The user is tutoring students")
	//ErrCredentials declares invalid credentials
	ErrCredentials = errors.New("Incorrect password")
	//ErrPasswordTooShort declares the stated password is too short
	ErrPasswordTooShort = errors.New("Password too short (8 chars. min)")
	//ErrNoPendingRequests declares there is no password renewal request
	ErrNoPendingRequests = errors.New("No pending reset request. You might use a bad or an expired reset token.")
	//ErrInvalidPeriod declared the internship period is incorrect
	ErrInvalidPeriod = errors.New("invalid internship period")
	//ErrConventionExists declares a convention for the student already exists
	ErrConventionExists = errors.New("convention already scanned")
	//ErrInvalidMajor declares the declared major is not supported
	ErrInvalidMajor = errors.New("Unknown major")
	//ErrInvalidPromotion declares the promotion is not supported
	ErrInvalidPromotion = errors.New("Unknown promotion")
	//ErrDeadlinePassed declares the deadline for a report passed
	ErrDeadlinePassed = errors.New("Deadline passed")
	//ErrGradedReport declares the report is already graded
	ErrGradedReport = errors.New("Report already graded")
	//ErrSessionExpired declares an expired session
	ErrSessionExpired = errors.New("Session expired")
	//ErrInvalidToken declares an invalid session token
	ErrInvalidToken = errors.New("Invalid session")
	//ErrUnknownSurvey declares the survey does not exist
	ErrUnknownSurvey = errors.New("Unknown survey or student")
	//ErrSurveyUploaded declares the survey has already been uploaded
	ErrSurveyUploaded = errors.New("Survey already fullfilled")
	//ErrInvalidSurvey declares the answers are invalid
	ErrInvalidSurvey = errors.New("Invalid answers")
	//ErrUnknownAlumni declares there is no alumni information for the students
	ErrUnknownAlumni = errors.New("No informations for future alumni")
	//ErrInvalidAlumniEmail declares the email cannot be used for alumni
	ErrInvalidAlumniEmail = errors.New("Invalid email. It must not be served by polytech' or unice")
	//ErrInvalidEmail declares the email is invalid
	ErrInvalidEmail = errors.New("Invalid email")
	//ErrUnknownDefense declares the defense is unknown
	ErrUnknownDefense = errors.New("Unknown defense")

	//ErrDefenseSessionConflit declares a session that is in conflict with another
	ErrDefenseSessionConflit = errors.New("There is already a session for that slot")
	ErrDefenseExists         = errors.New("The defense is already planned")
	ErrDefenseConflict       = errors.New("A defense is already planned for that slot")
	ErrDefenseJuryConflict   = errors.New("The teacher is already in a jury for that period")
)

Functions

func InMajor

func InMajor(major string) func(Internship) bool

InMajor is a filter that keep only the internships in the given major

func StudentInMajor

func StudentInMajor(major string) func(Student) bool

StudentInMajor is a filter that keep only the students in the given major

func Tutoring

func Tutoring(tut string) func(Internship) bool

Tutoring is a filter that keep only the internships tutored by the given user

Types

type Alumni

type Alumni struct {
	Contact     string
	Position    string
	France      bool
	Permanent   bool
	SameCompany bool
}

Alumni denotes the basic information for a student future

type Anonymiser

type Anonymiser interface {
	Anonymise()
}

type Category

type Category struct {
	En string
	Fr string
	Q  []Question
}

Category contains questions with a title in french or english

type Company

type Company struct {
	//The company name
	Name string
	//The company website
	WWW string
	//The job title
	Title string
}

Company stores meaningful information for a company hosting a student.

func (*Company) Anonymise

func (c *Company) Anonymise()

Anonymise removes the internship subject title

type Convention

type Convention struct {
	Creation   time.Time
	Student    Student
	Tutor      User
	Supervisor Person
	Company    Company
	Begin      time.Time
	End        time.Time
	//Ignore this convention (don't managed by wints if true)
	Skip           bool
	Valid          bool
	ForeignCountry bool
	Lab            bool
	Gratification  int
}

Convention declares a student convention

func (*Convention) Anonymise

func (c *Convention) Anonymise()

Anonymise the company, the person

type Defense

type Defense struct {
	Room      string
	SessionId string
	Public    bool
	Local     bool
	Grade     int
	Time      time.Time
	Student   Student
	Company   Company
}

Defense depicts the defense of a student

func (*Defense) Anonymise

func (d *Defense) Anonymise()

type DefenseSession

type DefenseSession struct {
	Juries   []User
	Defenses []Defense
	Id       string
	Room     string
}

DefenseSession groups all the defenses that occurs during a session

func (DefenseSession) Anonymise

func (s DefenseSession) Anonymise()

func (DefenseSession) InJury

func (s DefenseSession) InJury(em string) bool

InJury check if a user is a part of a jury

type Internship

type Internship struct {
	Convention Convention
	//The headers for each
	Reports []ReportHeader
	//The surveys
	Surveys []SurveyHeader
	//Defense
	Defense Defense
}

Internship is the core type to specify required data related to an internship

func (*Internship) Anonymise

func (i *Internship) Anonymise()

Anonymise the convention, the reports and the surveys

type Internships

type Internships []Internship

Internships aliases slices of internship to exhibit filtering methods

func (Internships) Anonymise

func (ss Internships) Anonymise()

Anonymise every internships

func (Internships) Filter

func (ss Internships) Filter(filters ...func(Internship) bool) Internships

Filter returns the internships that pass the given filters

type Internshipser

type Internshipser interface {
	Internships() (Internships, error)
}

Internshipser is a basic interface to browse internships

type Person

type Person struct {
	Firstname string
	Lastname  string
	Email     string
	Tel       string
}

Person just gathers contact information for someone.

func (*Person) Anonymise

func (p *Person) Anonymise()

Anonymise the person by removing any personal information

func (Person) Fullname

func (p Person) Fullname() string

Fullname provides the user fullname, starting with its firstname

func (Person) String

func (p Person) String() string

String returns the person email

type Question

type Question struct {
	En       string
	Fr       string
	Type     string
	Required bool
	IsMark   bool
}

Question has a title in french or english

type ReportHeader

type ReportHeader struct {
	Kind string
	//The report deadline
	Deadline time.Time
	Delivery *time.Time `,json:"omitempty"`
	Reviewed *time.Time `,json:"omitempty"`
	Grade    int
	//The tutor comment
	Comment string
	Private bool
	ToGrade bool
}

ReportHeader provides the metadata associated to a student report

func (*ReportHeader) Anonymise

func (m *ReportHeader) Anonymise()

Anonymise the report comment

func (*ReportHeader) Graded

func (m *ReportHeader) Graded() bool

Graded indicates if a report has been graded

func (*ReportHeader) In

func (m *ReportHeader) In() bool

In indicates if a report has been uploaded

type Role

type Role string

Role aims at giving the possible level of Role for a user.

func (Role) Level

func (p Role) Level() int

Level returns the authentication level associated to a given role

func (Role) String

func (p Role) String() string

String() versions of the role

func (Role) SubRole

func (p Role) SubRole() string

SubRole extract the second level role if exists.

func (Role) Value

func (p Role) Value() (driver.Value, error)

Value returns String()

type Session

type Session struct {
	Email  string
	Token  []byte
	Expire time.Time
}

Session denotes a user session

type Student

type Student struct {
	User      User
	Promotion string
	Major     string
	Alumni    *Alumni `,json:"omitempty"`
	//Skip indicates we don't care about this student. Might left the school for example
	Skip bool
	Male bool
}

Student denotes a student that as a promotion, a major.

type StudentReports

type StudentReports struct {
	Student Student
	Reports []ReportHeader
}

StudentReports aggregate the reports of a given student

type Students

type Students []Student

Students aliases slices of student to exhibit filtering methods

func (Students) Filter

func (ss Students) Filter(filter func(Student) bool) Students

Filter returns the students that pass the given filter

type Survey

type Survey struct {
	En string
	Fr string

	Categories []Category
}

Survey agglomerates Cateogies with a title in French or English

type SurveyHeader

type SurveyHeader struct {
	Kind string
	//Invitation the moment where the request must be sent
	Invitation time.Time
	//LastInvitation the moment where the last request has been emitted
	LastInvitation time.Time
	//The deadline where the survey shall be uploaded
	Deadline time.Time
	//The moment the survey was committed
	Delivery *time.Time `,json:"omitempty"`
	//The token to access in write mode
	Token string
	//Survey content
	Cnt map[string]string
}

SurveyHeader provides the metadata associated to a student survey

func (*SurveyHeader) Anonymise

func (s *SurveyHeader) Anonymise()

Anonymise removes the token

type User

type User struct {
	Person    Person
	Role      Role
	LastVisit *time.Time `,json:"omitempty"`
}

User is a person with an account

func (User) Fullname

func (u User) Fullname() string

Fullname delegates to Person.String()

func (User) String

func (u User) String() string

String delegates to Person.String()

Jump to

Keyboard shortcuts

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