-- https://www.phpmyadmin.net/
--

START TRANSACTION;



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

--
-- Table structure for table `quiz_answers`
--

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

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

--
-- Table structure for table `quiz_attempts`
--

CREATE TABLE `quiz_attempts` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `question_id` int(11) DEFAULT NULL,
  `selected_answer_id` int(11) DEFAULT NULL,
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `quiz_questions`
--

CREATE TABLE `quiz_questions` (
  `id` int(11) NOT NULL,
  `question_text` text NOT NULL,
  `option_a` varchar(255) NOT NULL,
  `option_b` varchar(255) NOT NULL,
  `option_c` varchar(255) NOT NULL,
  `option_d` varchar(255) NOT NULL,
  `correct_option` char(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `quiz_questions`
--

INSERT INTO `quiz_questions` (`id`, `question_text`, `option_a`, `option_b`, `option_c`, `option_d`, `correct_option`) VALUES
(1, 'What is the capital of France?', 'Paris', 'Berlin', 'London', 'Rome', 'A'),
(2, 'Which planet is known as the Red Planet?', 'Mars', 'Venus', 'Jupiter', 'Saturn', 'A'),
(3, 'What is the largest mammal?', 'Elephant', 'Blue Whale', 'Giraffe', 'Horse', 'B'),
(4, 'what is the name of city of rwanda', 'kigali', 'burundi', 'kabare', 'gasabo', 'a'),
(5, 'how many district in kigali', '4', '3', '12', '2', '3');

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

--
-- Table structure for table `user_scores`
--

CREATE TABLE `user_scores` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `score` float DEFAULT NULL,
  `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `user_scores`
--

INSERT INTO `user_scores` (`id`, `user_id`, `score`, `timestamp`) VALUES
(1, 7, 100, '2024-01-18 08:04:25'),
(2, 7, 100, '2024-01-18 08:04:56'),
(3, 8, 100, '2024-01-18 08:06:06'),
(4, 1, 0, '2024-01-18 08:14:33'),
(5, 1, 0, '2024-01-18 08:15:33'),
(6, 1, 0, '2024-01-18 08:18:08'),
(7, 1, 100, '2024-01-18 08:18:41'),
(8, 1, 66.6667, '2024-01-18 08:25:24'),
(9, 5, 33.3333, '2024-01-18 08:26:38'),
(10, 8, 100, '2024-01-18 08:27:13'),
(11, 1, 66.6667, '2024-01-18 08:42:14'),
(12, 11, 66.6667, '2024-01-18 08:54:01'),
(13, 12, 100, '2024-01-18 10:07:15'),
(14, 1, 0, '2024-01-18 10:12:26'),
(15, 13, 66.6667, '2024-01-18 11:08:08'),
(16, 1, 100, '2024-01-18 11:16:57'),
(17, 14, 66.6667, '2024-01-31 05:27:30'),
(18, 15, 0, '2024-01-31 09:30:29'),
(19, 15, 100, '2024-01-31 09:30:39'),
(20, 15, 66.6667, '2024-01-31 09:30:45'),
(21, 15, 66.6667, '2024-01-31 11:05:25'),
(22, 15, 100, '2024-02-02 05:23:04'),
(23, 15, 100, '2024-02-02 06:39:23'),
(24, 15, 100, '2024-02-02 06:44:36'),
(25, 15, 66.6667, '2024-02-02 06:46:56'),
(26, 16, 66.6667, '2024-02-02 07:19:24'),
(27, 16, 100, '2024-02-02 07:19:46'),
(28, 14, 66.6667, '2024-02-14 07:15:19'),
(29, 14, 66.6667, '2024-02-14 07:15:30'),
(30, 14, 66.6667, '2024-02-14 07:18:41'),
(31, 14, 100, '2024-02-14 07:23:28'),
(32, 14, 100, '2024-02-14 07:26:43'),
(33, 14, 66.6667, '2024-02-14 07:27:09'),
(34, 14, 66.6667, '2024-02-14 07:27:40'),
(35, 14, 66.6667, '2024-02-14 07:31:09'),
(36, 14, 66.6667, '2024-02-14 07:48:51'),
(38, 14, 66.6667, '2024-02-14 07:54:13'),
(39, 14, 66.6667, '2024-02-14 07:55:15'),
(40, 14, 66.6667, '2024-02-14 08:01:45'),
(41, 14, 100, '2024-02-14 08:02:03'),
(42, 14, 66.6667, '2024-02-14 08:03:30'),
(43, 14, 100, '2024-02-14 08:04:00'),
(44, 14, 100, '2024-02-14 08:04:29'),
(45, 14, 100, '2024-02-14 08:08:23'),
(46, 14, 100, '2024-02-14 08:08:41'),
(47, 14, 0, '2024-02-14 08:11:51'),
(48, 14, 66.6667, '2024-02-14 08:12:15'),
(49, 14, 66.6667, '2024-02-14 08:14:19'),
(50, 14, 100, '2024-02-14 08:14:51'),
(51, 14, 33.3333, '2024-02-14 08:15:11'),
(52, 14, 66.6667, '2024-02-14 08:16:34'),
(53, 14, 66.6667, '2024-02-14 08:19:54'),
(54, 14, 66.6667, '2024-02-14 08:19:59'),
(55, 14, 33.3333, '2024-02-14 08:20:11'),
(56, 14, 66.6667, '2024-02-14 08:20:41'),
(57, 14, 33.3333, '2024-02-14 08:20:49'),
(58, 14, 33.3333, '2024-02-14 08:21:17'),
(59, 14, 33.3333, '2024-02-14 08:21:31'),
(60, 14, 33.3333, '2024-02-14 08:21:46'),
(61, 14, 33.3333, '2024-02-14 08:22:12'),
(62, 14, 66.6667, '2024-02-14 08:22:20'),
(63, 14, 100, '2024-02-14 08:22:29'),
(64, 14, 100, '2024-02-14 08:22:45'),
(65, 14, 100, '2024-02-14 08:26:52'),
(66, 14, 100, '2024-02-14 08:27:11'),
(67, 14, 33.3333, '2024-02-14 08:36:19'),
(68, 14, 100, '2024-02-14 08:36:30'),
(69, 14, 100, '2024-02-14 08:38:46'),
(70, 14, 100, '2024-02-14 08:44:11'),
(71, 14, 100, '2024-02-14 08:47:45'),
(72, 14, 100, '2024-02-14 08:48:58'),
(73, 14, 100, '2024-02-14 08:50:15'),
(74, 14, 100, '2024-02-14 08:53:48'),
(75, 14, 100, '2024-02-14 08:57:12'),
(76, 14, 100, '2024-02-14 08:57:28'),
(77, 14, 100, '2024-02-14 08:59:46'),
(78, 14, 100, '2024-02-14 09:00:45'),
(79, 14, 100, '2024-02-14 09:05:10'),
(80, 14, 100, '2024-02-14 09:07:36'),
(81, 14, 100, '2024-02-14 09:08:24'),
(82, 14, 100, '2024-02-14 13:18:06'),
(83, 14, 100, '2024-02-14 13:21:17'),
(84, 14, 66.6667, '2024-02-14 13:28:18'),
(85, 14, 100, '2024-02-14 13:44:26'),
(86, 14, 100, '2024-02-14 13:46:21'),
(87, 14, 100, '2024-02-14 13:48:21'),
(88, 14, 100, '2024-02-14 13:49:29'),
(89, 14, 100, '2024-02-14 13:50:57'),
(90, 14, 100, '2024-02-14 13:51:26'),
(91, 14, 100, '2024-02-14 13:52:03'),
(92, 14, 100, '2024-02-14 13:56:33'),
(93, 14, 100, '2024-02-14 13:57:57'),
(94, 14, 100, '2024-02-14 13:59:48'),
(95, 14, 100, '2024-02-14 14:04:11'),
(96, 14, 100, '2024-02-14 14:05:35'),
(97, 14, 100, '2024-02-14 14:05:56'),
(98, 14, 100, '2024-02-14 14:07:16'),
(99, 14, 100, '2024-02-14 14:11:47'),
(100, 14, 100, '2024-02-14 14:12:46'),
(101, 14, 100, '2024-02-14 14:13:40'),
(102, 14, 100, '2024-02-14 14:14:33'),
(103, 14, 100, '2024-02-14 14:15:20'),
(104, 14, 66.6667, '2024-02-14 14:37:45'),
(105, 14, 100, '2024-02-17 08:42:38'),
(106, 14, 100, '2024-02-17 08:47:34'),
(107, 14, 66.6667, '2024-02-17 08:49:16'),
(108, 14, 33.3333, '2024-02-17 08:49:29'),
(109, 14, 0, '2024-02-17 09:27:34'),
(110, 14, 33.3333, '2024-02-17 09:28:02'),
(111, 14, 0, '2024-02-17 09:28:33'),
(112, 14, 66.6667, '2024-02-17 09:32:41'),
(113, 14, 66.6667, '2024-02-17 09:34:43'),
(114, 14, 0, '2024-02-17 09:35:15'),
(115, 14, 66.6667, '2024-02-17 09:38:30'),
(116, 14, 66.6667, '2024-02-17 09:40:06'),
(117, 14, 66.6667, '2024-02-17 09:45:12'),
(118, 14, 66.6667, '2024-02-17 09:45:59'),
(119, 14, 33.3333, '2024-02-17 09:46:20'),
(120, 14, 66.6667, '2024-02-17 09:49:43'),
(121, 14, 66.6667, '2024-02-17 09:53:06'),
(122, 14, 66.6667, '2024-02-17 09:55:27'),
(123, 14, 66.6667, '2024-02-17 09:56:01'),
(124, 14, 66.6667, '2024-02-17 09:56:29'),
(125, 14, 66.6667, '2024-02-17 09:56:46'),
(126, 14, 66.6667, '2024-02-17 10:01:59'),
(127, 14, 66.6667, '2024-02-17 10:05:27'),
(128, 14, 66.6667, '2024-02-17 10:05:35'),
(129, 14, 66.6667, '2024-02-17 10:07:07'),
(130, 14, 0, '2024-02-17 10:10:06'),
(131, 14, 33.3333, '2024-02-17 10:10:21'),
(132, 14, 0, '2024-02-17 10:10:57'),
(133, 14, 33.3333, '2024-02-17 10:11:19'),
(134, 14, 33.3333, '2024-02-17 10:12:06'),
(135, 14, 66.6667, '2024-02-17 10:12:20'),
(136, 14, 0, '2024-02-17 10:14:05'),
(137, 14, 66.6667, '2024-02-17 10:14:16'),
(138, 14, 66.6667, '2024-02-17 10:36:21'),
(139, 14, 66.6667, '2024-02-17 10:36:38'),
(140, 14, 66.6667, '2024-02-17 10:36:52'),
(141, 14, 0, '2024-02-17 10:37:28'),
(142, 14, 0, '2024-02-17 11:46:52'),
(143, 14, 75, '2024-02-17 12:21:39'),
(144, 14, 50, '2024-02-19 08:58:22'),
(145, 14, 25, '2024-02-19 08:59:20');

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

--
-- Indexes for table `quiz_attempts`
--
ALTER TABLE `quiz_attempts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `question_id` (`question_id`),
  ADD KEY `selected_answer_id` (`selected_answer_id`);

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

--
-- Indexes for table `user_scores`
--
ALTER TABLE `user_scores`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- AUTO_INCREMENT for table `quiz_answers`
--
ALTER TABLE `quiz_answers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `quiz_questions`
--
ALTER TABLE `quiz_questions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `user_scores`
--
ALTER TABLE `user_scores`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=146;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `quiz_answers`
--
ALTER TABLE `quiz_answers`
  ADD CONSTRAINT `quiz_answers_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `quiz_questions` (`id`);

--
-- Constraints for table `quiz_attempts`
--
ALTER TABLE `quiz_attempts`
  ADD CONSTRAINT `quiz_attempts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `quiz_attempts_ibfk_2` FOREIGN KEY (`question_id`) REFERENCES `quiz_questions` (`id`),
  ADD CONSTRAINT `quiz_attempts_ibfk_3` FOREIGN KEY (`selected_answer_id`) REFERENCES `quiz_answers` (`id`);

--
-- Constraints for table `user_scores`
--
ALTER TABLE `user_scores`
  ADD CONSTRAINT `user_scores_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);
COMMIT;

