This commit is contained in:
Yarcio 2025-06-15 22:38:41 +02:00
parent 4014e28e2a
commit 58f73367b3
8 changed files with 81 additions and 4 deletions

49
rank/index.php Normal file
View file

@ -0,0 +1,49 @@
<?php
include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
?>
<!DOCTYPE html>
<html lang="pl-PL">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ranking - quiz.czem.eu</title>
<meta name="description" content="quiz czem.eu">
<link rel="stylesheet" href="/styles/main.css">
<link rel="stylesheet" href="menu.css">
</head>
<body>
<h1>Ranking</h1>
<div class="wrap">
<main>
<?php
$conn = connectDB();
$stmt = $conn->prepare("SELECT correctAnswers, UID, testTime FROM tests WHERE rank = 1 ORDER BY correctAnswers DESC, testTime ASC");
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($correctAnswers, $UID, $testTime);
echo "<table class='rank'><th>Miejsce</th><th>Nazwa użytkownika</th><th>Poprawne</th><th>Wynik</th><th>Czas zapisania testu</th>";
$i = 0;
while ($stmt->fetch()) {
$stmtUser = $conn->prepare("SELECT username FROM users WHERE UID = ?");
$stmtUser->bind_param("i", $UID);
$stmtUser->execute();
$stmtUser->bind_result($username);
if ($stmtUser->fetch()) {
$i++;
$pr = $correctAnswers/20*100;
echo "<tr><td>$i</td><td>$username</td><td>$correctAnswers/20</td><td>$pr%</td><td>$testTime</td></tr>";
}
$stmtUser->close();
}
$stmt->close();
$conn->close();
echo "</table>"
?>
<h3><a href="../">Powrót</a></h3>
</main>
</div>
</body>
</html>

View file

@ -10,6 +10,7 @@ redirectLogged();
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wyniki - quiz.czem.eu</title>
<link rel="stylesheet" href="/styles/main.css">
<link rel="stylesheet" href="/styles/score.css">
</head>
<body>

View file

@ -10,6 +10,7 @@ redirectLogged();
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Zapisane pytania - quiz.czem.eu</title>
<link rel="stylesheet" href="/styles/main.css">
<link rel="stylesheet" href="/styles/score.css">
</head>
<body>

View file

@ -10,6 +10,7 @@ redirectLogged();
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Zapisane testy - quiz.czem.eu</title>
<link rel="stylesheet" href="/styles/main.css">
<link rel="stylesheet" href="/styles/score.css">
</head>
<body>

View file

@ -71,6 +71,18 @@ main article div.clickable h3 {
table,
table th,
table td {
border-spacing: 3px 20px;
border-spacing: 0;
border: 1px solid var(--border-basic);
}
table.rank tr:nth-child(2) {
background-color: gold;
}
table.rank tr:nth-child(3) {
background-color: silver;
}
table.rank tr:nth-child(4) {
background-color: brown;
}
table.rank td{
padding: 10px;
}

8
styles/score.css Normal file
View file

@ -0,0 +1,8 @@
@import url("/styles/variables.css");
table,
table th,
table td {
border-spacing: 3px 20px;
border: 1px solid var(--border-basic);
}

View file

@ -18,6 +18,7 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
<div class="wrap">
<main id="content">
<h3>Rozpocznij test</h3>
<p><sub>UWAGA W PYTANIACH MOGĄ WYSTĘPOWAĆ BŁĘDY</sub></p>
<form id="startForm">
<?php
if (isset($_GET["own"]))

View file

@ -18,12 +18,16 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
<div class="wrap">
<main id="content">
<h3>Rozwiąż pytanie</h3>
<p><sub>UWAGA W PYTANIACH MOGĄ WYSTĘPOWAĆ BŁĘDY</sub></p>
<form id="startForm">
Wyświetlania pytań:
<p style="text-align: left;">
<input type="radio" name="random" value="true" onchange="lastRandomQuestion=true;" checked> Losowo<br>
<input type="radio" name="random" value="false" onchange="lastRandomQuestion=false;" id="byQID"> Wg nr pytania w bazie<br>
<span id="QIDnum" style="visibility: hidden;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nr: <input type="number" name="QID" min="1" max="9999" value="1"></span>
<input type="radio" name="random" value="true" onchange="lastRandomQuestion=true;" checked>
Losowo<br>
<input type="radio" name="random" value="false" onchange="lastRandomQuestion=false;" id="byQID"> Wg
nr pytania w bazie<br>
<span id="QIDnum" style="visibility: hidden;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nr: <input
type="number" name="QID" min="1" max="9999" value="1"></span>
</p>
<p><input type="submit" value="Znajdź pytanie"></p>
<?php