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 InsertClassroomCode(db DB, item ClassroomCode) error
- func InsertManyClassroomCodes(tx *sql.Tx, items ...ClassroomCode) error
- type Classroom
- func DeleteClassroomById(tx DB, id IdClassroom) (Classroom, error)
- func ScanClassroom(row *sql.Row) (Classroom, error)
- func SelectClassroom(tx DB, id IdClassroom) (Classroom, error)
- func SelectClassroomByIdAndIdTeacher(tx DB, id IdClassroom, idTeacher IdTeacher) (item Classroom, found bool, err error)
- 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 IdClassroomSet
- type IdStudent
- type IdStudentSet
- type IdTeacher
- type IdTeacherSet
- type MatiereTag
- type Student
- type Students
- type Teacher
- 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 InsertClassroomCode ¶
func InsertClassroomCode(db DB, item ClassroomCode) error
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.
Types ¶
type Classroom ¶
type Classroom struct { Id IdClassroom `json:"id"` IdTeacher IdTeacher `json:"id_teacher" gomacro-sql-on-delete:"CASCADE"` Name string `json:"name"` MaxRankThreshold int // for the last guilde, default to 40000 }
Classroom is one group of student controlled by a teacher gomacro:SQL ADD UNIQUE(Id, IdTeacher)
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'.
func SelectClassroomByIdAndIdTeacher ¶
func SelectClassroomByIdAndIdTeacher(tx DB, id IdClassroom, idTeacher IdTeacher) (item Classroom, found bool, err error)
SelectClassroomByIdAndIdTeacher return zero or one item, thanks to a UNIQUE SQL constraint.
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'.
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 SelectClassroomsByIdTeachers ¶
func SelectClassroomsByIdTeachers(tx DB, idTeachers_ ...IdTeacher) (Classrooms, error)
func (Classrooms) ByIdTeacher ¶
func (items Classrooms) ByIdTeacher() map[IdTeacher]Classrooms
ByIdTeacher returns a map with 'IdTeacher' as keys.
func (Classrooms) IDs ¶
func (m Classrooms) IDs() []IdClassroom
func (Classrooms) IdTeachers ¶
func (items Classrooms) IdTeachers() []IdTeacher
IdTeachers returns the list of ids of IdTeacher contained in this table. They are not garanteed to be distinct.
type DB ¶
type DB interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *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 (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 DeleteClassroomsByIdTeachers ¶
func DeleteClassroomsByIdTeachers(tx DB, idTeachers_ ...IdTeacher) ([]IdClassroom, error)
func ScanIdClassroomArray ¶
func ScanIdClassroomArray(rs *sql.Rows) ([]IdClassroom, error)
ScanIdClassroomArray scans the result of a query returning a list of ID's.
type IdClassroomSet ¶
type IdClassroomSet map[IdClassroom]bool
func NewIdClassroomSetFrom ¶
func NewIdClassroomSetFrom(ids []IdClassroom) IdClassroomSet
func (IdClassroomSet) Add ¶
func (s IdClassroomSet) Add(id IdClassroom)
func (IdClassroomSet) Has ¶
func (s IdClassroomSet) Has(id IdClassroom) bool
func (IdClassroomSet) Keys ¶
func (s IdClassroomSet) Keys() []IdClassroom
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 IdStudentSet ¶
func NewIdStudentSetFrom ¶
func NewIdStudentSetFrom(ids []IdStudent) IdStudentSet
func (IdStudentSet) Add ¶
func (s IdStudentSet) Add(id IdStudent)
func (IdStudentSet) Has ¶
func (s IdStudentSet) Has(id IdStudent) bool
func (IdStudentSet) Keys ¶
func (s IdStudentSet) Keys() []IdStudent
type IdTeacher ¶
type IdTeacher int64
func DeleteTeachersByIDs ¶
Deletes the Teacher in the database and returns the ids.
type IdTeacherSet ¶
func NewIdTeacherSetFrom ¶
func NewIdTeacherSetFrom(ids []IdTeacher) IdTeacherSet
func (IdTeacherSet) Add ¶
func (s IdTeacherSet) Add(id IdTeacher)
func (IdTeacherSet) Has ¶
func (s IdTeacherSet) Has(id IdTeacher) bool
func (IdTeacherSet) Keys ¶
func (s IdTeacherSet) Keys() []IdTeacher
type MatiereTag ¶
type MatiereTag string
MatiereTag are special tags to indicate the topic of a question/exercice
const ( Autre MatiereTag = "AUTRE" Mathematiques MatiereTag = "MATHS" Francais MatiereTag = "FRANCAIS" HistoireGeo MatiereTag = "HISTOIRE-GEO" Espagnol MatiereTag = "ESPAGNOL" Italien MatiereTag = "ITALIEN" Allemand MatiereTag = "ALLEMAND" Anglais MatiereTag = "ANGLAIS" SES MatiereTag = "SES" PhysiqueChimie MatiereTag = "PHYSIQUE" SVT MatiereTag = "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 Teachers ¶
func SelectAllTeachers ¶
SelectAll returns all the items in the teachers table.
func SelectTeachers ¶
SelectTeachers returns the entry matching the given 'ids'.