Documentation ¶
Overview ¶
Package editor provides the data structures used to create questions and exercices
Index ¶
- func IdExerciceArrayToPQ(ids []IdExercice) pq.Int64Array
- func IdExercicegroupArrayToPQ(ids []IdExercicegroup) pq.Int64Array
- func IdQuestionArrayToPQ(ids []IdQuestion) pq.Int64Array
- func IdQuestiongroupArrayToPQ(ids []IdQuestiongroup) pq.Int64Array
- func InsertExerciceQuestion(db DB, item ExerciceQuestion) error
- func InsertExercicegroupTag(db DB, item ExercicegroupTag) error
- func InsertManyExerciceQuestions(tx *sql.Tx, items ...ExerciceQuestion) error
- func InsertManyExercicegroupTags(tx *sql.Tx, items ...ExercicegroupTag) error
- func InsertManyQuestiongroupTags(tx *sql.Tx, items ...QuestiongroupTag) error
- func InsertQuestiongroupTag(db DB, item QuestiongroupTag) error
- func NormalizeTag(tag string) string
- func SelectExercicegroupByTags(db DB, userID teacher.IdTeacher, pattern Tags) (map[IdExercicegroup]ExercicegroupTags, error)
- func SelectQuestiongroupByTags(db DB, userID teacher.IdTeacher, pattern Tags) (map[IdQuestiongroup]QuestiongroupTags, error)
- func UpdateExerciceQuestionList(tx *sql.Tx, idExercice IdExercice, l ExerciceQuestions) error
- func UpdateExercicegroupTags(tx *sql.Tx, tags Tags, id IdExercicegroup) error
- func UpdateQuestiongroupTags(tx *sql.Tx, tags Tags, id IdQuestiongroup) error
- type Crible
- type DB
- type DifficultyQuery
- type DifficultyTag
- type Exercice
- type ExerciceQuestion
- func ScanExerciceQuestion(row *sql.Row) (ExerciceQuestion, error)
- func SelectExerciceQuestionByIdExerciceAndIndex(tx DB, idExercice IdExercice, index int) (item ExerciceQuestion, found bool, err error)
- func SelectExerciceQuestionByIdQuestion(tx DB, idQuestion IdQuestion) (item ExerciceQuestion, found bool, err error)
- type ExerciceQuestions
- func DeleteExerciceQuestionsByIdExercices(tx DB, idExercices_ ...IdExercice) (ExerciceQuestions, error)
- func DeleteExerciceQuestionsByIdQuestions(tx DB, idQuestions_ ...IdQuestion) (ExerciceQuestions, error)
- func ScanExerciceQuestions(rs *sql.Rows) (ExerciceQuestions, error)
- func SelectAllExerciceQuestions(db DB) (ExerciceQuestions, error)
- func SelectExerciceQuestionsByIdExercices(tx DB, idExercices_ ...IdExercice) (ExerciceQuestions, error)
- func SelectExerciceQuestionsByIdQuestions(tx DB, idQuestions_ ...IdQuestion) (ExerciceQuestions, error)
- func (items ExerciceQuestions) ByIdExercice() map[IdExercice]ExerciceQuestions
- func (items ExerciceQuestions) ByIdQuestion() map[IdQuestion]ExerciceQuestion
- func (l ExerciceQuestions) EnsureOrder()
- func (items ExerciceQuestions) IdExercices() []IdExercice
- func (items ExerciceQuestions) IdQuestions() []IdQuestion
- type Exercicegroup
- type ExercicegroupTag
- type ExercicegroupTags
- func DeleteExercicegroupTagsByIdExercicegroups(tx DB, idExercicegroups_ ...IdExercicegroup) (ExercicegroupTags, error)
- func ScanExercicegroupTags(rs *sql.Rows) (ExercicegroupTags, error)
- func SelectAllExercicegroupTags(db DB) (ExercicegroupTags, error)
- func SelectExercicegroupTagsByIdExercicegroups(tx DB, idExercicegroups_ ...IdExercicegroup) (ExercicegroupTags, error)
- type Exercicegroups
- func ScanExercicegroups(rs *sql.Rows) (Exercicegroups, error)
- func SelectAllExercicegroups(db DB) (Exercicegroups, error)
- func SelectExercicegroups(tx DB, ids ...IdExercicegroup) (Exercicegroups, error)
- func SelectExercicegroupsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) (Exercicegroups, error)
- type Exercices
- type Flow
- type IdExercice
- type IdExerciceSet
- type IdExercicegroup
- type IdExercicegroupSet
- type IdQuestion
- func DeleteQuestionsByIDs(tx DB, ids ...IdQuestion) ([]IdQuestion, error)
- func DeleteQuestionsByIdGroups(tx DB, idGroups_ ...IdQuestiongroup) ([]IdQuestion, error)
- func DeleteQuestionsByNeedExercices(tx DB, needExercices_ ...IdExercice) ([]IdQuestion, error)
- func ScanIdQuestionArray(rs *sql.Rows) ([]IdQuestion, error)
- type IdQuestionSet
- type IdQuestiongroup
- type IdQuestiongroupSet
- type LevelTag
- type OptionalIdExercice
- type OptionalIdQuestiongroup
- type Question
- func DeleteQuestionById(tx DB, id IdQuestion) (Question, error)
- func ScanQuestion(row *sql.Row) (Question, error)
- func SelectQuestion(tx DB, id IdQuestion) (Question, error)
- func SelectQuestionByIdAndNeedExercice(tx DB, id IdQuestion, needExercice OptionalIdExercice) (item Question, found bool, err error)
- type Questiongroup
- type QuestiongroupTag
- type QuestiongroupTags
- func DeleteQuestiongroupTagsByIdQuestiongroups(tx DB, idQuestiongroups_ ...IdQuestiongroup) (QuestiongroupTags, error)
- func ScanQuestiongroupTags(rs *sql.Rows) (QuestiongroupTags, error)
- func SelectAllQuestiongroupTags(db DB) (QuestiongroupTags, error)
- func SelectQuestiongroupTagsByIdQuestiongroups(tx DB, idQuestiongroups_ ...IdQuestiongroup) (QuestiongroupTags, error)
- type Questiongroups
- func ScanQuestiongroups(rs *sql.Rows) (Questiongroups, error)
- func SelectAllQuestiongroups(db DB) (Questiongroups, error)
- func SelectQuestiongroups(tx DB, ids ...IdQuestiongroup) (Questiongroups, error)
- func SelectQuestiongroupsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) (Questiongroups, error)
- type Questions
- func ScanQuestions(rs *sql.Rows) (Questions, error)
- func SelectAllQuestions(db DB) (Questions, error)
- func SelectQuestions(tx DB, ids ...IdQuestion) (Questions, error)
- func SelectQuestionsByIdGroups(tx DB, idGroups_ ...IdQuestiongroup) (Questions, error)
- func SelectQuestionsByNeedExercices(tx DB, needExercices_ ...IdExercice) (Questions, error)
- type Section
- type TagGroup
- type TagIndex
- type TagListSet
- type TagQuery
- type TagSection
- type Tags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IdExerciceArrayToPQ ¶
func IdExerciceArrayToPQ(ids []IdExercice) pq.Int64Array
func IdExercicegroupArrayToPQ ¶
func IdExercicegroupArrayToPQ(ids []IdExercicegroup) pq.Int64Array
func IdQuestionArrayToPQ ¶
func IdQuestionArrayToPQ(ids []IdQuestion) pq.Int64Array
func IdQuestiongroupArrayToPQ ¶
func IdQuestiongroupArrayToPQ(ids []IdQuestiongroup) pq.Int64Array
func InsertExerciceQuestion ¶
func InsertExerciceQuestion(db DB, item ExerciceQuestion) error
func InsertExercicegroupTag ¶
func InsertExercicegroupTag(db DB, item ExercicegroupTag) error
func InsertManyExerciceQuestions ¶
func InsertManyExerciceQuestions(tx *sql.Tx, items ...ExerciceQuestion) error
Insert the links ExerciceQuestion in the database. It is a no-op if 'items' is empty.
func InsertManyExercicegroupTags ¶
func InsertManyExercicegroupTags(tx *sql.Tx, items ...ExercicegroupTag) error
Insert the links ExercicegroupTag in the database. It is a no-op if 'items' is empty.
func InsertManyQuestiongroupTags ¶
func InsertManyQuestiongroupTags(tx *sql.Tx, items ...QuestiongroupTag) error
Insert the links QuestiongroupTag in the database. It is a no-op if 'items' is empty.
func InsertQuestiongroupTag ¶
func InsertQuestiongroupTag(db DB, item QuestiongroupTag) error
func NormalizeTag ¶
NormalizeTag returns `tag` with spaces and accents stripped and in upper case.
func SelectExercicegroupByTags ¶
func SelectExercicegroupByTags(db DB, userID teacher.IdTeacher, pattern Tags) (map[IdExercicegroup]ExercicegroupTags, error)
SelectExercicegroupByTags returns the question groups matching the given query, and available to `userID`, returning their tags. It panics if `pattern` is empty.
func SelectQuestiongroupByTags ¶
func SelectQuestiongroupByTags(db DB, userID teacher.IdTeacher, pattern Tags) (map[IdQuestiongroup]QuestiongroupTags, error)
SelectQuestiongroupByTags returns the question groups matching the given query, and available to `userID`, returning their tags. It panics if `pattern` is empty.
func UpdateExerciceQuestionList ¶
func UpdateExerciceQuestionList(tx *sql.Tx, idExercice IdExercice, l ExerciceQuestions) error
UpdateExerciceQuestionList set the questions for the given exercice, overiding `IdExercice` and `index` fields of the list items. Do NOT commit or rollback
func UpdateExercicegroupTags ¶
func UpdateExercicegroupTags(tx *sql.Tx, tags Tags, id IdExercicegroup) error
UpdateExercicegroupTags enforces proper IdExercicegroup, mutating `tags`. It does NOT commit or rollback.
func UpdateQuestiongroupTags ¶
func UpdateQuestiongroupTags(tx *sql.Tx, tags Tags, id IdQuestiongroup) error
UpdateQuestiongroupTags sets the tags of [id], normalizing and validating [tags] It does NOT commit or rollback.
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 DifficultyQuery ¶
type DifficultyQuery []DifficultyTag
DifficultyQuery is an union of tags. An empty slice means no selection : all variants are accepted.
func (DifficultyQuery) Match ¶
func (dq DifficultyQuery) Match(diff DifficultyTag) bool
Match returns `true` if the query accepts `diff`. Questions with no difficulty always match
func (*DifficultyQuery) Scan ¶
func (s *DifficultyQuery) Scan(src interface{}) error
type DifficultyTag ¶
type DifficultyTag string
DifficultyTag are special question tags used to indicate the difficulty of one question. It is used to select question among question groups
const ( DiffEmpty DifficultyTag = "" Diff1 DifficultyTag = "\u2605" // 1 étoile Diff2 DifficultyTag = "\u2605\u2605" // 2 étoiles Diff3 DifficultyTag = "\u2605\u2605\u2605" // 3 étoiles )
type Exercice ¶
type Exercice struct { Id IdExercice IdGroup IdExercicegroup Subtitle string // subtitle, only shown to the teacher // Parameters are parameters shared by all the questions. // It is used instead of the Question.Parameters field, which is empty Parameters questions.Parameters Difficulty DifficultyTag }
Exercice is the data structure for a full exercice, composed of a list of questions. The questions are linked together by a shared Parameters set, and are to be tried sequentially.
func DeleteExerciceById ¶
func DeleteExerciceById(tx DB, id IdExercice) (Exercice, error)
Deletes the Exercice and returns the item
func SelectExercice ¶
func SelectExercice(tx DB, id IdExercice) (Exercice, error)
SelectExercice returns the entry matching 'id'.
type ExerciceQuestion ¶
type ExerciceQuestion struct { IdExercice IdExercice `json:"id_exercice" gomacro-sql-on-delete:"CASCADE"` IdQuestion IdQuestion `json:"id_question"` Bareme int `json:"bareme"` Index int `json:"-"` }
TODO: check delete question API ExerciceQuestion models an ordered list of questions. All link items should be updated at once to preserve `Index` invariants gomacro:SQL ADD PRIMARY KEY (IdExercice, Index) gomacro:SQL ADD FOREIGN KEY (IdExercice, IdQuestion) REFERENCES Questions (NeedExercice, Id) gomacro:SQL ADD UNIQUE (IdQuestion)
func ScanExerciceQuestion ¶
func ScanExerciceQuestion(row *sql.Row) (ExerciceQuestion, error)
func SelectExerciceQuestionByIdExerciceAndIndex ¶
func SelectExerciceQuestionByIdExerciceAndIndex(tx DB, idExercice IdExercice, index int) (item ExerciceQuestion, found bool, err error)
SelectExerciceQuestionByIdExerciceAndIndex return zero or one item, thanks to a UNIQUE SQL constraint.
func SelectExerciceQuestionByIdQuestion ¶
func SelectExerciceQuestionByIdQuestion(tx DB, idQuestion IdQuestion) (item ExerciceQuestion, found bool, err error)
SelectExerciceQuestionByIdQuestion return zero or one item, thanks to a UNIQUE SQL constraint.
func (ExerciceQuestion) Delete ¶
func (item ExerciceQuestion) Delete(tx DB) error
Delete the link ExerciceQuestion from the database. Only the foreign keys IdExercice, IdQuestion fields are used in 'item'.
type ExerciceQuestions ¶
type ExerciceQuestions []ExerciceQuestion
func DeleteExerciceQuestionsByIdExercices ¶
func DeleteExerciceQuestionsByIdExercices(tx DB, idExercices_ ...IdExercice) (ExerciceQuestions, error)
func DeleteExerciceQuestionsByIdQuestions ¶
func DeleteExerciceQuestionsByIdQuestions(tx DB, idQuestions_ ...IdQuestion) (ExerciceQuestions, error)
func ScanExerciceQuestions ¶
func ScanExerciceQuestions(rs *sql.Rows) (ExerciceQuestions, error)
func SelectAllExerciceQuestions ¶
func SelectAllExerciceQuestions(db DB) (ExerciceQuestions, error)
SelectAll returns all the items in the exercice_questions table.
func SelectExerciceQuestionsByIdExercices ¶
func SelectExerciceQuestionsByIdExercices(tx DB, idExercices_ ...IdExercice) (ExerciceQuestions, error)
func SelectExerciceQuestionsByIdQuestions ¶
func SelectExerciceQuestionsByIdQuestions(tx DB, idQuestions_ ...IdQuestion) (ExerciceQuestions, error)
func (ExerciceQuestions) ByIdExercice ¶
func (items ExerciceQuestions) ByIdExercice() map[IdExercice]ExerciceQuestions
ByIdExercice returns a map with 'IdExercice' as keys.
func (ExerciceQuestions) ByIdQuestion ¶
func (items ExerciceQuestions) ByIdQuestion() map[IdQuestion]ExerciceQuestion
ByIdQuestion returns a map with 'IdQuestion' as keys.
func (ExerciceQuestions) EnsureOrder ¶
func (l ExerciceQuestions) EnsureOrder()
EnsureOrder must be call on the questions of one exercice, to make sure the order in the slice is consistent with the one indicated by `Index`
func (ExerciceQuestions) IdExercices ¶
func (items ExerciceQuestions) IdExercices() []IdExercice
IdExercices returns the list of ids of IdExercice contained in this link table. They are not garanteed to be distinct.
func (ExerciceQuestions) IdQuestions ¶
func (items ExerciceQuestions) IdQuestions() []IdQuestion
IdQuestions returns the list of ids of IdQuestion contained in this link table. They are not garanteed to be distinct.
type Exercicegroup ¶
type Exercicegroup struct { Id IdExercicegroup Title string // title shown to the student Public bool // in practice only true for admins IdTeacher teacher.IdTeacher // IdTeacher is the owner of the exercice }
Exercicegroup groups the variant of the same exercice
func DeleteExercicegroupById ¶
func DeleteExercicegroupById(tx DB, id IdExercicegroup) (Exercicegroup, error)
Deletes the Exercicegroup and returns the item
func ScanExercicegroup ¶
func ScanExercicegroup(row *sql.Row) (Exercicegroup, error)
func SelectExercicegroup ¶
func SelectExercicegroup(tx DB, id IdExercicegroup) (Exercicegroup, error)
SelectExercicegroup returns the entry matching 'id'.
func (Exercicegroup) Insert ¶
func (item Exercicegroup) Insert(tx DB) (out Exercicegroup, err error)
Insert one Exercicegroup in the database and returns the item with id filled.
func (Exercicegroup) IsVisibleBy ¶
func (qu Exercicegroup) IsVisibleBy(userID teacher.IdTeacher) bool
IsVisibleBy returns `true` if the exercice group is public or owned by `userID`
func (Exercicegroup) Update ¶
func (item Exercicegroup) Update(tx DB) (out Exercicegroup, err error)
Update Exercicegroup in the database and returns the new version.
type ExercicegroupTag ¶
type ExercicegroupTag struct { Tag string IdExercicegroup IdExercicegroup `gomacro-sql-on-delete:"CASCADE"` Section Section }
gomacro:SQL ADD UNIQUE(IdExercicegroup, Tag) gomacro:SQL ADD CHECK(Tag = upper(Tag))
add unique constraints : gomacro:SQL CREATE UNIQUE INDEX ExercicegroupTag_level ON ExercicegroupTag (IdExercicegroup) WHERE Section = #[Section.Level] gomacro:SQL CREATE UNIQUE INDEX ExercicegroupTag_chapter ON ExercicegroupTag (IdExercicegroup) WHERE Section = #[Section.Chapter] gomacro:SQL CREATE UNIQUE INDEX ExercicegroupTag_matiere ON ExercicegroupTag (IdExercicegroup) WHERE Section = #[Section.Matiere]
func ScanExercicegroupTag ¶
func ScanExercicegroupTag(row *sql.Row) (ExercicegroupTag, error)
func SelectExercicegroupTagByIdExercicegroupAndTag ¶
func SelectExercicegroupTagByIdExercicegroupAndTag(tx DB, idExercicegroup IdExercicegroup, tag string) (item ExercicegroupTag, found bool, err error)
SelectExercicegroupTagByIdExercicegroupAndTag return zero or one item, thanks to a UNIQUE SQL constraint.
func (ExercicegroupTag) Delete ¶
func (item ExercicegroupTag) Delete(tx DB) error
Delete the link ExercicegroupTag from the database. Only the foreign keys IdExercicegroup fields are used in 'item'.
type ExercicegroupTags ¶
type ExercicegroupTags []ExercicegroupTag
func DeleteExercicegroupTagsByIdExercicegroups ¶
func DeleteExercicegroupTagsByIdExercicegroups(tx DB, idExercicegroups_ ...IdExercicegroup) (ExercicegroupTags, error)
func ScanExercicegroupTags ¶
func ScanExercicegroupTags(rs *sql.Rows) (ExercicegroupTags, error)
func SelectAllExercicegroupTags ¶
func SelectAllExercicegroupTags(db DB) (ExercicegroupTags, error)
SelectAll returns all the items in the exercicegroup_tags table.
func SelectExercicegroupTagsByIdExercicegroups ¶
func SelectExercicegroupTagsByIdExercicegroups(tx DB, idExercicegroups_ ...IdExercicegroup) (ExercicegroupTags, error)
func (ExercicegroupTags) ByIdExercicegroup ¶
func (items ExercicegroupTags) ByIdExercicegroup() map[IdExercicegroup]ExercicegroupTags
ByIdExercicegroup returns a map with 'IdExercicegroup' as keys.
func (ExercicegroupTags) IdExercicegroups ¶
func (items ExercicegroupTags) IdExercicegroups() []IdExercicegroup
IdExercicegroups returns the list of ids of IdExercicegroup contained in this link table. They are not garanteed to be distinct.
func (ExercicegroupTags) Tags ¶
func (exes ExercicegroupTags) Tags() Tags
Tags returns the tags, sorted by section then tag
type Exercicegroups ¶
type Exercicegroups map[IdExercicegroup]Exercicegroup
func ScanExercicegroups ¶
func ScanExercicegroups(rs *sql.Rows) (Exercicegroups, error)
func SelectAllExercicegroups ¶
func SelectAllExercicegroups(db DB) (Exercicegroups, error)
SelectAll returns all the items in the exercicegroups table.
func SelectExercicegroups ¶
func SelectExercicegroups(tx DB, ids ...IdExercicegroup) (Exercicegroups, error)
SelectExercicegroups returns the entry matching the given 'ids'.
func SelectExercicegroupsByIdTeachers ¶
func SelectExercicegroupsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) (Exercicegroups, error)
func (Exercicegroups) ByIdTeacher ¶
func (items Exercicegroups) ByIdTeacher() map[teacher.IdTeacher]Exercicegroups
ByIdTeacher returns a map with 'IdTeacher' as keys.
func (Exercicegroups) IDs ¶
func (m Exercicegroups) IDs() []IdExercicegroup
func (Exercicegroups) IdTeachers ¶
func (items Exercicegroups) IdTeachers() []teacher.IdTeacher
IdTeachers returns the list of ids of IdTeacher contained in this table. They are not garanteed to be distinct.
func (Exercicegroups) RestrictVisible ¶
func (qus Exercicegroups) RestrictVisible(userID teacher.IdTeacher)
RestrictVisible remove the questions not visible by `userID`
type Exercices ¶
type Exercices map[IdExercice]Exercice
func SelectAllExercices ¶
SelectAll returns all the items in the exercices table.
func SelectExercices ¶
func SelectExercices(tx DB, ids ...IdExercice) (Exercices, error)
SelectExercices returns the entry matching the given 'ids'.
func SelectExercicesByIdGroups ¶
func SelectExercicesByIdGroups(tx DB, idGroups_ ...IdExercicegroup) (Exercices, error)
func (Exercices) ByGroup ¶
func (qus Exercices) ByGroup() map[IdExercicegroup][]Exercice
func (Exercices) ByIdGroup ¶
func (items Exercices) ByIdGroup() map[IdExercicegroup]Exercices
ByIdGroup returns a map with 'IdGroup' as keys.
func (Exercices) IDs ¶
func (m Exercices) IDs() []IdExercice
func (Exercices) IdGroups ¶
func (items Exercices) IdGroups() []IdExercicegroup
IdGroups returns the list of ids of IdGroup contained in this table. They are not garanteed to be distinct.
type IdExercice ¶
type IdExercice int64
func DeleteExercicesByIDs ¶
func DeleteExercicesByIDs(tx DB, ids ...IdExercice) ([]IdExercice, error)
Deletes the Exercice in the database and returns the ids.
func DeleteExercicesByIdGroups ¶
func DeleteExercicesByIdGroups(tx DB, idGroups_ ...IdExercicegroup) ([]IdExercice, error)
func ScanIdExerciceArray ¶
func ScanIdExerciceArray(rs *sql.Rows) ([]IdExercice, error)
ScanIdExerciceArray scans the result of a query returning a list of ID's.
func (IdExercice) AsOptional ¶
func (id IdExercice) AsOptional() OptionalIdExercice
type IdExerciceSet ¶
type IdExerciceSet map[IdExercice]bool
func NewIdExerciceSetFrom ¶
func NewIdExerciceSetFrom(ids []IdExercice) IdExerciceSet
func (IdExerciceSet) Add ¶
func (s IdExerciceSet) Add(id IdExercice)
func (IdExerciceSet) Has ¶
func (s IdExerciceSet) Has(id IdExercice) bool
func (IdExerciceSet) Keys ¶
func (s IdExerciceSet) Keys() []IdExercice
type IdExercicegroup ¶
type IdExercicegroup int64
func DeleteExercicegroupsByIDs ¶
func DeleteExercicegroupsByIDs(tx DB, ids ...IdExercicegroup) ([]IdExercicegroup, error)
Deletes the Exercicegroup in the database and returns the ids.
func DeleteExercicegroupsByIdTeachers ¶
func DeleteExercicegroupsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) ([]IdExercicegroup, error)
func ScanIdExercicegroupArray ¶
func ScanIdExercicegroupArray(rs *sql.Rows) ([]IdExercicegroup, error)
ScanIdExercicegroupArray scans the result of a query returning a list of ID's.
type IdExercicegroupSet ¶
type IdExercicegroupSet map[IdExercicegroup]bool
func NewIdExercicegroupSetFrom ¶
func NewIdExercicegroupSetFrom(ids []IdExercicegroup) IdExercicegroupSet
func (IdExercicegroupSet) Add ¶
func (s IdExercicegroupSet) Add(id IdExercicegroup)
func (IdExercicegroupSet) Has ¶
func (s IdExercicegroupSet) Has(id IdExercicegroup) bool
func (IdExercicegroupSet) Keys ¶
func (s IdExercicegroupSet) Keys() []IdExercicegroup
type IdQuestion ¶
type IdQuestion int64
func DeleteQuestionsByIDs ¶
func DeleteQuestionsByIDs(tx DB, ids ...IdQuestion) ([]IdQuestion, error)
Deletes the Question in the database and returns the ids.
func DeleteQuestionsByIdGroups ¶
func DeleteQuestionsByIdGroups(tx DB, idGroups_ ...IdQuestiongroup) ([]IdQuestion, error)
func DeleteQuestionsByNeedExercices ¶
func DeleteQuestionsByNeedExercices(tx DB, needExercices_ ...IdExercice) ([]IdQuestion, error)
func ScanIdQuestionArray ¶
func ScanIdQuestionArray(rs *sql.Rows) ([]IdQuestion, error)
ScanIdQuestionArray scans the result of a query returning a list of ID's.
type IdQuestionSet ¶
type IdQuestionSet map[IdQuestion]bool
func NewIdQuestionSetFrom ¶
func NewIdQuestionSetFrom(ids []IdQuestion) IdQuestionSet
func (IdQuestionSet) Add ¶
func (s IdQuestionSet) Add(id IdQuestion)
func (IdQuestionSet) Has ¶
func (s IdQuestionSet) Has(id IdQuestion) bool
func (IdQuestionSet) Keys ¶
func (s IdQuestionSet) Keys() []IdQuestion
type IdQuestiongroup ¶
type IdQuestiongroup int64
func DeleteQuestiongroupsByIDs ¶
func DeleteQuestiongroupsByIDs(tx DB, ids ...IdQuestiongroup) ([]IdQuestiongroup, error)
Deletes the Questiongroup in the database and returns the ids.
func DeleteQuestiongroupsByIdTeachers ¶
func DeleteQuestiongroupsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) ([]IdQuestiongroup, error)
func ScanIdQuestiongroupArray ¶
func ScanIdQuestiongroupArray(rs *sql.Rows) ([]IdQuestiongroup, error)
ScanIdQuestiongroupArray scans the result of a query returning a list of ID's.
func (IdQuestiongroup) AsOptional ¶
func (id IdQuestiongroup) AsOptional() OptionalIdQuestiongroup
type IdQuestiongroupSet ¶
type IdQuestiongroupSet map[IdQuestiongroup]bool
func NewIdQuestiongroupSetFrom ¶
func NewIdQuestiongroupSetFrom(ids []IdQuestiongroup) IdQuestiongroupSet
func (IdQuestiongroupSet) Add ¶
func (s IdQuestiongroupSet) Add(id IdQuestiongroup)
func (IdQuestiongroupSet) Has ¶
func (s IdQuestiongroupSet) Has(id IdQuestiongroup) bool
func (IdQuestiongroupSet) Keys ¶
func (s IdQuestiongroupSet) Keys() []IdQuestiongroup
type LevelTag ¶
type LevelTag string
LevelTag are special question tags used to indicate the level (class) for the question.
type OptionalIdExercice ¶
type OptionalIdExercice struct { Valid bool ID IdExercice }
func (*OptionalIdExercice) Scan ¶
func (s *OptionalIdExercice) Scan(src interface{}) error
type OptionalIdQuestiongroup ¶
type OptionalIdQuestiongroup struct { ID IdQuestiongroup Valid bool }
func (*OptionalIdQuestiongroup) Scan ¶
func (s *OptionalIdQuestiongroup) Scan(src interface{}) error
type Question ¶
type Question struct { Id IdQuestion // only used for question in groups (not in exercices) Subtitle string // used to differentiate questions inside a group Difficulty DifficultyTag // NeedExercice is not null if the question is part // of an exercice and requires its parameters to be // instantiated NeedExercice OptionalIdExercice `gomacro-sql-foreign:"Exercice"` // IdGroup is not null for the standalone questions, accessed by a group IdGroup OptionalIdQuestiongroup `gomacro-sql-foreign:"Questiongroup" gomacro-sql-on-delete:"CASCADE"` Enonce questions.Enonce Parameters questions.Parameters // Correction an optional content describing the expected solution, // to be instantiated with the same parameters as [Enonce] Correction questions.Enonce }
Question is a standalone question version, used for instance in games or as part of a full exercice. gomacro:SQL ADD CHECK(NeedExercice IS NOT NULL OR IdGroup IS NOT NULL) gomacro:SQL ADD UNIQUE(Id, NeedExercice) TODO: add constraint for empty Parameters for questions in exercices
func DeleteQuestionById ¶
func DeleteQuestionById(tx DB, id IdQuestion) (Question, error)
Deletes the Question and returns the item
func SelectQuestion ¶
func SelectQuestion(tx DB, id IdQuestion) (Question, error)
SelectQuestion returns the entry matching 'id'.
func SelectQuestionByIdAndNeedExercice ¶
func SelectQuestionByIdAndNeedExercice(tx DB, id IdQuestion, needExercice OptionalIdExercice) (item Question, found bool, err error)
SelectQuestionByIdAndNeedExercice return zero or one item, thanks to a UNIQUE SQL constraint.
func (Question) Page ¶
func (qu Question) Page() questions.QuestionPage
type Questiongroup ¶
type Questiongroup struct { Id IdQuestiongroup Title string Public bool // in practice only true for admins IdTeacher teacher.IdTeacher }
Questiongroup groups several variant of the same question
func DeleteQuestiongroupById ¶
func DeleteQuestiongroupById(tx DB, id IdQuestiongroup) (Questiongroup, error)
Deletes the Questiongroup and returns the item
func ScanQuestiongroup ¶
func ScanQuestiongroup(row *sql.Row) (Questiongroup, error)
func SelectQuestiongroup ¶
func SelectQuestiongroup(tx DB, id IdQuestiongroup) (Questiongroup, error)
SelectQuestiongroup returns the entry matching 'id'.
func (Questiongroup) Insert ¶
func (item Questiongroup) Insert(tx DB) (out Questiongroup, err error)
Insert one Questiongroup in the database and returns the item with id filled.
func (Questiongroup) IsVisibleBy ¶
func (qu Questiongroup) IsVisibleBy(userID teacher.IdTeacher) bool
IsVisibleBy returns `true` if the question is public or owned by `userID`
func (Questiongroup) Update ¶
func (item Questiongroup) Update(tx DB) (out Questiongroup, err error)
Update Questiongroup in the database and returns the new version.
type QuestiongroupTag ¶
type QuestiongroupTag struct { Tag string IdQuestiongroup IdQuestiongroup `gomacro-sql-on-delete:"CASCADE"` Section Section }
gomacro:SQL ADD UNIQUE(IdQuestiongroup, Tag) gomacro:SQL ADD CHECK(Tag = upper(Tag))
add unique constraints : gomacro:SQL CREATE UNIQUE INDEX QuestiongroupTag_level ON QuestiongroupTag (IdQuestiongroup) WHERE Section = #[Section.Level] gomacro:SQL CREATE UNIQUE INDEX QuestiongroupTag_chapter ON QuestiongroupTag (IdQuestiongroup) WHERE Section = #[Section.Chapter] gomacro:SQL CREATE UNIQUE INDEX QuestiongroupTag_matiere ON QuestiongroupTag (IdQuestiongroup) WHERE Section = #[Section.Matiere]
func ScanQuestiongroupTag ¶
func ScanQuestiongroupTag(row *sql.Row) (QuestiongroupTag, error)
func SelectQuestiongroupTagByIdQuestiongroupAndTag ¶
func SelectQuestiongroupTagByIdQuestiongroupAndTag(tx DB, idQuestiongroup IdQuestiongroup, tag string) (item QuestiongroupTag, found bool, err error)
SelectQuestiongroupTagByIdQuestiongroupAndTag return zero or one item, thanks to a UNIQUE SQL constraint.
func (QuestiongroupTag) Delete ¶
func (item QuestiongroupTag) Delete(tx DB) error
Delete the link QuestiongroupTag from the database. Only the foreign keys IdQuestiongroup fields are used in 'item'.
type QuestiongroupTags ¶
type QuestiongroupTags []QuestiongroupTag
func DeleteQuestiongroupTagsByIdQuestiongroups ¶
func DeleteQuestiongroupTagsByIdQuestiongroups(tx DB, idQuestiongroups_ ...IdQuestiongroup) (QuestiongroupTags, error)
func ScanQuestiongroupTags ¶
func ScanQuestiongroupTags(rs *sql.Rows) (QuestiongroupTags, error)
func SelectAllQuestiongroupTags ¶
func SelectAllQuestiongroupTags(db DB) (QuestiongroupTags, error)
SelectAll returns all the items in the questiongroup_tags table.
func SelectQuestiongroupTagsByIdQuestiongroups ¶
func SelectQuestiongroupTagsByIdQuestiongroups(tx DB, idQuestiongroups_ ...IdQuestiongroup) (QuestiongroupTags, error)
func (QuestiongroupTags) ByIdQuestiongroup ¶
func (items QuestiongroupTags) ByIdQuestiongroup() map[IdQuestiongroup]QuestiongroupTags
ByIdQuestiongroup returns a map with 'IdQuestiongroup' as keys.
func (QuestiongroupTags) IdQuestiongroups ¶
func (items QuestiongroupTags) IdQuestiongroups() []IdQuestiongroup
IdQuestiongroups returns the list of ids of IdQuestiongroup contained in this link table. They are not garanteed to be distinct.
func (QuestiongroupTags) Tags ¶
func (qus QuestiongroupTags) Tags() Tags
Tags returns the tags for the given IdQuestiongroup, sorted by section then tag
type Questiongroups ¶
type Questiongroups map[IdQuestiongroup]Questiongroup
func ScanQuestiongroups ¶
func ScanQuestiongroups(rs *sql.Rows) (Questiongroups, error)
func SelectAllQuestiongroups ¶
func SelectAllQuestiongroups(db DB) (Questiongroups, error)
SelectAll returns all the items in the questiongroups table.
func SelectQuestiongroups ¶
func SelectQuestiongroups(tx DB, ids ...IdQuestiongroup) (Questiongroups, error)
SelectQuestiongroups returns the entry matching the given 'ids'.
func SelectQuestiongroupsByIdTeachers ¶
func SelectQuestiongroupsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) (Questiongroups, error)
func (Questiongroups) ByIdTeacher ¶
func (items Questiongroups) ByIdTeacher() map[teacher.IdTeacher]Questiongroups
ByIdTeacher returns a map with 'IdTeacher' as keys.
func (Questiongroups) IDs ¶
func (m Questiongroups) IDs() []IdQuestiongroup
func (Questiongroups) IdTeachers ¶
func (items Questiongroups) IdTeachers() []teacher.IdTeacher
IdTeachers returns the list of ids of IdTeacher contained in this table. They are not garanteed to be distinct.
func (Questiongroups) RestrictVisible ¶
func (qus Questiongroups) RestrictVisible(userID teacher.IdTeacher)
RestrictVisible remove the questions not visible by `userID`
type Questions ¶
type Questions map[IdQuestion]Question
func SelectAllQuestions ¶
SelectAll returns all the items in the questions table.
func SelectQuestions ¶
func SelectQuestions(tx DB, ids ...IdQuestion) (Questions, error)
SelectQuestions returns the entry matching the given 'ids'.
func SelectQuestionsByIdGroups ¶
func SelectQuestionsByIdGroups(tx DB, idGroups_ ...IdQuestiongroup) (Questions, error)
func SelectQuestionsByNeedExercices ¶
func SelectQuestionsByNeedExercices(tx DB, needExercices_ ...IdExercice) (Questions, error)
func (Questions) ByGroup ¶
func (qus Questions) ByGroup() map[IdQuestiongroup][]Question
func (Questions) IDs ¶
func (m Questions) IDs() []IdQuestion
func (Questions) RestrictNeedExercice ¶
func (qus Questions) RestrictNeedExercice()
RestrictNeedExercice remove the questions marked as requiring an exercice
type Section ¶
type Section uint8
Section defines one kind of tag.
const ( Level Section // Niveau Chapter // Chapitre TrivMath // Triv'Math SubLevel // Filière Matiere // Matière )
type TagGroup ¶
TagGroup groups the tags for one question/exercice, used to resolve the tag hierachy
type TagIndex ¶
type TagIndex struct { Matiere teacher.MatiereTag Level LevelTag Chapter string }
TagIndex summarize the classification induced by tags
type TagListSet ¶
type TagListSet struct {
// contains filtered or unexported fields
}
TagListSet is a map[[]TagSection]bool, where the order in the key list is ignored. Tags should be normalized before using this set.
func NewTagListSet ¶
func NewTagListSet() TagListSet
func (TagListSet) Add ¶
func (tls TagListSet) Add(tags Tags)
func (TagListSet) Has ¶
func (tls TagListSet) Has(tags Tags) bool
func (TagListSet) List ¶
func (tls TagListSet) List() []Tags
List returns the content of the set (in arbitrary order)
type TagQuery ¶
type TagQuery struct { // Union, empty means no criterion Difficulties DifficultyQuery Tags []string }
TagQuery is an intersection of tags, with an optionnal one for the difficulty
type TagSection ¶
type Tags ¶
type Tags []TagSection