diff --git a/orm/contest.go b/orm/contest.go index 8d948d45..b7786a1f 100644 --- a/orm/contest.go +++ b/orm/contest.go @@ -33,8 +33,11 @@ type Contest struct { ResetStartTime bool - Questions []*Question - Participants []*Participant `gorm:"many2many:subscriptions"` + Questions []*Question + Participants []*Participant `gorm:"many2many:subscriptions"` + Responses []*Response + StartedResponses []*Response + SavedResponses []*Response prevStartTime time.Time } @@ -87,7 +90,17 @@ func (c *Contest) Read(db *Database, args map[string]string, w http.ResponseWrit id := args["id"] - if err := db._db.Preload("Participants").Preload("Questions").First(&contest, id).Error; err != nil { + if err := db._db. + Preload("Participants"). + Preload("Responses"). + Preload("StartedResponses", func(tx *gorm.DB) *gorm.DB { + return db.DB().Debug().Where("start_time <> ?", time.Time{}) + }). + Preload("SavedResponses", func(tx *gorm.DB) *gorm.DB { + return db.DB().Debug().Where("end_time <> ?", time.Time{}) + }). + Preload("Questions"). + First(&contest, id).Error; err != nil { return nil, err } diff --git a/scripts/export_participants/.gitignore b/scripts/export_participants/.gitignore index afed0735..3ebacd69 100644 --- a/scripts/export_participants/.gitignore +++ b/scripts/export_participants/.gitignore @@ -1 +1,2 @@ *.csv +*.xlsx \ No newline at end of file diff --git a/templates/contests_show.html.tpl b/templates/contests_show.html.tpl index 6e43edf9..9ecc4a71 100644 --- a/templates/contests_show.html.tpl +++ b/templates/contests_show.html.tpl @@ -21,7 +21,12 @@