From 4014e28e2ac35162aec41ac20c1d79f30dd37913 Mon Sep 17 00:00:00 2001 From: Yarcio Date: Sun, 15 Jun 2025 22:04:08 +0200 Subject: [PATCH] wyniki update --- index.php | 28 +++++++++------ menu.css | 25 +------------ php/functions.php | 14 +++++++- score/index.php | 20 ++++++----- score/questions/index.php | 51 ++++++++++++++++++++++++++ score/score.css | 0 score/tests/index.php | 75 +++++++++++++++++++++++++++++++++++++++ styles/main.css | 38 ++++++++++++++++++++ 8 files changed, 206 insertions(+), 45 deletions(-) create mode 100644 score/questions/index.php delete mode 100644 score/score.css create mode 100644 score/tests/index.php diff --git a/index.php b/index.php index 22e469f..8dc66d1 100644 --- a/index.php +++ b/index.php @@ -8,27 +8,28 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php"; Menu - quiz.czem.eu + -

WitajWitaj na quiz.czem.eu

Wybierz typ quizu

-
+

Jedno Pytanie

Wyświetl jedno pytanie z bazy quizu oraz natychmiastowo dostań na nie odpowiedź

-
+

Test 20 pytań

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

-
+

Własna długość testu

Kiedy 20 pytań to za dużo bądź za mało, zmień długość testu zależnie od swoich potrzeb

@@ -39,19 +40,24 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";

Inne

-
-

Twoje wyniki

-
-
+ +

Twoje wyniki

+
"; + ?> +

Rankingi

-
+

Wyloguj się

-
+

Przejdź do czem.eu

-
+

Kod źródłowy

diff --git a/menu.css b/menu.css index 95e1935..6f372a9 100644 --- a/menu.css +++ b/menu.css @@ -4,28 +4,5 @@ main { min-width: 200px; 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; -} + diff --git a/php/functions.php b/php/functions.php index 6d0bfd2..57048e6 100644 --- a/php/functions.php +++ b/php/functions.php @@ -15,6 +15,18 @@ function jsonMsg($messsage) { } function checkLogin() { session_start(); - if (isset($_SESSION["UID"])) return true; + if (isset($_SESSION["UID"])) + return true; return false; +} +function checkLogged() { + if (isset($_SESSION["username"])) + return true; + return false; +} +function redirectLogged() { + if (!checkLogged()) { + header("Location: /"); + exit(); + } } \ No newline at end of file diff --git a/score/index.php b/score/index.php index 71fee53..215c9ad 100644 --- a/score/index.php +++ b/score/index.php @@ -1,5 +1,6 @@ @@ -7,22 +8,23 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php"; - quiz.czem.eu + Wyniki - quiz.czem.eu -

Twoje wyniki na testy i pytania

-

Przejdź do zapisanych wyników

-
-

Zapisane Testy

-
-
-

Pojedyńcze pytania

-
+

Przejdź do zapisanych wyników

+
+
+

Testy

+
+
+

Pojedyńcze pytania

+
+

Wróć do strony głównej

diff --git a/score/questions/index.php b/score/questions/index.php new file mode 100644 index 0000000..dd56e47 --- /dev/null +++ b/score/questions/index.php @@ -0,0 +1,51 @@ + + + + + + + + Zapisane pytania - quiz.czem.eu + + + + +

Zapisane pytania

+
+
+ 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 ""; + 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 " + + + "; + } + + $stmtQuestion->close(); + } + $stmt->close(); + $conn->close(); + echo "
PytanieOdpowiedziTwoja odpowiedźPrawidłowa?Prawidłowa odpowiedźCzas zapisania odpowiedzi na pytanie
$contentA: $answerA$answeredChar$right$answerChar$questionsTime
B: $answerB
C: $answerC
D: $answerD
"; + ?> +

Powrót

+
+
+ + + \ No newline at end of file diff --git a/score/score.css b/score/score.css deleted file mode 100644 index e69de29..0000000 diff --git a/score/tests/index.php b/score/tests/index.php new file mode 100644 index 0000000..ea6370e --- /dev/null +++ b/score/tests/index.php @@ -0,0 +1,75 @@ + + + + + + + + Zapisane testy - quiz.czem.eu + + + + +

Zapisane testy

+
+
+ 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 ""; + $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 " + + + "; + } + + $stmtQuestion->close(); + } + $stmt->close(); + echo "
NrPytanieOdpowiedziTwoja odpowiedźPrawidłowa?Prawidłowa odpowiedź
$i/$testLength$contentA: $answerA$answeredChar$right$answerChar
B: $answerB
C: $answerC
D: $answerD

Powrót

"; + } 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 ""; + while ($stmt->fetch()) { + $rankAns = $rank ? "W rankingu" : "Nie"; + $pr = $correctAnswers / $testLength * 100; + echo ""; + } + $stmt->close(); + echo "
Przejdź do opowiedzi na testZapisane w rankingu?Poprawne odpowiedziDługość testuWynik testuCzas zapisania testu
$rankAns$correctAnswers$testLength$pr%$testTime

Powrót

"; + } + $conn->close(); + ?> +
+
+ + + \ No newline at end of file diff --git a/styles/main.css b/styles/main.css index c9f0c12..f848a02 100644 --- a/styles/main.css +++ b/styles/main.css @@ -30,9 +30,47 @@ div.wrap { justify-content: center; margin: 10px; } + main form p#info { text-align: center; display: none; color: red; 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); +} \ No newline at end of file