Test dashboard
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé GARNIER 2 years ago
parent 7eeb85f78b
commit baa261a88f

@ -85,6 +85,9 @@ class UserController
case "getPlayerScore":
$this->getPlayerScore();
break;
case "getDashboardInfo":
$this->getDashboardInfo();
break;
default:
$error = "Action non valide";
require($rep . $vues['erreur']);
@ -493,4 +496,18 @@ class UserController
require($rep . $vues['erreur']);
}
}
public function getDashboardInfo(){
try {
global $rep, $vues, $error;
$model = new UserModel();
$idPartie = $_SESSION['idPartie'];
$lesInfos = $model->getDashboardInfo($idPartie);
$lesInfos = json_encode($lesInfos);
echo $lesInfos;
}
catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
}

@ -320,4 +320,19 @@ class UserModel
}
return $score;
}
public function getLesEnigmes(int $idPartie) : array{
return $this->partie_gateway->getLesIdEnigmes($idPartie);
}
public function getDashboardInfo(int $idPartie){
$lesJoueurs = $this->getLesJoueurs($idPartie);
// $lesMailJoueurs = array();
$lesPseudos = array();
$lesScores = array();
foreach ($lesJoueurs as $joueur){
// $lesMailJoueurs[] = $joueur->getEmail();
$lesPseudos[] = $joueur->getPseudo();
$lesScores[] = $this->getPlayerScore($joueur->getEmail(), $idPartie);
}
return array($lesPseudos, $lesScores);
}
}

@ -1,97 +1,134 @@
function dashboard () {
let playersPseudo;
data = [];
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=getDashboardInfo', true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function () {
console.log(xhr.responseText);
playersPseudo = xhr.responseText;
lesInfos = JSON.parse(xhr.responseText);
console.log(lesInfos);
var nbJoueur = lesInfos[0].length;
for (i = 0; i < nbJoueur; i++) {
v1 = {}
v1.type="line";
v1.xValueFormatString=lesInfos[0][i];
v1.dataPoints=[];
for (j = 0; j < lesInfos[1].length; j++) {
v1.dataPoints.push({x:j+1,y:lesInfos[1][j]});
}
data.push(v1);
}
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
zoomEnabled: true,
theme: "dark2",
title: {
text: "Score"
},
axisX: {
title: "Enigme",
valueFormatString: "####",
interval: 1
},
axisY: {
title: "Point",
titleFontColor: "#6D78AD",
lineColor: "#6D78AD",
gridThickness: 0,
lineThickness: 1,
},
legend: {
verticalAlign: "top",
fontSize: 16,
},
data
});
chart.render();
}
console.log(playersPseudo);
xhr.send(null);
xhr.send(null);
}
data = [];
// data = [];
if (playersPseudo[0] != null) {
v1 = {}
v1.type="line";
v1.xValueFormatString=playersPseudo[0];
v1.dataPoints=[];
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&pseudo='. playersPseudo[0], true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () {
console.log(xhr.responseText);
return JSON.parse(xhr.responseText);
};
// if (playersPseudo[0] != null) {
// v1 = {}
// v1.type="line";
// v1.xValueFormatString=playersPseudo[0];
// v1.dataPoints=[];
// var xhr = new XMLHttpRequest();
// xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&pseudo='. playersPseudo[0], true);
// xhr.responseType = 'text';
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// var score = xhr.onload = function () {
// console.log(xhr.responseText);
// return JSON.parse(xhr.responseText);
// };
xhr.send(null);
for (i = 0; i < score.length; i++) {
v1.dataPoints.push({x:i+1,y:score[i]});
}
data.push(v1);
}
// xhr.send(null);
// for (i = 0; i < score.length; i++) {
// v1.dataPoints.push({x:i+1,y:score[i]});
// }
// data.push(v1);
// }
if (playersPseudo[1] != null) {
console.log("test1");
v2 = {}
v2.type="line";
v2.xValueFormatString=playersPseudo[1];
v2.dataPoints=[];
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[1], true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () {
console.log(xhr.responseText);
return JSON.parse(xhr.responseText);
};
xhr.send(null);
for (i = 0; i < score.length; i++) {
v2.dataPoints.push({x:i+1,y:score[i]});
}
data.push(v2);
}
// if (playersPseudo[1] != null) {
// console.log("test1");
// v2 = {}
// v2.type="line";
// v2.xValueFormatString=playersPseudo[1];
// v2.dataPoints=[];
// var xhr = new XMLHttpRequest();
// xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[1], true);
// xhr.responseType = 'text';
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// var score = xhr.onload = function () {
// console.log(xhr.responseText);
// return JSON.parse(xhr.responseText);
// };
// xhr.send(null);
// for (i = 0; i < score.length; i++) {
// v2.dataPoints.push({x:i+1,y:score[i]});
// }
// data.push(v2);
// }
if (playersPseudo[2] != null) {
v3 = {}
v3.type="line";
v3.xValueFormatString=playersPseudo[2];
v3.dataPoints=[];
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[2], true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () {
return JSON.parse(xhr.responseText);
};
xhr.send(null);
for (i = 0; i < score.length; i++) {
v3.dataPoints.push({x:i+1,y:score[i]});
}
data.push(v3);
}
// if (playersPseudo[2] != null) {
// v3 = {}
// v3.type="line";
// v3.xValueFormatString=playersPseudo[2];
// v3.dataPoints=[];
// var xhr = new XMLHttpRequest();
// xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[2], true);
// xhr.responseType = 'text';
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// var score = xhr.onload = function () {
// return JSON.parse(xhr.responseText);
// };
// xhr.send(null);
// for (i = 0; i < score.length; i++) {
// v3.dataPoints.push({x:i+1,y:score[i]});
// }
// data.push(v3);
// }
if (playersPseudo[3] != null) {
v4 = {}
v4.type="line";
v4.xValueFormatString=playersPseudo[3];
v4.dataPoints=[];
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[3], true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var score = xhr.onload = function () {
return JSON.parse(xhr.responseText);
};
xhr.send(null);
for (i = 0; i < score.length; i++) {
v4.dataPoints.push({x:i+1,y:score[i]});
}
data.push(v4);
}
// if (playersPseudo[3] != null) {
// v4 = {}
// v4.type="line";
// v4.xValueFormatString=playersPseudo[3];
// v4.dataPoints=[];
// var xhr = new XMLHttpRequest();
// xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersPseudo[3], true);
// xhr.responseType = 'text';
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// var score = xhr.onload = function () {
// return JSON.parse(xhr.responseText);
// };
// xhr.send(null);
// for (i = 0; i < score.length; i++) {
// v4.dataPoints.push({x:i+1,y:score[i]});
// }
// data.push(v4);
// }
// data = [];
@ -102,34 +139,7 @@
// v4.dataPoints.push({x:1,y:100});
// data.push(v4);
// console.log(data);
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
zoomEnabled: true,
theme: "dark2",
title: {
text: "Score"
},
axisX: {
title: "Enigme",
valueFormatString: "####",
interval: 1
},
axisY: {
title: "Point",
titleFontColor: "#6D78AD",
lineColor: "#6D78AD",
gridThickness: 0,
lineThickness: 1,
},
legend: {
verticalAlign: "top",
fontSize: 16,
},
data
});
chart.render();
}
// }
window.addEventListener("load", start);
function start(){

Loading…
Cancel
Save