Add on exercice page the last try time
This commit is contained in:
parent
aeb4b5dd52
commit
6b5e51f4e3
2
check.pl
2
check.pl
|
@ -67,6 +67,8 @@ for my $f (readdir $dh)
|
|||
{'RaiseError' => 1, 'PrintError' => 1})
|
||||
or die $DBI::errstr if !$dbh;
|
||||
|
||||
query($dbh, "INSERT INTO exercice_tries (id_exercice, id_team, time) VALUES ('$exercice', $team, CURRENT_TIMESTAMP);");
|
||||
|
||||
my $sth = query($dbh, "SELECT format, value FROM exercice_keys WHERE id_exercice = ".$dbh->quote($exercice));
|
||||
|
||||
# Check solutions
|
||||
|
|
|
@ -47,6 +47,20 @@ CREATE TABLE IF NOT EXISTS `exercice_files` (
|
|||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `exercice_tries`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `exercice_tries` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_exercice` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`id_team` smallint(5) unsigned NOT NULL,
|
||||
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `exercice_keys`
|
||||
--
|
||||
|
|
|
@ -156,6 +156,23 @@ class Exercice
|
|||
return $res["time"];
|
||||
}
|
||||
|
||||
function last_try($team)
|
||||
{
|
||||
$id = $this->id;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($id);
|
||||
$res = $db->unique_query("SELECT `time` FROM exercice_tries WHERE id_exercice = '$id'
|
||||
AND id_team = ".intval($team->get_id())." ORDER BY time DESC LIMIT 1");
|
||||
|
||||
$db->deconnexion();
|
||||
|
||||
if (!empty($res))
|
||||
return $res["time"];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
function set_number()
|
||||
{
|
||||
if ($this->require == "")
|
||||
|
|
|
@ -53,9 +53,12 @@
|
|||
</div>
|
||||
<div class="panel-body">
|
||||
{if $cur_exercice->has_solved($my_team)}
|
||||
Déjà résolu à {$cur_exercice->has_solved($my_team)|date_format:"%H:%M:%S"} :)
|
||||
<strong>Résolu à {$cur_exercice->has_solved($my_team)|date_format:"%H:%M:%S"} :)</strong>
|
||||
{else}
|
||||
<form role="form" method="post" action="/{$SALT_USER}/{$my_team->get_id()}/{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$cur_exercice->id}/submission">
|
||||
{if $cur_exercice->last_try($my_team)}
|
||||
<label>Dernière solution testée à</label> {$cur_exercice->last_try($my_team)|date_format:"%H:%M:%S"}
|
||||
{/if}
|
||||
<form role="form" method="post" action="/{$SALT_USER}/{$my_team->get_id()}/{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$cur_exercice->id}/submission" >
|
||||
<div class="form-group">
|
||||
<label for="solution">Soumettre la solution :</label>
|
||||
<input type="text" class="form-control" id="solution" name="solution">
|
||||
|
|
Loading…
Reference in New Issue
Block a user