blob: ff1796243fcdbc613154f18ae6380b1533db31d1 [file] [log] [blame]
Andreu2211ab22019-09-23 18:13:26 +02001<html>
2<head>
3 <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
4 <link rel="stylesheet" href="./css/basic.css" />
5 <link rel="stylesheet" href="./css/ranking.css" />
6</head>
7
8<body>
9
10<?php
11 require './credentials.php';
12 require './php/utils.php';
13
14 // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi";
15 // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills, sum(CASE WHEN morts.grau = users.grau THEN 1 ELSE 2 END) AS kills_pondered FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY kills_pondered DESC";
16 // Mateix grau i curs => 1, Mateix grau diferent curs => 2, Diferent grau => 3
17 // $getranking = "SELECT morts.assassi AS id, users.grau, users.curs, count(morts.assassi) AS kills, sum(CASE WHEN morts.grau = users.grau AND morts.curs = users.curs THEN 1 WHEN morts.grau = users.grau AND morts.curs != users.curs THEN 2 ELSE 3 END) AS kills_pondered FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY kills_pondered DESC";
18
19 // Mateix grau i curs => 100, Mateix grau diferent curs => 150, Diferent grau => 200
20 $getranking = "SELECT morts.assassi AS id, users.nom, users.grau, users.curs, count(morts.assassi) AS kills,
21 sum(morts.grau = users.grau AND morts.curs = users.curs) AS companys_classe,
22 sum(morts.grau = users.grau AND morts.curs != users.curs) AS companys_grau,
23 sum(morts.grau != users.grau) AS companys_facu,
24 sum(CASE WHEN morts.grau = users.grau AND morts.curs = users.curs THEN 100 WHEN morts.grau = users.grau AND morts.curs != users.curs THEN 150 ELSE 200 END) AS score
25 FROM morts INNER JOIN users ON morts.assassi = users.id GROUP BY morts.assassi ORDER BY score DESC";
26
27 $results = query($getranking);
28?>
29
30<div id="outter-container">
31 <div id="inner-container">
32 <h1>Rànquing</h1>
33 <p>La puntuació de cada jugador es calcula com a una suma ponderada entre companys de classe (mateix curs, mateix grau), companys de grau (mateix grau) i companys de facultat (diferents grau). Amb puntuacions +100, +150 i +200; respectivament.</p>
34
35 <table id="ranking" cellspacing="0" cellpadding="0">
36 <tr id="header">
37 <th></th>
38 <th>Nom</th>
39 <th>Classe</th>
40 <th>Grau</th>
41 <th>Facu</th>
42 <th>Total</th>
43 <th>Punts</th>
44 </tr>
45 <?php
46 $id = 43;
47 $i = 1;
48
49 while ($row = $results->fetch_object()) {
50 if ($i == 1) echo "<tr class='gold top3'>";
51 else if ($i == 2) echo "<tr class='silver top3'>";
52 else if ($i == 3) echo "<tr class='bronze top3'>";
53 else if ($row->id == $id) echo "<tr class='me'>";
54 else echo "<tr>";
55
56 echo "<td>". ($i > 3 ? $i : '') ."</td>";
57 echo "<td>$row->nom</td>";
58 echo "<td>$row->companys_classe</td>";
59 echo "<td>$row->companys_grau</td>";
60 echo "<td>$row->companys_facu</td>";
61 echo "<td>$row->kills</td>";
62 echo "<td>$row->score</td>";
63 echo "</tr>";
64
65 $i = $i + 1;
66 }
67 ?>
68 </table>
69 </div>
70</div>
71
72</body>
73</html>