Calcul dashboard
continuous-integration/drone/push Build is failing Details

ServeurDeTest
Noé GARNIER 2 years ago
parent ed6aa54a3e
commit 9a020f8130

@ -463,27 +463,14 @@ class UserController
require($rep . $vues['erreur']); require($rep . $vues['erreur']);
} }
} }
public function getPlayersEmail(){
try {
global $rep, $vues, $error;
$model = new UserModel();
$idPartie = $_SESSION['idPartie'];
$lesJoueurs = $model->getLesJoueurs($idPartie);
$lesJoueurs = json_encode($lesJoueurs);
echo ($lesJoueurs);
}
catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
public function getPlayerScore(){ public function getPlayerScore(){
try { try {
global $rep, $vues, $error; global $rep, $vues, $error;
$model = new UserModel(); $model = new UserModel();
$idPartie = $_SESSION['idPartie']; $idPartie = $_SESSION['idPartie'];
$joueur = $_POST['joueur']; $pseudo = $_POST['pseudo'];
$score = $model->getPlayerScore($joueur, $idPartie); $mailUtilisateur = $model->getMailFromPseudo($pseudo);
$score = $model->getPlayerScore($mailUtilisateur, $idPartie);
$score = json_encode($score); $score = json_encode($score);
echo $score; echo $score;
} }

@ -50,6 +50,20 @@ class UtilisateurGateway
$results=$this->con->getResults(); $results=$this->con->getResults();
return UtilisateurFactory::createUtilisateur($results); return UtilisateurFactory::createUtilisateur($results);
} }
public function getMailByPseudo(string $pseudo) : string{
global $error;
$query = "SELECT email FROM Utilisateur WHERE pseudo=:pseudo LIMIT 1";
$this->con->executeQuery($query, array(
':pseudo' => array($pseudo,SQLITE3_TEXT)
));
$results=$this->con->getResults();
$email = $results[0]['email'];
if ($results == null){
$error = "Email non trouvé.";
throw new Exception("Email Incorrect");
}
return $email;
}
public function getMdpByEmail(string $email) : string{ public function getMdpByEmail(string $email) : string{
global $error; global $error;

@ -294,6 +294,9 @@ class UserModel
} }
return $lesPseudos; return $lesPseudos;
} }
public function getMailFromPseudo(string $pseudo) : string{
return $this->utilisateur_gateway->getMailByPseudo($pseudo);
}
public function getPlayerScore(string $mailUtilisateur,int $idPartie) : array{ public function getPlayerScore(string $mailUtilisateur,int $idPartie) : array{
global $playerNumberPerGame; global $playerNumberPerGame;
$score = array(); $score = array();

@ -1,12 +1,4 @@
function dashboard () { function dashboard () {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayersEmail', true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var playersEmail = xhr.onload = function () {
console.log(xhr.responseText);
return JSON.parse(xhr.responseText);
};
xhr.send(null); xhr.send(null);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayersPseudo', true); xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayersPseudo', true);
@ -18,13 +10,13 @@
data = []; data = [];
if (playersEmail[0] != null) { if (playersPseudo[0] != null) {
v1 = {} v1 = {}
v1.type="line"; v1.type="line";
v1.xValueFormatString=playersPseudo[0]; v1.xValueFormatString=playersPseudo[0];
v1.dataPoints=[]; v1.dataPoints=[];
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[0], true); xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&pseudo='. playersPseudo[0], true);
xhr.responseType = 'text'; xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () { var score = xhr.onload = function () {
@ -37,13 +29,13 @@
data.push(v1); data.push(v1);
} }
if (playersEmail[1] != null) { if (playersPseudo[1] != null) {
v2 = {} v2 = {}
v2.type="line"; v2.type="line";
v2.xValueFormatString=playersPseudo[1]; v2.xValueFormatString=playersPseudo[1];
v2.dataPoints=[]; v2.dataPoints=[];
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[1], true); xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[1], true);
xhr.responseType = 'text'; xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () { var score = xhr.onload = function () {
@ -56,13 +48,13 @@
data.push(v2); data.push(v2);
} }
if (playersEmail[2] != null) { if (playersPseudo[2] != null) {
v3 = {} v3 = {}
v3.type="line"; v3.type="line";
v3.xValueFormatString=playersPseudo[2]; v3.xValueFormatString=playersPseudo[2];
v3.dataPoints=[]; v3.dataPoints=[];
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[2], true); xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[2], true);
xhr.responseType = 'text'; xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () { var score = xhr.onload = function () {
@ -75,13 +67,13 @@
data.push(v3); data.push(v3);
} }
if (playersEmail[3] != null) { if (playersPseudo[3] != null) {
v4 = {} v4 = {}
v4.type="line"; v4.type="line";
v4.xValueFormatString=playersPseudo[3]; v4.xValueFormatString=playersPseudo[3];
v4.dataPoints=[]; v4.dataPoints=[];
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[3], true); xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[3], true);
xhr.responseType = 'text'; xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () { var score = xhr.onload = function () {

Loading…
Cancel
Save