teacher

package
v0.0.0-...-8b20b1e Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeltaTokenJours = 3
)
View Source
const ValidateInscriptionEndPoint = "inscription"

Variables

This section is empty.

Functions

func JWTTeacher

func JWTTeacher(c echo.Context) tc.IdTeacher

JWTTeacher expects a JWT authentified request, and must only be used in routes protected by `JWTMiddleware`

Types

type AskInscriptionIn

type AskInscriptionIn struct {
	Mail            string
	Password        string
	FavoriteMatiere tc.MatiereTag
}

type AskInscriptionOut

type AskInscriptionOut struct {
	Error           string // empty for no error
	IsPasswordError bool
}

type AttachStudentToClassroom1Out

type AttachStudentToClassroom1Out []StudentHeader

type AttachStudentToClassroom2In

type AttachStudentToClassroom2In struct {
	ClassroomCode string
	IdStudent     tc.IdStudent
	Birthday      string // 2006-01-02
	Device        string // the name of the device the student is using
}

type AttachStudentToClassroom2Out

type AttachStudentToClassroom2Out struct {
	ErrInvalidBirthday bool
	ErrAlreadyAttached bool // Deprecated
	IdCrypted          string
}

type CheckStudentClassroomOut

type CheckStudentClassroomOut struct {
	IsOK bool // if false, ignore the other fields
	Meta StudentClassroomHeader

	// Advance exposes the global advance of the student,
	// as defined by its events.
	Advance events.StudentAdvance
}

type ClassroomExt

type ClassroomExt struct {
	Classroom tc.Classroom

	NbStudents int
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller provides the route handling teacher inscription, connection and settings.

func NewController

func NewController(db *sql.DB, smtp pass.SMTP, teacherKey, studentKey pass.Encrypter, host, demoCode string) *Controller

NewController return a new controller. `LoadAdminTeacher` should be called once.

func (*Controller) AskInscription

func (ct *Controller) AskInscription(c echo.Context) error

AskInscription send a link to register a new user account.

func (*Controller) AttachStudentToClassroomStep1

func (ct *Controller) AttachStudentToClassroomStep1(c echo.Context) error

AttachStudentToClassroomStep1 uses a temporary classroom code to attach a student to the classroom. More precisely, it checks the given code and returns a list of student propositions. As a special case, it also accepts a special demo code <DEMO_CODE>.[0-9] which creates a profile linked to the demo classroom.

func (*Controller) AttachStudentToClassroomStep2

func (ct *Controller) AttachStudentToClassroomStep2(c echo.Context) error

AttachStudentToClassroomStep2 validates the birthday and actually attaches the client to a student account and a classroom.

func (*Controller) CheckStudentClassroom

func (ct *Controller) CheckStudentClassroom(c echo.Context) error

CheckStudentClassroom is called on app startup, to check that the student credentials are still up to date.

func (*Controller) CleanupClassroomCodes

func (ct *Controller) CleanupClassroomCodes() error

func (*Controller) GetDevTokens

func (ct *Controller) GetDevTokens() (string, string, error)

GetDevTokens creates a new user and returns a valid token, so that client frontend doesn't have to use password when developping.

func (*Controller) JWTMiddleware

func (ct *Controller) JWTMiddleware() echo.MiddlewareFunc

func (*Controller) JWTMiddlewareForQuery

func (ct *Controller) JWTMiddlewareForQuery() echo.MiddlewareFunc

expects the token to be in the `token` query parameters

func (*Controller) LoadAdminTeacher

func (ct *Controller) LoadAdminTeacher() (tc.Teacher, error)

LoadAdminTeacher loads and stores the admin account. By convention, only one account has admin rights. It is manually created at DB setup, and never added (neiter removed) at run time.

func (*Controller) LoadDemoClassroom

func (ct *Controller) LoadDemoClassroom() (tc.Classroom, error)

LoadDemoClassroom loads and stores the demo classroom, which is a [Classroom] manually created at DB setup, and attributed to the admin account, with a special ID = 1 .

func (*Controller) Loggin

func (ct *Controller) Loggin(c echo.Context) error

func (*Controller) StudentUpdatePlaylist

func (ct *Controller) StudentUpdatePlaylist(c echo.Context) error

StudentUpdatePlaylist is called to register an event when a student updates its playlist

func (*Controller) TeacherAddStudent

func (ct *Controller) TeacherAddStudent(c echo.Context) error

TeacherAddStudent adds a new student to the given classroom.

func (*Controller) TeacherCreateClassroom

func (ct *Controller) TeacherCreateClassroom(c echo.Context) error

func (*Controller) TeacherDeleteClassroom

func (ct *Controller) TeacherDeleteClassroom(c echo.Context) error

TeacherDeleteClassroom remove the classrooms and all related students

func (*Controller) TeacherDeleteStudent

func (ct *Controller) TeacherDeleteStudent(c echo.Context) error

TeacherDeleteStudent removes the student from the classroom and completely deletes it.

func (*Controller) TeacherGenerateClassroomCode

func (ct *Controller) TeacherGenerateClassroomCode(c echo.Context) error

TeacherGenerateClassroomCode generates a temporary code to link students app to the classroom.

func (*Controller) TeacherGetClassroomStudents

func (ct *Controller) TeacherGetClassroomStudents(c echo.Context) error

func (*Controller) TeacherGetClassrooms

func (ct *Controller) TeacherGetClassrooms(c echo.Context) error

func (*Controller) TeacherGetSettings

func (ct *Controller) TeacherGetSettings(c echo.Context) error

TeacherGetSettings returns the teacher global settings.

func (*Controller) TeacherImportStudents

func (ct *Controller) TeacherImportStudents(c echo.Context) error

TeacherImportStudents import a CSV file generated by Pronote. Other formats could be added in the future.

func (*Controller) TeacherResetPassword

func (ct *Controller) TeacherResetPassword(c echo.Context) error

TeacherResetPassword generates a new password for the given account and sends it by email.

func (*Controller) TeacherUpdateClassroom

func (ct *Controller) TeacherUpdateClassroom(c echo.Context) error

func (*Controller) TeacherUpdateSettings

func (ct *Controller) TeacherUpdateSettings(c echo.Context) error

func (*Controller) TeacherUpdateStudent

func (ct *Controller) TeacherUpdateStudent(c echo.Context) error

TeacherUpdateStudent updates the student profile.

func (*Controller) ValidateInscription

func (ct *Controller) ValidateInscription(c echo.Context) error

type GenerateClassroomCodeOut

type GenerateClassroomCodeOut struct {
	Code string
}

type LogginIn

type LogginIn struct {
	Mail     string
	Password string
}

type LogginOut

type LogginOut struct {
	Error           string // empty means success
	IsPasswordError bool
	Token           string // token to use in the next requests
}

type OptionalIdReview

type OptionalIdReview struct {
	InReview bool
	Id       reviews.IdReview
}

type Origin

type Origin struct {
	Visibility   Visibility
	PublicStatus PublicStatus
	IsInReview   OptionalIdReview // true if the owner has already started a review for the resource
}

type PublicStatus

type PublicStatus uint8

PublicStatus exposes the status of an admin resource

const (
	NotAdmin PublicStatus = iota
	AdminPublic
	AdminNotPublic
)

func NewPublicStatus

func NewPublicStatus(ownerID, userID, adminID teacher.IdTeacher, public bool) PublicStatus

type StudentClassroomHeader

type StudentClassroomHeader struct {
	Student           StudentClient
	ClassroomName     string
	TeacherMail       string // or contact, to be displayed
	TeacherContactURL string // optional, display a link if provided
}

type StudentClient

type StudentClient struct {
	Name    string
	Surname string

	Id               tc.IdStudent   // Depreacted
	Birthday         tc.Date        // Depreacted
	IdClassroom      tc.IdClassroom `json:"id_classroom"` // Deprecated
	TrivialSuccess   int            // Deprecated
	IsClientAttached bool           // Deprecated
}

type StudentExt

type StudentExt struct {
	Student tc.Student
	Success evs.StudentAdvance
}

type StudentHeader

type StudentHeader struct {
	Id                 tc.IdStudent
	Label              string
	HasAttachedClients bool
}

func NewStudentHeader

func NewStudentHeader(st tc.Student) StudentHeader

type TeacherSettings

type TeacherSettings struct {
	Mail                string
	Password            string
	HasEditorSimplified bool
	Contact             tc.Contact
	FavoriteMatiere     teacher.MatiereTag
}

type UserMeta

type UserMeta struct {
	IdTeacher tc.IdTeacher
	jwt.StandardClaims
}

UserMeta are custom claims extending default ones.

type Visibility

type Visibility uint8

Visibility is the status of a ressource, among :

  • personnal : read/write acces for the current teacher
  • verified by admins : read access only
const (
	Hidden    Visibility = iota // not accessible by the user, except in reviews
	Personnal                   // Personnel
	Admin                       // Officiel
)

func NewVisibility

func NewVisibility(ownerID, userID, adminID teacher.IdTeacher, public bool) Visibility

NewVisibility returns the visilbity of the ressource owned by `ownerID` and requested by `userID`, or `false` if `userID` does not have access to it.

func (Visibility) Restricted

func (vis Visibility) Restricted() bool

Restricted returns true if the item access if forbidden.

Jump to

Keyboard shortcuts

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