Add some statistical info to contest view
This commit is contained in:
parent
be1cc96af3
commit
62b26cc7b2
3 changed files with 23 additions and 4 deletions
|
@ -35,6 +35,9 @@ type Contest struct {
|
|||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
1
scripts/export_participants/.gitignore
vendored
1
scripts/export_participants/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
*.csv
|
||||
*.xlsx
|
|
@ -21,7 +21,12 @@
|
|||
<dd class="col-sm-9">{{.Data.NumQuestions}}</dd>
|
||||
<dt class="col-sm-3">Numero di risposte per domanda</dt>
|
||||
<dd class="col-sm-9">{{.Data.NumAnswersPerQuestion}}</dd>
|
||||
|
||||
<dt class="col-sm-3">Numero di partecipanti iscritti</dt>
|
||||
<dd class="col-sm-9">{{len .Data.Participants}}</dd>
|
||||
<dt class="col-sm-3">Numero di prove visualizzate</dt>
|
||||
<dd class="col-sm-9">{{len .Data.StartedResponses}}</dd>
|
||||
<dt class="col-sm-3">Numero di prove salvate</dt>
|
||||
<dd class="col-sm-9">{{len .Data.SavedResponses}}</dd>
|
||||
</dl>
|
||||
|
||||
<div class="row">
|
||||
|
|
Loading…
Reference in a new issue