From 891e8ceeb5bcba4f503b36e0eb8db46671c9d21d Mon Sep 17 00:00:00 2001 From: Wisdurm Date: Thu, 6 Nov 2025 13:16:32 +0200 Subject: [PATCH] refak --- index.php | 7 -- admin.php => public/admin.php | 6 +- public/index.php | 8 ++ login.php => public/login.php | 4 +- database.php => src/database.php | 0 logout.php => src/logout.php | 6 +- taitaja2025.sql | 147 ++++++++++++++++++++++++++++++- 7 files changed, 162 insertions(+), 16 deletions(-) delete mode 100644 index.php rename admin.php => public/admin.php (84%) create mode 100644 public/index.php rename login.php => public/login.php (95%) rename database.php => src/database.php (100%) rename logout.php => src/logout.php (53%) diff --git a/index.php b/index.php deleted file mode 100644 index e8e957b..0000000 --- a/index.php +++ /dev/null @@ -1,7 +0,0 @@ - - - - Kirjaudu sisään - \ No newline at end of file diff --git a/admin.php b/public/admin.php similarity index 84% rename from admin.php rename to public/admin.php index de68c36..404e69b 100644 --- a/admin.php +++ b/public/admin.php @@ -1,5 +1,5 @@ - + Kirjaudu ulos - \ No newline at end of file + diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..3ab7e95 --- /dev/null +++ b/public/index.php @@ -0,0 +1,8 @@ + + + + + Kirjaudu sisään + diff --git a/login.php b/public/login.php similarity index 95% rename from login.php rename to public/login.php index 57ea947..c6d72d7 100644 --- a/login.php +++ b/public/login.php @@ -1,5 +1,5 @@ \ No newline at end of file +?> diff --git a/taitaja2025.sql b/taitaja2025.sql index 8314fae..6747b0c 100644 --- a/taitaja2025.sql +++ b/taitaja2025.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Host: localhost --- Generation Time: Nov 06, 2025 at 09:41 AM +-- Generation Time: Nov 06, 2025 at 12:14 PM -- Server version: 10.4.32-MariaDB -- PHP Version: 8.2.12 @@ -23,6 +23,97 @@ SET time_zone = "+00:00"; -- -------------------------------------------------------- +-- +-- Table structure for table `answers` +-- + +CREATE TABLE `answers` ( + `id` int(11) NOT NULL, + `text` varchar(255) NOT NULL, + `question_id` int(11) NOT NULL, + `correct` tinyint(1) NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `answers` +-- + +INSERT INTO `answers` (`id`, `text`, `question_id`, `correct`) VALUES +(1, '256', 1, 1), +(2, 'JAAKKO', 1, 0), +(3, '16', 1, 0), +(4, '32', 1, 0), +(5, 'Ei määritetty', 5, 1), +(6, '8/3', 5, 0), +(7, '1,5', 5, 0), +(8, '6', 5, 0), +(9, 'Suomi', 3, 0), +(10, 'Marianhamina', 3, 0), +(11, '\\0x0000', 3, 1), +(12, 'Matias Tuikan koti', 3, 0), +(13, 'todo', 7, 0), +(14, 'todo', 7, 0), +(15, 'todq', 7, 1), +(16, 'tuikkamatias@gmail.com', 2, 1), +(17, 'matias.tuikka@gmail.com', 2, 0), +(18, 'matias08@gmail.com', 2, 0), +(19, 'tuikka.matias@protonmail.com', 2, 0), +(20, 'Kannus', 6, 1), +(21, 'Kälviä', 6, 0), +(22, 'Kaustinen', 6, 0), +(23, 'Kalajoki', 6, 0), +(24, 'Etelä-Amerikassa', 4, 1), +(25, 'Afrikassa', 4, 0), +(26, 'Aasia', 4, 0), +(27, 'Oseania', 4, 0); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `questions` +-- + +CREATE TABLE `questions` ( + `id` int(11) NOT NULL, + `question` varchar(255) DEFAULT NULL, + `subject_id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `questions` +-- + +INSERT INTO `questions` (`id`, `question`, `subject_id`) VALUES +(1, 'Mikä on 2^8?', 1), +(2, 'Mikä on Matias Tuikan sähköposti?', 3), +(3, 'Mikä on Helsingin pääkaupunki?', 2), +(4, 'Missä Trinidad ja Tobago sijaitsee?', 2), +(5, 'Mikä on 2 × 4 / 3?', 1), +(6, 'Missä paikkakunnassa Matias asuu?', 3), +(7, 'Mikä on Matiaksen suurin haave?', 3); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `subjects` +-- + +CREATE TABLE `subjects` ( + `id` int(11) NOT NULL, + `name` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `subjects` +-- + +INSERT INTO `subjects` (`id`, `name`) VALUES +(1, 'Matematiikka'), +(2, 'Maantieto'), +(3, 'Matias Tuikka'); + +-- -------------------------------------------------------- + -- -- Table structure for table `users` -- @@ -44,6 +135,26 @@ INSERT INTO `users` (`id`, `name`, `password`) VALUES -- Indexes for dumped tables -- +-- +-- Indexes for table `answers` +-- +ALTER TABLE `answers` + ADD PRIMARY KEY (`id`), + ADD KEY `jaakko` (`question_id`); + +-- +-- Indexes for table `questions` +-- +ALTER TABLE `questions` + ADD PRIMARY KEY (`id`), + ADD KEY `subject_id` (`subject_id`); + +-- +-- Indexes for table `subjects` +-- +ALTER TABLE `subjects` + ADD PRIMARY KEY (`id`); + -- -- Indexes for table `users` -- @@ -54,11 +165,45 @@ ALTER TABLE `users` -- AUTO_INCREMENT for dumped tables -- +-- +-- AUTO_INCREMENT for table `answers` +-- +ALTER TABLE `answers` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28; + +-- +-- AUTO_INCREMENT for table `questions` +-- +ALTER TABLE `questions` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; + +-- +-- AUTO_INCREMENT for table `subjects` +-- +ALTER TABLE `subjects` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; + -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `answers` +-- +ALTER TABLE `answers` + ADD CONSTRAINT `jaakko` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`); + +-- +-- Constraints for table `questions` +-- +ALTER TABLE `questions` + ADD CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`); COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -- 2.47.3