service

package
v0.0.0-...-2f4d8a3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SystemStudentLoginID = "system-student"
	TatoebaWorkbookName  = "tatoeba"
	OrganizationName     = "cocotola"
)
View Source
var (
	ErrQuotaExceeded              = errors.New("quota exceeded")
	QuotaUnitPersitance QuotaUnit = "persitance"
	QuotaUnitMonth      QuotaUnit = "month"
	QuotaUnitDay        QuotaUnit = "day"
	QuotaNameSize       QuotaName = "Size"
	QuotaNameUpdate     QuotaName = "Update"
)
View Source
var ErrAudioNotFound = errors.New("audio not found")
View Source
var ErrProblemAlreadyExists = errors.New("problem already exists")
View Source
var ErrProblemNotFound = errors.New("problem not found")
View Source
var ErrProblemOtherError = errors.New("problem other error")
View Source
var ErrStudyResultNotFound = errors.New("StudyResult not found")
View Source
var ErrWorkbookAlreadyExists = errors.New("workbook already exists")
View Source
var ErrWorkbookNotFound = errors.New("workbook not found")
View Source
var ErrWorkbookPermissionDenied = errors.New("permission denied")

Functions

func GetSystemSpaceID

func GetSystemSpaceID() userD.SpaceID

func GetSystemStudentID

func GetSystemStudentID() userD.AppUserID

func GetTatoebaWorkbookID

func GetTatoebaWorkbookID() domain.WorkbookID

func InitAppProperties

func InitAppProperties(systemSpaceID userD.SpaceID, systemStudentID userD.AppUserID, tatoebaWorkbookID domain.WorkbookID)

func SetSystemSpaceID

func SetSystemSpaceID(propertiesSystemSpaceID userD.SpaceID)

func SetSystemStudentID

func SetSystemStudentID(propertiesSystemStudentID userD.AppUserID)

func SetTatoebaWorkbookID

func SetTatoebaWorkbookID(propertiesTatoebaWorkbookID domain.WorkbookID)

Types

type Audio

type Audio interface {
	GetAudioModel() domain.AudioModel
}

func NewAudio

func NewAudio(audioModel domain.AudioModel) (Audio, error)

type CountAnsweredResult

type CountAnsweredResult struct {
	WorkbookID    uint
	ProblemTypeID uint
	StudyTypeID   uint
	Answered      int
	Mastered      int
}

type CountAnsweredResults

type CountAnsweredResults struct {
	Results []CountAnsweredResult
}

type GuestStudent

type GuestStudent interface {
	domain.StudentModel

	GetDefaultSpace(ctx context.Context) (userS.Space, error)

	FindWorkbooksFromPublicSpace(ctx context.Context, condition domain.WorkbookSearchCondition) (domain.WorkbookSearchResult, error)
}

func NewGuestStudent

func NewGuestStudent(ctx context.Context, pf ProcessorFactory, rf RepositoryFactory, studentModel domain.StudentModel) (GuestStudent, error)

type Problem

type Problem interface {
	domain.ProblemModel
	ProblemFeature
}

func NewProblem

func NewProblem(synthesizerClient SynthesizerClient, problemModel domain.ProblemModel) (Problem, error)

type ProblemAddParameterIterator

type ProblemAddParameterIterator interface {
	Next() (domain.ProblemAddParameter, error)
}

type ProblemAddProcessor

type ProblemAddProcessor interface {
	AddProblem(ctx context.Context, repo RepositoryFactory, operator domain.StudentModel, workbookModel domain.WorkbookModel, param domain.ProblemAddParameter) ([]domain.ProblemID, []domain.ProblemID, []domain.ProblemID, error)
}

type ProblemEvent

type ProblemEvent interface {
	GetOrganizationID() userD.OrganizationID
	GetAppUserID() userD.AppUserID
	GetProblemEventType() ProblemEventType
	GetProblemType() domain.ProblemTypeName
	GetProblemIDs() []domain.ProblemID
}

func NewProblemEvent

func NewProblemEvent(organizationID userD.OrganizationID, appUserID userD.AppUserID, problemEventType ProblemEventType, problemType domain.ProblemTypeName, problemIDs []domain.ProblemID) ProblemEvent

type ProblemEventType

type ProblemEventType int
const ProblemEventTypeAdd ProblemEventType = 1
const ProblemEventTypeRemove ProblemEventType = 3
const ProblemEventTypeUpdate ProblemEventType = 2

type ProblemFeature

type ProblemFeature interface {
}

type ProblemImportProcessor

type ProblemImportProcessor interface {
	CreateCSVReader(ctx context.Context, workbookID domain.WorkbookID, reader io.Reader) (ProblemAddParameterIterator, error)
}

type ProblemMonitor

type ProblemMonitor interface {
	Attach(observer ProblemObserver) error
	Detach(observer ProblemObserver) error
	NotifyObservers(ctx context.Context, event ProblemEvent) error
}

func NewProblemMonitor

func NewProblemMonitor() ProblemMonitor

type ProblemObserver

type ProblemObserver interface {
	Update(ctx context.Context, problemNotification ProblemEvent) error
}

type ProblemQuotaHandler

type ProblemQuotaHandler interface {
	ProblemObserver
}

type ProblemQuotaProcessor

type ProblemQuotaProcessor interface {
	GetUnitForSizeQuota() QuotaUnit

	GetLimitForSizeQuota() int

	GetUnitForUpdateQuota() QuotaUnit

	GetLimitForUpdateQuota() int
}

type ProblemRemoveProcessor

type ProblemRemoveProcessor interface {
	RemoveProblem(ctx context.Context, repo RepositoryFactory, operator domain.StudentModel, id domain.ProblemSelectParameter2) ([]domain.ProblemID, []domain.ProblemID, []domain.ProblemID, error)
}

type ProblemRepository

type ProblemRepository interface {
	// FindProblems searches for problems based on search condition
	FindProblems(ctx context.Context, operator domain.StudentModel, param domain.ProblemSearchCondition) (domain.ProblemSearchResult, error)

	FindAllProblems(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID) (domain.ProblemSearchResult, error)

	FindProblemsByProblemIDs(ctx context.Context, operator domain.StudentModel, param domain.ProblemIDsCondition) (domain.ProblemSearchResult, error)

	FindProblemsByCustomCondition(ctx context.Context, operator domain.StudentModel, condition interface{}) ([]domain.ProblemModel, error)

	FindProblemByID(ctx context.Context, operator domain.StudentModel, id domain.ProblemSelectParameter1) (Problem, error)

	FindProblemIDs(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID) ([]domain.ProblemID, error)

	// AddProblem register a new problem
	AddProblem(ctx context.Context, operator domain.StudentModel, param domain.ProblemAddParameter) (domain.ProblemID, error)

	UpdateProblem(ctx context.Context, operator domain.StudentModel, id domain.ProblemSelectParameter2, param domain.ProblemUpdateParameter) error

	UpdateProblemProperty(ctx context.Context, operator domain.StudentModel, id domain.ProblemSelectParameter2, param domain.ProblemUpdateParameter) error

	RemoveProblem(ctx context.Context, operator domain.StudentModel, id domain.ProblemSelectParameter2) error

	CountProblems(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID) (int, error)
}

type ProblemTypeRepository

type ProblemTypeRepository interface {
	FindAllProblemTypes(ctx context.Context) ([]domain.ProblemType, error)
}

type ProblemWithResults

type ProblemWithResults interface {
	domain.ProblemModel
	GetResults() []bool
	GetLevel() int
}

func NewProblemWithResults

func NewProblemWithResults(problem domain.ProblemModel, results []bool, level int) ProblemWithResults

type ProcessorFactory

type ProcessorFactory interface {
	NewProblemAddProcessor(problemType domain.ProblemTypeName) (ProblemAddProcessor, error)

	NewProblemUpdateProcessor(problemType domain.ProblemTypeName) (ProblemUpdateProcessor, error)

	NewProblemRemoveProcessor(problemType domain.ProblemTypeName) (ProblemRemoveProcessor, error)

	NewProblemImportProcessor(problemType domain.ProblemTypeName) (ProblemImportProcessor, error)

	NewProblemQuotaProcessor(problemType domain.ProblemTypeName) (ProblemQuotaProcessor, error)
}

type QuotaName

type QuotaName string

type QuotaUnit

type QuotaUnit string

type Recordbook

type Recordbook interface {
	GetStudent() Student

	GetWorkbookID() domain.WorkbookID

	GetResults(ctx context.Context) (map[domain.ProblemID]domain.StudyRecord, error)

	GetResultsSortedLevel(ctx context.Context) ([]domain.StudyRecordWithProblemID, error)

	SetResult(ctx context.Context, problemType domain.ProblemTypeName, problemID domain.ProblemID, result, mastered bool) error
}

func NewRecordbook

func NewRecordbook(rf RepositoryFactory, student Student, workbookID domain.WorkbookID, studyType domain.StudyTypeName) (Recordbook, error)

type RecordbookRepository

type RecordbookRepository interface {
	FindStudyRecords(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID, studyType domain.StudyTypeName) (map[domain.ProblemID]domain.StudyRecord, error)

	SetResult(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID, studyType domain.StudyTypeName, problemType domain.ProblemTypeName, problemID domain.ProblemID, studyResult, mastered bool) error

	CountMasteredProblems(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID) (map[domain.StudyTypeName]int, error)
}

type RecordbookSummary

type RecordbookSummary interface {
	GetCompletionRate(ctx context.Context) (map[domain.StudyTypeName]int, error)
}

func NewRecordbookSummary

func NewRecordbookSummary(rf RepositoryFactory, student Student, workbookID domain.WorkbookID) (RecordbookSummary, error)

type RepositoryFactory

type RepositoryFactory interface {
	NewWorkbookRepository(ctx context.Context) WorkbookRepository

	NewProblemRepository(ctx context.Context, problemType domain.ProblemTypeName) (ProblemRepository, error)

	NewProblemTypeRepository(ctx context.Context) ProblemTypeRepository

	NewStudyTypeRepository(ctx context.Context) StudyTypeRepository

	NewStudyRecordRepository(ctx context.Context) StudyRecordRepository

	NewRecordbookRepository(ctx context.Context) RecordbookRepository

	NewUserQuotaRepository(ctx context.Context) UserQuotaRepository

	NewStatRepository(ctx context.Context) StatRepository

	NewStudyStatRepository(ctx context.Context) StudyStatRepository

	NewUserRepositoryFactory(ctx context.Context) (userS.RepositoryFactory, error)

	NewJobRepositoryFactory(ctx context.Context) (jobS.RepositoryFactory, error)
}

type Stat

type Stat interface {
	domain.StatModel
}

func NewStat

func NewStat(statModel domain.StatModel) (Stat, error)

type StatRepository

type StatRepository interface {
	FindStat(ctx context.Context, operatorID userD.AppUserID) (Stat, error)
}

type Student

type Student interface {
	domain.StudentModel

	GetDefaultSpace(ctx context.Context) (userS.Space, error)
	GetPersonalSpace(ctx context.Context) (userS.Space, error)

	FindWorkbooksFromPersonalSpace(ctx context.Context, condition domain.WorkbookSearchCondition) (domain.WorkbookSearchResult, error)

	FindWorkbookByID(ctx context.Context, id domain.WorkbookID) (Workbook, error)

	FindWorkbookByName(ctx context.Context, name string) (Workbook, error)

	AddWorkbookToPersonalSpace(ctx context.Context, parameter domain.WorkbookAddParameter) (domain.WorkbookID, error)

	UpdateWorkbook(ctx context.Context, workbookID domain.WorkbookID, version int, parameter domain.WorkbookUpdateParameter) error

	RemoveWorkbook(ctx context.Context, id domain.WorkbookID, version int) error

	CheckQuota(ctx context.Context, problemType domain.ProblemTypeName, name QuotaName) error

	FindRecordbook(ctx context.Context, workbookID domain.WorkbookID, studyType domain.StudyTypeName) (Recordbook, error)

	FindRecordbookSummary(ctx context.Context, workbookID domain.WorkbookID) (RecordbookSummary, error)

	GetStat(ctx context.Context) (Stat, error)

	FindPreferences(ctx context.Context) (userS.UserPreferences, error)
}

func NewStudent

func NewStudent(ctx context.Context, pf ProcessorFactory, rf RepositoryFactory, studentModel domain.StudentModel) (Student, error)

type StudyEvent

type StudyEvent interface {
	GetOrganizationID() userD.OrganizationID
	GetAppUserID() userD.AppUserID
	GetStudyEventType() StudyEventType
	GetProblemType() domain.ProblemTypeName
	GetStudyType() domain.StudyTypeName
	GetProblemID() domain.ProblemID
}

func NewStudyEvent

func NewStudyEvent(organizationID userD.OrganizationID, appUserID userD.AppUserID, studyEventType StudyEventType, problemType domain.ProblemTypeName, studyType domain.StudyTypeName, problemID domain.ProblemID) StudyEvent

type StudyEventType

type StudyEventType int
const StudyEventTypeAnswer StudyEventType = 1

type StudyMonitor

type StudyMonitor interface {
	Attach(observer StudyObserver) error
	Detach(observer StudyObserver) error
	NotifyObservers(ctx context.Context, event StudyEvent) error
}

func NewStudyMonitor

func NewStudyMonitor() StudyMonitor

type StudyObserver

type StudyObserver interface {
	Update(ctx context.Context, studyNotification StudyEvent) error
}

type StudyRecordRepository

type StudyRecordRepository interface {
	AddRecord(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID, problemType domain.ProblemTypeName, studyType domain.StudyTypeName, problemID domain.ProblemID, mastered bool) error

	CountAnsweredProblems(ctx context.Context, operator userD.SystemOwnerModel, targetUserID userD.AppUserID, targetDate time.Time) (*CountAnsweredResults, error)
}

type StudyStatRepository

type StudyStatRepository interface {
	AggregateResults(ctx context.Context, operator userD.SystemOwnerModel, targetDate time.Time, userID userD.AppUserID) error
	CleanStudyStats(ctx context.Context, operator userD.SystemOwnerModel, expirationDate time.Time) error
}

type StudyTypeRepository

type StudyTypeRepository interface {
	FindAllStudyTypes(ctx context.Context) ([]domain.StudyType, error)
}

type SynthesizerClient

type SynthesizerClient interface {
	Synthesize(ctx context.Context, lang2 domain.Lang2, text string) (Audio, error)

	FindAudioByAudioID(ctx context.Context, audioID domain.AudioID) (Audio, error)
}

type SystemStudent

type SystemStudent interface {
	domain.SystemStudentModel

	FindWorkbookFromSystemSpace(ctx context.Context, name string) (Workbook, error)

	AddWorkbookToSystemSpace(ctx context.Context, parameter domain.WorkbookAddParameter) (domain.WorkbookID, error)
}

func NewSystemStudent

func NewSystemStudent(rf RepositoryFactory, systemStudentModel domain.SystemStudentModel) (SystemStudent, error)

type Transaction

type Transaction interface {
	Do(ctx context.Context, fn func(rf RepositoryFactory) error) error
}

type UserQuotaRepository

type UserQuotaRepository interface {
	IsExceeded(ctx context.Context, organizationID userD.OrganizationID, appUserID userD.AppUserID, name string, unit QuotaUnit, limit int) (bool, error)

	Increment(ctx context.Context, organizationID userD.OrganizationID, appUserID userD.AppUserID, name string, unit QuotaUnit, limit int, count int) (bool, error)
}

type Workbook

type Workbook interface {
	domain.WorkbookModel

	// FindProblems searches for problems based on search condition
	FindProblems(ctx context.Context, operator domain.StudentModel, param domain.ProblemSearchCondition) (domain.ProblemSearchResult, error)

	FindAllProblems(ctx context.Context, operator domain.StudentModel) (domain.ProblemSearchResult, error)

	FindProblemsByProblemIDs(ctx context.Context, operator domain.StudentModel, param domain.ProblemIDsCondition) (domain.ProblemSearchResult, error)

	FindProblemIDs(ctx context.Context, operator domain.StudentModel) ([]domain.ProblemID, error)

	// FindProblems searches for problem based on a problem ID
	FindProblemByID(ctx context.Context, operator domain.StudentModel, problemID domain.ProblemID) (Problem, error)

	AddProblem(ctx context.Context, operator domain.StudentModel, param domain.ProblemAddParameter) ([]domain.ProblemID, []domain.ProblemID, []domain.ProblemID, error)

	UpdateProblem(ctx context.Context, operator domain.StudentModel, id domain.ProblemSelectParameter2, param domain.ProblemUpdateParameter) ([]domain.ProblemID, []domain.ProblemID, []domain.ProblemID, error)

	UpdateProblemProperty(ctx context.Context, operator domain.StudentModel, id domain.ProblemSelectParameter2, param domain.ProblemUpdateParameter) ([]domain.ProblemID, []domain.ProblemID, []domain.ProblemID, error)

	RemoveProblem(ctx context.Context, operator domain.StudentModel, id domain.ProblemSelectParameter2) ([]domain.ProblemID, []domain.ProblemID, []domain.ProblemID, error)

	UpdateWorkbook(ctx context.Context, operator domain.StudentModel, version int, parameter domain.WorkbookUpdateParameter) error

	RemoveWorkbook(ctx context.Context, operator domain.StudentModel, version int) error

	CountProblems(ctx context.Context, operator domain.StudentModel) (int, error)
}

func NewWorkbook

func NewWorkbook(ctx context.Context, rf RepositoryFactory, pf ProcessorFactory, workbookModel domain.WorkbookModel) (Workbook, error)

type WorkbookRepository

type WorkbookRepository interface {
	FindPersonalWorkbooks(ctx context.Context, operator domain.StudentModel, param domain.WorkbookSearchCondition) (domain.WorkbookSearchResult, error)

	FindWorkbookByID(ctx context.Context, operator domain.StudentModel, id domain.WorkbookID) (Workbook, error)

	FindWorkbookByName(ctx context.Context, operator userD.AppUserModel, spaceID userD.SpaceID, name string) (Workbook, error)

	AddWorkbook(ctx context.Context, operator userD.AppUserModel, spaceID userD.SpaceID, param domain.WorkbookAddParameter) (domain.WorkbookID, error)

	UpdateWorkbook(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID, version int, param domain.WorkbookUpdateParameter) error

	RemoveWorkbook(ctx context.Context, operator domain.StudentModel, workbookID domain.WorkbookID, version int) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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