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

START TRANSACTION;



--
-- Database: `ehlv`
--

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

--
-- Table structure for table `activities`
--

CREATE TABLE `activities` (
  `id` int(11) NOT NULL,
  `activity_description` text NOT NULL,
  `due_date` datetime NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `creation_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `activities`
--

INSERT INTO `activities` (`id`, `activity_description`, `due_date`, `created_at`, `creation_date`) VALUES
(1, 'assigment', '2025-01-16 15:07:00', '2025-01-12 07:07:51', '2025-01-13 01:39:26'),
(3, 'resume', '2025-01-24 15:25:00', '2025-01-12 07:25:47', '2025-01-13 01:39:26'),
(7, 'assignment1', '2025-01-14 16:06:00', '2025-01-13 08:06:55', '2025-01-13 08:06:55');

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

--
-- Table structure for table `assessments`
--

CREATE TABLE `assessments` (
  `assessment_id` int(11) NOT NULL,
  `matricnum` varchar(15) NOT NULL,
  `activity_id` int(11) NOT NULL,
  `module_id` varchar(20) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `uploaded_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `upload_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `original_filename` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `assessments`
--

INSERT INTO `assessments` (`assessment_id`, `matricnum`, `activity_id`, `module_id`, `file_path`, `uploaded_at`, `upload_date`, `original_filename`) VALUES
(3, '555555', 3, 'module1', 'uploads/assessments/555555_3_1749626611.pdf', '2025-06-11 07:23:31', '2025-06-11 07:23:31', NULL),
(4, '555555', 4, 'module2', 'uploads/assessments/555555_4_1749957849.pdf', '2025-06-15 03:24:09', '2025-06-15 03:24:09', NULL);

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

--
-- Table structure for table `data_student`
--

CREATE TABLE `data_student` (
  `data_id` int(11) NOT NULL,
  `data_name` varchar(255) NOT NULL,
  `data_matricnum` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `data_student`
--

INSERT INTO `data_student` (`data_id`, `data_name`, `data_matricnum`) VALUES
(7, 'hakim', '555555'),
(11, 'zul', '220099'),
(12, 'amar', '220088'),
(16, 'haris', '883399');

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

--
-- Table structure for table `groups`
--

CREATE TABLE `groups` (
  `id` int(11) NOT NULL,
  `group_activity_id` int(11) NOT NULL,
  `group_name` varchar(255) NOT NULL,
  `member_count` int(11) DEFAULT 0,
  `status` varchar(50) DEFAULT 'open'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `group_activities`
--

CREATE TABLE `group_activities` (
  `group_id` int(11) NOT NULL,
  `activity_title` varchar(255) NOT NULL,
  `total_groups` int(11) NOT NULL,
  `group_names` text NOT NULL,
  `max_students` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `file_path` varchar(255) DEFAULT NULL,
  `due_date` datetime DEFAULT NULL,
  `module_id` varchar(20) DEFAULT 'module1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `group_activities`
--

INSERT INTO `group_activities` (`group_id`, `activity_title`, `total_groups`, `group_names`, `max_students`, `created_at`, `file_path`, `due_date`, `module_id`) VALUES
(1, 'safa', 1, 'group', 3, '2025-03-26 20:58:04', NULL, NULL, 'module1'),
(2, 'safa2', 1, 'group2', 3, '2025-03-26 21:01:39', NULL, NULL, 'module1'),
(3, 'assigment', 3, 'Alpha, Beta, Gamma', 5, '2025-04-24 16:30:56', '', '2025-04-30 11:59:00', 'module1'),
(4, 'ass', 2, 'saya, awak', 4, '2025-04-24 16:33:37', '', '2025-04-30 12:00:00', 'module1'),
(5, 'ass1', 2, 'dada, sasa', 4, '2025-04-24 16:35:49', '', '2025-04-30 11:59:00', 'module1'),
(6, 'ass2', 2, 'dad, sas', 4, '2025-04-24 17:31:32', '', '2025-04-30 12:00:00', 'module1'),
(7, 'ass2_updated', 2, 'dad, sas', 4, '2025-04-28 17:19:41', '', '2025-04-30 12:00:00', 'module1'),
(8, 'hai', 3, 'saya, awak, kita', 5, '2025-05-06 15:50:29', '', '2025-05-28 12:00:00', 'module1'),
(9, 'ass_module2', 6, 'Group 1, Group 2, Group 3, Group 4, Group 5, Group 6', 5, '2025-06-09 16:42:27', '', '2025-06-30 23:59:00', 'module2'),
(10, 'lab7', 5, 'Group 1, Group 2, Group 3, Group 4, Group 5', 3, '2025-06-11 10:13:57', 'uploads/module1/1749636837_quiz_Amirul_Affizalhairi.pdf', '0000-00-00 00:00:00', 'module1'),
(11, 'test1', 9, 'Group 1, Group 2, Group 3, Group 4, Group 5, Group 6, Group 7, Group 8, Group 9', 3, '2025-06-16 08:02:24', 'uploads/module1/1750060944_quiz_Amirul_Affizalhairi.pdf', '0000-00-00 00:00:00', 'module1'),
(12, 'test2', 4, 'Group 1, Group 2, Group 3, Group 4', 4, '2025-06-16 14:19:50', 'uploads/module3/1750083590_quiz_Amirul_Affizalhairi.pdf', '0000-00-00 00:00:00', 'module3');

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

--
-- Table structure for table `group_activity_columns`
--

CREATE TABLE `group_activity_columns` (
  `id` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  `selected_column_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `group_activity_columns`
--

INSERT INTO `group_activity_columns` (`id`, `group_id`, `selected_column_id`, `created_at`, `updated_at`) VALUES
(1, 8, 1, '2025-06-05 13:38:30', '2025-06-05 13:38:30'),
(2, 12, 8, '2025-06-16 15:13:18', '2025-06-16 15:13:18');

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

--
-- Table structure for table `group_marks`
--

CREATE TABLE `group_marks` (
  `id` int(11) NOT NULL,
  `activity_id` int(11) NOT NULL,
  `group_name` varchar(255) NOT NULL,
  `column_id` int(11) NOT NULL,
  `actual_mark` decimal(5,2) NOT NULL,
  `module_id` varchar(20) DEFAULT 'module1',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `group_marks`
--

INSERT INTO `group_marks` (`id`, `activity_id`, `group_name`, `column_id`, `actual_mark`, `module_id`, `created_at`, `updated_at`) VALUES
(1, 8, 'saya', 1, 49.00, 'module1', '2025-06-10 01:27:47', '2025-06-16 10:05:13'),
(3, 8, 'awak', 1, 10.00, 'module1', '2025-06-13 18:58:41', '2025-06-13 18:58:41'),
(4, 8, 'kita', 1, 5.00, 'module1', '2025-06-16 07:27:14', '2025-06-16 07:27:14'),
(5, 12, 'Group 1', 8, 20.00, 'module3', '2025-06-16 15:14:18', '2025-06-16 15:14:18'),
(6, 12, 'Group 2', 8, 40.00, 'module3', '2025-06-16 15:18:55', '2025-06-16 15:18:55');

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

--
-- Table structure for table `group_members`
--

CREATE TABLE `group_members` (
  `id` int(11) NOT NULL,
  `activity_id` int(11) NOT NULL,
  `group_name` varchar(255) NOT NULL,
  `matricnum` varchar(15) NOT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `joined_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `group_members`
--

INSERT INTO `group_members` (`id`, `activity_id`, `group_name`, `matricnum`, `file_path`, `joined_at`) VALUES
(7, 6, 'dad', '555555', NULL, '2025-05-04 22:58:38'),
(8, 5, 'dada', '555555', NULL, '2025-05-04 23:00:21'),
(11, 1, 'group', '555555', NULL, '2025-05-05 08:29:31'),
(13, 4, 'saya', '555555', NULL, '2025-05-05 11:45:26'),
(14, 7, 'dad', '555555', NULL, '2025-05-05 11:46:46'),
(16, 8, 'saya', '220099', NULL, '2025-05-18 14:18:55'),
(18, 8, 'awak', '123456', NULL, '2025-05-22 15:57:21'),
(19, 8, 'kita', '555555', 'uploads/group_files/555555_8_kita_1749617490_quiz_Amirul_Affizalhairi.pdf', '2025-05-22 15:57:28'),
(20, 8, 'saya', '220088', NULL, '2025-05-22 15:57:34'),
(21, 3, 'Alpha', '123456', NULL, '2025-06-03 23:39:39'),
(22, 3, 'Beta', '555555', NULL, '2025-06-03 23:39:47'),
(23, 3, 'Gamma', '220099', NULL, '2025-06-03 23:39:54'),
(24, 3, 'Alpha', '220088', NULL, '2025-06-03 23:40:00'),
(29, 2, 'group2', '555555', NULL, '2025-06-14 19:05:35'),
(30, 9, 'Group 2', '555555', 'uploads/group_files/555555_group_9_1749995775.pdf', '2025-06-14 19:06:34'),
(31, 9, 'Group 2', '220088', NULL, '2025-06-16 07:26:31'),
(32, 10, 'Group 3', '883399', 'uploads/group_files/883399_group_10_1750079462.pdf', '2025-06-16 13:10:48'),
(33, 11, 'Group 2', '883399', NULL, '2025-06-16 14:14:38'),
(34, 12, 'Group 1', '220088', NULL, '2025-06-16 15:13:45'),
(35, 12, 'Group 2', '123456', NULL, '2025-06-16 15:13:52'),
(36, 12, 'Group 1', '555555', NULL, '2025-06-16 15:14:04'),
(37, 12, 'Group 2', '883399', NULL, '2025-06-16 15:18:32');

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

--
-- Table structure for table `group_selected_columns`
--

CREATE TABLE `group_selected_columns` (
  `group_id` int(11) NOT NULL,
  `column_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `individual_activities`
--

CREATE TABLE `individual_activities` (
  `indi_id` int(11) NOT NULL,
  `activity_name` varchar(255) NOT NULL,
  `due_date` date NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `module_id` varchar(20) DEFAULT 'module1',
  `description` text DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `individual_activities`
--

INSERT INTO `individual_activities` (`indi_id`, `activity_name`, `due_date`, `created_at`, `module_id`, `description`, `file_path`) VALUES
(2, 'assigment1', '2025-05-22', '2025-05-30 02:34:03', 'module1', NULL, NULL),
(3, 'assigment3', '2025-05-22', '2025-05-30 02:34:19', 'module1', NULL, NULL),
(4, 'ass_module2', '2025-06-25', '2025-06-09 16:43:36', 'module2', NULL, NULL),
(5, 'haha', '2025-06-26', '2025-06-11 04:49:20', 'module1', NULL, NULL),
(6, 'test', '2025-06-30', '2025-06-16 08:01:50', 'module1', NULL, NULL),
(7, 'test3', '2025-06-30', '2025-06-16 08:23:46', 'module1', NULL, 'uploads/module1/1750062226_quiz_Amirul_Affizalhairi.pdf'),
(8, 'test1', '2025-06-18', '2025-06-16 14:19:17', 'module3', NULL, 'uploads/module3/1750083557_quiz_Amirul_Affizalhairi.pdf');

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

--
-- Table structure for table `individual_activity_columns`
--

CREATE TABLE `individual_activity_columns` (
  `id` int(11) NOT NULL,
  `indi_id` int(11) NOT NULL,
  `selected_column_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `individual_activity_columns`
--

INSERT INTO `individual_activity_columns` (`id`, `indi_id`, `selected_column_id`, `created_at`, `updated_at`) VALUES
(1, 3, 3, '2025-06-10 00:52:06', '2025-06-10 01:26:58'),
(3, 5, 5, '2025-06-11 07:08:53', '2025-06-11 12:19:12'),
(5, 8, 7, '2025-06-16 15:16:15', '2025-06-16 15:16:15');

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

--
-- Table structure for table `individual_activity_students`
--

CREATE TABLE `individual_activity_students` (
  `id` int(11) NOT NULL,
  `indi_id` int(11) NOT NULL,
  `student_id` int(11) NOT NULL,
  `attachment_path` varchar(255) DEFAULT NULL,
  `attached_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `individual_marks`
--

CREATE TABLE `individual_marks` (
  `id` int(11) NOT NULL,
  `indi_id` int(11) NOT NULL,
  `matricnum` varchar(50) NOT NULL,
  `column_id` int(11) NOT NULL,
  `actual_mark` decimal(5,2) NOT NULL,
  `module_id` varchar(20) NOT NULL DEFAULT 'module1',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `learning_materials`
--

CREATE TABLE `learning_materials` (
  `id` int(11) NOT NULL,
  `material_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `file_size` int(11) NOT NULL,
  `file_type` varchar(100) NOT NULL,
  `uploaded_by` varchar(255) NOT NULL,
  `uploaded_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `module_id` varchar(20) DEFAULT 'module1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `learning_materials`
--

INSERT INTO `learning_materials` (`id`, `material_name`, `description`, `file_name`, `file_path`, `file_size`, `file_type`, `uploaded_by`, `uploaded_at`, `module_id`) VALUES
(1, 'ass', 'resume', 'ARUBA_LAB_Configure AP_Step-by-step_TTK.pdf', 'uploads/learning_materials/68405f735b42c_1749049203.pdf', 690540, 'application/pdf', 'Teacher', '2025-06-04 15:00:03', 'module1'),
(2, 'baoek', 'sila hantar kerja ni secepat mungkin', 'C_I_FinalProjectReport__GROUP_8__UPAY.docx.pdf', 'uploads/learning_materials/module1/1749461111_C_I_FinalProjectReport__GROUP_8__UPAY.docx.pdf', 3934710, 'application/pdf', 'Teacher', '2025-06-09 09:25:11', 'module1'),
(3, 'resume', 'must submit today', '', 'uploads/learning_materials/module3/1750083516_quiz_Amirul Affizalhairi.pdf', 636767, '', '', '2025-06-16 14:18:36', 'module3');

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

--
-- Table structure for table `login_history`
--

CREATE TABLE `login_history` (
  `id` int(11) NOT NULL,
  `user_id` varchar(50) NOT NULL,
  `user_type` enum('student','educator') NOT NULL,
  `user_name` varchar(100) NOT NULL,
  `login_time` timestamp NOT NULL DEFAULT current_timestamp(),
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `action_type` enum('login','registration','logout') NOT NULL DEFAULT 'login',
  `logout_time` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `login_history`
--

INSERT INTO `login_history` (`id`, `user_id`, `user_type`, `user_name`, `login_time`, `ip_address`, `user_agent`, `action_type`, `logout_time`) VALUES
(1, '123456', 'student', 'AMIRUL AFFIZALHAIRI', '2025-06-16 02:30:00', '192.168.1.100', NULL, 'login', '2025-06-16 04:30:00'),
(2, '555555', 'student', 'hakim', '2025-06-16 03:15:00', '192.168.1.101', NULL, 'login', '2025-06-16 04:45:00'),
(3, '1111', 'educator', 'Teacher', '2025-06-16 01:45:00', '192.168.1.102', NULL, 'login', '2025-06-16 02:10:00'),
(4, '220099', 'student', 'zul', '2025-06-16 06:20:00', '192.168.1.103', NULL, 'login', '2025-06-16 07:18:00'),
(5, '1111', 'educator', 'Teacher', '2025-06-16 10:45:15', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', '2025-06-16 11:10:54'),
(6, '1111', 'educator', 'Teacher', '2025-06-16 11:27:53', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', '2025-06-16 12:42:17'),
(7, '123456', 'educator', 'Alif', '2025-06-16 12:48:52', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', NULL),
(8, '883399', 'student', 'haris', '2025-06-16 13:00:05', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', NULL),
(9, '883399', 'student', 'haris', '2025-06-16 13:01:03', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', NULL),
(10, '1111', 'educator', 'Teacher', '2025-06-16 13:24:38', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', NULL),
(11, '883399', 'student', 'haris', '2025-06-16 13:24:58', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', '2025-06-16 14:11:34'),
(12, '883399', 'student', 'haris', '2025-06-16 14:12:35', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', NULL),
(13, '1111', 'educator', 'Teacher', '2025-06-16 14:17:07', '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36', 'login', NULL);

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

--
-- Stand-in structure for view `login_statistics`
-- (See below for the actual view)
--
CREATE TABLE `login_statistics` (
`user_type` enum('student','educator')
,`action_type` enum('login','registration','logout')
,`login_date` date
,`count` bigint(21)
);

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

--
-- Table structure for table `marking_columns`
--

CREATE TABLE `marking_columns` (
  `column_id` int(11) NOT NULL,
  `mark_name` varchar(255) DEFAULT NULL,
  `shortname` varchar(50) DEFAULT NULL,
  `full_mark` int(11) DEFAULT NULL,
  `percentage` int(11) DEFAULT NULL,
  `used` tinyint(1) DEFAULT 0,
  `module_id` varchar(20) DEFAULT 'module1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `marking_columns`
--

INSERT INTO `marking_columns` (`column_id`, `mark_name`, `shortname`, `full_mark`, `percentage`, `used`, `module_id`) VALUES
(1, 'lab1', 'l1', 50, 20, 1, 'module1'),
(2, 'lab4', 'l4', 50, 20, 1, 'module1'),
(3, 'assignment', 'ass1', 30, 5, 1, 'module1'),
(4, 'ass3', 'ass3', 30, 10, 0, 'module1'),
(5, 'sa', 's1', 100, 100, 0, 'module1'),
(6, 'ass1', 'a1', 100, 50, 0, 'module2'),
(7, 'tes1', 't1', 50, 20, 0, 'module3'),
(8, 'test2', 't2', 50, 10, 0, 'module3');

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

--
-- Table structure for table `news_posts`
--

CREATE TABLE `news_posts` (
  `id` int(11) NOT NULL,
  `content` text NOT NULL,
  `educator_name` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `module_id` varchar(20) DEFAULT 'module1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `news_posts`
--

INSERT INTO `news_posts` (`id`, `content`, `educator_name`, `created_at`, `module_id`) VALUES
(1, 'class cancel', 'Teacher', '2025-06-04 15:00:30', 'module1'),
(2, 'Mal kerja', 'Teacher', '2025-06-09 09:23:58', 'module1'),
(3, 'class cancel', 'Teacher', '2025-06-16 14:18:05', 'module3');

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

--
-- Stand-in structure for view `session_tracking`
-- (See below for the actual view)
--
CREATE TABLE `session_tracking` (
`user_id` varchar(50)
,`user_name` varchar(100)
,`user_type` enum('student','educator')
,`login_time` timestamp
,`logout_time` timestamp
,`session_duration_minutes` bigint(21)
);

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

--
-- Table structure for table `student_marks`
--

CREATE TABLE `student_marks` (
  `id` int(11) NOT NULL,
  `matricnum` varchar(50) NOT NULL,
  `shortname` varchar(100) NOT NULL,
  `actual_mark` decimal(5,2) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `module_id` varchar(20) DEFAULT 'module1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `student_marks`
--

INSERT INTO `student_marks` (`id`, `matricnum`, `shortname`, `actual_mark`, `created_at`, `updated_at`, `module_id`) VALUES
(1, '123456', 'a1', 85.00, '2025-06-09 16:44:51', '2025-06-09 16:44:51', 'module2'),
(2, '220099', 'l1', 49.00, '2025-06-10 01:27:47', '2025-06-16 10:05:13', 'module1'),
(3, '220088', 'l1', 49.00, '2025-06-10 01:27:47', '2025-06-16 10:05:13', 'module1'),
(6, '123456', 'l1', 10.00, '2025-06-13 18:58:41', '2025-06-13 18:58:41', 'module1'),
(12, '220088', 'ass1', 10.00, '2025-06-13 20:04:35', '2025-06-16 09:33:31', 'module1'),
(13, '123456', 's1', 20.00, '2025-06-16 07:16:46', '2025-06-16 07:16:46', 'module1'),
(14, '555555', 'l1', 5.00, '2025-06-16 07:27:14', '2025-06-16 07:27:14', 'module1'),
(15, '123456', 'ass1', 3.00, '2025-06-16 09:08:48', '2025-06-16 09:08:48', 'module1'),
(16, '123456', 't1', 0.00, '2025-06-16 14:20:25', '2025-06-16 14:20:25', 'module3'),
(17, '220088', 't1', 10.00, '2025-06-16 14:20:25', '2025-06-16 15:16:47', 'module3'),
(18, '220099', 't1', 0.00, '2025-06-16 14:20:25', '2025-06-16 14:20:25', 'module3'),
(19, '555555', 't1', 0.00, '2025-06-16 14:20:25', '2025-06-16 14:20:25', 'module3'),
(20, '883399', 't1', 35.00, '2025-06-16 14:20:25', '2025-06-16 15:19:14', 'module3'),
(21, '123456', 't2', 40.00, '2025-06-16 14:20:49', '2025-06-16 15:18:55', 'module3'),
(22, '220088', 't2', 20.00, '2025-06-16 14:20:49', '2025-06-16 15:14:17', 'module3'),
(23, '220099', 't2', 0.00, '2025-06-16 14:20:49', '2025-06-16 14:20:49', 'module3'),
(24, '555555', 't2', 20.00, '2025-06-16 14:20:49', '2025-06-16 15:14:18', 'module3'),
(25, '883399', 't2', 40.00, '2025-06-16 14:20:49', '2025-06-16 15:18:55', 'module3');

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

--
-- Table structure for table `student_preferences`
--

CREATE TABLE `student_preferences` (
  `id` int(11) NOT NULL,
  `matricnum` varchar(15) NOT NULL,
  `selected_module` varchar(20) DEFAULT 'module1',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `student_preferences`
--

INSERT INTO `student_preferences` (`id`, `matricnum`, `selected_module`, `created_at`, `updated_at`) VALUES
(1, '555555', 'module1', '2025-06-08 03:52:35', '2025-06-16 08:04:01'),
(2, '883399', 'module3', '2025-06-16 13:06:51', '2025-06-16 15:18:02');

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

--
-- Stand-in structure for view `student_summary`
-- (See below for the actual view)
--
CREATE TABLE `student_summary` (
`matricnum` varchar(15)
,`fname` varchar(50)
,`email` varchar(100)
,`group_activities_count` bigint(21)
,`marks_count` bigint(21)
,`preferred_module` varchar(20)
);

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

--
-- Table structure for table `user_preferences`
--

CREATE TABLE `user_preferences` (
  `id` int(11) NOT NULL,
  `edu_name` varchar(100) NOT NULL,
  `selected_module` varchar(20) DEFAULT 'module1',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `user_preferences`
--

INSERT INTO `user_preferences` (`id`, `edu_name`, `selected_module`, `created_at`, `updated_at`) VALUES
(1, 'Teacher', 'module3', '2025-06-08 03:50:22', '2025-06-16 14:17:51');

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

--
-- Structure for view `login_statistics`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `login_statistics`  AS SELECT `login_history`.`user_type` AS `user_type`, `login_history`.`action_type` AS `action_type`, cast(`login_history`.`login_time` as date) AS `login_date`, count(0) AS `count` FROM `login_history` GROUP BY `login_history`.`user_type`, `login_history`.`action_type`, cast(`login_history`.`login_time` as date) ORDER BY cast(`login_history`.`login_time` as date) DESC ;

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

--
-- Structure for view `session_tracking`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `session_tracking`  AS SELECT `login_history`.`user_id` AS `user_id`, `login_history`.`user_name` AS `user_name`, `login_history`.`user_type` AS `user_type`, `login_history`.`login_time` AS `login_time`, `login_history`.`logout_time` AS `logout_time`, CASE WHEN `login_history`.`logout_time` is not null THEN timestampdiff(MINUTE,`login_history`.`login_time`,`login_history`.`logout_time`) ELSE NULL END AS `session_duration_minutes` FROM `login_history` WHERE `login_history`.`action_type` = 'login' ORDER BY `login_history`.`login_time` DESC ;

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

--
-- Structure for view `student_summary`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `student_summary`  AS SELECT `s`.`matricnum` AS `matricnum`, `s`.`fname` AS `fname`, `s`.`email` AS `email`, count(distinct `gm`.`activity_id`) AS `group_activities_count`, count(distinct `sm`.`shortname`) AS `marks_count`, `sp`.`selected_module` AS `preferred_module` FROM (((`students` `s` left join `group_members` `gm` on(`s`.`matricnum` = `gm`.`matricnum`)) left join `student_marks` `sm` on(`s`.`matricnum` = `sm`.`matricnum`)) left join `student_preferences` `sp` on(`s`.`matricnum` = `sp`.`matricnum`)) GROUP BY `s`.`matricnum`, `s`.`fname`, `s`.`email`, `sp`.`selected_module` ;

--
-- Indexes for dumped tables
--

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

--
-- Indexes for table `assessments`
--
ALTER TABLE `assessments`
  ADD PRIMARY KEY (`assessment_id`),
  ADD KEY `activity_id` (`activity_id`),
  ADD KEY `fk_assessments_student` (`matricnum`),
  ADD KEY `idx_module_id` (`module_id`);

--
-- Indexes for table `data_student`
--
ALTER TABLE `data_student`
  ADD PRIMARY KEY (`data_id`),
  ADD UNIQUE KEY `data_matricnum` (`data_matricnum`);

--
-- Indexes for table `groups`
--
ALTER TABLE `groups`
  ADD PRIMARY KEY (`id`),
  ADD KEY `group_activity_id` (`group_activity_id`);

--
-- Indexes for table `group_activities`
--
ALTER TABLE `group_activities`
  ADD PRIMARY KEY (`group_id`),
  ADD KEY `idx_activities_module` (`module_id`);

--
-- Indexes for table `group_activity_columns`
--
ALTER TABLE `group_activity_columns`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_group` (`group_id`),
  ADD KEY `fk_group_activity_columns_column` (`selected_column_id`);

--
-- Indexes for table `group_marks`
--
ALTER TABLE `group_marks`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_group_column` (`activity_id`,`group_name`,`column_id`),
  ADD KEY `column_id` (`column_id`);

--
-- Indexes for table `group_members`
--
ALTER TABLE `group_members`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_member_activity` (`activity_id`,`matricnum`),
  ADD KEY `fk_group_members_matricnum` (`matricnum`),
  ADD KEY `idx_group_members_activity_matricnum` (`activity_id`,`matricnum`),
  ADD KEY `idx_group_members_group` (`activity_id`,`group_name`);

--
-- Indexes for table `group_selected_columns`
--
ALTER TABLE `group_selected_columns`
  ADD PRIMARY KEY (`group_id`,`column_id`),
  ADD KEY `column_id` (`column_id`);

--
-- Indexes for table `individual_activities`
--
ALTER TABLE `individual_activities`
  ADD PRIMARY KEY (`indi_id`),
  ADD KEY `idx_individual_module` (`module_id`);

--
-- Indexes for table `individual_activity_columns`
--
ALTER TABLE `individual_activity_columns`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_individual_activity` (`indi_id`),
  ADD KEY `fk_individual_activity_columns_column` (`selected_column_id`);

--
-- Indexes for table `individual_activity_students`
--
ALTER TABLE `individual_activity_students`
  ADD PRIMARY KEY (`id`),
  ADD KEY `indi_id` (`indi_id`),
  ADD KEY `student_id` (`student_id`);

--
-- Indexes for table `individual_marks`
--
ALTER TABLE `individual_marks`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_individual_mark` (`indi_id`,`matricnum`,`column_id`),
  ADD UNIQUE KEY `unique_individual_mark_module` (`indi_id`,`matricnum`,`column_id`,`module_id`),
  ADD KEY `fk_individual_marks_column` (`column_id`),
  ADD KEY `fk_individual_marks_student` (`matricnum`);

--
-- Indexes for table `learning_materials`
--
ALTER TABLE `learning_materials`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_materials_module` (`module_id`);

--
-- Indexes for table `login_history`
--
ALTER TABLE `login_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_login_history_user` (`user_id`,`user_type`),
  ADD KEY `idx_login_history_time` (`login_time`),
  ADD KEY `idx_action_type` (`action_type`),
  ADD KEY `idx_user_action` (`user_id`,`user_type`,`action_type`),
  ADD KEY `idx_logout_time` (`logout_time`);

--
-- Indexes for table `marking_columns`
--
ALTER TABLE `marking_columns`
  ADD PRIMARY KEY (`column_id`),
  ADD UNIQUE KEY `unique_shortname_module` (`shortname`,`module_id`),
  ADD KEY `idx_columns_module` (`module_id`);

--
-- Indexes for table `news_posts`
--
ALTER TABLE `news_posts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_news_module` (`module_id`);

--
-- Indexes for table `student_marks`
--
ALTER TABLE `student_marks`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_student_column_module` (`matricnum`,`shortname`,`module_id`),
  ADD KEY `idx_marks_module` (`module_id`);

--
-- Indexes for table `student_preferences`
--
ALTER TABLE `student_preferences`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_student` (`matricnum`),
  ADD KEY `idx_students_module` (`selected_module`);

--
-- Indexes for table `user_preferences`
--
ALTER TABLE `user_preferences`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_edu` (`edu_name`),
  ADD KEY `idx_educators_module` (`selected_module`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

--
-- AUTO_INCREMENT for table `data_student`
--
ALTER TABLE `data_student`
  MODIFY `data_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

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

--
-- AUTO_INCREMENT for table `group_activities`
--
ALTER TABLE `group_activities`
  MODIFY `group_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

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

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

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

--
-- AUTO_INCREMENT for table `individual_activities`
--
ALTER TABLE `individual_activities`
  MODIFY `indi_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

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

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

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

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

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

--
-- AUTO_INCREMENT for table `marking_columns`
--
ALTER TABLE `marking_columns`
  MODIFY `column_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `assessments`
--
ALTER TABLE `assessments`
  ADD CONSTRAINT `fk_assessments_individual_activities` FOREIGN KEY (`activity_id`) REFERENCES `individual_activities` (`indi_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_assessments_student` FOREIGN KEY (`matricnum`) REFERENCES `students` (`matricnum`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `group_activity_columns`
--
ALTER TABLE `group_activity_columns`
  ADD CONSTRAINT `fk_group_activity_columns_activity` FOREIGN KEY (`group_id`) REFERENCES `group_activities` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_group_activity_columns_column` FOREIGN KEY (`selected_column_id`) REFERENCES `marking_columns` (`column_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `group_marks`
--
ALTER TABLE `group_marks`
  ADD CONSTRAINT `fk_group_marks_activities` FOREIGN KEY (`activity_id`) REFERENCES `group_activities` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_group_marks_columns` FOREIGN KEY (`column_id`) REFERENCES `marking_columns` (`column_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `group_members`
--
ALTER TABLE `group_members`
  ADD CONSTRAINT `fk_group_members_activities` FOREIGN KEY (`activity_id`) REFERENCES `group_activities` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_group_members_students` FOREIGN KEY (`matricnum`) REFERENCES `students` (`matricnum`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `group_selected_columns`
--
ALTER TABLE `group_selected_columns`
  ADD CONSTRAINT `fk_group_selected_activities` FOREIGN KEY (`group_id`) REFERENCES `group_activities` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_group_selected_columns` FOREIGN KEY (`column_id`) REFERENCES `marking_columns` (`column_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `individual_activity_columns`
--
ALTER TABLE `individual_activity_columns`
  ADD CONSTRAINT `fk_individual_activity_columns_column` FOREIGN KEY (`selected_column_id`) REFERENCES `marking_columns` (`column_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `individual_activity_students`
--
ALTER TABLE `individual_activity_students`
  ADD CONSTRAINT `fk_individual_students_activity` FOREIGN KEY (`indi_id`) REFERENCES `individual_activities` (`indi_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `individual_marks`
--
ALTER TABLE `individual_marks`
  ADD CONSTRAINT `fk_individual_marks_activities` FOREIGN KEY (`indi_id`) REFERENCES `individual_activities` (`indi_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_individual_marks_column` FOREIGN KEY (`column_id`) REFERENCES `marking_columns` (`column_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_individual_marks_student` FOREIGN KEY (`matricnum`) REFERENCES `students` (`matricnum`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `student_preferences`
--
ALTER TABLE `student_preferences`
  ADD CONSTRAINT `fk_student_preferences` FOREIGN KEY (`matricnum`) REFERENCES `students` (`matricnum`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

