fixup! sync: Extract function that import flags from importer

This commit is contained in:
nemunaire 2019-07-10 16:58:20 +02:00
parent a3d473983d
commit 4c7fd839b6

View File

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