ceintures

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NbDomains = Matrices + 1 // gomacro:no-enum
	NbRanks   = Noire + 1    // gomacro:no-enum
)

Variables

This section is empty.

Functions

func IdBeltquestionArrayToPQ

func IdBeltquestionArrayToPQ(ids []IdBeltquestion) pq.Int64Array

func InsertBeltevolution

func InsertBeltevolution(db DB, item Beltevolution) error

func InsertManyBeltevolutions

func InsertManyBeltevolutions(tx *sql.Tx, items ...Beltevolution) error

Insert the links Beltevolution in the database. It is a no-op if 'items' is empty.

Types

type Advance

type Advance [NbDomains]Rank

Advance stores, for each Domain, the rank the student has checked.

func (*Advance) Scan

func (s *Advance) Scan(src interface{}) error

func (Advance) Value

func (s Advance) Value() (driver.Value, error)

type Beltevolution

type Beltevolution struct {
	IdStudent tc.IdStudent
	Level     Level
	Advance   Advance
	Stats     Stats
}

Beltevolution is the evolution of one student in a belt scheme.

gomacro:SQL ADD UNIQUE(IdStudent)

func ScanBeltevolution

func ScanBeltevolution(row *sql.Row) (Beltevolution, error)

func SelectBeltevolutionByIdStudent

func SelectBeltevolutionByIdStudent(tx DB, idStudent teacher.IdStudent) (item Beltevolution, found bool, err error)

SelectBeltevolutionByIdStudent return zero or one item, thanks to a UNIQUE SQL constraint.

func (Beltevolution) Delete

func (item Beltevolution) Delete(tx DB) error

Delete the link Beltevolution from the database. Only the foreign keys IdStudent fields are used in 'item'.

type Beltevolutions

type Beltevolutions []Beltevolution

func DeleteBeltevolutionsByIdStudents

func DeleteBeltevolutionsByIdStudents(tx DB, idStudents_ ...teacher.IdStudent) (Beltevolutions, error)

func ScanBeltevolutions

func ScanBeltevolutions(rs *sql.Rows) (Beltevolutions, error)

func SelectAllBeltevolutions

func SelectAllBeltevolutions(db DB) (Beltevolutions, error)

SelectAll returns all the items in the beltevolutions table.

func SelectBeltevolutionsByIdStudents

func SelectBeltevolutionsByIdStudents(tx DB, idStudents_ ...teacher.IdStudent) (Beltevolutions, error)

func (Beltevolutions) ByIdStudent

func (items Beltevolutions) ByIdStudent() map[teacher.IdStudent]Beltevolution

ByIdStudent returns a map with 'IdStudent' as keys.

func (Beltevolutions) IdStudents

func (items Beltevolutions) IdStudents() []teacher.IdStudent

IdStudents returns the list of ids of IdStudent contained in this link table. They are not garanteed to be distinct.

type Beltquestion

type Beltquestion struct {
	Id IdBeltquestion

	Domain Domain // Location
	Rank   Rank   // Location

	Parameters questions.Parameters
	Enonce     questions.Enonce
	// Correction an optional content describing the expected solution,
	// to be instantiated with the same parameters as [Enonce]
	Correction questions.Enonce

	// Repeat is the number of times the question is proposed,
	// defaulting to 1
	Repeat int
}

Beltquestion is one question, contained in a domain and color.

gomacro:SQL _SELECT KEY(Domain, Rank) gomacro:SQL ADD CHECK(Repeat > 0)

func DeleteBeltquestionById

func DeleteBeltquestionById(tx DB, id IdBeltquestion) (Beltquestion, error)

Deletes the Beltquestion and returns the item

func ScanBeltquestion

func ScanBeltquestion(row *sql.Row) (Beltquestion, error)

func SelectBeltquestion

func SelectBeltquestion(tx DB, id IdBeltquestion) (Beltquestion, error)

SelectBeltquestion returns the entry matching 'id'.

func (Beltquestion) Insert

func (item Beltquestion) Insert(tx DB) (out Beltquestion, err error)

Insert one Beltquestion in the database and returns the item with id filled.

func (Beltquestion) Page

func (Beltquestion) Update

func (item Beltquestion) Update(tx DB) (out Beltquestion, err error)

Update Beltquestion in the database and returns the new version.

type Beltquestions

type Beltquestions map[IdBeltquestion]Beltquestion

func DeleteBeltquestionsByDomainAndRank

func DeleteBeltquestionsByDomainAndRank(tx DB, domain Domain, rank Rank) (item Beltquestions, err error)

DeleteBeltquestionsByDomainAndRank deletes the item matching the given fields, returning the deleted items.

func ScanBeltquestions

func ScanBeltquestions(rs *sql.Rows) (Beltquestions, error)

func SelectAllBeltquestions

func SelectAllBeltquestions(db DB) (Beltquestions, error)

SelectAll returns all the items in the beltquestions table.

func SelectBeltquestions

func SelectBeltquestions(tx DB, ids ...IdBeltquestion) (Beltquestions, error)

SelectBeltquestions returns the entry matching the given 'ids'.

func SelectBeltquestionsByDomainAndRank

func SelectBeltquestionsByDomainAndRank(tx DB, domain Domain, rank Rank) (item Beltquestions, err error)

SelectBeltquestionsByDomainAndRank selects the items matching the given fields.

func (Beltquestions) IDs

func (m Beltquestions) IDs() []IdBeltquestion

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 Domain

type Domain uint8

Domain is a sub topic, like "Calcul littéral", "Calcul mental".

For now, we only support one scheme in maths.

const (
	CalculMentalI  Domain = iota // Calcul mental I
	CalculMentalII               // Calcul mental II
	Puissances                   // Puissances et racines
	Fractions                    // Fractions
	Reduction                    // Réduction
	Factorisation                // Factorisation
	Developpement                // Développement
	IsolerVariable               // Isoler une variable
	Equations                    // Équations
	Inequations                  // Inéquations
	Derivation                   // Dérivation
	Matrices                     // Matrices et systèmes
)

type IdBeltquestion

type IdBeltquestion int64

func DeleteBeltquestionsByIDs

func DeleteBeltquestionsByIDs(tx DB, ids ...IdBeltquestion) ([]IdBeltquestion, error)

Deletes the Beltquestion in the database and returns the ids.

func ScanIdBeltquestionArray

func ScanIdBeltquestionArray(rs *sql.Rows) ([]IdBeltquestion, error)

ScanIdBeltquestionArray scans the result of a query returning a list of ID's.

type IdBeltquestionSet

type IdBeltquestionSet map[IdBeltquestion]bool

func NewIdBeltquestionSetFrom

func NewIdBeltquestionSetFrom(ids []IdBeltquestion) IdBeltquestionSet

func (IdBeltquestionSet) Add

func (IdBeltquestionSet) Has

func (IdBeltquestionSet) Keys

func (s IdBeltquestionSet) Keys() []IdBeltquestion

type Level

type Level uint8
const (
	Seconde   Level = iota // Seconde
	Premiere               // Première
	Terminale              // Terminale
	PostBac                // Post-bac
)

type Rank

type Rank uint8

Rank is the belt color, that is the level of progression in one Domain.

const (
	StartRank Rank = iota // Départ
	Blanche               // Blanche
	Jaune                 // Jaune
	Orange                // Orange
	VerteI                // Verte clair
	VerteII               // Verte foncée
	Bleue                 // Bleue
	Violet                // Violette
	Rouge                 // Rouge
	Marron                // Marron
	Noire                 // Noire
)

type Stat

type Stat struct {
	Success uint16 // number of questions answered with success
	Failure uint16 // number of questions answered with failure
}

func (*Stat) Add

func (s *Stat) Add(other Stat)

type Stats

type Stats [NbDomains][NbRanks]Stat // by domain and rank

func (*Stats) Scan

func (s *Stats) Scan(src interface{}) error

func (Stats) Value

func (s Stats) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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