libfic: Type key is now Label
This commit is contained in:
parent
a1c6eadbe5
commit
9a9d5fcda4
5 changed files with 34 additions and 33 deletions
|
|
@ -214,7 +214,7 @@ func (e Exercice) CheckResponse(resps map[string]string, t Team) (bool, error) {
|
|||
|
||||
valid := true
|
||||
for _, key := range keys {
|
||||
if res, ok := resps[key.Type]; !ok {
|
||||
if res, ok := resps[key.Label]; !ok {
|
||||
valid = false
|
||||
} else if !key.Check(res) {
|
||||
if !PartialValidation || t.HasPartiallySolved(key) == nil {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
type Key struct {
|
||||
Id int64 `json:"id"`
|
||||
IdExercice int64 `json:"idExercice"`
|
||||
Type string `json:"type"`
|
||||
Label string `json:"type"`
|
||||
Checksum []byte `json:"value"`
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ func (e Exercice) GetKeys() ([]Key, error) {
|
|||
var k Key
|
||||
k.IdExercice = e.Id
|
||||
|
||||
if err := rows.Scan(&k.Id, &k.IdExercice, &k.Type, &k.Checksum); err != nil {
|
||||
if err := rows.Scan(&k.Id, &k.IdExercice, &k.Label, &k.Checksum); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
keys = append(keys, k)
|
||||
|
|
@ -58,7 +58,7 @@ func (e Exercice) AddKey(name string, checksum []byte) (Key, error) {
|
|||
}
|
||||
|
||||
func (k Key) Update() (int64, error) {
|
||||
if res, err := DBExec("UPDATE exercice_keys SET id_exercice = ?, type = ?, cksum = ? WHERE id_key = ?", k.IdExercice, k.Type, k.Checksum, k.Id); err != nil {
|
||||
if res, err := DBExec("UPDATE exercice_keys SET id_exercice = ?, type = ?, cksum = ? WHERE id_key = ?", k.IdExercice, k.Label, k.Checksum, k.Id); err != nil {
|
||||
return 0, err
|
||||
} else if nb, err := res.RowsAffected(); err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
|
|
@ -130,9 +130,9 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
} else {
|
||||
for _, k := range keys {
|
||||
if t == nil {
|
||||
exercice.Keys = append(exercice.Keys, fmt.Sprintf("%x", k.Checksum)+k.Type)
|
||||
exercice.Keys = append(exercice.Keys, fmt.Sprintf("%x", k.Checksum)+k.Label)
|
||||
} else {
|
||||
exercice.Keys = append(exercice.Keys, k.Type)
|
||||
exercice.Keys = append(exercice.Keys, k.Label)
|
||||
if PartialValidation {
|
||||
exercice.SolvedMat = append(exercice.SolvedMat, t.HasPartiallySolved(k) != nil)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue