28 lines
830 B
Go
28 lines
830 B
Go
package file
|
|
|
|
import (
|
|
"git.andreafazzi.eu/andrea/probo/pkg/models"
|
|
"git.andreafazzi.eu/andrea/probo/pkg/store"
|
|
)
|
|
|
|
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),
|
|
}
|
|
},
|
|
},
|
|
)
|
|
|
|
}
|