wyniki update
This commit is contained in:
parent
b140f84fd4
commit
4014e28e2a
8 changed files with 206 additions and 45 deletions
28
index.php
28
index.php
|
@ -8,27 +8,28 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Menu - quiz.czem.eu</title>
|
<title>Menu - quiz.czem.eu</title>
|
||||||
|
<meta name="description" content="quiz czem.eu">
|
||||||
<link rel="stylesheet" href="/styles/main.css">
|
<link rel="stylesheet" href="/styles/main.css">
|
||||||
<link rel="stylesheet" href="menu.css">
|
<link rel="stylesheet" href="menu.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Witaj<i><?php if (isset($_SESSION["username"]))
|
<h1>Witaj<i><?php if (checkLogged())
|
||||||
echo " " . $_SESSION["username"]; ?> </i>na quiz.czem.eu</h1>
|
echo " " . $_SESSION["username"]; ?> </i>na quiz.czem.eu</h1>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<main>
|
<main>
|
||||||
<h2>Wybierz typ quizu</h2>
|
<h2>Wybierz typ quizu</h2>
|
||||||
<article>
|
<article>
|
||||||
<div onclick="window.location.href = '/test/single/'">
|
<div onclick="window.location.href = '/test/single/'" class="clickable">
|
||||||
<h3>Jedno Pytanie</h3>
|
<h3>Jedno Pytanie</h3>
|
||||||
<p>Wyświetl jedno pytanie z bazy quizu oraz natychmiastowo dostań na nie odpowiedź</p>
|
<p>Wyświetl jedno pytanie z bazy quizu oraz natychmiastowo dostań na nie odpowiedź</p>
|
||||||
</div>
|
</div>
|
||||||
<div onclick="window.location.href = '/test/'">
|
<div onclick="window.location.href = '/test/'" class="clickable">
|
||||||
<h3>Test 20 pytań</h3>
|
<h3>Test 20 pytań</h3>
|
||||||
<p>Wykonaj test 20 pytań, wynik oraz prawidłowość odpowiedzi pojawi się dopiero po oddaniu, w
|
<p>Wykonaj test 20 pytań, wynik oraz prawidłowość odpowiedzi pojawi się dopiero po oddaniu, w
|
||||||
trakcie możesz zmieniać odpowiedzi na już rozwiązane pytania</p>
|
trakcie możesz zmieniać odpowiedzi na już rozwiązane pytania</p>
|
||||||
</div>
|
</div>
|
||||||
<div onclick="window.location.href = '/test/?own'">
|
<div onclick="window.location.href = '/test/?own'" class="clickable">
|
||||||
<h3>Własna długość testu</h3>
|
<h3>Własna długość testu</h3>
|
||||||
<p>Kiedy 20 pytań to za dużo bądź za mało, zmień długość testu zależnie od swoich potrzeb</p>
|
<p>Kiedy 20 pytań to za dużo bądź za mało, zmień długość testu zależnie od swoich potrzeb</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,19 +40,24 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
||||||
<main>
|
<main>
|
||||||
<h2>Inne</h2>
|
<h2>Inne</h2>
|
||||||
<article>
|
<article>
|
||||||
<div onclick="window.location.href = '/score/'">
|
<?php
|
||||||
<h3>Twoje wyniki</h3>
|
if (checkLogged())
|
||||||
</div>
|
echo "
|
||||||
<div onclick="window.location.href = '/'">
|
<div onclick='window.location.href = `/score/`' class='clickable'>
|
||||||
|
<h3>Twoje wyniki</h3>
|
||||||
|
</div>";
|
||||||
|
?>
|
||||||
|
<div onclick="window.location.href = '/rank/'" class="clickable">
|
||||||
<h3>Rankingi</h3>
|
<h3>Rankingi</h3>
|
||||||
</div>
|
</div>
|
||||||
<div onclick="window.location.href = '/login/'">
|
<div onclick="window.location.href = '/login/'" class="clickable">
|
||||||
<h3>Wyloguj się</h3>
|
<h3>Wyloguj się</h3>
|
||||||
</div>
|
</div>
|
||||||
<div onclick="window.open('https://czem.eu/', '_blank').focus()">
|
<div onclick="window.open('https://czem.eu/', '_blank').focus()" class="clickable">
|
||||||
<h3>Przejdź do czem.eu</h3>
|
<h3>Przejdź do czem.eu</h3>
|
||||||
</div>
|
</div>
|
||||||
<div onclick="window.open('https://drive.czem.eu/index.php/s/fraNKJTyi4wN7Nw', '_blank').focus()">
|
<div onclick="window.open('https://drive.czem.eu/index.php/s/fraNKJTyi4wN7Nw', '_blank').focus()"
|
||||||
|
class="clickable">
|
||||||
<h3>Kod źródłowy</h3>
|
<h3>Kod źródłowy</h3>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|
25
menu.css
25
menu.css
|
@ -4,28 +4,5 @@ main {
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
}
|
}
|
||||||
main article {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
}
|
|
||||||
main article div {
|
|
||||||
margin: 30px;
|
|
||||||
padding: 20px 35px;
|
|
||||||
width: 250px;
|
|
||||||
background-color: var(--color-alt);
|
|
||||||
border: 1px solid var(--border-basic);
|
|
||||||
border-radius: 20px;
|
|
||||||
transition: 0.2s;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
main article div:hover {
|
|
||||||
background-color: var(--color-alt-hover);
|
|
||||||
}
|
|
||||||
main article div:active {
|
|
||||||
background-color: var(--color-alt-active);
|
|
||||||
}
|
|
||||||
main article div h3 {
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,18 @@ function jsonMsg($messsage) {
|
||||||
}
|
}
|
||||||
function checkLogin() {
|
function checkLogin() {
|
||||||
session_start();
|
session_start();
|
||||||
if (isset($_SESSION["UID"])) return true;
|
if (isset($_SESSION["UID"]))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
function checkLogged() {
|
||||||
|
if (isset($_SESSION["username"]))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
function redirectLogged() {
|
||||||
|
if (!checkLogged()) {
|
||||||
|
header("Location: /");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
||||||
|
redirectLogged();
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="pl-PL">
|
<html lang="pl-PL">
|
||||||
|
@ -7,22 +8,23 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>quiz.czem.eu</title>
|
<title>Wyniki - quiz.czem.eu</title>
|
||||||
<link rel="stylesheet" href="/styles/main.css">
|
<link rel="stylesheet" href="/styles/main.css">
|
||||||
<link rel="stylesheet" href="score.css">
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Twoje wyniki na testy i pytania</h1>
|
<h1>Twoje wyniki na testy i pytania</h1>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<main>
|
<main>
|
||||||
<h3>Przejdź do zapisanych wyników</h3>
|
<h2>Przejdź do zapisanych wyników</h2>
|
||||||
<div onclick="window.location.href = 'tests/'">
|
<article>
|
||||||
<h3>Zapisane Testy</h3>
|
<div onclick="window.location.href = 'tests/'" class="clickable">
|
||||||
</div>
|
<h3>Testy</h3>
|
||||||
<div onclick="window.location.href = 'questions/'">
|
</div>
|
||||||
<h3>Pojedyńcze pytania</h3>
|
<div onclick="window.location.href = 'questions/'" class="clickable">
|
||||||
</div>
|
<h3>Pojedyńcze pytania</h3>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
<h3><a href="/">Wróć do strony głównej</a></h3>
|
<h3><a href="/">Wróć do strony głównej</a></h3>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
51
score/questions/index.php
Normal file
51
score/questions/index.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
||||||
|
redirectLogged();
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl-PL">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<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">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Zapisane pytania</h1>
|
||||||
|
<div class="wrap">
|
||||||
|
<main>
|
||||||
|
<?php
|
||||||
|
$conn = connectDB();
|
||||||
|
$stmt = $conn->prepare("SELECT QID, answerChar, correct, questionTime FROM questionanswers WHERE UID = ?");
|
||||||
|
$stmt->bind_param("i", $_SESSION["UID"]);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->store_result();
|
||||||
|
$stmt->bind_result($QID, $answeredChar, $correct, $questionsTime);
|
||||||
|
echo "<table><tr><th>Pytanie</th><th>Odpowiedzi</th><th>Twoja odpowiedź</th><th>Prawidłowa?</th><th>Prawidłowa odpowiedź</th><th>Czas zapisania odpowiedzi na pytanie</th></tr>";
|
||||||
|
while ($stmt->fetch()) {
|
||||||
|
$stmtQuestion = $conn->prepare("SELECT content, answerA, answerB, answerC, answerD, answerChar FROM questions WHERE QID = ?");
|
||||||
|
$stmtQuestion->bind_param("i", $QID);
|
||||||
|
$stmtQuestion->execute();
|
||||||
|
$stmtQuestion->bind_result($content, $answerA, $answerB, $answerC, $answerD, $answerChar);
|
||||||
|
if ($stmtQuestion->fetch()) {
|
||||||
|
$right = $correct ? "tak" : "nie";
|
||||||
|
echo "<tr><td rowspan='4'>$content</td><td>A: $answerA</td><td rowspan='4'>$answeredChar</td><td rowspan='4'>$right</td><td rowspan='4'>$answerChar</td><td rowspan='4'>$questionsTime</td></tr>
|
||||||
|
<tr><td>B: $answerB</td></tr>
|
||||||
|
<tr><td>C: $answerC</td></tr>
|
||||||
|
<tr><td>D: $answerD</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmtQuestion->close();
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
$conn->close();
|
||||||
|
echo "</table>";
|
||||||
|
?>
|
||||||
|
<h3><a href="../">Powrót</a></h3>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
75
score/tests/index.php
Normal file
75
score/tests/index.php
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
||||||
|
redirectLogged();
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl-PL">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<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">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Zapisane testy</h1>
|
||||||
|
<div class="wrap">
|
||||||
|
<main>
|
||||||
|
<?php
|
||||||
|
$conn = connectDB();
|
||||||
|
if (isset($_GET["TID"])) {
|
||||||
|
$stmt = $conn->prepare("SELECT testLength FROM tests WHERE UID = ? AND TID = ?");
|
||||||
|
$stmt->bind_param("ii", $_SESSION["UID"], $_GET["TID"]);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($testLength);
|
||||||
|
if (!$stmt->fetch()) {
|
||||||
|
exit("ID testu nie zgadza się z ID użytkownika");
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
$stmt = $conn->prepare("SELECT QID, answeredChar, correct FROM testanswers WHERE TID = ?");
|
||||||
|
$stmt->bind_param("i", $_GET["TID"]);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->store_result();
|
||||||
|
$stmt->bind_result($QID, $answeredChar, $correct);
|
||||||
|
echo "<table><tr><th>Nr</th><th>Pytanie</th><th>Odpowiedzi</th><th>Twoja odpowiedź</th><th>Prawidłowa?</th><th>Prawidłowa odpowiedź</th></tr>";
|
||||||
|
$i = 0;
|
||||||
|
while ($stmt->fetch()) {
|
||||||
|
$stmtQuestion = $conn->prepare("SELECT content, answerA, answerB, answerC, answerD, answerChar FROM questions WHERE QID = ?");
|
||||||
|
$stmtQuestion->bind_param("i", $QID);
|
||||||
|
$stmtQuestion->execute();
|
||||||
|
$stmtQuestion->bind_result($content, $answerA, $answerB, $answerC, $answerD, $answerChar);
|
||||||
|
if ($stmtQuestion->fetch()) {
|
||||||
|
$i++;
|
||||||
|
$right = $correct ? "tak" : "nie";
|
||||||
|
echo "<tr><td rowspan='4'>$i/$testLength</td><td rowspan='4'>$content</td><td>A: $answerA</td><td rowspan='4'>$answeredChar</td><td rowspan='4'>$right</td><td rowspan='4'>$answerChar</td></tr>
|
||||||
|
<tr><td>B: $answerB</td></tr>
|
||||||
|
<tr><td>C: $answerC</td></tr>
|
||||||
|
<tr><td>D: $answerD</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmtQuestion->close();
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
echo "</table><h3><a href='../tests/'>Powrót</a></h3>";
|
||||||
|
} else {
|
||||||
|
$stmt = $conn->prepare("SELECT TID, rank, correctAnswers, testLength, testTime FROM tests WHERE UID = ?");
|
||||||
|
$stmt->bind_param("i", $_SESSION["UID"]);
|
||||||
|
$stmt->bind_result($TID, $rank, $correctAnswers, $testLength, $testTime);
|
||||||
|
$stmt->execute();
|
||||||
|
echo "<table><tr><th>Przejdź do opowiedzi na test</th><th>Zapisane w rankingu?</th><th>Poprawne odpowiedzi</th><th>Długość testu</th><th>Wynik testu</th><th>Czas zapisania testu</th></tr>";
|
||||||
|
while ($stmt->fetch()) {
|
||||||
|
$rankAns = $rank ? "W rankingu" : "Nie";
|
||||||
|
$pr = $correctAnswers / $testLength * 100;
|
||||||
|
echo "<tr><td><input type='button' onclick='window.location.href += `?TID=$TID`' value='Wyświetl'></td><td>$rankAns</td><td>$correctAnswers</td><td>$testLength</td><td>$pr%</td><td>$testTime</td></tr>";
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
echo "</table><h3><a href='../'>Powrót</a></h3>";
|
||||||
|
}
|
||||||
|
$conn->close();
|
||||||
|
?>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -30,9 +30,47 @@ div.wrap {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
main form p#info {
|
main form p#info {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: none;
|
display: none;
|
||||||
color: red;
|
color: red;
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main article {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
}
|
||||||
|
|
||||||
|
main article div.clickable {
|
||||||
|
margin: 30px;
|
||||||
|
padding: 20px 35px;
|
||||||
|
width: 250px;
|
||||||
|
background-color: var(--color-alt);
|
||||||
|
border: 1px solid var(--border-basic);
|
||||||
|
border-radius: 20px;
|
||||||
|
transition: 0.2s;
|
||||||
|
user-select: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
main article div.clickable:hover {
|
||||||
|
background-color: var(--color-alt-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
main article div.clickable:active {
|
||||||
|
background-color: var(--color-alt-active);
|
||||||
|
}
|
||||||
|
|
||||||
|
main article div.clickable h3 {
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table,
|
||||||
|
table th,
|
||||||
|
table td {
|
||||||
|
border-spacing: 3px 20px;
|
||||||
|
border: 1px solid var(--border-basic);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue