Utilise a new field to send justifications instead of too complex guessing crap
This commit is contained in:
parent
69a866bbbf
commit
d40922629b
6 changed files with 69 additions and 24 deletions
|
|
@ -19,6 +19,7 @@ import (
|
|||
type ResponsesUpload struct {
|
||||
Keys map[int64]string `json:"flags"`
|
||||
MCQs map[int64]bool `json:"mcqs"`
|
||||
MCQJ map[int64]string `json:"justifications"`
|
||||
}
|
||||
|
||||
func treatSubmission(pathname string, team fic.Team, exercice_id string) {
|
||||
|
|
@ -78,6 +79,25 @@ func treatSubmission(pathname string, team fic.Team, exercice_id string) {
|
|||
return
|
||||
}
|
||||
|
||||
// Handle MCQ justifications: convert to expected keyid
|
||||
for cid, j := range responses.MCQJ {
|
||||
if mcq, choice, err := fic.GetMCQbyChoice(cid); err != nil {
|
||||
log.Println(id, "[ERR] Unable to retrieve mcq from justification:", err)
|
||||
return
|
||||
} else if mcq.IdExercice != exercice.Id {
|
||||
log.Println(id, "[ERR] We retrieve an invalid MCQ: from exercice", mcq.IdExercice, "whereas expected from exercice", exercice.Id)
|
||||
return
|
||||
} else if key, err := mcq.GetJustifiedFlag(exercice, choice); err != nil {
|
||||
log.Println(id, "[ERR] Unable to retrieve mcq justification flag:", err)
|
||||
return
|
||||
} else {
|
||||
if responses.Keys == nil {
|
||||
responses.Keys = map[int64]string{}
|
||||
}
|
||||
responses.Keys[key.Id] = j
|
||||
}
|
||||
}
|
||||
|
||||
// Check given answers
|
||||
solved, err := exercice.CheckResponse(cksum[:], responses.Keys, responses.MCQs, team)
|
||||
if err != nil {
|
||||
|
|
|
|||
Reference in a new issue