Display exercices when theme is not locked, but not flags
This commit is contained in:
parent
d8462cf58e
commit
375f1da071
1 changed files with 154 additions and 141 deletions
|
@ -116,13 +116,24 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Retrieve themes
|
||||
themes, err := GetThemes()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
mapthemes := map[int64]*Theme{}
|
||||
for _, theme := range themes {
|
||||
mapthemes[theme.Id] = theme
|
||||
}
|
||||
|
||||
// Fill exercices, only if the challenge is started
|
||||
ret.Exercices = map[string]myTeamExercice{}
|
||||
if exos, err := GetDiscountedExercices(); err != nil {
|
||||
return ret, err
|
||||
} else if started {
|
||||
for _, e := range exos {
|
||||
if t == nil || (!e.Disabled && t.HasAccess(e)) {
|
||||
if t == nil || ((!e.Disabled || !mapthemes[e.IdTheme].Locked) && t.HasAccess(e)) {
|
||||
exercice := myTeamExercice{}
|
||||
exercice.Disabled = e.Disabled
|
||||
exercice.WIP = e.WIP
|
||||
|
@ -209,6 +220,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
|
||||
// Expose exercice flags
|
||||
|
||||
if !e.Disabled {
|
||||
justifiedMCQ := map[int]myTeamFlag{}
|
||||
|
||||
if labels, err := e.GetFlagLabels(); err != nil {
|
||||
|
@ -376,6 +388,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
|
||||
// Sort flags by order
|
||||
sort.Sort(ByOrder(exercice.Flags))
|
||||
}
|
||||
|
||||
// Hash table ordered by exercice Id
|
||||
ret.Exercices[fmt.Sprintf("%d", e.Id)] = exercice
|
||||
|
|
Reference in a new issue