summaryrefslogtreecommitdiff
path: root/pages/score.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/score.php')
-rw-r--r--pages/score.php210
1 files changed, 210 insertions, 0 deletions
diff --git a/pages/score.php b/pages/score.php
new file mode 100644
index 0000000..841decc
--- /dev/null
+++ b/pages/score.php
@@ -0,0 +1,210 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn;
+if (!$isLoggedIn) header("Location: /login") and die();
+
+$title = "Score System Testing"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php';
+
+?>
+
+<br>
+<div class="container">
+ <div id="page-content">
+ <h2>Score System Testing</h2>
+
+ <h4>Raindrops System (<code><?php
+
+ $scores = [];
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = $score["total"];
+ }
+ }
+
+ $total = array_reduce($scores, function($a, $b) {
+ return $a + $b;
+ });
+
+ echo round($total / (count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true)) - 1));
+
+ ?></code>)</h4>
+ <ul>
+ <?php
+
+ $scores = [];
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ $name = $member["display_name"] ?? $member["name"];
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = [
+ "name" => $name,
+ "page" => "/raindrops/" . $member["name"],
+ "score" => $score["total"],
+ "details" => $score
+ ];
+ }
+ }
+
+ uasort($scores, function($a, $b) {
+ return $b["score"] - $a["score"];
+ });
+
+ ?>
+
+ <?php foreach ($scores as $score): ?>
+ <li>
+ <details>
+ <summary><a href="<?= $score["page"] ?>"><?= $score["name"] ?></a> (<code><?= $score["score"] ?></code>)</summary>
+ <pre><?= json_encode($score["details"], JSON_PRETTY_PRINT) ?></pre>
+ </details>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+
+
+ <h4>Cloudburst System (<code><?php
+
+ $scores = [];
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = $score["total"];
+ }
+ }
+
+ $total = array_reduce($scores, function($a, $b) {
+ return $a + $b;
+ });
+
+ echo round($total / (count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true)) - 1));
+
+ ?></code>)</h4>
+ <ul>
+ <?php
+
+ $scores = [];
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ $name = $member["display_name"] ?? $member["name"];
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = [
+ "name" => $name,
+ "page" => "/cloudburst/" . $member["name"],
+ "score" => $score["total"],
+ "details" => $score
+ ];
+ }
+ }
+
+ uasort($scores, function($a, $b) {
+ return $b["score"] - $a["score"];
+ });
+
+ ?>
+
+ <?php foreach ($scores as $score): ?>
+ <li>
+ <details>
+ <summary><a href="<?= $score["page"] ?>"><?= $score["name"] ?></a> (<code><?= $score["score"] ?></code>)</summary>
+ <pre><?= json_encode($score["details"], JSON_PRETTY_PRINT) ?></pre>
+ </details>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+
+ <h4>Global (<code><?php
+
+ $scores = [];
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = $score["total"];
+ }
+ }
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = $score["total"];
+ }
+ }
+
+ $total = array_reduce($scores, function($a, $b) {
+ return $a + $b;
+ });
+
+ echo round($total / ((count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true)) + count(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true))) - 2));
+
+ ?></code>)</h4>
+ <ul>
+ <?php
+
+ $scores = [];
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ $name = $member["display_name"] ?? $member["name"];
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = [
+ "name" => $name,
+ "page" => "/raindrops/" . $member["name"],
+ "score" => $score["total"],
+ "details" => $score
+ ];
+ }
+ }
+ foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) {
+ if ($member["name"] !== "unknown") {
+ $name = $member["display_name"] ?? $member["name"];
+ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";
+ $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-$member[id]-metadata.json"), true);
+ $score = calculateScore($metadata, $member["display_name"] ?? $member["name"]);
+
+ $scores[] = [
+ "name" => $name,
+ "page" => "/cloudburst/" . $member["name"],
+ "score" => $score["total"],
+ "details" => $score
+ ];
+ }
+ }
+
+ uasort($scores, function($a, $b) {
+ return $b["score"] - $a["score"];
+ });
+
+ ?>
+
+ <?php foreach ($scores as $score): ?>
+ <li>
+ <details>
+ <summary><a href="<?= $score["page"] ?>"><?= $score["name"] ?></a> (<code><?= $score["score"] ?></code>)</summary>
+ <pre><?= json_encode($score["details"], JSON_PRETTY_PRINT) ?></pre>
+ </details>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+ </div>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>