diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 6160c77a..ee4a137e 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -55,6 +55,39 @@ class PartieGateway } return $listePartie; } + + public function getDashBoardData(Partie $partie) : array{ + $query="SELECT joueur + FROM Participer p + WHERE p.partie=:idPartie"; + $this->con->executeQuery($query,array( + 'idPartie' => array($partie->getIdPartie(),PDO::PARAM_INT))); + $listeIdJoueur=$this->con->getResults(); + $DashboardData=array(); + foreach($listeIdJoueur as $joueur){ + $points=0; + $query="SELECT pe.utilisateur,pe.points,pe.temps,u.pseudo + FROM Utilisateur u,PasserEnigme pe,Partie p + WHERE points IS NOT NULL + AND u.email=pe.utilisateur + AND pe.partie=:idPartie + AND pe.utilisateur=:joueur + GROUP BY pe.utilisateur,pe.points,pe.temps,u.pseudo + ORDER BY u.pseudo,pe.temps ASC"; + $this->con->executequery($query,array( + 'idPartie' => array($partie->getIdPartie(),PDO::PARAM_INT), + 'joueur' => array($joueur,PDO::PARAM_STR))); + $results=$this->con->getResults(); + $joueurDashboardData=array(); + foreach($results as $row) + { + $points+=$row['pe.points']; + $joueurDashboardData[]=array($points,$row['pe.temps']); + } + $DashboardData[]=array($results[0]['u.pseudo'] => $joueurDashboardData); + } + return $DashboardData; + } public function showAll() : void{ $query= "SELECT * FROM Partie"; diff --git a/WEB/Controller/UtilisateurGateway.php b/WEB/Controller/UtilisateurGateway.php index 18ef5de8..908d92fb 100644 --- a/WEB/Controller/UtilisateurGateway.php +++ b/WEB/Controller/UtilisateurGateway.php @@ -1,5 +1,5 @@