Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 1c6de898 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

new score table

parent 27bc247a
......@@ -15,20 +15,20 @@ class Score{
include_once('./sys/load_iso.php');
$this->lang_iso = new IsoLang();
$sql = "SELECT DISTINCT `langue` FROM `score` WHERE `score`.`userid` = '".$this->user->id."'";
$sql = "SELECT DISTINCT `langue` FROM `stats` WHERE `stats`.`userid` = '".$this->user->id."'";
$this->db->query($sql);
if($this->db->has_result()){
while($tempObj = $this->db->fetch_object()){
$this->languages[$tempObj->langue] = $tempObj->langue;
//new ScoreTable creates ather database queries, so we separate both processes
//new ScoreTable creates other database queries, so we separate both processes
}
foreach($this->languages as $lang){
$this->languages[$lang] = new ScoreTable($this->user, $lang);
$this->languages[$lang]->get_score_table(false);
$this->languages[$lang]->get_score_table(true);
}
$this->languages[GlobalScoreTable::ALL_LANG] =
new GlobalScoreTable($this->user);
$this->languages[GlobalScoreTable::ALL_LANG]->get_score_table(false);
$this->languages[GlobalScoreTable::ALL_LANG]->get_score_table(true);
}
}
......
......@@ -158,6 +158,15 @@ $lang['score_diviner']= 'Augur Score';
$lang['score_global']= 'Global score';
$lang['global_score'] = 'Global rankings';
$lang['scores_by_language'] = "Rankings by language";
$lang['abandons']='Forfeits';
$lang['erreurs']='Err.';
$lang['enr_deposes']='Desc.';
$lang['w-l-perc']='Win %';
$lang['score']='Score';
$lang['carte_crees']='Created cards';
$lang['arbitrages']='Arbitrations';
$lang['err_arb']='Arbitration err.';
$lang['parties']='Games';
// Timeout
$lang['diviner_timeout'] = 'You did not give an anwser in time';
......
......@@ -153,6 +153,17 @@ $lang['score_global'] = 'Score global';
$lang['userName'] = 'Joueur';
$lang['global_score'] = 'Classement général';
$lang['scores_by_language'] = 'Scores par langue';
$lang['abandons']='Forfaits';
$lang['erreurs']='Err.';
$lang['enr_deposes']='Desc.';
$lang['w-l-perc']='% Gains';
$lang['score']='Score';
$lang['carte_crees']='Cartes créées';
$lang['arbitrages']='Arbitrages';
$lang['err_arb']='Err. arbitrage';
$lang['parties']='Parties';
// Timeout
$lang['diviner_timeout'] = 'Tu n\'as pas fourni de réponse dans le temps imparti';
......
......@@ -34,23 +34,75 @@ class ScoreLine extends EmptyScoreLine {
protected $augur;
protected $global;
protected $position;
protected $o_wl;
protected $o_en;
protected $o_er;
protected $d_a;
protected $d_er;
protected $d_c;
protected $a_en;
protected $a_wl;
protected $o_a;
protected $view = './views/score_line.table.display.php';
public function __construct($un, $o, $d, $a, $g, $p, $h=false, $v=false, $is_global = false){
//see create_scoring_table() for $compositeObject structure
public function __construct($compositeObject, $p, $h=false, $v=false, $is_global = false){
parent::__construct($h, $v, $is_global);
$this->user_name = $un;
$this->oracle = $o;
$this->druid = $d;
$this->augur = $a;
$this->global = $g;
$this->user_name = $compositeObject->name;
$this->oracle = $compositeObject->o;
$this->druid = $compositeObject->d;
$this->augur = $compositeObject->a;
$this->global = $compositeObject->g;
$this->position = $p;
//oracle stats
$this->o_wl = $compositeObject->o_wl;
$this->o_er = $compositeObject->o_er;
$this->o_en = $compositeObject->o_en;
$this->d_a = $compositeObject->d_a;
$this->d_er = $compositeObject->d_er;
$this->d_c = $compositeObject->d_c;
$this->a_en = $compositeObject->a_en;
$this->a_wl = $compositeObject->a_wl;
$this->o_a = $compositeObject->o_a;
}
public function get_oracle_recordings(){
return $this->o_en;
}
public function get_oracle_errors(){
return $this->o_er;
}
public function get_oracle_perc(){
return $this->o_wl;
}
public function get_oracle_forfeits(){
return $this->o_a;
}
public function get_druid_arbitration(){
return $this->d_a;
}
public function get_druid_arbitration_err(){
return $this->d_er;
}
public function get_druid_cards(){
return $this->d_c;
}
public function get_augur_recordings(){
return $this->a_en;
}
public function get_augur_perc(){
return $this->a_wl;
}
//stats
//position
public function get_position(){
return $this->position;
}
//scores
public function get_user_name(){
return $this->user_name;
}
......@@ -80,9 +132,9 @@ class GlobalScoreLine extends ScoreLine{
protected $language_list;
protected $view = "./views/global_score_line.table.display.php";
//string containing the list of languages used…
public function __construct($un, $o, $d, $a, $g, $p, $ll, $h=false, $v=false){
parent::__construct($un, $o, $d, $a, $g, $p, $h, $v, true);
$this->language_list = $ll;
public function __construct($compositeObject, $p, $h=false, $v=false){
parent::__construct($compositeObject, $p, $h, $v, true);
$this->language_list = $compositeObject->l;
}
public function get_language_list(){
......@@ -161,6 +213,10 @@ class ScoreTable{
return $this->language;
}
public function get_iso_language(){
return $this->lang_iso->any_to_iso($this->language);
}
public function is_built(){
return (count($this->scores)>0);
}
......@@ -172,15 +228,25 @@ class ScoreTable{
private function create_scoring_table(){
if(!$this->is_built()){
//we have not yet run that method
$query = "SELECT `score`.`scoreOracle` as `o`,
`score`.`scoreDruide` as `d`,
`score`.`scoreDevin` as `a`,
`score`.`scoreGlobal` as `g`,
`user`.`username` as `name`
FROM `score`,`user`
WHERE `score`.`langue`='".$this->language.
"'AND `user`.`userid`=`score`.`userid`
ORDER BY `scoreGlobal` DESC";
$query = "SELECT
`stats`.`nbAbandons_oracle` as `o_a`,
`stats`.`nbErreurs_oracle` as `o_er`,
`stats`.`nbEnregistrements_oracle` as `o_en`,
ROUND(`stats`.`nbSucces_oracle`*100/GREATEST(1,`stats`.`nbLectures_oracle`)) as `o_wl`,
`stats`.`score_oracle` as `o`,
`stats`.`nbArbitrages_druide` as `d_a`,
`stats`.`nbErrArbitrage_druide` as `d_er`,
`stats`.`nbCartes_druide` as `d_c`,
`stats`.`score_druide` as `d`,
`stats`.`nbEnregistrements_devin` as `a_en`,
ROUND(`stats`.`nbMotsTrouves_devin`*100/GREATEST(1,`stats`.`nbEnregistrements_devin`)) as `a_wl`,
`stats`.`score_devin` as `a`,
(`stats`.`score_devin`+`stats`.`score_druide`+`stats`.`score_oracle`) as `g`,
`user`.`username` as `name`
FROM `stats`,`user`
WHERE `stats`.`langue`='".$this->get_iso_language()."'".
" AND `user`.`userid`=`stats`.`userid`
ORDER BY `g` DESC";
$this->db->query($query);
if($this->db->affected_rows() > 0){
$this->scores=array();
......@@ -192,8 +258,7 @@ class ScoreTable{
$this->usr_pos = $pos;
}
array_push($this->scores,
new ScoreLine($tmpObj->name,
$tmpObj->o, $tmpObj->d, $tmpObj->a, $tmpObj->g, $pos, $highlight, $this->line_view));
new ScoreLine($tmpObj, $pos, $highlight, $this->line_view));
$pos++;
}
$this->make_incomplete();
......@@ -270,16 +335,28 @@ class GlobalScoreTable extends ScoreTable{
protected function create_scoring_table(){
if(!$this->is_built()){
//we have not yet run that method
$query = "SELECT SUM(`score`.`scoreOracle`) as `o`,
SUM(`score`.`scoreDruide`) as `d`,
SUM(`score`.`scoreDevin`) as `a`,
SUM(`score`.`scoreGlobal`) as `g`,
`user`.`username` as `name`,
GROUP_CONCAT(`score`.`langue` SEPARATOR '+') as `l`
FROM `score`,`user`
WHERE `user`.`userid`=`score`.`userid`
GROUP BY `name`
ORDER BY `g` DESC" ;
$query =
"SELECT
`stats`.`nbAbandons_oracle` as `o_a`,
`stats`.`nbErreurs_oracle` as `o_er`,
`stats`.`nbEnregistrements_oracle` as `o_en`,
ROUND(`stats`.`nbSucces_oracle`*100/GREATEST(1,`stats`.`nbLectures_oracle`)) as `o_wl`,
`stats`.`score_oracle` as `o`,
`stats`.`nbArbitrages_druide` as `d_a`,
`stats`.`nbErrArbitrage_druide` as `d_er`,
`stats`.`nbCartes_druide` as `d_c`,
`stats`.`score_druide` as `d`,
`stats`.`nbEnregistrements_devin` as `a_en`,
ROUND(`stats`.`nbMotsTrouves_devin`*100/GREATEST(1,`stats`.`nbEnregistrements_devin`)) as `a_wl`,
`stats`.`score_devin` as `a`,
(`stats`.`score_devin`+`stats`.`score_druide`+`stats`.`score_oracle`) as `g`,
`user`.`username` as `name`,
GROUP_CONCAT(`stats`.`langue` SEPARATOR '+') as `l`
FROM `stats`,`user`
WHERE `user`.`userid`=`stats`.`userid`
GROUP BY `name`
ORDER BY `g` DESC" ;
$this->db->query($query);
if($this->db->has_result()){
$this->scores=array();
......@@ -291,8 +368,7 @@ class GlobalScoreTable extends ScoreTable{
$this->usr_pos = $pos;
}
array_push($this->scores,
new GlobalScoreLine($tmpObj->name,
$tmpObj->o, $tmpObj->d, $tmpObj->a, $tmpObj->g, $pos, $tmpObj->l,
new GlobalScoreLine($tmpObj, $pos,
$highlight, $this->line_view));
$pos++;
}
......
......@@ -215,10 +215,19 @@ body{
cursor:pointer;
}
.header{
color:white;
font-size:larger;
}
.highlight{
background-color: black;
color:white;
}
.highlight:hover{
color:black;
font-style: italic;
}
.onglet_0{
cursor:pointer;
}
......
......@@ -6,10 +6,10 @@ else{
$class = "";
}
if($scoreLine->isGlobal()){
$width = 7;
$width = 16;
}
else{
$width = 6;
$width = 15;
}
$res = "<tr$class><td colspan='$width'>…</td></tr>";
?>
......@@ -6,12 +6,21 @@ else{
$class = "";
}
$res = "<tr$class>".
"<td>".$scoreLine->get_position()."</td>".
"<td style = 'font-weight:bold;' >".$scoreLine->get_user_name()."</td>".
"<td style = 'text-decoration:italics' >".$scoreLine->get_global_score()."</td>".
"<td>".$scoreLine->get_oracle_score()."</td>".
"<td>".$scoreLine->get_druid_score()."</td>".
"<td>".$scoreLine->get_augur_score()."</td>".
"<td>".$scoreLine->get_language_list()."</td>".
"</tr>";
"<td>".$scoreLine->get_position()."</td>".
"<td style = 'font-weight:bold;' >".$scoreLine->get_user_name()."</td>".
"<td>".$scoreLine->get_oracle_forfeits()."</td>".
"<td>".$scoreLine->get_oracle_errors()."</td>".
"<td>".$scoreLine->get_oracle_recordings()."</td>".
"<td>".$scoreLine->get_oracle_perc()."</td>".
"<td>".$scoreLine->get_oracle_score()."</td>".
"<td>".$scoreLine->get_druid_arbitration()."</td>".
"<td>".$scoreLine->get_druid_arbitration_err()."</td>".
"<td>".$scoreLine->get_druid_cards()."</td>".
"<td>".$scoreLine->get_druid_score()."</td>".
"<td>".$scoreLine->get_augur_recordings()."</td>".
"<td>".$scoreLine->get_augur_perc()."</td>".
"<td>".$scoreLine->get_augur_score()."</td>".
"<td style = 'text-decoration:italics' >".$scoreLine->get_global_score()."</td>".
"<td>".$scoreLine->get_language_list()."</td>".
"</tr>";
?>
......@@ -5,13 +5,22 @@ if(!isset($lang)){
$res = "<table class='table table-hover sortable' id='GlobScore'>
<thead>
<tr>
<th>".$lang['classement']."</th>
<th>".$lang['userName']."</th>
<th>".$lang['score_global']."</th>
<th>".$lang['score_oracle']."</th>
<th>".$lang['score_druid']."</th>
<th>".$lang['score_diviner']."</th>
<th>".$lang['listLangues']."</th>
<th class='header'>".$lang['classement']."</th>
<th class='header'>".$lang['userName']."</th>
<th><span class='header'>".$lang['score_oracle']."</span><br /><br />".$lang['abandons']."</th>
<th>".$lang['erreurs']."</th>
<th>".$lang['enr_deposes']."</th>
<th>".$lang['w-l-perc']."</th>
<th>".$lang['score']."</th>
<th><span class='header'>".$lang['score_druid']."</span><br /><br />".$lang['arbitrages']."</th>
<th>".$lang['err_arb']."</th>
<th>".$lang['carte_crees']."</th>
<th>".$lang['score']."</th>
<th><span class='header'>".$lang['score_diviner']."</span><br /><br />".$lang['parties']."</th>
<th>".$lang['w-l-perc']."</th>
<th>".$lang['score']."</th>
<th class='header'>".$lang['score_global']."</th>
<th>".$lang['listLangues']."</th>
</tr>
</thead>
<tbody>";
......
......@@ -6,20 +6,53 @@ $title = $lang['scores'];
include('./views/page.header.html');
?>
<script type="text/javascript" src="./sys/sorttable.js"></script>
<script type="text/javascript" src="./controllersJS/tabs.js"></script>
<div id="main-container">
<h2><?php echo $lang['global_score']; ?></h2>
<?php
echo $theScore->languages[GlobalScoreTable::ALL_LANG];
?>
<h2><?php echo $lang['scores_by_language']; ?></h2>
<?php foreach($theScore->languages as $langue => $table){
if($langue !== GlobalScoreTable::ALL_LANG){
echo "<h3>".$theScore->lang_iso->any_to_french($langue)."</h3>\n".$table;
<div id="infos-container">
<div id="onglets">
</div>
<div id="contenu-onglets">
<!-- Score global -->
<div class="contenu_onglet" id="contenu_onglet_global">
<div class="row">
<div class="col-md-9" role="main">
<?php echo $theScore->languages[GlobalScoreTable::ALL_LANG];?>
</div>
</div>
</div>
<?php
$ids = "'global'";
$titles = "\"".$lang['global_score']."\"";
foreach($theScore->languages as $langue => $table){
if($langue !== GlobalScoreTable::ALL_LANG){
$id = $theScore->lang_iso->any_to_iso($langue);
?>
<div class="contenu_onglet" id="contenu_onglet_<?php echo $id; ?>">
<div class="row">
<div class="col-md-9" role="main">
<?php
$ids .= ",'$id'";
$titles .= ",\"".$theScore->lang_iso->any_to_french($langue)."\"";
echo $table;
?>
</div>
</div>
</div>
<?php
}
}
}
?>
?>
</div>
<script type="text/javascript">
var tabs = new TabMenu(
[<?php echo $ids; ?>],
[<?php echo $titles; ?>]
);
window.onload = function(){
tabs.init('onglets');
tabs.switchTo('niouzes');
}
</script>
<?php
include('./views/page.footer.html');
?>
......@@ -8,9 +8,18 @@ else{
$res = "<tr$class>".
"<td>".$scoreLine->get_position()."</td>".
"<td style = 'font-weight:bold;' >".$scoreLine->get_user_name()."</td>".
"<td style = 'text-decoration:italics' >".$scoreLine->get_global_score()."</td>".
"<td>".$scoreLine->get_oracle_forfeits()."</td>".
"<td>".$scoreLine->get_oracle_errors()."</td>".
"<td>".$scoreLine->get_oracle_recordings()."</td>".
"<td>".$scoreLine->get_oracle_perc()."</td>".
"<td>".$scoreLine->get_oracle_score()."</td>".
"<td>".$scoreLine->get_druid_arbitration()."</td>".
"<td>".$scoreLine->get_druid_arbitration_err()."</td>".
"<td>".$scoreLine->get_druid_cards()."</td>".
"<td>".$scoreLine->get_druid_score()."</td>".
"<td>".$scoreLine->get_augur_recordings()."</td>".
"<td>".$scoreLine->get_augur_perc()."</td>".
"<td>".$scoreLine->get_augur_score()."</td>".
"<td style = 'text-decoration:italics' >".$scoreLine->get_global_score()."</td>".
"</tr>";
?>
......@@ -5,12 +5,21 @@ if(!isset($lang)){
$res = "<table class='table table-hover sortable' id='Score".$scoreTable->get_language()."'>
<thead>
<tr>
<th>".$lang['classement']."</th>
<th>".$lang['userName']."</th>
<th>".$lang['score_global']."</th>
<th>".$lang['score_oracle']."</th>
<th>".$lang['score_druid']."</th>
<th>".$lang['score_diviner']."</th>
<th class='header'>".$lang['classement']."</th>
<th class='header'>".$lang['userName']."</th>
<th><span class='header'>".$lang['score_oracle']."</span><br /><br />".$lang['abandons']."</th>
<th>".$lang['erreurs']."</th>
<th>".$lang['enr_deposes']."</th>
<th>".$lang['w-l-perc']."</th>
<th>".$lang['score']."</th>
<th><span class='header'>".$lang['score_druid']."</span><br /><br />".$lang['arbitrages']."</th>
<th>".$lang['err_arb']."</th>
<th>".$lang['carte_crees']."</th>
<th>".$lang['score']."</th>
<th><span class='header'>".$lang['score_diviner']."</span><br /><br />".$lang['parties']."</th>
<th>".$lang['w-l-perc']."</th>
<th>".$lang['score']."</th>
<th class='header'>".$lang['score_global']."</th>
</tr>
</thead>
<tbody>";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment