-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 02, 2024 at 08:17 PM
-- Server version: 10.4.27-MariaDB
-- PHP Version: 8.0.25

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `quiz_db`
--

-- --------------------------------------------------------

--
-- Table structure for table `answers`
--

CREATE TABLE `ja_nswers` (
  `id` int(11) NOT NULL,
  `question_id` int(11) DEFAULT NULL,
  `answer` text NOT NULL,
  `is_correct` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `answers`
--

INSERT INTO `ja_answers` (`id`, `question_id`, `answer`, `is_correct`) VALUES
(221, 57, '2', 0),
(222, 57, '4', 1),
(223, 57, '8', 0),
(228, 60, '1', 0),
(229, 60, '2', 1),
(230, 60, '3', 0),
(231, 60, '4', 0),
(232, 61, '5', 0),
(233, 61, '6', 1),
(234, 61, '7', 0),
(235, 61, '8', 0),
(236, 62, 'a', 1),
(237, 62, 'a', 0),
(238, 62, 'a', 0),
(239, 62, 'a', 0),
(240, 63, 'a', 1),
(241, 63, 'a', 0),
(242, 63, 'a', 0),
(243, 63, 'a', 0),
(244, 64, '2', 0),
(245, 64, '8', 0),
(246, 64, '4', 1);

-- --------------------------------------------------------

--
-- Table structure for table `questions`
--

CREATE TABLE `ja_questions` (
  `id` int(11) NOT NULL,
  `test_id` int(11) DEFAULT NULL,
  `question` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `questions`
--

INSERT INTO `ja_questions` (`id`, `test_id`, `question`) VALUES
(57, 76, '2+2?'),
(60, 79, 'jautajums1'),
(61, 79, 'jautajums2'),
(62, 79, 'a'),
(63, 79, 'a'),
(64, 80, '2+2?');

-- --------------------------------------------------------

--
-- Table structure for table `tests`
--

CREATE TABLE `ja_tests` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `creator_id` int(11) DEFAULT NULL,
  `description` text NOT NULL,
  `category` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `tests`
--

INSERT INTO `ja_tests` (`id`, `name`, `creator_id`, `description`, `category`) VALUES
(76, 'test1123', 44, 'tests 1 tests', 'test123'),
(79, 'test3', 43, 'test3', 'test3'),
(80, 'Pirmais tests', 55, 'Šis ir pirmais tests.', 'Matemātika');

-- --------------------------------------------------------

--
-- Table structure for table `test_results`
--

CREATE TABLE `ja_test_results` (
  `id` int(11) NOT NULL,
  `test_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `score` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `username` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `test_results`
--

INSERT INTO `ja_test_results` (`id`, `test_id`, `user_id`, `score`, `created_at`, `username`) VALUES
(86, 76, 43, 1, '2024-06-01 17:34:05', NULL),
(87, 76, 43, 1, '2024-06-01 17:39:59', NULL),
(88, 76, 43, 1, '2024-06-01 17:40:11', NULL),
(89, 76, 43, 1, '2024-06-01 17:41:52', NULL),
(90, 76, 43, 0, '2024-06-01 17:41:57', NULL),
(91, 79, 43, 1, '2024-06-01 18:15:13', NULL),
(92, 76, 43, 1, '2024-06-02 11:12:21', NULL),
(93, 80, 55, 1, '2024-06-02 13:57:31', NULL),
(94, 80, 44, 1, '2024-06-02 17:22:56', NULL),
(95, 79, 44, 2, '2024-06-02 17:23:04', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `ja_users` (
  `id` int(11) NOT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `role` varchar(255) NOT NULL,
  `class` varchar(255) DEFAULT NULL,
  `is_admin` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `ja_users` (`id`, `username`, `password`, `email`, `role`, `class`, `is_admin`) VALUES
(42, 'Aleksandrs212', '$2y$10$w.ypXm5oQjO75D0fyUmerOEBcXMDQ5d2IgRyMC8SVFMIHHpVULN4e', 'aleksis212458@gmail.com', '', NULL, 0),
(43, 'test102131', '$2y$10$BTWyyoIEC0hC4saqR8GMFe2wk4abiadI3dM9ezDZEP00nIX1ObPGK', 'test10132123312@gmail.com', 'student', 'testesana', 0),
(44, 'Skolotajs', '$2y$10$icxTA3tbDbOCDRRGgoK6B.463SAnqOxJ90aPvhWqL7jOI/fqw2aYG', 'test20@gmail.com', 'teacher', '', 0),
(54, 'admin', '$2y$10$lMXiJb1CilL0XKUxhKxmlu/UcDqdzFi4nNba3E5qGJZcB2.6EJ1Le', 'aleksis2458@gmail.com', 'student', 'admin', 1),
(55, 'Aleksandrs123', '$2y$10$lNH29uQfcRQGpP0INUsFKurZphu.nfH5sMi838GLgj1Fw2zLP4UBa', 'aleksandrs123@gmail.com', 'student', '410', 0);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `answers`
--
ALTER TABLE `ja_answers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_question_id` (`question_id`);

--
-- Indexes for table `questions`
--
ALTER TABLE `jaquestions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_test_id` (`test_id`);

--
-- Indexes for table `tests`
--
ALTER TABLE `jatests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `creator_id` (`creator_id`);

--
-- Indexes for table `test_results`
--
ALTER TABLE `ja_test_results`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `fk_test_results_test_id` (`test_id`);

--
-- Indexes for table `users`
--
ALTER TABLE `ja_users`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `answers`
--
ALTER TABLE `ja_answers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=247;

--
-- AUTO_INCREMENT for table `questions`
--
ALTER TABLE `ja_questions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=65;

--
-- AUTO_INCREMENT for table `tests`
--
ALTER TABLE `ja_tests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=85;

--
-- AUTO_INCREMENT for table `test_results`
--
ALTER TABLE `ja_test_results`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=96;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `ja_users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=56;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `answers`
--
ALTER TABLE `ja_answers`
  ADD CONSTRAINT `fk_question_id` FOREIGN KEY (`question_id`) REFERENCES `ja_questions` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `questions`
--
ALTER TABLE `ja_questions`
  ADD CONSTRAINT `fk_test_id` FOREIGN KEY (`test_id`) REFERENCES `ja_tests` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `tests`
--
ALTER TABLE `ja_tests`
  ADD CONSTRAINT `jtests_ibfk_1` FOREIGN KEY (`creator_id`) REFERENCES `ja_users` (`id`);

--
-- Constraints for table `test_results`
--
ALTER TABLE `ja_test_results`
  ADD CONSTRAINT `fk_test_results_test_id` FOREIGN KEY (`test_id`) REFERENCES `ja_tests` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `test_results_ibfk_1` FOREIGN KEY (`test_id`) REFERENCES `ja_tests` (`id`),
  ADD CONSTRAINT `test_results_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `ja_users` (`id`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
