Documentation
¶
Overview ¶
Package events implements an event system to reward student progression across the whole app.
See https://docs.google.com/spreadsheets/d/1nY7zKsZ6JjW51QDSbt7OgaVSqzL-UoBHu6Qp6C3P7XQ
Index ¶
Constants ¶
const NbEvents = 11
Variables ¶
This section is empty.
Functions ¶
func InsertEvent ¶
Types ¶
type Advance ¶
type Advance []dayEvents // sorted by day
Advance is the stored list of events, for one student. Generally speaking, its features are dynamic : see the various access methods
func NewAdvance ¶
func (Advance) Stats ¶
func (adv Advance) Stats(maxRankThreshold int) StudentAdvance
Stats aggregate the events and compute the associated rank.
The rank is computed using [maxRankThreshold], the amount of points required to access the last rank, and a fixed progression scale :
| Rank | 0 | 1 | 2 | 3 | 4 | 5 | 6 | Ratio (%) | 0 | 5 | 15 | 30 | 50 | 73 | 100
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 Event ¶
type EventK ¶
type EventK int16
const ( E_IsyTriv_Create EventK = iota // Créer une partie d'IsyTriv E_IsyTriv_Streak3 // Réussir trois questions IsyTriv d'affilée E_IsyTriv_Win // Remporter une partie IsyTriv E_Homework_TaskDone // Terminer un exercice E_Homework_TravailDone // Terminer une feuille d'exercices E_All_QuestionRight // Répondre correctement à une question E_All_QuestionWrong // Répondre incorrectement à une question E_Misc_SetPlaylist // Modifier sa playlist // these events are computed from the others and // not store in the DB, but are displayed like regular events E_ConnectStreak3 // Se connecter 3 jours de suite E_ConnectStreak7 // Se connecter 7 jours de suite E_ConnectStreak30 // Se connecter 30 jours de suite )
type EventNotification ¶
type EventNotification struct { Events []EventK // the events (often with length 1) Points int // the number of points earned }
func RegisterEvents ¶
func RegisterEvents(db *sql.DB, idStudent teacher.IdStudent, events ...EventK) (EventNotification, error)
RegisterEvents stores the given events for the given student at the present time.
It returns the number of points earned by the student.
func (*EventNotification) HideIfNoPoints ¶
func (en *EventNotification) HideIfNoPoints()
type Events ¶
type Events []Event
func SelectAllEvents ¶
SelectAll returns all the items in the events table.
func (Events) ByIdStudent ¶
ByIdStudent returns a map with 'IdStudent' as keys.
func (Events) IdStudents ¶
IdStudents returns the list of ids of IdStudent contained in this link table. They are not garanteed to be distinct.