<?php
$idbank=$_GET['idbank'];
$soalQ = mysqli_query($koneksi, "SELECT * FROM soal_quiz WHERE id_bank='$idbank'");
$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 = '';
($soal['jawaban'] == 'E') ? $jwbE = 'checked' : $jwbE = '';
$idmateri=$soal['idmateri'];
?>
<div class='row'>
	<div class='col-md-12'>
	 <div class="card">
             <div class="card-header">
         <div class='btn-group' style='margin-top:-5px'>					
						<a class='btn btn-sm btn-outline-danger'>No Soal : <?= $soal['nomor'] ?></a>
					</div>	
            <div class="row">
			  <div class="card-body">					
		<form id="formquiz"  enctype="multipart/form-data">
		
					<div class='right'>
					<button type='submit' name='simpanpg' onclick="tinyMCE.triggerSave(true,true);" class='btn btn-sm btn-outline-primary'><i class='fa fa-check-circle'></i> Simpan</button>
						<a href="?pg=quizbank&id=<?= $idmateri ?>" class='btn btn-sm btn-outline-danger'><i class='fa fa-times-circle'></i></a>
					</div>
			            </div>
						 <input type="hidden" class="form-control" name="idbank" value="<?= $soal['id_bank'] ?>">
                 
						<div class='row'>
						  <div class='col-md-6'>
						<div class='box-body'>
                                            <textarea id='editor2' name='isi_soal' class='editor1' rows='10' cols='60' style='width:100%;'><?= $soal['soal'] ?></textarea>
                                        </div>
                                    </div>
								
								<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">
                                            OPSI 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">
                                                    <div class="box-body">
												<div class='form-group'>
											
													<textarea name='pilA' class='editor1 pilihan form-control'><?= $soal['pilA'] ?></textarea>
												</div>                  
                                                  </div>  
												    </div>
													 </div>  
												   
										<div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExampleB" role="button" aria-expanded="false" aria-controls="collapseExampleB">
                                            OPSI 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="collapseExampleB">
                                                    <div class="box-body">
												<div class='form-group'>

													<textarea name='pilB' class='editor1 pilihan form-control'><?= $soal['pilB'] ?></textarea>
												</div>
													</div>
													</div>
													 </div>  
													<div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExampleC" role="button" aria-expanded="false" aria-controls="collapseExampleC">
                                            OPSI 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="collapseExampleC">
                                                    <div class="box-body">
												<div class='form-group'>

													<textarea name='pilC' class='editor1 pilihan form-control'><?= $soal['pilC'] ?></textarea>
												</div>
													</div>
													</div>
													 </div>  
													 <div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExampleD" role="button" aria-expanded="false" aria-controls="collapseExampleD">
                                            OPSI 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="collapseExampleD">
                                                    <div class="box-body">
												<div class='form-group'>

													<textarea name='pilD' class='editor1 pilihan form-control'><?= $soal['pilD'] ?></textarea>
												</div>
													</div>
													</div>
													 </div>
													 <?php if($setting['jenjang']=='SMK' OR $setting['jenjang']=='SMA' OR $setting['jenjang']=='PAKET-C'){ ?>
													<div class="example-content bg-white">
                                    <p>
                                      <a class="btn btn-outline-primary" data-bs-toggle="collapse" href="#collapseExampleE" role="button" aria-expanded="false" aria-controls="collapseExampleE">
                                            OPSI 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="collapseExampleE">
                                                    <div class="box-body">
												<div class='form-group'>
													<textarea name='pilE' class='editor1 pilihan form-control'><?= $soal['pilE'] ?></textarea>
												</div>
													</div>
													</div>
													 </div>
													 <?php } ?>
												    </div>
													</div>
                                    <div class="modal-footer">
                                      
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
			
<script>
    $('#formquiz').submit(function(e){
    e.preventDefault();
    var data = new FormData(this);
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_learn/crud_quiz.php?pg=editpg',
        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;
});
</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'
		}],
	});
</script>