Documentation
¶
Overview ¶
Package teacher provides the data structures related to teacher and student accounts.
Index ¶
- Constants
- func CleanupClassroomCodes(db DB) error
- func IdClassroomArrayToPQ(ids []IdClassroom) pq.Int64Array
- func IdStudentArrayToPQ(ids []IdStudent) pq.Int64Array
- func IdTeacherArrayToPQ(ids []IdTeacher) pq.Int64Array
- func InsertManyClassroomCodes(tx *sql.Tx, items ...ClassroomCode) error
- func InsertManyTeacherClassrooms(tx *sql.Tx, items ...TeacherClassroom) error
- type Classroom
- type ClassroomCode
- type ClassroomCodes
- func DeleteClassroomCodesByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (ClassroomCodes, error)
- func ScanClassroomCodes(rs *sql.Rows) (ClassroomCodes, error)
- func SelectAllClassroomCodes(db DB) (ClassroomCodes, error)
- func SelectClassroomCodesByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (ClassroomCodes, error)
- type Classrooms
- type Client
- type Clients
- type Contact
- type DB
- type Date
- type IdClassroom
- type IdStudent
- type IdTeacher
- type MatiereTag
- type Student
- type Students
- type Teacher
- type TeacherClassroom
- type TeacherClassrooms
- func DeleteTeacherClassroomsByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (TeacherClassrooms, error)
- func DeleteTeacherClassroomsByIdTeachers(tx DB, idTeachers_ ...IdTeacher) (TeacherClassrooms, error)
- func ScanTeacherClassrooms(rs *sql.Rows) (TeacherClassrooms, error)
- func SelectAllTeacherClassrooms(db DB) (TeacherClassrooms, error)
- func SelectTeacherClassroomsByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (TeacherClassrooms, error)
- func SelectTeacherClassroomsByIdTeachers(tx DB, idTeachers_ ...IdTeacher) (TeacherClassrooms, error)
- type Teachers
- type Time
Constants ¶
const DateLayout = "2006-01-02"
Variables ¶
This section is empty.
Functions ¶
func CleanupClassroomCodes ¶
CleanupClassroomCodes removes the expired codes.
func IdClassroomArrayToPQ ¶
func IdClassroomArrayToPQ(ids []IdClassroom) pq.Int64Array
func IdStudentArrayToPQ ¶
func IdStudentArrayToPQ(ids []IdStudent) pq.Int64Array
func IdTeacherArrayToPQ ¶
func IdTeacherArrayToPQ(ids []IdTeacher) pq.Int64Array
func InsertManyClassroomCodes ¶
func InsertManyClassroomCodes(tx *sql.Tx, items ...ClassroomCode) error
Insert the links ClassroomCode in the database. It is a no-op if 'items' is empty.
func InsertManyTeacherClassrooms ¶
func InsertManyTeacherClassrooms(tx *sql.Tx, items ...TeacherClassroom) error
Insert the links TeacherClassroom in the database. It is a no-op if 'items' is empty.
Types ¶
type Classroom ¶
type Classroom struct {
Id IdClassroom `json:"id"`
Name string `json:"name"`
MaxRankThreshold int // for the last guilde, default to 40000
}
Classroom is one group of student controlled by one or many teachers
func DeleteClassroomById ¶
func DeleteClassroomById(tx DB, id IdClassroom) (Classroom, error)
Deletes the Classroom and returns the item
func SelectClassroom ¶
func SelectClassroom(tx DB, id IdClassroom) (Classroom, error)
SelectClassroom returns the entry matching 'id'.
type ClassroomCode ¶
type ClassroomCode struct {
IdClassroom IdClassroom `gomacro-sql-on-delete:"CASCADE"`
Code string
ExpiresAt Time
}
ClassroomCode is a time limited, user friendly, code to access one class gomacro:SQL ADD UNIQUE(Code)
func ScanClassroomCode ¶
func ScanClassroomCode(row *sql.Row) (ClassroomCode, error)
func SelectClassroomCodeByCode ¶
func SelectClassroomCodeByCode(tx DB, code string) (item ClassroomCode, found bool, err error)
SelectClassroomCodeByCode return zero or one item, thanks to a UNIQUE SQL constraint.
func (ClassroomCode) Delete ¶
func (item ClassroomCode) Delete(tx DB) error
Delete the link ClassroomCode from the database. Only the foreign keys IdClassroom fields are used in 'item'.
func (ClassroomCode) Insert ¶
func (item ClassroomCode) Insert(db DB) error
type ClassroomCodes ¶
type ClassroomCodes []ClassroomCode
func DeleteClassroomCodesByIdClassrooms ¶
func DeleteClassroomCodesByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (ClassroomCodes, error)
func ScanClassroomCodes ¶
func ScanClassroomCodes(rs *sql.Rows) (ClassroomCodes, error)
func SelectAllClassroomCodes ¶
func SelectAllClassroomCodes(db DB) (ClassroomCodes, error)
SelectAll returns all the items in the classroom_codes table.
func SelectClassroomCodesByIdClassrooms ¶
func SelectClassroomCodesByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (ClassroomCodes, error)
func (ClassroomCodes) ByIdClassroom ¶
func (items ClassroomCodes) ByIdClassroom() map[IdClassroom]ClassroomCodes
ByIdClassroom returns a map with 'IdClassroom' as keys.
func (ClassroomCodes) Codes ¶
func (ccs ClassroomCodes) Codes() map[string]bool
func (ClassroomCodes) IdClassrooms ¶
func (items ClassroomCodes) IdClassrooms() []IdClassroom
IdClassrooms returns the list of ids of IdClassroom contained in this link table. They are not garanteed to be distinct.
type Classrooms ¶
type Classrooms map[IdClassroom]Classroom
func ScanClassrooms ¶
func ScanClassrooms(rs *sql.Rows) (Classrooms, error)
func SelectAllClassrooms ¶
func SelectAllClassrooms(db DB) (Classrooms, error)
SelectAll returns all the items in the classrooms table.
func SelectClassrooms ¶
func SelectClassrooms(tx DB, ids ...IdClassroom) (Classrooms, error)
SelectClassrooms returns the entry matching the given 'ids'.
func SelectClassroomsByIdTeacher ¶
func SelectClassroomsByIdTeacher(db DB, id IdTeacher) (Classrooms, error)
SelectClassroomsByIdTeacher does NOT wrap the error.
func (Classrooms) IDs ¶
func (m Classrooms) IDs() []IdClassroom
type DB ¶
type DB interface {
Exec(query string, args ...any) (sql.Result, error)
Query(query string, args ...any) (*sql.Rows, error)
QueryRow(query string, args ...any) *sql.Row
Prepare(query string) (*sql.Stmt, error)
}
DB groups transaction like objects, and is implemented by *sql.DB and *sql.Tx
type Date ¶
Date represents a day, without time zone consideration
func NewDateFrom ¶
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
type IdClassroom ¶
type IdClassroom int64
func DeleteClassroomsByIDs ¶
func DeleteClassroomsByIDs(tx DB, ids ...IdClassroom) ([]IdClassroom, error)
Deletes the Classroom in the database and returns the ids.
func ScanIdClassroomArray ¶
func ScanIdClassroomArray(rs *sql.Rows) ([]IdClassroom, error)
ScanIdClassroomArray scans the result of a query returning a list of ID's.
type IdStudent ¶
type IdStudent int64
func DeleteStudentsByIDs ¶
Deletes the Student in the database and returns the ids.
func DeleteStudentsByIdClassrooms ¶
func DeleteStudentsByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) ([]IdStudent, error)
type IdTeacher ¶
type IdTeacher int64
func DeleteTeachersByIDs ¶
Deletes the Teacher in the database and returns the ids.
type MatiereTag ¶
type MatiereTag string
MatiereTag are special tags to indicate the topic of a question/exercice
const ( Autre MatiereTag = "AUTRE" // AUTRE Mathematiques MatiereTag = "MATHS" // MATHS Francais MatiereTag = "FRANCAIS" // FRANCAIS HistoireGeo MatiereTag = "HISTOIRE-GEO" // HISTOIRE-GEO Espagnol MatiereTag = "ESPAGNOL" // ESPAGNOL Italien MatiereTag = "ITALIEN" // ITALIEN Allemand MatiereTag = "ALLEMAND" // ALLEMAND Anglais MatiereTag = "ANGLAIS" // ANGLAIS SES MatiereTag = "SES" // SES PhysiqueChimie MatiereTag = "PHYSIQUE" // PHYSIQUE SVT MatiereTag = "SVT" // SVT )
type Student ¶
type Student struct {
Id IdStudent
Name string
Surname string
Birthday Date
IdClassroom IdClassroom `json:"id_classroom" gomacro-sql-on-delete:"CASCADE"`
Clients Clients
}
Student is a student profile, always attached to a classroom.
func DeleteStudentById ¶
Deletes the Student and returns the item
func SelectStudent ¶
SelectStudent returns the entry matching 'id'.
type Students ¶
func SelectAllStudents ¶
SelectAll returns all the items in the students table.
func SelectStudents ¶
SelectStudents returns the entry matching the given 'ids'.
func SelectStudentsByIdClassrooms ¶
func SelectStudentsByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (Students, error)
func (Students) ByIdClassroom ¶
func (items Students) ByIdClassroom() map[IdClassroom]Students
ByIdClassroom returns a map with 'IdClassroom' as keys.
func (Students) IdClassrooms ¶
func (items Students) IdClassrooms() []IdClassroom
IdClassrooms returns the list of ids of IdClassroom contained in this table. They are not garanteed to be distinct.
type Teacher ¶
type Teacher struct {
Id IdTeacher `json:"id"`
Mail string `json:"mail"`
PasswordCrypted []byte `json:"password_crypted"` // crypted
IsAdmin bool `json:"is_admin"` // almost always false
HasSimplifiedEditor bool `json:"has_simplified_editor"` // true will hide maths widgets in editor
Contact Contact `json:"contact"` // if empty, [Mail] is used
FavoriteMatiere MatiereTag
}
Teacher stores the data associated to one teacher account gomacro:SQL ADD UNIQUE(Mail)
func DeleteTeacherById ¶
Deletes the Teacher and returns the item
func SelectTeacher ¶
SelectTeacher returns the entry matching 'id'.
func SelectTeacherByMail ¶
SelectTeacherByMail return zero or one item, thanks to a UNIQUE SQL constraint.
type TeacherClassroom ¶
type TeacherClassroom struct {
IdTeacher IdTeacher
IdClassroom IdClassroom
}
TeacherClassroom is a link table describing the owners of a classroom.
gomacro:SQL ADD UNIQUE(IdTeacher, IdClassroom)
func ScanTeacherClassroom ¶
func ScanTeacherClassroom(row *sql.Row) (TeacherClassroom, error)
func SelectTeacherClassroomByIdTeacherAndIdClassroom ¶
func SelectTeacherClassroomByIdTeacherAndIdClassroom(tx DB, idTeacher IdTeacher, idClassroom IdClassroom) (item TeacherClassroom, found bool, err error)
SelectTeacherClassroomByIdTeacherAndIdClassroom return zero or one item, thanks to a UNIQUE SQL constraint.
func (TeacherClassroom) Delete ¶
func (item TeacherClassroom) Delete(tx DB) error
Delete the link TeacherClassroom from the database. Only the foreign keys IdTeacher, IdClassroom fields are used in 'item'.
func (TeacherClassroom) Insert ¶
func (item TeacherClassroom) Insert(db DB) error
type TeacherClassrooms ¶
type TeacherClassrooms []TeacherClassroom
func DeleteTeacherClassroomsByIdClassrooms ¶
func DeleteTeacherClassroomsByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (TeacherClassrooms, error)
func DeleteTeacherClassroomsByIdTeachers ¶
func DeleteTeacherClassroomsByIdTeachers(tx DB, idTeachers_ ...IdTeacher) (TeacherClassrooms, error)
func ScanTeacherClassrooms ¶
func ScanTeacherClassrooms(rs *sql.Rows) (TeacherClassrooms, error)
func SelectAllTeacherClassrooms ¶
func SelectAllTeacherClassrooms(db DB) (TeacherClassrooms, error)
SelectAll returns all the items in the teacher_classrooms table.
func SelectTeacherClassroomsByIdClassrooms ¶
func SelectTeacherClassroomsByIdClassrooms(tx DB, idClassrooms_ ...IdClassroom) (TeacherClassrooms, error)
func SelectTeacherClassroomsByIdTeachers ¶
func SelectTeacherClassroomsByIdTeachers(tx DB, idTeachers_ ...IdTeacher) (TeacherClassrooms, error)
func (TeacherClassrooms) ByIdClassroom ¶
func (items TeacherClassrooms) ByIdClassroom() map[IdClassroom]TeacherClassrooms
ByIdClassroom returns a map with 'IdClassroom' as keys.
func (TeacherClassrooms) ByIdTeacher ¶
func (items TeacherClassrooms) ByIdTeacher() map[IdTeacher]TeacherClassrooms
ByIdTeacher returns a map with 'IdTeacher' as keys.
func (TeacherClassrooms) IdClassrooms ¶
func (items TeacherClassrooms) IdClassrooms() []IdClassroom
IdClassrooms returns the list of ids of IdClassroom contained in this link table. They are not garanteed to be distinct.
func (TeacherClassrooms) IdTeachers ¶
func (items TeacherClassrooms) IdTeachers() []IdTeacher
IdTeachers returns the list of ids of IdTeacher contained in this link table. They are not garanteed to be distinct.
type Teachers ¶
func SelectAllTeachers ¶
SelectAll returns all the items in the teachers table.
func SelectTeachers ¶
SelectTeachers returns the entry matching the given 'ids'.