Example #1
0
 function edit($segment_3 = '', $segment_4 = '')
 {
     $id = (int) $segment_3;
     $uri_back = (string) $segment_4;
     # ambil satu
     $retrieve = $this->mapel_model->retrieve($id);
     if (empty($retrieve)) {
         redirect('mapel');
     }
     if (!empty($uri_back)) {
         $uri_back = deurl_redirect($uri_back);
     } else {
         $uri_back = site_url('mapel');
     }
     $data['uri_back'] = $uri_back;
     $data['mapel'] = $retrieve;
     if ($this->form_validation->run('mapel/edit') == TRUE and !is_demo_app()) {
         $nama = $this->input->post('nama', TRUE);
         $info = $this->input->post('info', TRUE);
         $aktif = $this->input->post('status', TRUE);
         if (empty($aktif)) {
             $aktif = 0;
         }
         $this->mapel_model->update($id, $nama, $info, $aktif);
         $this->session->set_flashdata('mapel', get_alert('success', 'Matapelajaran berhasil di perbaharui.'));
         redirect($uri_back);
     }
     $this->twig->display('edit-mapel.html', $data);
 }
Example #2
0
 function delete($segment_3 = '', $segment_4 = '')
 {
     # versi 1.2 siswa tidak bisa tambah,edit,hapus materi
     if (is_siswa()) {
         redirect('materi');
     }
     $materi_id = (int) $segment_3;
     $uri_back = (string) $segment_4;
     if (empty($uri_back)) {
         $uri_back = site_url('materi');
     } else {
         $uri_back = deurl_redirect($uri_back);
     }
     $materi = $this->materi_model->retrieve($materi_id);
     if (empty($materi)) {
         redirect($uri_back);
     }
     # cek kepemilikan
     if (is_pengajar() and $materi['pengajar_id'] != get_sess_data('user', 'id')) {
         redirect($uri_back);
     }
     if (is_siswa() and $materi['siswa_id'] != get_sess_data('user', 'id')) {
         redirect($uri_back);
     }
     # jika file
     if (!empty($materi['file']) and is_file(get_path_file($materi['file']))) {
         unlink(get_path_file($materi['file']));
     }
     $this->materi_model->delete($materi['id']);
     $this->session->set_flashdata('materi', get_alert('warning', 'Materi berhasil dihapus.'));
     redirect($uri_back);
 }
Example #3
0
 function hapus_pilihan($segment_3 = '', $segment_4 = '', $segment_5 = '', $segment_6 = '')
 {
     $tugas_id = (int) $segment_3;
     $pertanyaan_id = (int) $segment_4;
     $pilihan_id = (int) $segment_5;
     $uri_back = (string) $segment_6;
     $tugas = $this->tugas_model->retrieve($tugas_id);
     if (empty($tugas) or $tugas['type_id'] != 3) {
         exit("Tugas tidak ditemukan");
     }
     # jika sebagai pengajar, cek kepemilikan
     if (is_pengajar() and $tugas['pengajar_id'] != get_sess_data('user', 'id')) {
         exit("Tugas tidak ditemukan");
     }
     $pertanyaan = $this->tugas_model->retrieve_pertanyaan($pertanyaan_id);
     if (empty($pertanyaan)) {
         exit("Pertanyaan tidak ditemukan");
     }
     $pilihan = $this->tugas_model->retrieve_pilihan($pilihan_id, $pertanyaan['id']);
     if (empty($pilihan)) {
         exit("Pilihan tidak ditemukan");
     }
     if (empty($uri_back)) {
         $uri_back = site_url('tugas/manajemen_soal/' . $tugas['id']);
     } else {
         $uri_back = deurl_redirect($uri_back);
     }
     $this->tugas_model->delete_pilihan($pilihan['id']);
     redirect($uri_back . '#pilihan-' . $pertanyaan['id']);
 }
Example #4
0
 function mapel($act = 'list', $segment_4 = '', $segment_5 = '')
 {
     $this->must_login();
     $data['web_title'] = 'Manajemen Matapelajaran | Administrator';
     switch ($act) {
         case 'edit':
             $content_file = 'admin_mapel/edit.html';
             $id = (int) $segment_4;
             $uri_back = (string) $segment_5;
             //ambil satu
             $retrieve = $this->mapel_model->retrieve($id);
             if (empty($retrieve)) {
                 redirect('admin/mapel');
             }
             if (!empty($uri_back)) {
                 $uri_back = deurl_redirect($uri_back);
             } else {
                 $uri_back = site_url('admin/mapel');
             }
             $data['uri_back'] = $uri_back;
             $data['module_title'] = anchor($uri_back, 'Manajemen Matapelajaran') . ' / Edit';
             $data['mapel'] = $retrieve;
             if ($this->form_validation->run('admin/mapel/edit') == TRUE) {
                 $nama = $this->input->post('nama', TRUE);
                 $info = $this->input->post('info', TRUE);
                 $aktif = $this->input->post('status', TRUE);
                 if (empty($aktif)) {
                     $aktif = 0;
                 }
                 $this->mapel_model->update($id, $nama, $info, $aktif);
                 $this->session->set_flashdata('mapel', get_alert('success', 'Matapelajaran berhasil di perbaharui.'));
                 redirect($uri_back);
             }
             break;
         case 'add':
             $content_file = 'admin_mapel/add.html';
             $data['module_title'] = anchor('admin/mapel', 'Manajemen Matapelajaran') . ' / Tambah';
             if ($this->form_validation->run() == TRUE) {
                 //buat mapel
                 $nama = $this->input->post('nama', TRUE);
                 $info = $this->input->post('info', TRUE);
                 $this->mapel_model->create($nama, $info);
                 $this->session->set_flashdata('mapel', get_alert('success', 'Matapelajaran baru berhasil disimpan.'));
                 redirect('admin/mapel');
             }
             break;
         default:
         case 'list':
             $content_file = 'admin_mapel/list.html';
             $data['module_title'] = 'Manajemen Matapelajaran';
             $page_no = (int) $segment_4;
             $page_no = empty($page_no) ? 1 : $page_no;
             //ambil semua data mepel
             $retrieve_all = $this->mapel_model->retrieve_all(10, $page_no);
             $data['mapels'] = $retrieve_all['results'];
             $data['pagination'] = $this->pager->view($retrieve_all, 'admin/mapel/list/');
             break;
     }
     $data = array_merge(default_parser_item(), $data);
     $this->twig->display($content_file, $data);
 }
Example #5
0
 function mapel_kelas($act = 'list', $segment_4 = '', $segment_5 = '', $segment_6 = '', $segment_7 = '')
 {
     $data['comp_js'] = load_comp_js(array(base_url('assets/comp/jquery/ajax.js')));
     switch ($act) {
         case 'aktifkan':
             $parent_id = (int) $segment_4;
             $kelas_id = (int) $segment_5;
             $mapel_kelas_id = (int) $segment_6;
             $uri_back = (string) $segment_7;
             # ambil parent
             $parent = $this->kelas_model->retrieve($parent_id);
             if (empty($parent)) {
                 redirect('kelas/mapel_kelas');
             }
             $kelas = $this->kelas_model->retrieve($kelas_id);
             if (empty($kelas)) {
                 redirect('kelas/mapel_kelas');
             }
             $mapel_kelas = $this->mapel_model->retrieve_kelas($mapel_kelas_id);
             if (empty($mapel_kelas)) {
                 redirect('kelas/mapel_kelas');
             }
             if (empty($uri_back)) {
                 $uri_back = site_url('kelas/mapel_kelas/#subkelas-' . $kelas_id);
             } else {
                 $uri_back = deurl_redirect($uri_back);
                 $uri_back = rtrim($uri_back, '/');
                 $uri_back = $uri_back . '/#subkelas-' . $kelas_id;
             }
             if (!is_demo_app()) {
                 # update
                 $this->mapel_model->update_kelas($mapel_kelas_id, $mapel_kelas['kelas_id'], $mapel_kelas['mapel_id'], 1);
             }
             $this->session->set_flashdata('edit-mapel-kelas-' . $kelas['id'], get_alert('success', 'Matapelajaran kelas berhasil diaktifkan.'));
             redirect($uri_back);
             break;
         case 'remove':
             $parent_id = (int) $segment_4;
             $kelas_id = (int) $segment_5;
             $mapel_kelas_id = (int) $segment_6;
             $uri_back = (string) $segment_7;
             # ambil parent
             $parent = $this->kelas_model->retrieve($parent_id);
             if (empty($parent)) {
                 redirect('kelas/mapel_kelas');
             }
             $kelas = $this->kelas_model->retrieve($kelas_id);
             if (empty($kelas)) {
                 redirect('kelas/mapel_kelas');
             }
             if (empty($uri_back)) {
                 $uri_back = site_url('kelas/mapel_kelas/#subkelas-' . $kelas_id);
             } else {
                 $uri_back = deurl_redirect($uri_back);
                 $uri_back = rtrim($uri_back, '/');
                 $uri_back = $uri_back . '/#subkelas-' . $kelas_id;
             }
             if (!is_demo_app()) {
                 # hapus data
                 $this->mapel_model->delete_kelas($mapel_kelas_id);
             }
             $this->session->set_flashdata('edit-mapel-kelas-' . $kelas['id'], get_alert('warning', 'Matapelajaran kelas berhasil dihapus.'));
             redirect($uri_back);
             break;
         case 'add':
             $parent_id = (int) $segment_4;
             $kelas_id = (int) $segment_5;
             $uri_back = (string) $segment_6;
             # ambil parent
             $parent = $this->kelas_model->retrieve($parent_id);
             if (empty($parent)) {
                 redirect('kelas/mapel_kelas');
             }
             $kelas = $this->kelas_model->retrieve($kelas_id);
             if (empty($kelas)) {
                 redirect('kelas/mapel_kelas');
             }
             if (empty($uri_back)) {
                 $uri_back = site_url('kelas/mapel_kelas/add/' . $parent_id . '/' . $kelas_id);
             } else {
                 $uri_back = deurl_redirect($uri_back);
             }
             $data['uri_back'] = $uri_back;
             $content_file = 'tambah-mapel-kelas.html';
             $data['kelas'] = $kelas;
             $data['parent'] = $parent;
             # ambil semua matapelajaran
             $retrieve_all = $this->mapel_model->retrieve_all_mapel();
             $data['mapels'] = $retrieve_all;
             # ambil matapelajaran pada kelas ini
             $retrieve_all_kelas = $this->mapel_model->retrieve_all_kelas();
             $mapel_kelas_id = array();
             foreach ($retrieve_all_kelas as $v) {
                 $mapel_kelas_id[] = $v['mapel_id'];
             }
             if ($this->form_validation->run('kelas/mapel_kelas/add') == TRUE and !is_demo_app()) {
                 $mapel = $this->input->post('mapel', TRUE);
                 $mapel_post_id = array();
                 foreach ($mapel as $mapel_id) {
                     if (is_numeric($mapel_id) and $mapel_id > 0) {
                         # cek dulu
                         $check = $this->mapel_model->retrieve_kelas(null, $kelas_id, $mapel_id);
                         if (empty($check)) {
                             $this->mapel_model->create_kelas($kelas_id, $mapel_id);
                         } else {
                             # update aktif jadi 1
                             $this->mapel_model->update_kelas($check['id'], $kelas_id, $mapel_id, 1);
                         }
                         $mapel_post_id[] = $mapel_id;
                     }
                 }
                 # cari perbedaan
                 if (count($mapel_kelas_id) > count($mapel_post_id)) {
                     $diff_mapel_kelas = array_diff($mapel_kelas_id, $mapel_post_id);
                     foreach ($diff_mapel_kelas as $mapel_id) {
                         # ambil data
                         $retrieve = $this->mapel_model->retrieve_kelas(null, $kelas_id, $mapel_id);
                         if (!empty($retrieve)) {
                             # hapus
                             $this->mapel_model->delete_kelas($retrieve['id']);
                         }
                     }
                 }
                 $this->session->set_flashdata('mapel', get_alert('success', 'Matapelajaran kelas berhasil disimpan.'));
                 redirect('kelas/mapel_kelas/add/' . $parent_id . '/' . $kelas_id . '/' . enurl_redirect($uri_back));
             }
             break;
         default:
         case 'list':
             # detect post
             if (!empty($_POST)) {
                 $post_parent_id = (int) $this->input->post('parent_kelas', true);
                 $post_sub_id = (int) $this->input->post('sub_kelas', true);
                 redirect('kelas/mapel_kelas/list/' . $post_parent_id . '/' . $post_sub_id);
             }
             $content_file = 'list-mapel-kelas.html';
             $parent_kelas_id = (int) $segment_4;
             $sub_kelas_id = (int) $segment_5;
             $data['filter']['parent_id'] = $parent_kelas_id;
             $data['filter']['sub_id'] = $sub_kelas_id;
             if (!empty($parent_kelas_id)) {
                 $data['filter']['result']['parent'] = $this->kelas_model->retrieve($parent_kelas_id);
                 $data['sub_kelas'] = $this->kelas_model->retrieve_all($parent_kelas_id, array('aktif' => 1));
             }
             if (!empty($sub_kelas_id)) {
                 $data['filter']['result']['sub'] = $this->kelas_model->retrieve($sub_kelas_id);
             }
             $data['mapel_kelas_hirarki'] = $this->mapel_kelas_hirarki('', array('parent_id' => $parent_kelas_id, 'sub_id' => $sub_kelas_id));
             $data['parent_kelas'] = $this->kelas_model->retrieve_all(null, array('aktif' => 1));
             break;
     }
     $this->twig->display($content_file, $data);
 }