class

package
v0.0.0-...-769062f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class struct {
	ID            string       `json:"_id" bson:"_id"`
	Name          string       `json:"name" bson:"name"`
	Subjects      []*Subject   `json:"subjects" bson:"subjects"`
	Report        *ClassReport `json:"report" bson:"report"` // nil until a report is generated
	CreatedAt     string       `json:"createdAt" bson:"createdAt"`
	LastUpdatedAt string       `json:"lastUpdatedAt" bson:"lastUpdatedAt"`
}

type ClassReport

type ClassReport struct {
	TotalStudents                   int    `json:"totalStudents" bson:"totalStudents"`
	HighestStudentScore             int    `json:"highestStudentScore" bson:"highestStudentScore"`
	HighestStudentScoreAsPercentage string `json:"highestStudentScoreAsPercentage" bson:"highestStudentScoreAsPercentage"`
	LowestStudentScore              int    `json:"lowestStudentScore" bson:"lowestStudentScore"`
	LowestStudentScoreAsPercentage  string `json:"lowestStudentScoreAsPercentage" bson:"lowestStudentScoreAsPercentage"`
	GeneratedAt                     string `json:"generatedAt" bson:"generatedAt"`
}

type ClassRepository

type ClassRepository struct {
	// contains filtered or unexported fields
}

func (*ClassRepository) Class

func (cr *ClassRepository) Class(classID string) (*Class, error)

Class returns information for the class that match the provided classID. Implements Repository.

func (*ClassRepository) Classes

func (cr *ClassRepository) Classes(hasReport *bool) ([]*Class, error)

Classes returns information for all the classes in the database. Implements Repository.

func (*ClassRepository) Create

func (cr *ClassRepository) Create(className string, subjects []*Subject) (string, error)

Create creates a new class in the database. Returns db.ErrorInvalidRequest is the provided class name matches any record in the database. Implements Repository.

func (*ClassRepository) Exists

func (cr *ClassRepository) Exists(classID string) (bool, error)

Exists checks if classID exists. Implements Repository.

func (*ClassRepository) SaveClassReport

func (cr *ClassRepository) SaveClassReport(classID string, report *ClassReport) error

SaveClassReport saves a newly generated class report for the class that match the provided classID. Implements Repository.

type Repository

type Repository interface {
	// Create creates a new class in the database. Returns
	// db.ErrorInvalidRequest is the provided class name matches any record in
	// the database.
	Create(className string, subjects []*Subject) (string, error)
	// Class returns information for the class that match the provided classID.
	Class(classID string) (*Class, error)
	// Classes returns information for all the classes in the database. Set
	// hasReport to filter classes by report.
	Classes(hasReport *bool) ([]*Class, error)
	// Exists checks if classID exists.
	Exists(classID string) (bool, error)
	// SaveClassReport saves a newly generated class report for the class that
	// match the provided classID.
	SaveClassReport(classID string, report *ClassReport) error
}

func NewRepository

func NewRepository(ctx context.Context, db *mongo.Database) (Repository, error)

NewRepository creates a new instance of *ClassRepository.

type Subject

type Subject struct {
	Name     string `json:"name" bson:"name"`
	MaxScore int    `json:"maxScore" bson:"maxScore"`
}

Jump to

Keyboard shortcuts

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