-- ============================================
-- SETUP TIM MONITORING & EVALUASI (MONEV)
-- Database: lppm_kkn2026
-- ============================================

-- 1. Buat tabel tim monev
CREATE TABLE IF NOT EXISTS `kkn_monev` (
  `id`       INT AUTO_INCREMENT PRIMARY KEY,
  `nama`     VARCHAR(150) NOT NULL,
  `nidn`     VARCHAR(20) NOT NULL UNIQUE,
  `email`    VARCHAR(150) DEFAULT NULL,
  `user_id`  INT DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- 2. Insert data pemonev
INSERT INTO `kkn_monev` (`nama`, `nidn`, `email`) VALUES
('Syariefful Ikhwan, S.T., M.M.', '0620027902', 'syariefful@umus.ac.id'),
('Dedi Romli Triputra, Lc., M.S.I.', '0625078601', 'dediromli@umus.ac.id');

-- 3. Tabel penugasan monev ke mahasiswa
CREATE TABLE IF NOT EXISTS `kkn_monev_mhs` (
  `id`        INT AUTO_INCREMENT PRIMARY KEY,
  `monev_id`  INT NOT NULL,
  `nim`       VARCHAR(20) NOT NULL,
  KEY `monev_id` (`monev_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- 4. Insert penugasan Syariefful Ikhwan (monev_id=1) — 36 mahasiswa
INSERT INTO `kkn_monev_mhs` (`monev_id`, `nim`) VALUES
(1,'55201230032'),(1,'62201230016'),(1,'54201230005'),
(1,'61201230014'),(1,'61201210041'),(1,'61201250048'),
(1,'61201230015'),(1,'13211230003'),(1,'41203230002'),
(1,'22201230009'),(1,'86206230002'),(1,'55201230008'),
(1,'22201230022'),(1,'55201220059'),(1,'86206230009'),
(1,'61201230057'),(1,'55201230005'),(1,'22201230012'),
(1,'62201230013'),(1,'86206230024'),(1,'61201230054'),
(1,'55201250017'),(1,'22201250022'),(1,'86206230045'),
(1,'86206230023'),(1,'88201230011'),(1,'55201230006'),
(1,'55201230013'),(1,'61201230025'),(1,'55201230024'),
(1,'88201230002'),(1,'22201230007'),(1,'61201230021'),
(1,'86206230035'),(1,'61201230043'),(1,'61201250013');

-- 5. Insert penugasan Dedi Romli Triputra (monev_id=2) — 36 mahasiswa
INSERT INTO `kkn_monev_mhs` (`monev_id`, `nim`) VALUES
(2,'86206240095'),(2,'61201250018'),(2,'55201220014'),
(2,'61201230039'),(2,'61201210041'),(2,'61201250048'),
(2,'41203230002'),(2,'61201230020'),(2,'86206250165'),
(2,'55201230007'),(2,'22201250040'),(2,'62201250013'),
(2,'62201230007'),(2,'62201230001'),(2,'86206230009'),
(2,'86206230072'),(2,'22201230012'),(2,'55201230045'),
(2,'61201230054'),(2,'61201240057'),(2,'88201230006'),
(2,'22201230021'),(2,'62201230011'),(2,'62201230009'),
(2,'55201230006'),(2,'55201230020'),(2,'61201250047'),
(2,'55201230013'),(2,'61201230030'),(2,'62201220037'),
(2,'86206230044'),(2,'62201230004'),(2,'86206230040'),
(2,'86206230010'),(2,'86206230057'),(2,'41203230006');

-- 6. Tabel nilai monev
CREATE TABLE IF NOT EXISTS `kkn_monev_nilai` (
  `id`        INT AUTO_INCREMENT PRIMARY KEY,
  `monev_id`  INT NOT NULL,
  `mhs_id`    INT NOT NULL,
  `k1`        DECIMAL(5,2) DEFAULT NULL COMMENT 'Kedisiplinan',
  `k2`        DECIMAL(5,2) DEFAULT NULL COMMENT 'Observasi',
  `k3`        DECIMAL(5,2) DEFAULT NULL COMMENT 'Pelaksanaan',
  `k4`        DECIMAL(5,2) DEFAULT NULL COMMENT 'Luaran',
  `k5`        DECIMAL(5,2) DEFAULT NULL COMMENT 'Sikap',
  `nilai_akhir` DECIMAL(5,2) DEFAULT NULL,
  `catatan`   TEXT DEFAULT NULL,
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY `monev_mhs` (`monev_id`, `mhs_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
