Spaces:
Runtime error
Runtime error
Commit ·
d877823
1
Parent(s): 9c9198b
Deploy files from GitHub repository
Browse files
models/entity/entity.go
CHANGED
|
@@ -214,13 +214,14 @@ type CPQuestionVerdict struct {
|
|
| 214 |
Score float32 `json:"score"`
|
| 215 |
}
|
| 216 |
type ExamEventAnswer struct {
|
| 217 |
-
Id
|
| 218 |
-
AttemptId
|
| 219 |
-
QuestionId
|
| 220 |
-
Answers
|
| 221 |
-
Score
|
| 222 |
-
|
| 223 |
-
|
|
|
|
| 224 |
}
|
| 225 |
|
| 226 |
func (ExamEventAnswer) TableName() string { return "exam_event_answer" }
|
|
@@ -230,8 +231,8 @@ type ExamEventAttempt struct {
|
|
| 230 |
AccountId uuid.UUID `json:"id_account"`
|
| 231 |
EventId uuid.UUID `json:"id_event"`
|
| 232 |
ExamId uuid.UUID `json:"id_exam"`
|
| 233 |
-
Questions *[]Questions `json:"questions"`
|
| 234 |
-
Answers *[]ExamEventAnswer `json:"answers"`
|
| 235 |
Account *Account `gorm:"foreignKey:AccountId"`
|
| 236 |
Event *Events `gorm:"foreignKey:EventId"`
|
| 237 |
Exam *Exam `gorm:"foreignKey:ExamId"`
|
|
|
|
| 214 |
Score float32 `json:"score"`
|
| 215 |
}
|
| 216 |
type ExamEventAnswer struct {
|
| 217 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
|
| 218 |
+
AttemptId uuid.UUID `json:"id_attempt" gorm:"index"` // FK ke ExamEventAttempt
|
| 219 |
+
QuestionId uuid.UUID `json:"id_question" gorm:"index"` // FK ke Questions
|
| 220 |
+
Answers []string `gorm:"type:text[]" json:"answers"`
|
| 221 |
+
Score float32 `json:"score"`
|
| 222 |
+
ExamEventAttempt *ExamEventAttempt `gorm:"foreignKey:AttemptId" json:"-"`
|
| 223 |
+
CreatedAt time.Time `json:"created_at"`
|
| 224 |
+
UpdatedAt time.Time `json:"updated_at"`
|
| 225 |
}
|
| 226 |
|
| 227 |
func (ExamEventAnswer) TableName() string { return "exam_event_answer" }
|
|
|
|
| 231 |
AccountId uuid.UUID `json:"id_account"`
|
| 232 |
EventId uuid.UUID `json:"id_event"`
|
| 233 |
ExamId uuid.UUID `json:"id_exam"`
|
| 234 |
+
Questions *[]Questions `gorm:"-" json:"questions"`
|
| 235 |
+
Answers *[]ExamEventAnswer `gorm:"foreignKey:AttemptId;references:Id" json:"answers"`
|
| 236 |
Account *Account `gorm:"foreignKey:AccountId"`
|
| 237 |
Event *Events `gorm:"foreignKey:EventId"`
|
| 238 |
Exam *Exam `gorm:"foreignKey:ExamId"`
|
repositories/exam_event_attempt_repository.go
CHANGED
|
@@ -39,6 +39,7 @@ func (r *examEventAttemptRepository) GetByExamEvent(ctx context.Context, eventId
|
|
| 39 |
|
| 40 |
err := r.db.WithContext(ctx).
|
| 41 |
Preload("Questions").
|
|
|
|
| 42 |
Where("id_event = ?", eventId).
|
| 43 |
Where("id_exam = ?", examId).
|
| 44 |
Where("id_account = ?", accountId).
|
|
|
|
| 39 |
|
| 40 |
err := r.db.WithContext(ctx).
|
| 41 |
Preload("Questions").
|
| 42 |
+
Preload("Answers").
|
| 43 |
Where("id_event = ?", eventId).
|
| 44 |
Where("id_exam = ?", examId).
|
| 45 |
Where("id_account = ?", accountId).
|