Friday release

This commit is contained in:
nemunaire 2013-12-14 06:11:14 +01:00
commit c349769425
16 changed files with 319 additions and 89 deletions

View file

@ -88,23 +88,26 @@ for my $f (readdir $dh)
# Register solve
if ($good == -1) {
say localtime().": Exercice $exercice doesn't exist ; given by team $team in theme $theme.";
say STDERR localtime().": Exercice $exercice doesn't exist ; given by team $team in theme $theme.";
}
elsif ($good == 1)
{
# Check if the exercice exists
$sth = query($dbh, "SELECT `require` FROM exercices E WHERE E.id_theme = $theme AND E.id = ".$dbh->quote($exercice));
if ($sth->rows && (my $row = get_row($sth)))
if ($sth->rows)
{
my $row = get_row($sth);
# Check if the team has solved dependancies
$sth = query($dbh, "SELECT COUNT(S.id) FROM solved S WHERE S.id_exercice = ".$dbh->quote(@$row[0])) if @$row[0];
if (! (@$row[0] && $sth->rows))
$sth = query($dbh, "SELECT S.id FROM solved S WHERE S.id_exercice = ".$dbh->quote(@$row[0])) if @$row[0];
if (! @$row[0] || $sth->rows)
{
# Check if the team has not already solved this exercice
$sth = query($dbh, "SELECT COUNT(S.id) FROM solved S WHERE S.id_exercice = ".$dbh->quote($exercice));
$sth = query($dbh, "SELECT S.id FROM solved S WHERE S.id_exercice = ".$dbh->quote($exercice));
if (! $sth->rows)
{
say localtime().": Team $team solve exercice $exercice in $theme";
say $team;
say STDERR localtime().": Team $team solve exercice $exercice in $theme";
query($dbh, "INSERT INTO solved (id_team, id_exercice, time) VALUES ($team, ".$dbh->quote($exercice).", CURRENT_TIMESTAMP);");
$exit++;
}
@ -121,7 +124,7 @@ for my $f (readdir $dh)
}
}
else {
say localtime().": Team $team didn't give the correct answer for exercice $exercice.";
say STDERR localtime().": Team $team didn't give the correct answer for exercice $exercice.";
}
# Remove the file