diff --git a/index.php b/index.php index a286ce7..39ce739 100644 --- a/index.php +++ b/index.php @@ -18,7 +18,7 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";

Wybierz typ quizu

-
+

Jedno Pytanie

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

diff --git a/js/functions.js b/js/functions.js deleted file mode 100644 index 4578583..0000000 --- a/js/functions.js +++ /dev/null @@ -1,8 +0,0 @@ -//msg -export function msg(message) { - const output = document.getElementById("info"); - output.innerHTML = result.msg; - output.style.display = "block"; -} - -//password show diff --git a/single/index.php b/single/index.php deleted file mode 100644 index 48d3931..0000000 --- a/single/index.php +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - Pytanie - quiz.czem.eu - - - - - -

Pojedyńcze pytanie - quiz PHP

-
-
- -
-
- - - \ No newline at end of file diff --git a/test/index.php b/test/index.php index c9e8a22..390e1a7 100644 --- a/test/index.php +++ b/test/index.php @@ -30,14 +30,13 @@ include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php"; if (!isset($_SESSION["username"])) echo "

Nie jesteś zalogowany,
więc żaden postęp nie zostanie zapisany!

"; else - echo "

" - ?> - -

Jednak nie chcesz zacząć?

-

Powrót do strony głównej

-
- - - + echo "

"; + ?> + +

Jednak nie chcesz zacząć?

+

Powrót do strony głównej

+ + + - \ No newline at end of file + \ No newline at end of file diff --git a/test/single/index.php b/test/single/index.php new file mode 100644 index 0000000..3a0117e --- /dev/null +++ b/test/single/index.php @@ -0,0 +1,41 @@ + + + + + + + + Test - quiz.czem.eu + + + + + + +

Pojedyńcze pytanie - quiz PHP

+
+
+
+ Wyświetlania pytań: +

+ Losowo
+ Wg nr pytania w bazie
+ +

+

+ Nie jesteś zalogowany,
więc żaden postęp nie zostanie zapisany!

"; + else + echo "

"; + ?> +
+

Jednak nie chcesz zacząć?

+

Powrót do strony głównej

+
+
+ + + \ No newline at end of file diff --git a/test/single/single.js b/test/single/single.js new file mode 100644 index 0000000..df6c52f --- /dev/null +++ b/test/single/single.js @@ -0,0 +1,31 @@ +document.addEventListener("DOMContentLoaded", function () { + async function generateQuestion(formE) { + formE.preventDefault(); + let formData = new FormData(formE.target); + formData.append("generateQuestion", "true") + const response = await fetch("single.php", { + method: "POST", + body: formData, + credentials: "include", + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }); + const result = await response.json(); + output.innerHTML = result.msg; + output.style.display = "block"; + } + const output = document.getElementById("info"); + const mainContent = document.getElementById("content"); + const randomRadio = document.querySelectorAll("input[name='random']"); + randomRadio.forEach(function (inputRadio) { + inputRadio.addEventListener("change", function (QIDnum) { + if (document.getElementById("byQID").checked) { + QIDnum.style.visibility = "visible"; + } else { + QIDnum.style.visibility = "hidden"; + } + }); + }); + document.getElementById("startForm").addEventListener("submit", generateQuestion); +}); \ No newline at end of file diff --git a/test/single/single.php b/test/single/single.php new file mode 100644 index 0000000..f0e48fd --- /dev/null +++ b/test/single/single.php @@ -0,0 +1,12 @@ + 100 || $_POST["testLength"] < 2) - jsonMsg("Test nie może być dłuższy niż 100 pytań ani krótszy niż 2"); + if ($_POST["testLength"] > 100 || $_POST["testLength"] < 1) + jsonMsg("Test nie może być dłuższy niż 100 pytań ani krótszy niż 1"); $conn = connectDB(); $stmt = $conn->prepare("SELECT QID FROM questions"); $stmt->execute();