-
Notifications
You must be signed in to change notification settings - Fork 0
/
cockroachdb-schema.go
88 lines (74 loc) · 1.55 KB
/
cockroachdb-schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package testparts
import (
"time"
"gorm.io/datatypes"
"gorm.io/gorm"
)
// ----- Preferences -----
type GromPreference struct {
gorm.Model
Key string `gorm:"uniqueIndex"`
Value string
}
// ----- Classes -----
type GormClass struct {
gorm.Model
Subject string `gorm:"uniqueIndex:index:idx_class"`
Sections []GormClassSection
Tests []GormTest
}
type GormClassSection struct {
gorm.Model
Section string `gorm:"uniqueIndex:index:idx_section"`
GormClassID uint `gorm:"uniqueIndex:index:idx_section"`
Students []GormStudent
}
type GormStudent struct {
gorm.Model
FamilyName string
GivenName string
GormClassSectionID uint
}
// ----- Tests -----
type GormTest struct {
gorm.Model
Title string `gorm:"index:idx_test"`
Length uint
MinQuestions uint
GormClassID uint
Sessions []GormTestSession
Attempts []GormTestAttempt
Questions []GormQuestion
}
type GormQuestion struct {
gorm.Model
Required bool
Question string
Points uint
GormTestID uint
Choices []GormQuestionChoice
}
type GormQuestionChoice struct {
gorm.Model
GormQuestionID uint
Choice string
Feedback string
Answer bool
}
type GormTestAttempt struct {
gorm.Model
GormStudentID uint
GormTestID uint
Score float64
AttemptStart time.Time
AttemptEnd time.Time
Answers datatypes.JSON
}
type GormTestSession struct {
gorm.Model
GormTestID uint
GormClassSectionID uint
QuestionTime time.Duration
StartDateTime time.Time
EndDateTime time.Time
}