fixup! sync: Extract function that import flags from importer
This commit is contained in:
parent
a3d473983d
commit
4c7fd839b6
@ -4,9 +4,9 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DisplayAllFlags doesn't respect the predefined constraint existing between flags.
|
// DisplayAllFlags doesn't respect the predefined constraint existing between flags.
|
||||||
@ -19,11 +19,11 @@ type myTeamFile struct {
|
|||||||
Size int64 `json:"size"`
|
Size int64 `json:"size"`
|
||||||
}
|
}
|
||||||
type myTeamHint struct {
|
type myTeamHint struct {
|
||||||
HintId int64 `json:"id"`
|
HintId int64 `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Content string `json:"content,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
File string `json:"file,omitempty"`
|
File string `json:"file,omitempty"`
|
||||||
Cost int64 `json:"cost"`
|
Cost int64 `json:"cost"`
|
||||||
}
|
}
|
||||||
type myTeamFlag struct {
|
type myTeamFlag struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
@ -43,31 +43,31 @@ type myTeamMCQJustifiedChoice struct {
|
|||||||
Justification myTeamFlag `json:"justification,omitempty"`
|
Justification myTeamFlag `json:"justification,omitempty"`
|
||||||
}
|
}
|
||||||
type myTeamMCQ struct {
|
type myTeamMCQ struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Justify bool `json:"justify,omitempty"`
|
Justify bool `json:"justify,omitempty"`
|
||||||
Choices map[int64]interface{} `json:"choices,omitempty"`
|
Choices map[int64]interface{} `json:"choices,omitempty"`
|
||||||
Solved *time.Time `json:"solved,omitempty"`
|
Solved *time.Time `json:"solved,omitempty"`
|
||||||
PSolved *time.Time `json:"part_solved,omitempty"`
|
PSolved *time.Time `json:"part_solved,omitempty"`
|
||||||
Soluce string `json:"soluce,omitempty"`
|
Soluce string `json:"soluce,omitempty"`
|
||||||
}
|
}
|
||||||
type myTeamExercice struct {
|
type myTeamExercice struct {
|
||||||
ThemeId int64 `json:"theme_id"`
|
ThemeId int64 `json:"theme_id"`
|
||||||
Statement string `json:"statement"`
|
Statement string `json:"statement"`
|
||||||
Overview string `json:"overview,omitempty"`
|
Overview string `json:"overview,omitempty"`
|
||||||
Finished string `json:"finished,omitempty"`
|
Finished string `json:"finished,omitempty"`
|
||||||
Hints []myTeamHint `json:"hints,omitempty"`
|
Hints []myTeamHint `json:"hints,omitempty"`
|
||||||
Gain int `json:"gain"`
|
Gain int `json:"gain"`
|
||||||
Files []myTeamFile `json:"files,omitempty"`
|
Files []myTeamFile `json:"files,omitempty"`
|
||||||
Flags map[int64]myTeamFlag `json:"flags,omitempty"`
|
Flags map[int64]myTeamFlag `json:"flags,omitempty"`
|
||||||
MCQs map[int64]myTeamMCQ `json:"mcqs,omitempty"`
|
MCQs map[int64]myTeamMCQ `json:"mcqs,omitempty"`
|
||||||
SolveDist int64 `json:"solve_dist,omitempty"`
|
SolveDist int64 `json:"solve_dist,omitempty"`
|
||||||
SolvedTime *time.Time `json:"solved_time,omitempty"`
|
SolvedTime *time.Time `json:"solved_time,omitempty"`
|
||||||
SolvedRank int64 `json:"solved_rank,omitempty"`
|
SolvedRank int64 `json:"solved_rank,omitempty"`
|
||||||
Tries int64 `json:"tries,omitempty"`
|
Tries int64 `json:"tries,omitempty"`
|
||||||
TotalTries int64 `json:"total_tries,omitempty"`
|
TotalTries int64 `json:"total_tries,omitempty"`
|
||||||
VideoURI string `json:"video_uri,omitempty"`
|
VideoURI string `json:"video_uri,omitempty"`
|
||||||
Issue string `json:"issue,omitempty"`
|
Issue string `json:"issue,omitempty"`
|
||||||
IssueKind string `json:"issuekind,omitempty"`
|
IssueKind string `json:"issuekind,omitempty"`
|
||||||
}
|
}
|
||||||
type myTeam struct {
|
type myTeam struct {
|
||||||
Id int64 `json:"team_id"`
|
Id int64 `json:"team_id"`
|
||||||
@ -251,7 +251,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m := myTeamMCQ{
|
m := myTeamMCQ{
|
||||||
Title: mcq.Title,
|
Title: mcq.Title,
|
||||||
Choices: map[int64]interface{}{},
|
Choices: map[int64]interface{}{},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,8 +273,8 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||||||
|
|
||||||
if m.PSolved != nil || v.Solved != nil {
|
if m.PSolved != nil || v.Solved != nil {
|
||||||
jc := myTeamMCQJustifiedChoice{
|
jc := myTeamMCQJustifiedChoice{
|
||||||
Label: e.Label,
|
Label: e.Label,
|
||||||
Value: v.Solved != nil,
|
Value: v.Solved != nil,
|
||||||
Justification: v,
|
Justification: v,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if t == nil {
|
if t == nil {
|
||||||
h := getHashedFlag([]byte(soluce))
|
h := ComputeHashedFlag([]byte(soluce))
|
||||||
m.Soluce = hex.EncodeToString(h[:])
|
m.Soluce = hex.EncodeToString(h[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user