<?php
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");

(isset($_GET['pg'])) ? $pg = $_GET['pg'] : $pg = '';
$user = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM users  WHERE id_user='$_SESSION[id_user]'"));
$id_user = $user['id_user'];


if ($pg == 'hapus') {
    $kode = $_POST['id'];
 
    $exec = mysqli_query($koneksi, "DELETE FROM soal_quiz WHERE id_bank=$kode");
   
}
if ($pg == 'simpan') {
	$data =[
	 'idmateri'=>$_POST['id_materi'],
	'nomor'=>$_POST['nomor'],
	'soal'=>$_POST['isi_soal'],
	'pilA'=>$_POST['pilA'],
	 'pilB'=>$_POST['pilB'],
	 'pilC'=>$_POST['pilC'],
	 'pilD'=>$_POST['pilD'],
	 'pilE'=>$_POST['pilE'],
	 'kode'=>'1',
	'jawaban'=>$_POST['jawaban']
	];
	 $exec = insert($koneksi, 'soal_Quiz', $data);
    echo"OK";	
}
if ($pg == 'editpg') {
 $idbank=$_POST['idbank'];
 $data =[
	
	'soal'=>$_POST['isi_soal'],
	'pilA'=>$_POST['pilA'],
	 'pilB'=>$_POST['pilB'],
	 'pilC'=>$_POST['pilC'],
	 'pilD'=>$_POST['pilD'],
	 'pilE'=>$_POST['pilE'],
	 'kode'=>'1',
	'jawaban'=>$_POST['jawaban']
	];
	 $exec = update($koneksi, 'soal_Quiz', $data,['id_bank'=>$idbank]);
    echo"OK";	
 
 }