Add a new setting to don't count same responses in scores

This commit is contained in:
nemunaire 2018-12-06 22:18:08 +01:00
commit 910ec94fd8
8 changed files with 44 additions and 5 deletions

View file

@ -145,12 +145,17 @@ func (t Team) CanSeeFlag(k Flag) bool {
// NbTry retrieves the number of attempts made by the Team to the given challenge.
func NbTry(t *Team, e Exercice) int {
tries_table := "exercice_tries"
if SubmissionUniqueness {
tries_table = "exercice_distinct_tries"
}
var cnt *int
if t != nil {
DBQueryRow("SELECT COUNT(*) FROM exercice_tries WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&cnt)
DBQueryRow("SELECT COUNT(*) FROM " + tries_table + " WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&cnt)
} else {
DBQueryRow("SELECT COUNT(*) FROM exercice_tries WHERE id_exercice = ?", e.Id).Scan(&cnt)
DBQueryRow("SELECT COUNT(*) FROM " + tries_table + " WHERE id_exercice = ?", e.Id).Scan(&cnt)
}
if cnt == nil {