reviews

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IdReviewArrayToPQ

func IdReviewArrayToPQ(ids []IdReview) pq.Int64Array

func InsertManyReviewExercices

func InsertManyReviewExercices(tx *sql.Tx, items ...ReviewExercice) error

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

func InsertManyReviewParticipations

func InsertManyReviewParticipations(tx *sql.Tx, items ...ReviewParticipation) error

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

func InsertManyReviewQuestions

func InsertManyReviewQuestions(tx *sql.Tx, items ...ReviewQuestion) error

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

func InsertManyReviewSheets

func InsertManyReviewSheets(tx *sql.Tx, items ...ReviewSheet) error

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

func InsertManyReviewTrivials

func InsertManyReviewTrivials(tx *sql.Tx, items ...ReviewTrivial) error

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

func InsertReviewExercice

func InsertReviewExercice(db DB, item ReviewExercice) error

func InsertReviewParticipation

func InsertReviewParticipation(db DB, item ReviewParticipation) error

func InsertReviewQuestion

func InsertReviewQuestion(db DB, item ReviewQuestion) error

func InsertReviewSheet

func InsertReviewSheet(db DB, item ReviewSheet) error

func InsertReviewTrivial

func InsertReviewTrivial(db DB, item ReviewTrivial) error

func LoadTargets

func LoadTargets(db DB) (map[IdReview]Target, error)

LoadTargets load all the targets associated to the reviews

func UpdateParticipation

func UpdateParticipation(db *sql.DB, part ReviewParticipation) error

UpdateParticipation update the fields given by [part]

Types

type Approval

type Approval uint8

Approval is the evaluation of one teacher about the review

const (
	// The teacher does not pronounce itself
	Neutral Approval = iota
	InFavor
	Opposed
)

type Comment

type Comment struct {
	Time    time.Time
	Message string
}

Comment stores the content of a comment in a review

type Comments

type Comments []Comment

func (*Comments) Scan

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

func (Comments) Value

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

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 IdReview

type IdReview int64

func DeleteReviewsByIDs

func DeleteReviewsByIDs(tx DB, ids ...IdReview) ([]IdReview, error)

Deletes the Review in the database and returns the ids.

func ScanIdReviewArray

func ScanIdReviewArray(rs *sql.Rows) ([]IdReview, error)

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

type IdReviewSet

type IdReviewSet map[IdReview]bool

func NewIdReviewSetFrom

func NewIdReviewSetFrom(ids []IdReview) IdReviewSet

func (IdReviewSet) Add

func (s IdReviewSet) Add(id IdReview)

func (IdReviewSet) Has

func (s IdReviewSet) Has(id IdReview) bool

func (IdReviewSet) Keys

func (s IdReviewSet) Keys() []IdReview

type Review

type Review struct {
	Id   IdReview
	Kind ReviewKind
}

Review stores the messages and evaluation about publishing a user created content in the admin account. An implicit invariant is that each Review is mapped to exactly one item from the tables ReviewTrivial, ReviewQuestion, ReviewExercice, ReviewSheet. gomacro:SQL ADD UNIQUE (Id, Kind)

func DeleteReviewById

func DeleteReviewById(tx DB, id IdReview) (Review, error)

Deletes the Review and returns the item

func ScanReview

func ScanReview(row *sql.Row) (Review, error)

func SelectReview

func SelectReview(tx DB, id IdReview) (Review, error)

SelectReview returns the entry matching 'id'.

func SelectReviewByIdAndKind

func SelectReviewByIdAndKind(tx DB, id IdReview, kind ReviewKind) (item Review, found bool, err error)

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

func (Review) Insert

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

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

func (Review) Update

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

Update Review in the database and returns the new version.

type ReviewExercice

type ReviewExercice struct {
	IdReview   IdReview `gomacro-sql-on-delete:"CASCADE"`
	IdExercice editor.IdExercicegroup
	Kind       ReviewKind // used for integrity
}

gomacro:SQL ADD FOREIGN KEY (IdReview, Kind) REFERENCES Review (ID, Kind) ON DELETE CASCADE gomacro:SQL ADD CHECK (Kind = #[ReviewKind.KExercice]) gomacro:SQL ADD UNIQUE (IdExercice) gomacro:SQL ADD UNIQUE (IdReview)

func ScanReviewExercice

func ScanReviewExercice(row *sql.Row) (ReviewExercice, error)

func SelectReviewExerciceByIdExercice

func SelectReviewExerciceByIdExercice(tx DB, idExercice editor.IdExercicegroup) (item ReviewExercice, found bool, err error)

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

func SelectReviewExerciceByIdReview

func SelectReviewExerciceByIdReview(tx DB, idReview IdReview) (item ReviewExercice, found bool, err error)

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

func (ReviewExercice) Delete

func (item ReviewExercice) Delete(tx DB) error

Delete the link ReviewExercice from the database. Only the foreign keys IdReview, IdExercice fields are used in 'item'.

func (ReviewExercice) Insert

func (tr ReviewExercice) Insert(tx *sql.Tx) error

func (ReviewExercice) Load

func (tr ReviewExercice) Load(db DB) (TargetHeader, error)

func (ReviewExercice) MoveToAdmin

func (tr ReviewExercice) MoveToAdmin(db DB, adminID teacher.IdTeacher) error

func (ReviewExercice) Review

func (tr ReviewExercice) Review() IdReview

func (ReviewExercice) WithIdReview

func (tr ReviewExercice) WithIdReview(r IdReview) Target

type ReviewExercices

type ReviewExercices []ReviewExercice

func DeleteReviewExercicesByIdExercices

func DeleteReviewExercicesByIdExercices(tx DB, idExercices_ ...editor.IdExercicegroup) (ReviewExercices, error)

func DeleteReviewExercicesByIdReviews

func DeleteReviewExercicesByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewExercices, error)

func ScanReviewExercices

func ScanReviewExercices(rs *sql.Rows) (ReviewExercices, error)

func SelectAllReviewExercices

func SelectAllReviewExercices(db DB) (ReviewExercices, error)

SelectAll returns all the items in the review_exercices table.

func SelectReviewExercicesByIdExercices

func SelectReviewExercicesByIdExercices(tx DB, idExercices_ ...editor.IdExercicegroup) (ReviewExercices, error)

func SelectReviewExercicesByIdReviews

func SelectReviewExercicesByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewExercices, error)

func (ReviewExercices) ByIdExercice

func (items ReviewExercices) ByIdExercice() map[editor.IdExercicegroup]ReviewExercice

ByIdExercice returns a map with 'IdExercice' as keys.

func (ReviewExercices) ByIdReview

func (items ReviewExercices) ByIdReview() map[IdReview]ReviewExercice

ByIdReview returns a map with 'IdReview' as keys.

func (ReviewExercices) IdExercices

func (items ReviewExercices) IdExercices() []editor.IdExercicegroup

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

func (ReviewExercices) IdReviews

func (items ReviewExercices) IdReviews() []IdReview

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

type ReviewKind

type ReviewKind uint8

ReviewKind is an enum describing the kind of item which may be in a review

const (
	KQuestion ReviewKind = iota // Question
	KExercice                   // Exercice
	KTrivial                    // Isy'Triv
	KSheet                      // Feuille d'exercice
)

func (ReviewKind) String

func (k ReviewKind) String() string

type ReviewParticipation

type ReviewParticipation struct {
	IdReview  IdReview          `gomacro-sql-on-delete:"CASCADE"`
	IdTeacher teacher.IdTeacher `gomacro-sql-on-delete:"CASCADE"`
	Approval  Approval
	Comments  Comments
}

gomacro:SQL ADD UNIQUE (IdReview, IdTeacher)

func ScanReviewParticipation

func ScanReviewParticipation(row *sql.Row) (ReviewParticipation, error)

func SelectReviewParticipationByIdReviewAndIdTeacher

func SelectReviewParticipationByIdReviewAndIdTeacher(tx DB, idReview IdReview, idTeacher teacher.IdTeacher) (item ReviewParticipation, found bool, err error)

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

func (ReviewParticipation) Delete

func (item ReviewParticipation) Delete(tx DB) error

Delete the link ReviewParticipation from the database. Only the foreign keys IdReview, IdTeacher fields are used in 'item'.

type ReviewParticipations

type ReviewParticipations []ReviewParticipation

func DeleteReviewParticipationsByIdReviews

func DeleteReviewParticipationsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewParticipations, error)

func DeleteReviewParticipationsByIdTeachers

func DeleteReviewParticipationsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) (ReviewParticipations, error)

func ScanReviewParticipations

func ScanReviewParticipations(rs *sql.Rows) (ReviewParticipations, error)

func SelectAllReviewParticipations

func SelectAllReviewParticipations(db DB) (ReviewParticipations, error)

SelectAll returns all the items in the review_participations table.

func SelectReviewParticipationsByIdReviews

func SelectReviewParticipationsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewParticipations, error)

func SelectReviewParticipationsByIdTeachers

func SelectReviewParticipationsByIdTeachers(tx DB, idTeachers_ ...teacher.IdTeacher) (ReviewParticipations, error)

func (ReviewParticipations) ByIdReview

func (items ReviewParticipations) ByIdReview() map[IdReview]ReviewParticipations

ByIdReview returns a map with 'IdReview' as keys.

func (ReviewParticipations) ByIdTeacher

ByIdTeacher returns a map with 'IdTeacher' as keys.

func (ReviewParticipations) IdReviews

func (items ReviewParticipations) IdReviews() []IdReview

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

func (ReviewParticipations) IdTeachers

func (items ReviewParticipations) IdTeachers() []teacher.IdTeacher

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

type ReviewQuestion

type ReviewQuestion struct {
	IdReview   IdReview `gomacro-sql-on-delete:"CASCADE"`
	IdQuestion editor.IdQuestiongroup
	Kind       ReviewKind // used for integrity
}

gomacro:SQL ADD FOREIGN KEY (IdReview, Kind) REFERENCES Review (ID, Kind) ON DELETE CASCADE gomacro:SQL ADD CHECK (Kind = #[ReviewKind.KQuestion]) gomacro:SQL ADD UNIQUE (IdQuestion) gomacro:SQL ADD UNIQUE (IdReview)

func ScanReviewQuestion

func ScanReviewQuestion(row *sql.Row) (ReviewQuestion, error)

func SelectReviewQuestionByIdQuestion

func SelectReviewQuestionByIdQuestion(tx DB, idQuestion editor.IdQuestiongroup) (item ReviewQuestion, found bool, err error)

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

func SelectReviewQuestionByIdReview

func SelectReviewQuestionByIdReview(tx DB, idReview IdReview) (item ReviewQuestion, found bool, err error)

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

func (ReviewQuestion) Delete

func (item ReviewQuestion) Delete(tx DB) error

Delete the link ReviewQuestion from the database. Only the foreign keys IdReview, IdQuestion fields are used in 'item'.

func (ReviewQuestion) Insert

func (tr ReviewQuestion) Insert(tx *sql.Tx) error

func (ReviewQuestion) Load

func (tr ReviewQuestion) Load(db DB) (TargetHeader, error)

func (ReviewQuestion) MoveToAdmin

func (tr ReviewQuestion) MoveToAdmin(db DB, adminID teacher.IdTeacher) error

func (ReviewQuestion) Review

func (tr ReviewQuestion) Review() IdReview

func (ReviewQuestion) WithIdReview

func (tr ReviewQuestion) WithIdReview(r IdReview) Target

type ReviewQuestions

type ReviewQuestions []ReviewQuestion

func DeleteReviewQuestionsByIdQuestions

func DeleteReviewQuestionsByIdQuestions(tx DB, idQuestions_ ...editor.IdQuestiongroup) (ReviewQuestions, error)

func DeleteReviewQuestionsByIdReviews

func DeleteReviewQuestionsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewQuestions, error)

func ScanReviewQuestions

func ScanReviewQuestions(rs *sql.Rows) (ReviewQuestions, error)

func SelectAllReviewQuestions

func SelectAllReviewQuestions(db DB) (ReviewQuestions, error)

SelectAll returns all the items in the review_questions table.

func SelectReviewQuestionsByIdQuestions

func SelectReviewQuestionsByIdQuestions(tx DB, idQuestions_ ...editor.IdQuestiongroup) (ReviewQuestions, error)

func SelectReviewQuestionsByIdReviews

func SelectReviewQuestionsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewQuestions, error)

func (ReviewQuestions) ByIdQuestion

func (items ReviewQuestions) ByIdQuestion() map[editor.IdQuestiongroup]ReviewQuestion

ByIdQuestion returns a map with 'IdQuestion' as keys.

func (ReviewQuestions) ByIdReview

func (items ReviewQuestions) ByIdReview() map[IdReview]ReviewQuestion

ByIdReview returns a map with 'IdReview' as keys.

func (ReviewQuestions) IdQuestions

func (items ReviewQuestions) IdQuestions() []editor.IdQuestiongroup

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

func (ReviewQuestions) IdReviews

func (items ReviewQuestions) IdReviews() []IdReview

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

type ReviewSheet

type ReviewSheet struct {
	IdReview IdReview `gomacro-sql-on-delete:"CASCADE"`
	IdSheet  homework.IdSheet
	Kind     ReviewKind // used for integrity
}

gomacro:SQL ADD FOREIGN KEY (IdReview, Kind) REFERENCES Review (ID, Kind) ON DELETE CASCADE gomacro:SQL ADD CHECK (Kind = #[ReviewKind.KSheet]) gomacro:SQL ADD UNIQUE (IdSheet) gomacro:SQL ADD UNIQUE (IdReview)

func ScanReviewSheet

func ScanReviewSheet(row *sql.Row) (ReviewSheet, error)

func SelectReviewSheetByIdReview

func SelectReviewSheetByIdReview(tx DB, idReview IdReview) (item ReviewSheet, found bool, err error)

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

func SelectReviewSheetByIdSheet

func SelectReviewSheetByIdSheet(tx DB, idSheet homework.IdSheet) (item ReviewSheet, found bool, err error)

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

func (ReviewSheet) Delete

func (item ReviewSheet) Delete(tx DB) error

Delete the link ReviewSheet from the database. Only the foreign keys IdReview, IdSheet fields are used in 'item'.

func (ReviewSheet) Insert

func (tr ReviewSheet) Insert(tx *sql.Tx) error

func (ReviewSheet) Load

func (tr ReviewSheet) Load(db DB) (TargetHeader, error)

func (ReviewSheet) MoveToAdmin

func (tr ReviewSheet) MoveToAdmin(db DB, adminID teacher.IdTeacher) error

func (ReviewSheet) Review

func (tr ReviewSheet) Review() IdReview

func (ReviewSheet) WithIdReview

func (tr ReviewSheet) WithIdReview(r IdReview) Target

type ReviewSheets

type ReviewSheets []ReviewSheet

func DeleteReviewSheetsByIdReviews

func DeleteReviewSheetsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewSheets, error)

func DeleteReviewSheetsByIdSheets

func DeleteReviewSheetsByIdSheets(tx DB, idSheets_ ...homework.IdSheet) (ReviewSheets, error)

func ScanReviewSheets

func ScanReviewSheets(rs *sql.Rows) (ReviewSheets, error)

func SelectAllReviewSheets

func SelectAllReviewSheets(db DB) (ReviewSheets, error)

SelectAll returns all the items in the review_sheets table.

func SelectReviewSheetsByIdReviews

func SelectReviewSheetsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewSheets, error)

func SelectReviewSheetsByIdSheets

func SelectReviewSheetsByIdSheets(tx DB, idSheets_ ...homework.IdSheet) (ReviewSheets, error)

func (ReviewSheets) ByIdReview

func (items ReviewSheets) ByIdReview() map[IdReview]ReviewSheet

ByIdReview returns a map with 'IdReview' as keys.

func (ReviewSheets) ByIdSheet

func (items ReviewSheets) ByIdSheet() map[homework.IdSheet]ReviewSheet

ByIdSheet returns a map with 'IdSheet' as keys.

func (ReviewSheets) IdReviews

func (items ReviewSheets) IdReviews() []IdReview

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

func (ReviewSheets) IdSheets

func (items ReviewSheets) IdSheets() []homework.IdSheet

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

type ReviewTrivial

type ReviewTrivial struct {
	IdReview  IdReview `gomacro-sql-on-delete:"CASCADE"`
	IdTrivial trivial.IdTrivial
	Kind      ReviewKind // used for integrity
}

gomacro:SQL ADD FOREIGN KEY (IdReview, Kind) REFERENCES Review (ID, Kind) ON DELETE CASCADE gomacro:SQL ADD CHECK (Kind = #[ReviewKind.KTrivial]) gomacro:SQL ADD UNIQUE (IdTrivial) gomacro:SQL ADD UNIQUE (IdReview)

func ScanReviewTrivial

func ScanReviewTrivial(row *sql.Row) (ReviewTrivial, error)

func SelectReviewTrivialByIdReview

func SelectReviewTrivialByIdReview(tx DB, idReview IdReview) (item ReviewTrivial, found bool, err error)

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

func SelectReviewTrivialByIdTrivial

func SelectReviewTrivialByIdTrivial(tx DB, idTrivial trivial.IdTrivial) (item ReviewTrivial, found bool, err error)

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

func (ReviewTrivial) Delete

func (item ReviewTrivial) Delete(tx DB) error

Delete the link ReviewTrivial from the database. Only the foreign keys IdReview, IdTrivial fields are used in 'item'.

func (ReviewTrivial) Insert

func (tr ReviewTrivial) Insert(tx *sql.Tx) error

func (ReviewTrivial) Load

func (tr ReviewTrivial) Load(db DB) (TargetHeader, error)

func (ReviewTrivial) MoveToAdmin

func (tr ReviewTrivial) MoveToAdmin(db DB, adminID teacher.IdTeacher) error

func (ReviewTrivial) Review

func (tr ReviewTrivial) Review() IdReview

func (ReviewTrivial) WithIdReview

func (tr ReviewTrivial) WithIdReview(r IdReview) Target

type ReviewTrivials

type ReviewTrivials []ReviewTrivial

func DeleteReviewTrivialsByIdReviews

func DeleteReviewTrivialsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewTrivials, error)

func DeleteReviewTrivialsByIdTrivials

func DeleteReviewTrivialsByIdTrivials(tx DB, idTrivials_ ...trivial.IdTrivial) (ReviewTrivials, error)

func ScanReviewTrivials

func ScanReviewTrivials(rs *sql.Rows) (ReviewTrivials, error)

func SelectAllReviewTrivials

func SelectAllReviewTrivials(db DB) (ReviewTrivials, error)

SelectAll returns all the items in the review_trivials table.

func SelectReviewTrivialsByIdReviews

func SelectReviewTrivialsByIdReviews(tx DB, idReviews_ ...IdReview) (ReviewTrivials, error)

func SelectReviewTrivialsByIdTrivials

func SelectReviewTrivialsByIdTrivials(tx DB, idTrivials_ ...trivial.IdTrivial) (ReviewTrivials, error)

func (ReviewTrivials) ByIdReview

func (items ReviewTrivials) ByIdReview() map[IdReview]ReviewTrivial

ByIdReview returns a map with 'IdReview' as keys.

func (ReviewTrivials) ByIdTrivial

func (items ReviewTrivials) ByIdTrivial() map[trivial.IdTrivial]ReviewTrivial

ByIdTrivial returns a map with 'IdTrivial' as keys.

func (ReviewTrivials) IdReviews

func (items ReviewTrivials) IdReviews() []IdReview

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

func (ReviewTrivials) IdTrivials

func (items ReviewTrivials) IdTrivials() []trivial.IdTrivial

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

type Reviews

type Reviews map[IdReview]Review

func ScanReviews

func ScanReviews(rs *sql.Rows) (Reviews, error)

func SelectAllReviews

func SelectAllReviews(db DB) (Reviews, error)

SelectAll returns all the items in the reviews table.

func SelectReviews

func SelectReviews(tx DB, ids ...IdReview) (Reviews, error)

SelectReviews returns the entry matching the given 'ids'.

func (Reviews) IDs

func (m Reviews) IDs() []IdReview

type Target

type Target interface {
	Review() IdReview
	WithIdReview(IdReview) Target

	// Insert inserts the target in the proper table
	Insert(tx *sql.Tx) error

	// Errors should not be wrapped
	Load(db DB) (TargetHeader, error)

	// MoveToAdmin update the targeted item, marking it
	// as Public and belonging to the given [adminID].
	// Errors should not be wrapped
	MoveToAdmin(db DB, adminID teacher.IdTeacher) error
}

func LoadTarget

func LoadTarget(db DB, id IdReview) (Target, error)

LoadTarget load all the target associated to the given review Errors are wrapped with utils.SQLError

type TargetHeader

type TargetHeader struct {
	Title string
	Owner teacher.IdTeacher
}

Jump to

Keyboard shortcuts

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