admin: sync mcq/ucq
This commit is contained in:
parent
d6012dfffb
commit
b079f7891c
5 changed files with 100 additions and 2 deletions
|
|
@ -119,11 +119,21 @@ func (n MCQ_entry) Delete() (int64, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (e Exercice) WipeMCQs() (int64, error) {
|
||||
if res, err := DBExec("DELETE FROM exercice_mcq, mcq_found, mcq_entries USING exercice_mcq NATURAL JOIN mcq_entries NATURAL JOIN mcq_found WHERE exercice_mcq.id_exercice = ?", e.Id); err != nil {
|
||||
return 0, err
|
||||
} else if nb, err := res.RowsAffected(); err != nil {
|
||||
return 0, err
|
||||
} else {
|
||||
return nb, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m MCQ) Check(vals map[int64]bool) int {
|
||||
diff := 0
|
||||
|
||||
for _, n := range m.Entries {
|
||||
if v, ok := vals[n.Id]; ok && v == n.Response {
|
||||
if v, ok := vals[n.Id]; (ok || !n.Response) && v == n.Response {
|
||||
continue
|
||||
}
|
||||
diff += 1
|
||||
|
|
|
|||
Reference in a new issue