<?php
if (!isset($_GET['id']) && !isset($_GET['no']) && !isset($_GET['jenis'])) :
	die("Anda tidak dizinkan mengakses langsung script ini!");
endif;
$nomor = $_GET['no'];
$jenis = $_GET['jenis'];
$id_bank = $_GET['id'];

$nom = mysqli_fetch_array(mysqli_query($koneksi, "SELECT max(nomor) AS nomer FROM soal WHERE id_bank='$id_bank'"));
if($nom['nomer']==''){
$nomor = 1;
}else{
$nomor =$nom['nomer'] + 1;
}
$mapel = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM banksoal WHERE id_bank='$id_bank'"));
$idmap=$mapel['kode'];

$jumsoal = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM soal WHERE id_bank='$id_bank' AND  nomor='$nomor' AND jenis='$jenis'"));
$soalQ = mysqli_query($koneksi, "SELECT * FROM soal WHERE id_bank='$id_bank' AND  nomor='$nomor' AND jenis='$jenis'");
$soal = mysqli_fetch_array($soalQ);
($soal['jawaban'] == 'A') ? $jwbA = 'checked' : $jwbA = '';
($soal['jawaban'] == 'B') ? $jwbB = 'checked' : $jwbB = '';
($soal['jawaban'] == 'C') ? $jwbC = 'checked' : $jwbC = '';
($soal['jawaban'] == 'D') ? $jwbD = 'checked' : $jwbD = '';
if ($mapel['opsi'] == 5) {
	($soal['jawaban'] == 'E') ? $jwbE = 'checked' : $jwbE = '';
}
?>
<?php include"sandik_bank/radio.php"; ?>
 <div class="row">
     <div class="col-md-12">
		<div class="card">
             <div class="card-header">									
					<h5 class='box-title'> 
					<?php if($jenis==1){ ?>
						SOAL PG
						<?php } ?>
						<?php if($jenis==2){ ?>
						SOAL ISIAN SINGKAT
						<?php } ?>
					</h5>
                </div>
				<div class="row">
			  <div class="card-body">
		<form id='formsoal' action='' method='post' enctype='multipart/form-data'>
			<div class="card">
             <div class="card-header">	

					<div class='btn-group' style='margin-top:-5px'>
						<a class='btn btn-sm btn-outline-primary'>Mapel </a>
						<a class='btn btn-sm btn-outline-primary'><?= $mapel['nama'] ?> </a>
						<a class='btn btn-sm btn-outline-danger'>No Soal :<b class="sandik"> <?= $nomor ?></b></a>
					
					</div>
					 <?php if($menu['opsi']==1 AND $jenis==1): ?>
					    <div class='btn-group' style='margin-top:-5px'>
							<select id='opsi' name="opsi" class='btn btn-sm btn-outline-secondary' >
                            <option value=''>Tambah Opsi</option>
                            
							   <option value='2'>2 Opsi</option>
                                    <option value='3'>3 Opsi</option>                             
                            <option value='4'>4 Opsi</option>
							  <option value='5'>5 Opsi</option>
                        </select>    
						</div>
						<?php endif; ?>
						<button type='submit' name='simpansoal' onclick="tinyMCE.triggerSave(true,true);" class='btn btn-sm btn-outline-primary right' style='margin-top:-5px'> Simpan</button>
						<a href='?pg=banksoal&ac=lihat&id=<?= $id_bank ?>' class='btn btn-sm btn-outline-danger right' style='margin-top:-5px'> Kembali</a>

					</div>
				</div>
                        
				<div class='box-body'>
					<input type='hidden' name='mapel' value='<?= $id_bank ?>'>
					<input type='hidden' name='jenis' value='<?= $jenis ?>'>
					<input type='hidden' name='nomor' value='<?= $nomor ?>'>
					
					<div class='row'>
						<div class='col-md-6'>
						<div class='box-body'>
								
									<form>
										<textarea id='editor2' name='isi_soal' class='editor1' rows='10' cols='80' style='width:100%;'><?= $soal['soal'] ?></textarea>
									</form>
								</div><p>
								<div class="row">
							<div class='col-md-6'>
								<div class='form-group'>
									<?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 "
										<label>Gambar</label><br />
										<img src='$homeurl/files/$soal[file]' style='max-width:100px;' />
										";
										} elseif (in_array($ext, $audio)) {
											echo "
										<label>Audio</label><br />
										<audio controls>
											<source src='$homeurl/files/$soal[file]' type='audio/$ext'>Your browser does not support the audio tag.</audio>
										";
										} else {
											echo "File tidak didukung!";
										}
										echo "<br /><a href='#'  data-id='$soal[id_soal]'  class='hapus  text-red'><i class='fa fa-times'></i> Hapus</a>";
									} else {
										echo "
										<label>Gambar / Audio</label>
										<input type='file' class='form-control' name='file' type='file'>
										";
									}
									?>
								</div>
							</div>
							<div class='col-md-6'>
								<div class='form-group'>
									<?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 "
										<label>Gambar</label><br />
										<img src='$homeurl/files/$soal[file1]' style='max-width:100px;' />
										";
										} elseif (in_array($ext, $audio)) {
											echo "
										<label>Audio</label><br />
										<audio controls>
											<source src='$homeurl/files/$soal[file1]' type='audio/$ext'>Your browser does not support the audio tag.</audio>
										";
										} else {
											echo "File tidak didukung!";
										}
											echo "<br /><a href='#'  data-id='$soal[id_soal]'  class='hapusQ  text-red'><i class='fa fa-times'></i> Hapus</a>";
									} else {
										echo "
										<label>Gambar / Audio</label>
										<input type='file' class='form-control' name='file1' type='file'>
										";
									}
									?>
								</div>
							</div>
							</div><p>
							<?php if($mapel['pembahasan']==1){ ?>
							
							<h5 class='card-title'>PEMBAHASAN</h5>
								<div class='box-body'>								
								<textarea id='bahasan' name='bahasan' class='editor1' rows='10' cols='80' style='width:100%;'><?= $soal['pembahasan'] ?></textarea>								
								</div>
							
							<?php } ?>
						 </div> 
						
						
					 <?php if ($jenis == '2') : ?>
						<div class='col-md-6'>
								<div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
                                            KUNCI JAWABAN
                                           </a>
										 </p>
                                                <div class="collapse" id="collapseExample">
                                                    <div class="box-body">
												<div class='form-group'>
                                               <textarea id='jawabesai' name='pilA' class='editor1 pilihan form-control' required ><?= $soal['pilA'] ?></textarea>
                           
												</div>
												
											</div>
											</div>
			                        <?php endif; ?>
						         
						<?php
						if ($jenis == '1') {
						?>
						   <?php if($menu['opsi']==0): ?>
							<div class='col-md-6'>
							
                                 <div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-A" role="button" aria-expanded="false" aria-controls="collapseExample-A">
                                            JAWABAN A
                                           </a>
										 <label class="radio right"><input type='radio' name='jawaban' value='A' required='true' <?= $jwbA ?> />
							            <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-A">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilA' class='editor1 pilihan form-control'><?= $soal['pilA'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar A</label><br />
														<img src='$homeurl/files/$soal[fileA]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileA&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil A</label>
														<input type='file' name='fileA' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
                                             <p>       
							<div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-B" role="button" aria-expanded="false" aria-controls="collapseExample-B">
                                            JAWABAN B
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='B' required='true' <?= $jwbB ?> /> 
							              <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-B">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilB' class='editor1 pilihan form-control'><?= $soal['pilB'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar B</label><br />
														<img src='$homeurl/files/$soal[fileB]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileB&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil B</label>
														<input type='file' name='fileB' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
							           <p>
							<div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-C" role="button" aria-expanded="false" aria-controls="collapseExample-C">
                                            JAWABAN C
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='C' required='true' <?= $jwbC ?> />
							              <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-C">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilC' class='editor1 pilihan form-control'><?= $soal['pilC'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar C</label><br />
														<img src='$homeurl/files/$soal[fileC]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileC&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil C</label>
														<input type='file' name='fileC' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
							           <p>
							       <div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-D" role="button" aria-expanded="false" aria-controls="collapseExample-D">
                                            JAWABAN D
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='D' required='true' <?= $jwbD ?> /> 
							              <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-D">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilD' class='editor1 pilihan form-control'><?= $soal['pilD'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar D</label><br />
														<img src='$homeurl/files/$soal[fileD]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileD&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil D</label>
														<input type='file' name='fileD' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div><p>
							    <?php if($setting['jenjang']=='SMA' OR $setting['jenjang']=='SMK' OR $setting['jenjang']=='PAKET-C'){ ?>
							   <div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-E" role="button" aria-expanded="false" aria-controls="collapseExample-E">
                                            JAWABAN E
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='E' required='true' <?= $jwbE ?> /> 
							             <span class="check"></span></label>
										</p>
                                                <div class="collapse" id="collapseExample-E">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilE' class='editor1 pilihan form-control'><?= $soal['pilE'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar D</label><br />
														<img src='$homeurl/files/$soal[fileE]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileE&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil E</label>
														<input type='file' name='fileE' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
								      <?php } ?>
									  
									  <?php elseif($menu['opsi']==1): ?>
							<div class='col-md-6'>
                                 <div class="example-content bg-white" >
                                    <p id="pilA" style="display: none;">
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-A" role="button" aria-expanded="false" aria-controls="collapseExample-A">
                                            JAWABAN A
                                           </a>
										 <label class="radio right"><input type='radio' name='jawaban' value='A' required='true' <?= $jwbA ?> />
							            <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-A">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilA' class='editor1 pilihan form-control'><?= $soal['pilA'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar A</label><br />
														<img src='$homeurl/files/$soal[fileA]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileA&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil A</label>
														<input type='file' name='fileA' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
                                         <p>     
							<div class="example-content bg-white">
                                    <p id="pilB" style="display: none;">
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-B" role="button" aria-expanded="false" aria-controls="collapseExample-B">
                                            JAWABAN B
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='B' required='true' <?= $jwbB ?> /> 
							              <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-B">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilB' class='editor1 pilihan form-control'><?= $soal['pilB'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar B</label><br />
														<img src='$homeurl/files/$soal[fileB]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileB&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil B</label>
														<input type='file' name='fileB' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
							          <p> 
							<div class="example-content bg-white">
                                    <p id="pilC" style="display: none;">
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-C" role="button" aria-expanded="false" aria-controls="collapseExample-C">
                                            JAWABAN C
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='C' required='true' <?= $jwbC ?> />
							              <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-C">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilC' class='editor1 pilihan form-control'><?= $soal['pilC'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar C</label><br />
														<img src='$homeurl/files/$soal[fileC]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileC&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil C</label>
														<input type='file' name='fileC' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
							           <p> 
							       <div class="example-content bg-white">
                                    <p id="pilD" style="display: none;">
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-D" role="button" aria-expanded="false" aria-controls="collapseExample-D">
                                            JAWABAN D
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='D' required='true' <?= $jwbD ?> /> 
							              <span class="check"></span></label>
										 </p>
                                                <div class="collapse" id="collapseExample-D">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilD' class='editor1 pilihan form-control'><?= $soal['pilD'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar D</label><br />
														<img src='$homeurl/files/$soal[fileD]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileD&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil D</label>
														<input type='file' name='fileD' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
							          <p> 
							   <div class="example-content bg-white">
                                    <p id="pilE" style="display: none;">
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExample-E" role="button" aria-expanded="false" aria-controls="collapseExample-E">
                                            JAWABAN E
                                           </a>
										<label class="radio right"><input type='radio' name='jawaban' value='E' required='true' <?= $jwbE ?> /> 
							             <span class="check"></span></label>
										</p>
                                                <div class="collapse" id="collapseExample-E">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilE' class='editor1 pilihan form-control'><?= $soal['pilE'] ?></textarea>
												</div>
												<div class='form-group'>
												<?php
												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 "
														<label>Gambar D</label><br />
														<img src='$homeurl/files/$soal[fileE]' style='max-width:80px;' />
														";
													} elseif (in_array($ext, $audio)) {
														echo "
														<label>Audio</label><br />
														<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!";
													}
													echo "<br /><a href='?pg=$pg&ac=hapusfile&id=$soal[id_soal]&file=fileE&jenis=$jenis' class='text-red'><i class='fa fa-times'></i> Hapus</a>";
												} else {
													echo "
														<label>Gambar / Audio Pil E</label>
														<input type='file' name='fileE' class='form-control' />
														";
												}
												?>
												</div>
											</div>
										</div>
								      
							       <?php endif; ?>
						       <?php } ?>
							
						
<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'
		}],
	});
</script>

<script type="text/javascript">
    $(function () {
        $("#opsi").change(function () {
            if ($(this).val() == "1") {
                $("#pilA").show();
                $("#pilB").hide();
				 $("#pilC").hide();
				  $("#pilD").hide();
				   $("#pilE").hide();
            } else if ($(this).val() == "2") {
                $("#pilA").show();
                $("#pilB").show();
				 $("#pilC").hide();
				  $("#pilD").hide();
				   $("#pilE").hide();
		} else if ($(this).val() == "3") {
                $("#pilA").show();
                $("#pilB").show();
				 $("#pilC").show();
				  $("#pilD").hide();
				   $("#pilE").hide();
		} else if ($(this).val() == "4") {
                $("#pilA").show();
                $("#pilB").show();
				 $("#pilC").show();
				  $("#pilD").show();
				   $("#pilE").hide();
	} else if ($(this).val() == "5") {
                $("#pilA").show();
                $("#pilB").show();
				 $("#pilC").show();
				  $("#pilD").show();
				   $("#pilE").show();
            }else{
				  $("#pilA").hide();
                $("#pilB").hide();
				 $("#pilC").hide();
				  $("#pilD").hide();
				   $("#pilE").hide();
			}
        });
    });
</script>
