Documentation ¶
Index ¶
- func IdSheetArrayToPQ(ids []IdSheet) pq.Int64Array
- func IdTravailArrayToPQ(ids []IdTravail) pq.Int64Array
- func InsertManySheetTasks(tx *sql.Tx, items ...SheetTask) error
- func InsertManyTravailExceptions(tx *sql.Tx, items ...TravailException) error
- func InsertSheetTask(db DB, item SheetTask) error
- func InsertTravailException(db DB, item TravailException) error
- type DB
- type IdSheet
- func DeleteSheetsByAnonymouss(tx DB, anonymouss_ ...IdTravail) ([]IdSheet, error)
- func DeleteSheetsByIDs(tx DB, ids ...IdSheet) ([]IdSheet, error)
- func DeleteSheetsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) ([]IdSheet, error)
- func LoadMonoquestionSheet(db DB, idMono tasks.IdMonoquestion) (tasks.IdTask, IdSheet, error)
- func LoadRandomMonoquestionSheet(db DB, idMono tasks.IdRandomMonoquestion) (tasks.IdTask, IdSheet, error)
- func ScanIdSheetArray(rs *sql.Rows) ([]IdSheet, error)
- type IdSheetSet
- type IdTravail
- func DeleteTravailsByIDs(tx DB, ids ...IdTravail) ([]IdTravail, error)
- func DeleteTravailsByIdClassrooms(tx DB, idClassrooms_ ...teacher.IdClassroom) ([]IdTravail, error)
- func DeleteTravailsByIdSheets(tx DB, idSheets_ ...IdSheet) ([]IdTravail, error)
- func ScanIdTravailArray(rs *sql.Rows) ([]IdTravail, error)
- type IdTravailSet
- type OptionalIdTravail
- type Sheet
- type SheetTask
- type SheetTasks
- func DeleteSheetTasksByIdSheets(tx DB, idSheets_ ...IdSheet) (SheetTasks, error)
- func DeleteSheetTasksByIdTasks(tx DB, idTasks_ ...tasks.IdTask) (SheetTasks, error)
- func ScanSheetTasks(rs *sql.Rows) (SheetTasks, error)
- func SelectAllSheetTasks(db DB) (SheetTasks, error)
- func SelectSheetTasksByIdSheets(tx DB, idSheets_ ...IdSheet) (SheetTasks, error)
- func SelectSheetTasksByIdTasks(tx DB, idTasks_ ...tasks.IdTask) (SheetTasks, error)
- type Sheets
- func ScanSheets(rs *sql.Rows) (Sheets, error)
- func SelectAllSheets(db DB) (Sheets, error)
- func SelectSheets(tx DB, ids ...IdSheet) (Sheets, error)
- func SelectSheetsByAnonymouss(tx DB, anonymouss_ ...IdTravail) (Sheets, error)
- func SelectSheetsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) (Sheets, error)
- type Time
- type Travail
- type TravailException
- type TravailExceptions
- func DeleteTravailExceptionsByIdStudentAndIdTravail(tx DB, idStudent teacher.IdStudent, idTravail IdTravail) (item TravailExceptions, err error)
- func DeleteTravailExceptionsByIdStudents(tx DB, idStudents_ ...teacher.IdStudent) (TravailExceptions, error)
- func DeleteTravailExceptionsByIdTravails(tx DB, idTravails_ ...IdTravail) (TravailExceptions, error)
- func ScanTravailExceptions(rs *sql.Rows) (TravailExceptions, error)
- func SelectAllTravailExceptions(db DB) (TravailExceptions, error)
- func SelectTravailExceptionsByIdStudentAndIdTravail(tx DB, idStudent teacher.IdStudent, idTravail IdTravail) (item TravailExceptions, err error)
- func SelectTravailExceptionsByIdStudents(tx DB, idStudents_ ...teacher.IdStudent) (TravailExceptions, error)
- func SelectTravailExceptionsByIdTravails(tx DB, idTravails_ ...IdTravail) (TravailExceptions, error)
- type Travails
- func ScanTravails(rs *sql.Rows) (Travails, error)
- func SelectAllTravails(db DB) (Travails, error)
- func SelectTravails(tx DB, ids ...IdTravail) (Travails, error)
- func SelectTravailsByIdClassrooms(tx DB, idClassrooms_ ...teacher.IdClassroom) (Travails, error)
- func SelectTravailsByIdSheets(tx DB, idSheets_ ...IdSheet) (Travails, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IdSheetArrayToPQ ¶
func IdSheetArrayToPQ(ids []IdSheet) pq.Int64Array
func IdTravailArrayToPQ ¶
func IdTravailArrayToPQ(ids []IdTravail) pq.Int64Array
func InsertManySheetTasks ¶
Insert the links SheetTask in the database. It is a no-op if 'items' is empty.
func InsertManyTravailExceptions ¶
func InsertManyTravailExceptions(tx *sql.Tx, items ...TravailException) error
Insert the links TravailException in the database. It is a no-op if 'items' is empty.
func InsertSheetTask ¶
func InsertTravailException ¶
func InsertTravailException(db DB, item TravailException) error
Types ¶
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 IdSheet ¶
type IdSheet int64
func DeleteSheetsByIDs ¶
Deletes the Sheet in the database and returns the ids.
func LoadMonoquestionSheet ¶
type IdSheetSet ¶
func NewIdSheetSetFrom ¶
func NewIdSheetSetFrom(ids []IdSheet) IdSheetSet
func (IdSheetSet) Add ¶
func (s IdSheetSet) Add(id IdSheet)
func (IdSheetSet) Has ¶
func (s IdSheetSet) Has(id IdSheet) bool
func (IdSheetSet) Keys ¶
func (s IdSheetSet) Keys() []IdSheet
type IdTravail ¶
type IdTravail int64
func DeleteTravailsByIDs ¶
Deletes the Travail in the database and returns the ids.
func DeleteTravailsByIdClassrooms ¶
func DeleteTravailsByIdClassrooms(tx DB, idClassrooms_ ...teacher.IdClassroom) ([]IdTravail, error)
func ScanIdTravailArray ¶
ScanIdTravailArray scans the result of a query returning a list of ID's.
func (IdTravail) AsOptional ¶
func (id IdTravail) AsOptional() OptionalIdTravail
type IdTravailSet ¶
func NewIdTravailSetFrom ¶
func NewIdTravailSetFrom(ids []IdTravail) IdTravailSet
func (IdTravailSet) Add ¶
func (s IdTravailSet) Add(id IdTravail)
func (IdTravailSet) Has ¶
func (s IdTravailSet) Has(id IdTravail) bool
func (IdTravailSet) Keys ¶
func (s IdTravailSet) Keys() []IdTravail
type OptionalIdTravail ¶
func (*OptionalIdTravail) Scan ¶
func (s *OptionalIdTravail) Scan(src interface{}) error
type Sheet ¶
type Sheet struct { Id IdSheet Title string // IdTeacher is the creator of the [Sheet] IdTeacher teacher.IdTeacher `gomacro-sql-on-delete:"CASCADE"` Level string // tag to classify by expected level, ignored on anonymous sheets // Anonymous is not null when the sheet is only // link to one [Travail]. // Anonymous [Sheet]s are deleted when the [Travail] is, // and are not shown in the favorites sheets panel. Anonymous OptionalIdTravail `gomacro-sql-on-delete:"CASCADE" gomacro-sql-foreign:"Travail"` Public bool // only true for admin account Matiere teacher.MatiereTag // tag to classify by expected topic, ignored on anonymous sheets }
Sheet is a list of exercices. gomacro:SQL ADD FOREIGN KEY (Id, Anonymous) REFERENCES Travail(IdSheet, Id) ON DELETE CASCADE
func DeleteSheetById ¶
Deletes the Sheet and returns the item
func SelectSheet ¶
SelectSheet returns the entry matching 'id'.
func (Sheet) IsVisibleBy ¶
IsVisibleBy returns `true` if the Sheet is public or owned by `userID`
type SheetTask ¶
type SheetTask struct { IdSheet IdSheet `gomacro-sql-on-delete:"CASCADE"` Index int `json:"-"` // order in the list IdTask tasks.IdTask }
gomacro:SQL ADD PRIMARY KEY (IdSheet, Index) A task may only appear in one sheet gomacro:SQL ADD UNIQUE (IdTask)
func SelectSheetTaskByIdSheetAndIndex ¶
func SelectSheetTaskByIdSheetAndIndex(tx DB, idSheet IdSheet, index int) (item SheetTask, found bool, err error)
SelectSheetTaskByIdSheetAndIndex return zero or one item, thanks to a UNIQUE SQL constraint.
func SelectSheetTaskByIdTask ¶
SelectSheetTaskByIdTask return zero or one item, thanks to a UNIQUE SQL constraint.
type SheetTasks ¶
type SheetTasks []SheetTask
func DeleteSheetTasksByIdSheets ¶
func DeleteSheetTasksByIdSheets(tx DB, idSheets_ ...IdSheet) (SheetTasks, error)
func DeleteSheetTasksByIdTasks ¶
func DeleteSheetTasksByIdTasks(tx DB, idTasks_ ...tasks.IdTask) (SheetTasks, error)
func ScanSheetTasks ¶
func ScanSheetTasks(rs *sql.Rows) (SheetTasks, error)
func SelectAllSheetTasks ¶
func SelectAllSheetTasks(db DB) (SheetTasks, error)
SelectAll returns all the items in the sheet_tasks table.
func SelectSheetTasksByIdSheets ¶
func SelectSheetTasksByIdSheets(tx DB, idSheets_ ...IdSheet) (SheetTasks, error)
func SelectSheetTasksByIdTasks ¶
func SelectSheetTasksByIdTasks(tx DB, idTasks_ ...tasks.IdTask) (SheetTasks, error)
func (SheetTasks) ByIdSheet ¶
func (items SheetTasks) ByIdSheet() map[IdSheet]SheetTasks
ByIdSheet returns a map with 'IdSheet' as keys.
func (SheetTasks) ByIdTask ¶
func (items SheetTasks) ByIdTask() map[tasks.IdTask]SheetTask
ByIdTask returns a map with 'IdTask' as keys.
func (SheetTasks) EnsureOrder ¶
func (l SheetTasks) EnsureOrder()
EnsureOrder enforce the slice order indicated by `Index`
func (SheetTasks) IdSheets ¶
func (items SheetTasks) IdSheets() []IdSheet
IdSheets returns the list of ids of IdSheet contained in this link table. They are not garanteed to be distinct.
func (SheetTasks) IdTasks ¶
func (items SheetTasks) IdTasks() []tasks.IdTask
IdTasks returns the list of ids of IdTask contained in this link table. They are not garanteed to be distinct.
type Sheets ¶
func SelectAllSheets ¶
SelectAll returns all the items in the sheets table.
func SelectSheets ¶
SelectSheets returns the entry matching the given 'ids'.
func (Sheets) ByIdTeacher ¶
ByIdTeacher returns a map with 'IdTeacher' as keys.
func (Sheets) IdTeachers ¶
IdTeachers returns the list of ids of IdTeacher contained in this table. They are not garanteed to be distinct.
func (Sheets) RestrictVisible ¶
RestrictVisible remove the sheets not visible by `userID`
type Travail ¶
type Travail struct { Id IdTravail IdClassroom teacher.IdClassroom `gomacro-sql-on-delete:"CASCADE"` IdSheet IdSheet `gomacro-sql-on-delete:"CASCADE"` // When 'true', the [Sheet] is evaluated, and may only // be done once. // Notation : a question gives point if it has been successfully completed (at least) once. // When 'false' the sheet is always available as free training. Noted bool // If [Noted] is true, // passed the Deadline, the sheet notations may not be modified anymore. // Else, this field is ignored Deadline Time // Pospone the access for students to this work ShowAfter Time }
Travail associates a Sheet to a classroom, with an optional deadline gomacro:SQL ADD UNIQUE(Id, IdSheet)
func DeleteTravailById ¶
Deletes the Travail and returns the item
func SelectTravail ¶
SelectTravail returns the entry matching 'id'.
func SelectTravailByIdAndIdSheet ¶
func SelectTravailByIdAndIdSheet(tx DB, id IdTravail, idSheet IdSheet) (item Travail, found bool, err error)
SelectTravailByIdAndIdSheet return zero or one item, thanks to a UNIQUE SQL constraint.
type TravailException ¶
type TravailException struct { IdStudent teacher.IdStudent `gomacro-sql-on-delete:"CASCADE"` IdTravail IdTravail `gomacro-sql-on-delete:"CASCADE"` // [Deadline] is an optionnal deadline overriding the one // setup in the related [Travail]. Deadline sql.NullTime // [IgnoreForMark] may be set to true to ignore this mark // when displaying the average. IgnoreForMark bool }
TravailException is a link table storing per student settings for a Travail
gomacro:SQL ADD UNIQUE(IdStudent, IdTravail) gomacro:SQL _SELECT KEY(IdStudent, IdTravail)
func ScanTravailException ¶
func ScanTravailException(row *sql.Row) (TravailException, error)
func SelectTravailExceptionByIdStudentAndIdTravail ¶
func SelectTravailExceptionByIdStudentAndIdTravail(tx DB, idStudent teacher.IdStudent, idTravail IdTravail) (item TravailException, found bool, err error)
SelectTravailExceptionByIdStudentAndIdTravail return zero or one item, thanks to a UNIQUE SQL constraint.
func (TravailException) Delete ¶
func (item TravailException) Delete(tx DB) error
Delete the link TravailException from the database. Only the foreign keys IdStudent, IdTravail fields are used in 'item'.
type TravailExceptions ¶
type TravailExceptions []TravailException
func DeleteTravailExceptionsByIdStudentAndIdTravail ¶
func DeleteTravailExceptionsByIdStudentAndIdTravail(tx DB, idStudent teacher.IdStudent, idTravail IdTravail) (item TravailExceptions, err error)
DeleteTravailExceptionsByIdStudentAndIdTravail deletes the item matching the given fields, returning the deleted items.
func DeleteTravailExceptionsByIdStudents ¶
func DeleteTravailExceptionsByIdStudents(tx DB, idStudents_ ...teacher.IdStudent) (TravailExceptions, error)
func DeleteTravailExceptionsByIdTravails ¶
func DeleteTravailExceptionsByIdTravails(tx DB, idTravails_ ...IdTravail) (TravailExceptions, error)
func ScanTravailExceptions ¶
func ScanTravailExceptions(rs *sql.Rows) (TravailExceptions, error)
func SelectAllTravailExceptions ¶
func SelectAllTravailExceptions(db DB) (TravailExceptions, error)
SelectAll returns all the items in the travail_exceptions table.
func SelectTravailExceptionsByIdStudentAndIdTravail ¶
func SelectTravailExceptionsByIdStudentAndIdTravail(tx DB, idStudent teacher.IdStudent, idTravail IdTravail) (item TravailExceptions, err error)
SelectTravailExceptionsByIdStudentAndIdTravail selects the items matching the given fields.
func SelectTravailExceptionsByIdStudents ¶
func SelectTravailExceptionsByIdStudents(tx DB, idStudents_ ...teacher.IdStudent) (TravailExceptions, error)
func SelectTravailExceptionsByIdTravails ¶
func SelectTravailExceptionsByIdTravails(tx DB, idTravails_ ...IdTravail) (TravailExceptions, error)
func (TravailExceptions) ByIdStudent ¶
func (items TravailExceptions) ByIdStudent() map[teacher.IdStudent]TravailExceptions
ByIdStudent returns a map with 'IdStudent' as keys.
func (TravailExceptions) ByIdTravail ¶
func (items TravailExceptions) ByIdTravail() map[IdTravail]TravailExceptions
ByIdTravail returns a map with 'IdTravail' as keys.
func (TravailExceptions) IdStudents ¶
func (items TravailExceptions) IdStudents() []teacher.IdStudent
IdStudents returns the list of ids of IdStudent contained in this link table. They are not garanteed to be distinct.
func (TravailExceptions) IdTravails ¶
func (items TravailExceptions) IdTravails() []IdTravail
IdTravails returns the list of ids of IdTravail contained in this link table. They are not garanteed to be distinct.
type Travails ¶
func SelectAllTravails ¶
SelectAll returns all the items in the travails table.
func SelectTravails ¶
SelectTravails returns the entry matching the given 'ids'.
func SelectTravailsByIdClassrooms ¶
func SelectTravailsByIdClassrooms(tx DB, idClassrooms_ ...teacher.IdClassroom) (Travails, error)
func (Travails) ByIdClassroom ¶
func (items Travails) ByIdClassroom() map[teacher.IdClassroom]Travails
ByIdClassroom returns a map with 'IdClassroom' as keys.
func (Travails) IdClassrooms ¶
func (items Travails) IdClassrooms() []teacher.IdClassroom
IdClassrooms returns the list of ids of IdClassroom contained in this table. They are not garanteed to be distinct.