probo/pkg/store/file/exam.go

29 lines
830 B
Go
Raw Normal View History

2023-11-28 16:19:49 +01:00
package file
import (
2024-02-06 09:03:57 +01:00
"git.andreafazzi.eu/andrea/probo/pkg/models"
"git.andreafazzi.eu/andrea/probo/pkg/store"
2023-11-28 16:19:49 +01:00
)
type ExamFileStore = FileStore[*models.Exam, *store.Store[*models.Exam]]
func NewExamFileStore(config *FileStoreConfig[*models.Exam, *store.ExamStore]) (*ExamFileStore, error) {
return NewFileStore[*models.Exam](config, store.NewStore[*models.Exam]())
}
func NewDefaultExamFileStore() (*ExamFileStore, error) {
return NewExamFileStore(
&FileStoreConfig[*models.Exam, *store.ExamStore]{
FilePathConfig: FilePathConfig{GetDefaultExamsDir(), "exam", ".json"},
IndexDirFunc: DefaultIndexDirFunc[*models.Exam, *store.ExamStore],
CreateEntityFunc: func() *models.Exam {
return &models.Exam{
Participant: &models.Participant{},
Quizzes: make([]*models.Quiz, 0),
}
},
},
)
}