frontend: display MCQ in interface
This commit is contained in:
parent
6903c91df2
commit
d6012dfffb
3 changed files with 81 additions and 16 deletions
|
|
@ -17,22 +17,29 @@ type myTeamFile struct {
|
|||
type myTeamHint struct {
|
||||
HintId int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content *string `json:"content"`
|
||||
File *string `json:"file"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
File *string `json:"file,omitempty"`
|
||||
Cost int64 `json:"cost"`
|
||||
}
|
||||
type myTeamMCQ struct {
|
||||
Title string `json:"title"`
|
||||
Kind string `json:"kind"`
|
||||
Choices map[int64]string `json:"choices,omitempty"`
|
||||
Solved *time.Time `json:"solved,omitempty"`
|
||||
}
|
||||
type myTeamExercice struct {
|
||||
ThemeId int `json:"theme_id"`
|
||||
Statement string `json:"statement"`
|
||||
Hints []myTeamHint `json:"hints"`
|
||||
Hints []myTeamHint `json:"hints,omitempty"`
|
||||
Gain float64 `json:"gain"`
|
||||
Files []myTeamFile `json:"files"`
|
||||
Keys []string `json:"keys"`
|
||||
SolvedMat []bool `json:"solved_matrix"`
|
||||
SolvedTime time.Time `json:"solved_time"`
|
||||
SolvedRank int64 `json:"solved_rank"`
|
||||
Tries int64 `json:"tries"`
|
||||
VideoURI string `json:"video_uri"`
|
||||
Files []myTeamFile `json:"files,omitempty"`
|
||||
Keys []string `json:"keys,omitempty"`
|
||||
SolvedMat []bool `json:"solved_matrix,omitempty"`
|
||||
MCQs []myTeamMCQ `json:"mcqs,omitempty"`
|
||||
SolvedTime time.Time `json:"solved_time,omitempty"`
|
||||
SolvedRank int64 `json:"solved_rank,omitempty"`
|
||||
Tries int64 `json:"tries,omitempty"`
|
||||
VideoURI string `json:"video_uri,omitempty"`
|
||||
}
|
||||
type myTeam struct {
|
||||
Id int64 `json:"team_id"`
|
||||
|
|
@ -121,6 +128,22 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Expose exercice MCQs
|
||||
|
||||
exercice.MCQs = []myTeamMCQ{}
|
||||
|
||||
if mcqs, err := e.GetMCQ(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
for _, mcq := range mcqs {
|
||||
choices := map[int64]string{}
|
||||
for _, e := range mcq.Entries {
|
||||
choices[e.Id] = e.Label
|
||||
}
|
||||
exercice.MCQs = append(exercice.MCQs, myTeamMCQ{mcq.Title, mcq.Kind, choices, t.HasPartiallyRespond(mcq)})
|
||||
}
|
||||
}
|
||||
|
||||
// Expose exercice keys
|
||||
|
||||
exercice.Keys = []string{}
|
||||
|
|
|
|||
Reference in a new issue