Implement label only flag
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2022-01-21 13:06:37 +01:00
parent b98e23d060
commit 01b05aaed0
9 changed files with 311 additions and 11 deletions

View file

@ -31,7 +31,7 @@ type myTeamHint struct {
Cost int64 `json:"cost"`
}
type myTeamFlag struct {
Id int `json:"id"`
Id int `json:"id,omitempty"`
order int8 `json:"order"`
Label string `json:"label"`
Type string `json:"type,omitempty"`
@ -50,6 +50,7 @@ type myTeamFlag struct {
Justify bool `json:"justify,omitempty"`
Choices map[string]interface{} `json:"choices,omitempty"`
ChoicesCost int64 `json:"choices_cost,omitempty"`
Variant string `json:"variant,omitempty"`
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
Step *float64 `json:"step,omitempty"`
@ -142,10 +143,8 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
} else {
exercice.Tries, stime = t.CountTries(e)
exercice.SolvedTime = stime
if exercice.Tries > 0 {
if DisplayMCQBadCount {
exercice.SolveDist = t.LastTryDist(e)
}
if DisplayMCQBadCount && exercice.Tries > 0 {
exercice.SolveDist = t.LastTryDist(e)
}
}
@ -194,6 +193,23 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
justifiedMCQ := map[int]myTeamFlag{}
if labels, err := e.GetFlagLabels(); err != nil {
return nil, err
} else {
for _, l := range labels {
if !DisplayAllFlags && t != nil && !t.CanSeeFlag(l) {
// Dependancy missing, skip the flag for now
continue
}
exercice.Flags = append(exercice.Flags, myTeamFlag{
order: l.Order,
Label: l.Label,
Variant: l.Variant,
})
}
}
if flags, err := e.GetFlagKeys(); err != nil {
return nil, err
} else {
@ -257,7 +273,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
flag.Multiline = k.Multiline
var fl FlagLabel
var fl FlagMCQLabel
if fl, err = k.GetMCQJustification(); err == nil {
k.Label = fl.Label
}