Summary table done.

This commit is contained in:
Quentin Grosyeux 2013-11-07 21:53:35 +01:00
parent bf36486bf3
commit 8758598104
4 changed files with 44 additions and 6 deletions

View File

@ -53,6 +53,11 @@ class Exercice
} }
} }
function get_id()
{
return $this->id;
}
// retourne le nombre d'equipes qui ont résolues l'exercice // retourne le nombre d'equipes qui ont résolues l'exercice
// trié par date // trié par date
function get_solved() function get_solved()

View File

@ -169,11 +169,30 @@ class Team
return $res['solved']; return $res['solved'];
} }
function get_solvedExercices() function get_solvedExercices($id_theme=-1)
{ {
$db = new BDD(); if ($id_theme != -1)
$ids = $db->query(""); {
$db->deconnexion(); $db = new BDD();
$ids = $db->query("SELECT id_theme, id_exercice
FROM `solved`
LEFT OUTER JOIN exercices ON `solved`.id_exercice = `exercices`.id
WHERE id_user =".$this->id." AND id_theme =".$id_theme);
$db->deconnexion();
$array = array();
$i = 0;
if ($ids)
{
foreach ($ids as $id){
$array[] = new Exercice($id['id_exercice']);
}
}
return $array;
}
return NULL;
} }
function authenticate($certificate) function authenticate($certificate)

View File

@ -2,7 +2,12 @@
if(!defined('ONYX')) exit; if(!defined('ONYX')) exit;
$team = new Team($TEAM);
//$solvedExercices = $team->get_solvedExercices();
$template->assign("themes", Theme::get_themes()); $template->assign("themes", Theme::get_themes());
$template->assign("nbExoMax", Exercice::get_nbExoMax()); $template->assign("nbExoMax", Exercice::get_nbExoMax());
$template->assign("team", $team);
//$template->assign("solvedExercices", $solvedExercices);
return "teams/summary"; return "teams/summary";

View File

@ -25,8 +25,17 @@
<tr> <tr>
<th>{$theme->get_name()}</th> <th>{$theme->get_name()}</th>
{$sum=0} {$sum=0}
{foreach from=$theme->get_exercicesOrdered() item=exo} {$themeID=$theme->get_id()}
{$pts=$exo->points}{$sum=$sum + $pts} {$solvedExercices=$team->get_solvedExercices($themeID)} {*TODO: This line give a Warning*}
{foreach from=$theme->get_exercicesOrdered() item=exo}
{$pts=0}
{for $i=0 to $nbExoMax}
{if !empty($solvedExercices.$i)}
{if $solvedExercices.$i->get_id() == $exo->get_id()}
{$pts=$solvedExercices.$i->points}{$sum=$sum + $pts}
{/if}
{/if}
{/for}
<td>{$pts}</td> <td>{$pts}</td>
{/foreach} {/foreach}
<td>{$sum}</td> <td>{$sum}</td>