<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
if ($ac == '') :
?>
    <div class='row'>
       <div class='col-md-12'>
           <div class="card">
              <div class="card-header">	
			    <?php if($menu['aplikasi']==0){ ?>
				     <div class="example-content"> 
					  <a href="?" class="btn btn-outline-danger right" ><i class="fas fa-times-circle"></i>Back</a>
			            <a href="?pg=buatbank" class="btn btn-outline-primary right"><i class="fas fa-plus-circle"></i>Bank</a>
                    </div>		
				<?php } ?>					
					 <h5 class='box-title'><?php if($menu['soal']==1){ ?>Bank Soal AKM<?php }else{ ?>Bank Soal CBT<?php } ?></h5>
                 </div>
				  
			
                <div class='card-body'>
				<div class="example-content">
                   <div class="table-responsive">
                        <table id="datatable1" class='table' style="font-size:12px">
                            <thead>
                                <tr>
                                    
                                    <th width='5%'>No</th>
									<th width='10%'>Kode</th>
									<th width='10%'>Level</th>
                                    <th>Mata Pelajaran</th>
                                        <th width='15%'>Status</th>	
                                       <?php if($menu['aplikasi']==0){ ?>										
                                      <th>Pengampu</th>	
									   <?php } ?>
                                     <th class="text-center">Action</th>									  
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if ($user['level'] == 'admin') :
                                    $mapelQ = mysqli_query($koneksi, "SELECT * FROM banksoal  ORDER BY date ASC");
                                elseif ($user['level'] == 'guru') :
                                    $mapelQ = mysqli_query($koneksi, "SELECT * FROM banksoal WHERE idguru='$user[id_user]'  ORDER BY date ASC");
                                endif;
                                ?>
                                <?php while ($mapel = mysqli_fetch_array($mapelQ)) : ?>
								<?php if($mapel['pembahasan']=='0'){{$bahas="Tidak";}} ?>
								<?php if($mapel['pembahasan']=='1'){{$bahas="Ya";}} ?>
                                    <?php
                                    $cek = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM soal WHERE id_bank='$mapel[id_bank]'"));
                                    $no++;
                                    ?>
                                    <tr>
                                       
                                        <td><?= $no ?></td>
                                           <td><?= $mapel['kode'] ?></td>
										   <td><?= $mapel['level'] ?></td>
                                           <td><?= $mapel['nama'] ?></td>
                                               
												<td>
                                            <?php

                                            if ($cek <> 0) {
                                                if ($mapel['status'] == '0') :
                                                    $status = 'non aktif';
                                                else :
                                                    $status = 'aktif';
                                                endif;
                                            } else {
                                                $status = 'Kosong';
                                            }
                                            $guruku = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM users WHERE id_user = '$mapel[idguru]'"));
                                            ?>
											 <?= $status ?>
                                                  </td>
												    <?php if($menu['aplikasi']==0){ ?>
												  <td><?= $guruku['nama'] ?></td>
													<?php } ?>
												<td class="text-center">  
                                                        
                                               <a href='?pg=<?= $pg ?>&ac=lihat&id=<?= $mapel['id_bank'] ?>' class='btn  btn-sm btn-outline-warning' data-bs-toggle="tooltip" data-bs-placement="top" title="View"><i class='fa fa-search'></i></a>
											     <?php if($menu['aplikasi']==0){ ?>
											  <?php if($menu['soal']==1): ?>
											  <a href='?pg=<?= $pg ?>&ac=upload11&id=<?= $mapel['id_bank'] ?>' class='btn  btn-sm btn-outline-primary' data-bs-toggle="tooltip" data-bs-placement="top" title="Impor"><i class='fa fa-upload'></i></a>              
                                              <?php else: ?>
											  <a href='?pg=<?= $pg ?>&ac=importsoal&id=<?= $mapel['id_bank'] ?>' class='btn  btn-sm btn-outline-primary' data-bs-toggle="tooltip" data-bs-placement="top" title="Impor"><i class='fa fa-upload'></i></a>              
											  <?php endif; ?>
											  <a href="?pg=editbank&id=<?= $mapel['id_bank'] ?>" class='btn btn-sm btn-outline-success' data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></a>                             
												<button data-id="<?= $mapel['id_bank'] ?>"  class="hapus btn btn-sm btn-outline-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="Hapus"><i class='fa fa-trash'></i></button>
												 <?php } ?>
									   </td>
                                    </tr>

                                   
                                <?php endwhile; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
   
	<script>
    $('#datatable1').on('click', '.hapus', function() {
        var id = $(this).data('id');
        console.log(id);
        Swal.fire({
				  title: 'Yakin hapus data?',
				  text: "You won't be able to revert this!",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#3085d6',
				  cancelButtonColor: '#d33',
				  confirmButtonText: 'Ya, Hapus!',
                  cancelButtonText: "Batal"				  
        }).then((result) => {
            if (result.value) {
                $.ajax({
                   url: 'sandik_bank/crud_banksoal.php?pg=hapus',
                    method: "POST",
                    data: 'id=' + id,
                    success: function(data) {
						  iziToast.info(
            {
                 title: 'Sukses!',
                message: 'Data berhasil dihapus',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'				  
                });
                        setTimeout(function() {
                            window.location.reload();
                        }, 2000);
                    }
                });
            }
            return false;
        })

    });
   </script>						
  <?php elseif ($ac == 'importsoal') : ?>
    <?php include "sandik_bank/import_soal.php"; ?>
<?php elseif ($ac == 'pg') : ?>
    <?php include 'sandik_bank/input_soal.php'; ?>
	
	<?php elseif ($ac == 'multi') : ?>
    <?php include 'sandik_bank/input_soal2.php'; ?>
	
	<?php elseif ($ac == 'bs') : ?>
    <?php include 'sandik_bank/input_soal3.php'; ?>
	
	<?php elseif ($ac == 'urut') : ?>
    <?php include 'sandik_bank/input_soal4.php'; ?>
	
	<?php elseif ($ac == 'multipgm') : ?>
    <?php include 'sandik_bank/input_soal5.php'; ?>
	
	<?php elseif ($ac == 'fo') : ?>
    <?php include 'sandik_bank/input_soal6.php'; ?>
<?php elseif ($ac == 'lihat') : ?>

    <?php
    $id_bank = $_GET['id'];
   if (isset($_REQUEST['tambah'])) {
        $sip = $_SERVER['SERVER_NAME'];
        $smax = mysqli_query($koneksi, "SELECT max(qid) AS maxi FROM savsoft_qbank");
        while ($hmax = mysqli_fetch_array($smax)) :
            $jumsoal = $hmax['maxi'];
        endwhile;
        $smaop = mysqli_query($koneksi, "SELECT max(oid) AS maxop FROM savsoft_options");
        while ($hmaop = mysqli_fetch_array($smaop)) {
            $jumop = $hmaop['maxop'];
        }

        $b_op = ($jumop != 0) ? ($jumop / $jumsoal) : 0;
        $no = 1;
        $sqlcek = mysqli_query($koneksi, "SELECT * FROM savsoft_qbank");
        while ($r = mysqli_fetch_array($sqlcek)) {
            $s_soal = mysqli_fetch_array(mysqli_query($koneksi, "select * from savsoft_qbank where qid='$no'"));
            $soal_tanya = $s_soal['question'];
            $l_soal = $s_soal['lid'];
            $c_id = $s_soal['cid'];
            $g_soal = $s_soal['description'];
            $g_soal = str_replace(" ", "", $g_soal);
            $smin = mysqli_query($koneksi, " select min(oid) as mini from savsoft_options where qid='$no'");
            while ($hmin = mysqli_fetch_array($smin)) {
                $min_op = $hmin['mini'];
            }
            $sqlopc = mysqli_query($koneksi, " select * from savsoft_options where qid='$no' and oid='$min_op'");
            $ropc = mysqli_fetch_array($sqlopc);
            $opj1 = $ropc['q_option'];
            $opj1 = str_replace(" &ndash;", "-", $opj1);
            $opjs1 = $ropc['score'];
            $fileA = $ropc['q_option_match'];
            $fileA = str_replace(" ", "", $fileA);

            $dele = mysqli_query($koneksi, "DELETE FROM savsoft_options WHERE qid='$no' AND oid='$min_op'");

            $smin = mysqli_query($koneksi, " select min(oid) as mini from savsoft_options where qid='$no'");
            while ($hmin = mysqli_fetch_array($smin)) {
                $min_op = $hmin['mini'];
            }

            $sqlopc = mysqli_query($koneksi, " select * from savsoft_options where qid='$no' and oid='$min_op'");
            $rubah = mysqli_query($koneksi, " select * from savsoft_options where qid='$no'");
            $ck_jum = mysqli_num_rows($rubah);

            $ropc = mysqli_fetch_array($sqlopc);
            $opj2 = $ropc['q_option'];
            $opj2 = str_replace(" &ndash;", "-", $opj2);
            $opjs2 = $ropc['score'];
            $fileB = $ropc['q_option_match'];
            $fileB = str_replace(" ", "", $fileB);
            $dele = mysqli_query($koneksi, " delete from savsoft_options where qid='$no' and oid='$min_op'");
            $smin = mysqli_query($koneksi, " select min(oid) as mini from savsoft_options where qid='$no'");
            while ($hmin = mysqli_fetch_array($smin)) {
                $min_op = $hmin['mini'];
            }
            $sqlopc = mysqli_query($koneksi, " select * from savsoft_options where qid='$no' and oid='$min_op'");
            $ropc = mysqli_fetch_array($sqlopc);
            $opj3 = $ropc['q_option'];
            $opj3 = str_replace(" &ndash;", "-", $opj3);
            $opjs3 = $ropc['score'];
            $fileC = $ropc['q_option_match'];
            $fileC = str_replace(" ", "", $fileC);
            $dele = mysqli_query($koneksi, " delete from savsoft_options where qid='$no' and oid='$min_op'");
            $smin = mysqli_query($koneksi, " select min(oid) as mini from savsoft_options where qid='$no'");
            while ($hmin = mysqli_fetch_array($smin)) {
                $min_op = $hmin['mini'];
            }

            $sqlopc = mysqli_query($koneksi, " select * from savsoft_options where qid='$no' and oid='$min_op'");
            $ropc = mysqli_fetch_array($sqlopc);
            $opj4 = $ropc['q_option'];
            $opj4 = str_replace(" &ndash;", "-", $opj4);
            $opjs4 = $ropc['score'];
            $fileD = $ropc['q_option_match'];
            $fileD = str_replace(" ", "", $fileD);
            $dele = mysqli_query($koneksi, " delete from savsoft_options where qid='$no' and oid='$min_op'");
            $smin = mysqli_query($koneksi, " select min(oid) as mini from savsoft_options where qid='$no'");
            while ($hmin = mysqli_fetch_array($smin)) {
                $min_op = $hmin['mini'];
            }

            $sqlopc = mysqli_query($koneksi, " select * from savsoft_options where qid='$no' and oid='$min_op'");
            $ropc = mysqli_fetch_array($sqlopc);
            $opj5 = $ropc['q_option'];
            $opj5 = str_replace(" &ndash;", "-", $opj5);
            $opjs5 = $ropc['score'];
            $fileE = $ropc['q_option_match'];
            $fileE = str_replace(" ", "", $fileE);
            $dele = mysqli_query($koneksi, " delete from savsoft_options where qid='$no' and oid='$min_op'");
            if ($opjs1 == 1) {
                $kunci = "A";
            }
            if ($opjs2 == 1) {
                $kunci = "B";
            }
            if ($opjs3 == 1) {
                $kunci = "C";
            }
            if ($opjs4 == 1) {
                $kunci = "D";
            }
            if ($opjs5 == 1) {
                $kunci = "E";
            }
            if ($ck_jum !== 0) {
                $jns = "1";
            }
            if ($ck_jum == 0) {
                $jns = "2";
            }
            // $jwb522 = str_replace("&amp;lt;", "<", $jwb521);
            // $jwb422 = str_replace("&amp;lt;", "<", $jwb421);
            // $jwb322 = str_replace("&amp;lt;", "<", $jwb321);
            // $jwb222 = str_replace("&amp;lt;", "<", $jwb221);
            // $jwb122 = str_replace("&amp;lt;", "<", $jwb121);
            $soal_tanya2 = str_replace("&amp;lt;", "<", $soal_tanya);
            // $jwb52 = str_replace("&amp;gt;", ">", $jwb522);
            // $jwb42 = str_replace("&amp;gt;", ">", $jwb422);
            // $jwb32 = str_replace("&amp;gt;", ">", $jwb322);
            // $jwb22 = str_replace("&amp;gt;", ">", $jwb222);
            // $jwb12 = str_replace("&amp;gt;", ">", $jwb122);
            $soal_tanya = str_replace("&amp;gt;", ">", $soal_tanya2);
			if($setting['jenjang']=='SMA' OR $setting['jenjang']=='SMK' OR $setting['jenjang']=='PAKET-C'){
				$opsie = 5;
			}else{
				$opsie = 4;
			}
            $exec = mysqli_query($koneksi, "INSERT INTO soal (id_bank,nomor,soal,pilA,pilB,pilC,pilD,pilE,jawaban,jenis,file1,fileA,fileB,fileC,fileD,fileE,groupsoal,opsi) VALUES ('$id_bank','$no','$soal_tanya','$opj1','$opj2','$opj3','$opj4','$opj5','$kunci','$jns','$g_soal','$fileA','$fileB','$fileC','$fileD','$fileE','CBT','$opsie')");
            if ($g_soal <> "") {
                $file = mysqli_query($koneksi, "INSERT INTO file_pendukung (nama_file,id_bank) values ('$g_soal','$id_bank')");
            }
            if ($fileA <> "") {
                $file = mysqli_query($koneksi, "INSERT INTO file_pendukung (nama_file,id_bank) values ('$fileA','$id_bank')");
            }
            if ($fileB <> "") {
                $file = mysqli_query($koneksi, "INSERT INTO file_pendukung (nama_file,id_bank) values ('$fileB','$id_bank')");
            }
            if ($fileC <> "") {
                $file = mysqli_query($koneksi, "INSERT INTO file_pendukung (nama_file,id_bank) values ('$fileC','$id_bank')");
            }
            if ($fileD <> "") {
                $file = mysqli_query($koneksi, "INSERT INTO file_pendukung (nama_file,id_bank) values ('$fileD','$id_bank')");
            }
            if ($fileE <> "") {
                $file = mysqli_query($koneksi, "INSERT INTO file_pendukung (nama_file,id_bank) values ('$fileE','$id_bank')");
            }
            $no++;
        }
        $hasil2 = mysqli_query($koneksi, "TRUNCATE TABLE savsoft_qbank");
        $hasil2 = mysqli_query($koneksi, "TRUNCATE TABLE savsoft_options");
    }
    $namamapel = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM banksoal WHERE id_bank='$id_bank'"));
    if ($namamapel['jml_esai'] == 0) {
        $hide = 'hidden';
    } else {
        $hide = '';
    }
    if ($namamapel['jml_soal'] == 0) {
        $hidex = 'hidden';
    } else {
        $hidex = '';
    }
    ?>

			<?php $bobot = fetch($koneksi, 'banksoal', ['id_bank' => $id_bank]); 
			$totalbobot=$bobot['bobot_pg']+$bobot['bobot_esai']+$bobot['bobot_multi']+$bobot['bobot_bs']+$bobot['bobot_urut'];
			?>
           <div class='row'>
       <div class='col-md-12'>
           <div class="card">
              <div class="card-header">	
				     <div class="example-content"> 
					   <?php if($menu['aplikasi']==0){ ?>
					 <button class='btn btn-sm btn-outline-success right' data-bs-toggle="modal" data-bs-target="#ubahbobot"><i class='fa fa-edit' data-bs-toggle="tooltip" data-bs-placement="top" title="Edit Bobot"></i> </button>
					   <?php } ?>
                        <button class='btn btn-sm btn-outline-primary right' onclick="frames['frameresult'].print()" data-bs-toggle="tooltip" data-bs-placement="top" title="Cetak Soal"><i class='fa fa-print'></i></button>
                        <iframe name='frameresult' src='sandik_bank/cetaksoal.php?id=<?= $id_bank ?>' style='border:none;width:1px;height:1px;'></iframe>
					     <?php if($menu['aplikasi']==0){ ?>
					   <button id="btnreset" data-id="<?= $id_bank ?>" class='btn btn-sm btn-outline-danger right' data-bs-toggle="tooltip" data-bs-placement="top" title="Hapus"><i class='fa fa-trash'></i></button>
						 <?php } ?>
						<a class='btn btn-sm btn-outline-warning right' href='?pg=banksoal' data-bs-toggle="tooltip" data-bs-placement="top" title="Beranda"><i class='fa fa-reply'></i></a>
						
			           
                    </div>			  
					 <h5 class='box-title'><?php if($menu['soal']==1){ ?>Bank Soal AKM<?php }else{ ?>Bank Soal CBT<?php } ?></h5>
                 </div>
				   <?php if($menu['aplikasi']==0){ ?>
                <div class='card-body'>
                  <div class="example-container">
                    <div class="example-content">
					    <div class="row">
                           <div class="col-md-4">
							<div class="form-group">
							<select  onChange="document.location.href=this.options[this.selectedIndex].value;" class="form-select form-control-sm">
								<option value="0">-- PILIH SOAL -- </option>
								 <?php if($bobot['bobot_pg']<>0){ ?>
								<option value="?pg=banksoal&ac=pg&id=<?= $bobot['id_bank'] ?>&jenis=1">PG</option>
								  <?php } ?>
								 <?php if($bobot['bobot_esai']<>0){ ?>
								 <option value="?pg=banksoal&ac=pg&id=<?= $bobot['id_bank'] ?>&jenis=2">ESAI</option>
								  <?php } ?>
								   <?php if($bobot['bobot_multi']<>0){ ?>
								 <option value="?pg=banksoal&ac=multi&id=<?= $bobot['id_bank'] ?>&jenis=3">PG MULTI CHOICE</option>
								 
								 <?php } ?>
								 <?php if($bobot['bobot_bs']<>0){ ?>
								 <option value="?pg=banksoal&ac=bs&id=<?= $bobot['id_bank'] ?>&jenis=4">BENAR SALAH</option>
								
								 <?php } ?>
								  <?php if($bobot['bobot_urut']<>0){ ?>
								    <option value="?pg=banksoal&ac=urut&id=<?= $bobot['id_bank'] ?>&jenis=5">MENJODOHKAN</option>
									 <option value="?pg=banksoal&ac=multipgm&id=<?= $bobot['id_bank'] ?>&jenis=5">MENGURUTKAN</option>
								 <?php } ?>
							    </select>

                                </div>
                            </div>
					
                	 <?php if($menu['soal']==0 AND $menu['opsi']==1): ?>
					
				           <div class="col-md-4">
							<div class="form-group">
							 <form id='formopsi' action='' method='post' enctype='multipart/form-data'>
							<select id='opsi' name="opsi" class='form-select form-control-sm' style="width:100%;" required >
                            <option value=''>Ubah Opsi Soal Impor</option>
           
                                    <option value='3'>3 Opsi</option>                             
                            <option value='4'>4 Opsi</option>
							  <option value='5'>5 Opsi</option>
                        </select>
						 </div>	
						 </div>
						 <div class="col-md-4">
							<div class="form-group">
					     <button type="submit" name="submit" class="btn btn-outline-primary">Simpan</button>
						</div>	
						 </div>
						</form>
				 <?php endif; ?>
				   </div>
				   </div>
				   <?php } ?>
				  <hr>
					 <script>
				  $('#formopsi').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
      
        $.ajax({
            type: 'POST',
            url: 'sandik_ujian/crud.php?pg=ubahopsi',
            enctype: 'multipart/form-data',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
               iziToast.info({
					title: 'Sukses!',
					message: 'Data berhasil disimpan',
					titleColor: '#FFFF00',
					messageColor: '#fff',
					backgroundColor: 'rgba(0, 0, 0, 0.5)',
					progressBarColor: '#FFFF00',
					position: 'topRight'			  
                });
                setTimeout(function() {
                    window.location.reload();
                }, 2000);

            }
        });
        return false;
    });
	$("#btnreset").click(function() {
        var id = $(this).data('id');
        swal({
            title: 'Konfirmasi ',
            text: 'Apakah kamu yakin akan menghapus semua soal ??',
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Ya, Hapus!'
        }).then((result) => {
            if (result.value) {
                $.ajax({
                    url: 'sandik_bank/crud_banksoal.php?pg=kosongsoal',
                    data: "id=" + id,
                    type: "POST",
                    success: function(respon) {
                        iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil dihapus',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'		  
                });
                        setTimeout(function() {
                            window.location.reload();
                        }, 2000);
                    }
                });
            }
            return false;
        })

    });
</script>        
			<div class="row">		
          <div class='col-md-12'>          
			   <div class="card-body">
					<h5 class='box-title'><i class='fa fa-th-list'></i>
					<?php if($menu['soal']==1){ ?> Soal AKM -<?php }else{ ?> Soal CBT-<?php } ?><?= $bobot['nama'] ?></h5>
									</div><br>
									<div class='table-responsive'>
                                    <table id="tabelsoal" class='table table-bordered'>
                                        <tbody>
                                            <?php $soalq = mysqli_query($koneksi, "SELECT * FROM soal where id_bank='$id_bank'  order by nomor "); ?>
                                            <?php while ($soal = mysqli_fetch_array($soalq)) : ?>

                                                <tr>
                                                    <td style='width:30px'>
                                                        <?= $soal['nomor'] ?>
                                                    </td>
                                                    <td style="text-align:justify">
                                                        <?php
                                                        if ($soal['file'] <> '') :
                                                            $audio = array('mp3', 'wav', 'ogg', 'MP3', 'WAV', 'OGG');
                                                            $image = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PNG', 'GIF', 'BMP');
                                                            $ext = explode(".", $soal['file']);
                                                            $ext = end($ext);
                                                            if (in_array($ext, $image)) {
                                                                echo "<p style='margin-bottom: 5px'><img src='$homeurl/files/$soal[file]' style='max-width:100px;'/></p>";
                                                            } elseif (in_array($ext, $audio)) {
                                                                echo "<p style='margin-bottom: 5px'><audio controls><source src='$homeurl/files/$soal[file]' type='audio/$ext'>Your browser does not support the audio tag.</audio></p>";
                                                            } else {
                                                                echo "File tidak didukung!";
                                                            }
                                                        endif;
                                                        ?>
                                                        <?= $soal['soal']; ?>
                                                        <?php
                                                        if ($soal['file1'] <> '') :
                                                            $audio = array('mp3', 'wav', 'ogg', 'MP3', 'WAV', 'OGG');
                                                            $image = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PNG', 'GIF', 'BMP');
                                                            $ext = explode(".", $soal['file1']);
                                                            $ext = end($ext);
                                                            if (in_array($ext, $image)) {
                                                                echo "<p style='margin-top: 5px'><img src='$homeurl/files/$soal[file1]' style='max-width:200px;' /></p>";
                                                            } elseif (in_array($ext, $audio)) {
                                                                echo "<p style='margin-top: 5px'><audio controls><source src='$homeurl/files/$soal[file1]' type='audio/$ext'>Your browser does not support the audio tag.</audio></p>";
                                                            } else {
                                                                echo "File tidak didukung!";
                                                            }
                                                        endif;
                                                        ?>
														<?php if ($soal['jenis'] == '1') : ?>
                                                        <table width="100%">
                                                            <tr>
                                                                <td style="padding: 3px;width: 2%; vertical-align: text-top;">A.</td>
                                                                <td style="padding: 3px;width: 31%; vertical-align: text-top;">
                                                                    <?php
                                                                    if ($soal['pilA'] <> '') {
                                                                        echo "$soal[pilA] ";
                                                                    }

                                                                    if ($soal['fileA'] <> '') {
                                                                        $audio = array('mp3', 'wav', 'ogg', 'MP3', 'WAV', 'OGG');
                                                                        $image = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PNG', 'GIF', 'BMP');
                                                                        $ext = explode(".", $soal['fileA']);
                                                                        $ext = end($ext);
                                                                        if (in_array($ext, $image)) {
                                                                            echo "<img src='$homeurl/files/$soal[fileA]' style='max-width:100px;'/>";
                                                                        } elseif (in_array($ext, $audio)) {
                                                                            echo "<audio controls><source src='$homeurl/files/$soal[fileA]' type='audio/$ext'>Your browser does not support the audio tag.</audio>";
                                                                        } else {
                                                                            echo "File tidak didukung!";
                                                                        }
                                                                    }
                                                                    ?>
                                                                </td>
																<?php if ($soal['opsi'] >=3 ) : ?>
                                                                <td style="padding: 3px;width: 2%; vertical-align: text-top;">C.</td>
                                                                <td style="padding: 3px;width: 31%; vertical-align: text-top;">
                                                                    <?php
                                                                    if (!$soal['pilC'] == "") {
                                                                        echo "$soal[pilC] ";
                                                                    }

                                                                    if ($soal['fileC'] <> '') {
                                                                        $audio = array('mp3', 'wav', 'ogg', 'MP3', 'WAV', 'OGG');
                                                                        $image = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PNG', 'GIF', 'BMP');
                                                                        $ext = explode(".", $soal['fileC']);
                                                                        $ext = end($ext);
                                                                        if (in_array($ext, $image)) {
                                                                            echo "<img src='$homeurl/files/$soal[fileC]' style='max-width:100px;' />";
                                                                        } elseif (in_array($ext, $audio)) {
                                                                            echo "<audio controls><source src='$homeurl/files/$soal[fileC]' type='audio/$ext'>Your browser does not support the audio tag.</audio>";
                                                                        } else {
                                                                            echo "File tidak didukung!";
                                                                        }
                                                                    }
                                                                    ?>
                                                                </td>
																 <?php endif; ?>
                                                                <?php if ($soal['opsi'] == 5) : ?>
                                                                    <td style="padding: 3px;width: 2%; vertical-align: text-top;">E.</td>
                                                                    <td style="padding: 3px; vertical-align: text-top;">
                                                                        <?php
                                                                        if (!$soal['pilE'] == "") {
                                                                            echo "$soal[pilE] ";
                                                                        }

                                                                        if ($soal['fileE'] <> '') {
                                                                            $audio = array('mp3', 'wav', 'ogg', 'MP3', 'WAV', 'OGG');
                                                                            $image = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PNG', 'GIF', 'BMP');
                                                                            $ext = explode(".", $soal['fileE']);
                                                                            $ext = end($ext);
                                                                            if (in_array($ext, $image)) {
                                                                                echo "<img src='$homeurl/files/$soal[fileE]' style='max-width:100px;' />";
                                                                            } elseif (in_array($ext, $audio)) {
                                                                                echo "<audio controls><source src='$homeurl/files/$soal[fileE]' type='audio/$ext'>Your browser does not support the audio tag.</audio>";
                                                                            } else {
                                                                                echo "File tidak didukung!";
                                                                            }
                                                                        }
                                                                        ?>
                                                                    </td>
                                                                <?php endif; ?>

                                                            </tr>

                                                            <tr>
															 <?php if ($soal['opsi'] >= 2) : ?>
                                                                <td style="padding: 3px;width: 2%; vertical-align: text-top;">B.</td>
                                                                <td style="padding: 3px;width: 31%; vertical-align: text-top;">
                                                                    <?php
                                                                    if (!$soal['pilB'] == "") {
                                                                        echo "$soal[pilB] ";
                                                                    }

                                                                    if ($soal['fileB'] <> '') {
                                                                        $audio = array('mp3', 'wav', 'ogg', 'MP3', 'WAV', 'OGG');
                                                                        $image = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PNG', 'GIF', 'BMP');
                                                                        $ext = explode(".", $soal['fileB']);
                                                                        $ext = end($ext);
                                                                        if (in_array($ext, $image)) {
                                                                            echo "<img src='$homeurl/files/$soal[fileB]' style='max-width:100px;' />";
                                                                        } elseif (in_array($ext, $audio)) {
                                                                            echo "<audio controls><source src='$homeurl/files/$soal[fileB]' type='audio/$ext'>Your browser does not support the audio tag.</audio>";
                                                                        } else {
                                                                            echo "File tidak didukung!";
                                                                        }
                                                                    }
                                                                    ?>
                                                                </td>
																<?php endif; ?>
                                                                <?php if ($soal['opsi'] >=4) : ?>
                                                                    <td style="padding: 3px;width: 2%; vertical-align: text-top;">D.</td>
                                                                    <td style="padding: 3px;width: 31%; vertical-align: text-top;">
                                                                        <?php
                                                                        if (!$soal['pilD'] == "") {
                                                                            echo "$soal[pilD] ";
                                                                        }

                                                                        if ($soal['fileD'] <> '') {
                                                                            $audio = array('mp3', 'wav', 'ogg', 'MP3', 'WAV', 'OGG');
                                                                            $image = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PNG', 'GIF', 'BMP');
                                                                            $ext = explode(".", $soal['fileD']);
                                                                            $ext = end($ext);
                                                                            if (in_array($ext, $image)) {
                                                                                echo "<img src='$homeurl/files/$soal[fileD]' style='max-width:100px;' />";
                                                                            } elseif (in_array($ext, $audio)) {
                                                                                echo "<audio controls><source src='$homeurl/files/$soal[fileD]' type='audio/$ext'>Your browser does not support the audio tag.</audio>";
                                                                            } else {
                                                                                echo "File tidak didukung!";
                                                                            }
                                                                        }
                                                                        ?>
                                                                    </td>

                                                                <?php endif; ?>

                                                            </tr>

                                                        </table>														
														<?php endif; ?>
															<?php if ($soal['jenis'] == '5' AND $soal['kode']=='U') : ?>
													 <table width="100%" class='table table-bordered'>
													 <tr>
														<td width="5%">1.</td>
															<td><?= $soal['pilA'] ?></td>
															<td width="10%"><input type="number" name="<?= $soal['id_soal'] ?>1" class="form-control"></td>
															
															</tr>
															 <?php if ($soal['opsi']>=2){ ?>
															<tr>
															<td>2.</td>
															<td><?= $soal['pilB'] ?></td>
															<td><input type="number" name="<?= $soal['id_soal'] ?>2" class="form-control"></td>
															
															</tr>
															<?php } ?>
															 <?php if ($soal['opsi']>=3){ ?>
															<tr>
															<td>3.</td>
															<td><?= $soal['pilC'] ?></td>
															<td><input type="number" name="<?= $soal['id_soal'] ?>3" class="form-control"></td>
															
															</tr>
															<?php } ?>
															 <?php if ($soal['opsi']>=4){ ?>
															<tr>
															<td>4.</td>
															<td><?= $soal['pilD'] ?></td>
															<td><input type="number" name="<?= $soal['id_soal'] ?>4" class="form-control"></td>
						
															</tr>
															<?php } ?>
															 <?php if ($soal['opsi'] ==5){ ?>
															<tr>
															<td>5.</td>
															<td><?= $soal['pilE'] ?></td>
															<td><input type="number" name="<?= $soal['id_soal'] ?>5" class="form-control"></td>
															
															</tr>
															<?php } ?>
															</table>
                                                    <?php endif; ?>
													
													<?php if ($soal['jenis'] == '3' AND $soal['kode'] == '') : ?>
													 <table width="100%">
													 <tr>
														      <td style="padding: 3px;width: 2%; vertical-align: text-top;">A.</td>
															 <td style="padding: 3px;width: 2%; vertical-align: text-top;"><input type="checkbox" name="<?= $soal['id_soal'] ?>"></td>
															 <td style="padding: 3px;width: 31%; vertical-align: text-top;"><?= $soal['pilA'] ?></td>
															 <?php if ($soal['opsi'] >=2){ ?>
															<td style="padding: 3px;width: 2%; vertical-align: text-top;">B.</td>
															 <td style="padding: 3px;width: 2%; vertical-align: text-top;"><input type="checkbox" name="<?= $soal['id_soal'] ?>"></td>
															 <td style="padding: 3px;width: 31%; vertical-align: text-top;"> <?= $soal['pilB'] ?></td>
															 <?php } ?>
															</tr>
															
															 <tr>
															 <?php if ($soal['opsi'] >=3){ ?>
														      <td style="padding: 3px;width: 2%; vertical-align: text-top;">C.</td>
															 <td style="padding: 3px;width: 2%; vertical-align: text-top;"><input type="checkbox" name="<?= $soal['id_soal'] ?>"></td>
															 <td style="padding: 3px;width: 31%; vertical-align: text-top;"><?= $soal['pilC'] ?></td>
															 <?php } ?>
															<?php if ($soal['opsi'] >=4){ ?>
															<td style="padding: 3px;width: 2%; vertical-align: text-top;">D.</td>
															 <td style="padding: 3px;width: 2%; vertical-align: text-top;"><input type="checkbox" name="<?= $soal['id_soal'] ?>"></td>
															 <td style="padding: 3px;width: 31%; vertical-align: text-top;"> <?= $soal['pilD'] ?></td>
															<?php } ?>
															</tr>
															
															 <?php if ($soal['opsi'] ==5){ ?>
															<tr>
														      <td style="padding: 3px;width: 2%; vertical-align: text-top;">E.</td>
															 <td style="padding: 3px;width: 2%; vertical-align: text-top;"><input type="checkbox" name="<?= $soal['id_soal'] ?>"></td>
															 <td style="padding: 3px;width: 31%; vertical-align: text-top;"><?= $soal['pilE'] ?></td>
															 <td style="padding: 3px;width: 2%; vertical-align: text-top;"></td>
															 <td style="padding: 3px;width: 2%; vertical-align: text-top;"></td>
															 <td style="padding: 3px;width: 31%; vertical-align: text-top;"> </td>
															
															</tr>
															<?php } ?>
															</table>
                                                    <?php endif; ?>
													
													
													
													<?php if ($soal['jenis'] == '4') : ?>
													 <table width="100%" class='table table-bordered'>
													 <?php if ($soal['pilA']<>''){ ?>
													<tr>
															<td class="text-center" ><b>Pernyataan</b></td>
															<td class="text-center" width="5%" ><b>Benar</b></td>
															<td class="text-center" width="5%" ><b>Salah</b></td>
															
															</tr>
													 <?php }else{ ?>
													 <tr>
															
															<td class="text-center" width="5%" ><b>Benar</b></td>
															<td class="text-center" width="5%" ><b>Salah</b></td>
															
															</tr>
													 <?php } ?>
															<tr>
															<?php if ($soal['pilA']<>''){ ?>
															<td><?= $soal['pilA'] ?></td>
															<?php } ?>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>1"></td>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>1"></td>
															
															</tr>
															 <?php if ($soal['opsi'] >=2){ ?>
															<tr>
															<?php if ($soal['pilB']<>''){ ?>
															<td><?= $soal['pilB'] ?></td>
															<?php } ?>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>2"></td>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>2"></td>
															
															</tr>
															 <?php } ?>
															  <?php if ($soal['opsi'] >=3){ ?>
															<tr>
															<?php if ($soal['pilC']<>''){ ?>
															<td><?= $soal['pilC'] ?></td>
															<?php } ?>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>3"></td>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>3"></td>
															
															</tr>
															 <?php } ?>
															 <?php if ($soal['opsi'] >=4){ ?>
															<tr>
															<?php if ($soal['pilD']<>''){ ?>
															<td><?= $soal['pilD'] ?></td>
															<?php } ?>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>4"></td>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>4"></td>
															
															</tr>
															 <?php } ?>
															 <?php if ($soal['opsi'] ==5){ ?>
															<tr>
															<?php if ($soal['pilE']<>''){ ?>
															<td><?= $soal['pilE'] ?></td>
															<?php } ?>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>5"></td>
															<td class="text-center"><input type="radio" name="<?= $soal['id_soal'] ?>5"></td>
															
															</tr>
															<?php } ?>
															</table>
                                                    <?php endif; ?>
													<?php if ($soal['jenis'] == '5' AND $soal['kode'] == '') : ?>
													 <table width="100%" class='table table-bordered'>
													       <tr>
														  
															<td class="text-center" ><b>Pernyataan</b></td>	
															<td class="text-center" width="5%" ><b></b></td>	
															<td class="text-center" width="5%" ><b></b></td>	
                                                            <td class="text-center" ><b>Jawaban</b></td>	
																													
															</tr>
                                                           
															<tr>															
															<td><?= $soal['perA'] ?></td>															
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><?= $soal['pilA'] ?></td>															
															</tr>
															 <?php if ($soal['opsi'] >=2){ ?>
															<tr>															
															<td><?= $soal['perB'] ?></td>															
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><?= $soal['pilB'] ?></td>															
															</tr>
															<?php } ?>
															 <?php if ($soal['opsi'] >=3){ ?>
															<tr>															
															<td><?= $soal['perC'] ?></td>															
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><?= $soal['pilC'] ?></td>															
															</tr>
															<?php } ?>
															 <?php if ($soal['opsi'] >=4){ ?>
															<tr>															
															<td><?= $soal['perD'] ?></td>															
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><?= $soal['pilD'] ?></td>															
															</tr>
															<?php } ?>
															 <?php if ($soal['opsi'] ==5){ ?>
															<tr>															
															<td><?= $soal['perE'] ?></td>															
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><input type="checkbox" name="<?= $soal['id_soal'] ?>1"></td>
															<td><?= $soal['pilE'] ?></td>															
															</tr>
															<?php } ?>
															</table>
                                                    <?php endif; ?>
													
                                                        <b> Kunci : <?= $soal['jawaban'] ?> </b>
                                                    </td>
													  <?php if($menu['aplikasi']==0){ ?>
													 <?php if ($setting['server'] == 'pusat') { ?>
                                                    <td width='10%'>
													  <button data-id="<?= $soal['id_soal'] ?>" class="hapus btn-sm btn btn-outline-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="Hapus"><i class="fas fa-times"></i></button>
                                                     
                                                   <?php if($soal['jenis']==3 AND $soal['kode']==''){ ?>
												   <a href="?pg=editsoal3&id_soal=<?php echo $soal['id_soal'] ?>" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></button></a>
												   <?php } ?>
												    <?php if($soal['jenis']==5 AND $soal['kode']=='U'){ ?>
												   <a href="?pg=editsoal7&id_soal=<?php echo $soal['id_soal'] ?>" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></button></a>
												   <?php } ?>
												    <?php if($soal['jenis']==1){ ?>
												   <a href="?pg=editsoal1&id_soal=<?php echo $soal['id_soal'] ?>" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></button></a>
												   <?php } ?>
												   <?php if($soal['jenis']==2){ ?>
												   <a href="?pg=editsoal2&id_soal=<?php echo $soal['id_soal'] ?>" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></button></a>
												   <?php } ?>
												    <?php if($soal['jenis']=='4' AND $soal['kode']==''){ ?>
												   <a href="?pg=editsoal4&id_soal=<?php echo $soal['id_soal'] ?>" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></button></a>
												   <?php } ?>
												   <?php if($soal['jenis']=='4' AND $soal['kode']=='FO'){ ?>
												   <a href="?pg=editsoal6&id_soal=<?php echo $soal['id_soal'] ?>" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></button></a>
												   <?php } ?>
												   <?php if($soal['jenis']==5 AND $soal['kode'] == ''){ ?>
												   <a href="?pg=editsoal5&id_soal=<?php echo $soal['id_soal'] ?>" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit"><i class='fa fa-edit'></i></button></a>
												   <?php } ?>
												  
												  </td>
													 <?php } ?>
													  <?php } ?>
                                                </tr>
                                                
                                            <?php endwhile; ?>
                                        </tbody>
                                    </table>
                        </div>
                    </div>
						 </div>
		   <div class="modal fade" id="ubahbobot" tabindex="-1" aria-labelledby="exampleModalLiveLabel" aria-hidden="true" style="margin-top:150px">
             <div class="modal-dialog modal-lg">
              <div class="modal-content">
              <div class="modal-header">
                  <h5 class="modal-title" id="exampleModalLiveLabel">Ubah Bobot</h5>
                   <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                      </div>
                       <div class="modal-body">
				                  <?php $siswa = fetch($koneksi, 'banksoal', ['id_bank' => $id_bank]);?>
                <form id="formtambahbobotpg">
				<input type="hidden" class="form-control" name="id_bank" value='<?= $siswa['id_bank'] ?>' required>
                    <div class='modal-body'>
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label for="">Bobot PG (%)</label>
                                    <input type="text" class="form-control" name="bobot_pg" value='<?= $siswa['bobot_pg'] ?>' required>
                                </div>
                             </div>
							 <div class="col-md-4">
                                <div class="form-group">
                                    <label for="">Bobot Isian Singkat (%)</label>
                                    <input type="text" class="form-control" name="bobot_esai" value='<?= $siswa['bobot_esai'] ?>' required>
                                </div>
                             </div>
							 <?php if($menu['soal']==1){ ?>
							 <div class="col-md-4">
                                <div class="form-group">
                                    <label for="">PG Kompleks  Multi (%)</label>
                                    <input type="text" class="form-control" name="bobot_multi" value='<?= $siswa['bobot_multi'] ?>' required>
                                </div>
                             </div>
							 <div class="col-md-4">
                                <div class="form-group">
                                    <label for="">PG Komplek BS | FO (%)</label>
                                    <input type="text" class="form-control" name="bobot_bs" value='<?= $siswa['bobot_bs'] ?>' required>
                                </div>
                             </div>
							 <div class="col-md-4">
                                <div class="form-group">
                                    <label for="">Bobot Menjodohkan (%)</label>
                                    <input type="text" class="form-control" name="bobot_urut" value='<?= $siswa['bobot_urut'] ?>' required>
                                </div>
                             </div>
							 <?php } ?>
							 
                  <div class="col-md-4">
                                <div class="form-group">
								 <br> <br>
                        <button type='submit' name='submit' class='btn btn-sm btn-outline-primary'><i class='fa fa-check'></i> Simpan</button>
                    </div>
					</div>
					 </div>
                </form>
            </div>
               </div>
                </div>
            </div>
        </div>
    </div>
          

	<?php elseif ($ac == 'upload11') : ?>
	<div class='row'>
       <div class='col-md-12'>
           <div class="card">
              <div class="card-header">	
				     <div class="example-content"> 
					  <a href="ujian" class="btn btn-sm btn-outline-danger right" >Beranda</a>
			          
                    </div>			  
					 <h5 class='box-title'>Impor Soal Excel</h5>
                 </div>
				  
					<?php
					$idmapel=$_GET['id'];
					$nom = mysqli_fetch_array(mysqli_query($koneksi, "SELECT max(nomor) AS nomer FROM soal WHERE id_bank='$idmapel' "));
					?>
                <div class='card-body'>
				<div class="example-content">
			
			   <form id="form-import" action='' method="POST" enctype="multipart/form-data">
                <div class='form-group'>
                    <label>Impor Soal</label>
                    <input type="file" class="form-control" name="file"  placeholder="" aria-describedby="helpfile" style="width:60%" required>
                     <small id="helpfile" class="form-text text-muted">File harus .xls</small>
                       </div>
							<input type="hidden" name="idmapel" value="<?= $idmapel ?>" >
                           
                            <input type="hidden" name="nomer" value="<?= $nom['nomer'] ?>" >							
                       
                               <div class="modal-footer">  
							   <a href="?pg=banksoal&ac=lihat&id=<?= $idmapel ?>" class="btn btn-sm btn-outline-warning"><i class='fa fa-times' ></i> Kembali</a>		
                                  <a href="template/formatsoal.xls" class="btn btn-sm btn-outline-primary" data-placement="top" data-toggle="tooltip" data-original-title="Format soal tidak bergambar"><i class='fa fa-download' ></i> Format</a>
								<button type="submit" id="edis" class="btn btn-sm btn-outline-success" onclick="fungsiSaya()"><i class='fa fa-upload'></i> Upload</button>
                                   </div>
								   </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
       <script>
    //IMPORT FILE PENDUKUNG 
    $('#form-import').on('submit', function(e) {
        e.preventDefault();
        $.ajax({
            type: 'post',
            url: 'sandik_bank/crud_imporsoal11.php',
            data: new FormData(this),
            processData: false,
            contentType: false,
            cache: false,
            beforeSend: function() {
                $('form button').on("click", function(e) {
                    e.preventDefault();
                });
            },
            success: function(data) {

                $('#importdata').modal('hide');
                 iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
                    });
                setTimeout(function() {
                    window.location.replace('?pg=banksoal&ac=lihat&id=<?= $idmapel ?>');
                }, 2000);


            }
        });
    });
   
</script>
<script>
function fungsiSaya() {
  var x = document.getElementById("edis");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
</script>
	

<?php endif; ?>
<script>
    $('#formsoal').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
        $.ajax({
            type: 'POST',
            url: 'sandik_bank/crud_banksoal.php?pg=simpan_soal',
            enctype: 'multipart/form-data',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            beforeSend: function() {},
            success: function(data) {
                iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
                    });
                    setTimeout(function() {
                        window.location.reload();
                    }, 2000);
            }
        })
        return false;
    });
	 
    
	
    $("#soallevel").change(function() {
        var level = $(this).val();
        console.log(level);
        $.ajax({
            type: "POST",
            url: "sandik_bank/crud_banksoal.php?pg=ambil_kelas", 
            data: "level=" + level, 
            success: function(response) { 
                $("#soalkelas").html(response);
            }
        });
    });
</script>
<script>
 $('#formtambahbobotpg').submit(function(e) {
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'sandik_bank/crud_banksoal.php?pg=tambahpg',
            data: $(this).serialize(),
            success: function(data) {
                console.log(data);
                if (data == 'OK') {
                   iziToast.info(
            {
                title: 'Sukses!',
                message: 'Bobot berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
                    });
                    setTimeout(function() {
                        window.location.reload();
                    }, 2000);
                } else {
                  iziToast.info(
            {
                title: 'Gagal!',
                message: 'Bobot Sudah ada',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
                    });
					setTimeout(function() {
                        window.location.reload();
                    }, 2000);
                }

            }
        });
        return false;
    });
	
$('#formtambahboboturaian').submit(function(e) {
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'sandik_bank/crud_banksoal.php?pg=tambahuraian',
            data: $(this).serialize(),
            success: function(data) {
                console.log(data);
                if (data == "OK") {
                    toastr.success("bobot nilai berhasil dibuat");
                } else {
                    toastr.error(data);
                }
                $('#tambahboboturaian').modal('hide');
                setTimeout(function() {
                    location.reload();
                }, 2000);

            }
        });
        return false;
    });
</script>

<script>
    tinymce.init({
        selector: '.editor1',
        plugins: [
            'advlist autolink lists link image charmap print preview hr anchor pagebreak',
            'searchreplace wordcount visualblocks visualchars code fullscreen',
            'insertdatetime media nonbreaking save table contextmenu directionality',
            'emoticons template paste textcolor colorpicker textpattern imagetools uploadimage paste formula'
        ],

        toolbar: 'bold italic fontselect fontsizeselect | alignleft aligncenter alignright bullist numlist  backcolor forecolor | formula code | imagetools link image paste ',
        fontsize_formats: '8pt 10pt 12pt 14pt 18pt 24pt 36pt',
        paste_data_images: true,

        images_upload_handler: function(blobInfo, success, failure) {
            success('data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64());
        },
        image_class_list: [{
            title: 'Responsive',
            value: 'img-responsive'
        }],
        setup: function(editor) {
            editor.on('change', function() {
                tinymce.triggerSave();
            });
        }
    });
</script>
<script>
$('#pg').click(function() {
   if($(this).is(":checked")){
      $("#bobot_pg").show();
   }
   else{
      $("#bobot_pg").hide();
   }
});
</script>
<script>
$('#multi').click(function() {
   if($(this).is(":checked")){
      $("#bobot_multi").show();
   }
   else{
      $("#bobot_multi").hide();
   }
});
</script>
<script>
$('#bs').click(function() {
   if($(this).is(":checked")){
      $("#bobot_bs").show();
   }
   else{
      $("#bobot_bs").hide();
   }
});
</script>
<script>
$('#esai').click(function() {
   if($(this).is(":checked")){
      $("#bobot_esai").show();
   }
   else{
      $("#bobot_esai").hide();
   }
});
</script>
<script>
$('#urut').click(function() {
   if($(this).is(":checked")){
      $("#bobot_urut").show();
   }
   else{
      $("#bobot_urut").hide();
   }
});
</script>
<script>
$('#kkm').click(function() {
   if($(this).is(":checked")){
      $("#bobot_kkm").show();
   }
   else{
      $("#bobot_kkm").hide();
   }
});
</script>
<script>
 $('#tabelsoal').on('click', '.hapus', function() {
        var id = $(this).data('id');
        console.log(id);
        Swal.fire({
				  title: 'Are you sure?',
				  text: "You won't be able to revert this!",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#3085d6',
				  cancelButtonColor: '#d33',
				  confirmButtonText: 'Yes, delete it!'	
        }).then((result) => {
            if (result.value) {
                $.ajax({
                     url: 'sandik_bank/crud_banksoal.php?pg=hapussoal',
                    method: "POST",
                    data: 'id=' + id,
                    success: function(data) {
                  iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil dihapus',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'				  
                });
                        setTimeout(function() {
                            window.location.reload();
                        }, 2000);
                    }
                });
            }
            return false;
        })

    });
	
	
</script>
