<script>
function triggerAudio(abc) {
    var playid = abc.id.substring(4);
    document.getElementById("audio"+playid).play();
}
</script>

<?php 
if (isset($_SESSION['UID']) && isset($_GET['bh'])) {
    $userId = $_SESSION['UID'];
    $bhId = $_GET['bh'];
    // Check history exists
    $lichSuBaiHocModel = DataProvider::GetOneRow("select * from lichsubaihoc where lsbh_TaiKhoan={$userId} AND lsbh_BaiHoc={$bhId}");
    if ($lichSuBaiHocModel) {
        // If exist, update counter
        $result = DataProvider::ExecuteQuery("update lichsubaihoc set lsbh_SoLanHoc=lsbh_SoLanHoc+1 where lsbh_ID={$lichSuBaiHocModel['lsbh_ID']}");
        //var_dump($result);
        //echo 'count';exit;
    } else {
        // If not exist, insert
        $result = DataProvider::ExecuteQuery("insert into lichsubaihoc(`lsbh_TaiKhoan`, `lsbh_BaiHoc`, `lsbh_ThoiGian`, `lsbh_SoLanHoc`) values ({$userId}, {$bhId}, now(), 1)");
        //var_dump($result);
        //echo 'insert';exit;
    }
}
$idBaiHoc = $_GET["bh"];
$idLoaiBaiHoc = $_GET["lbh"];
$result = DataProvider::GetRows("select * from cau where c_BaiHoc = {$idBaiHoc}");
foreach ($result as $value) {
    $chon = rand(1, 5);
    if ($chon == 1) {
<?php

require_once "process/xuly_dangnhap.php";
include_once "dataconfig/dataprovider.php";
$xx = new xuLyDangNhap();
if (isset($_POST['btnLogin'])) {
    //document.getElementById("result").innerHTML =''; // Variable To Store Error Message
    $xx->HandleError('');
    $id = $xx->CheckLoginInDB($_POST['txtUsername'], $_POST['txtPassword']);
    $sql = "select * from taikhoan where tk_TenDangNhap = '" . $_POST['txtUsername'] . "' and tk_MatKhau = '" . $_POST['txtPassword'] . "'";
    $result = DataProvider::GetOneRow($sql);
    if ($id > 0) {
        if (session_status() == PHP_SESSION_NONE) {
            session_start();
        }
        $_SESSION['UID'] = $id;
        $_SESSION["user_name"] = $_POST['txtUsername'];
        $_SESSION['DaDangNhap'] = 1;
        $_SESSION['LoaiNguoiDung'] = $result['tk_LoaiNguoiDung'];
        $xx->RedirectToURL("index.php");
    }
}
?>
  
<a id="thongbaoloi" class="show-top-notification-2 timer-notification" href="#"/>
<div class="top-notification-2 top-notification bg-red-dark timeout-notification">
    <h4>Thông báo</h4>
    <p>
        <?php 
echo $xx->GetErrorMessage();
?>
    $TypeBaiHoc = $_REQUEST["cbTypeBaiHoc"];
    if ($name == null) {
        $hinhanh = $_REQUEST["txtHinhAnh"];
    } else {
        $hinhanh = 'upload/HinhAnh/' . $name;
    }
    $solandoc = $_REQUEST["txtSoLanDoc"];
    $sql = "UPDATE baihoc SET bh_TenBaiHoc = '{$tenbaihoc}', bh_ngaytao = '{$tempngaytao}', bh_HinhDaiDien = '{$hinhanh}', bh_LoaiBaiHoc = '{$TypeBaiHoc}', bh_SoLanChon = '{$solandoc}' WHERE bh_ID= '{$id}' ";
    DataProvider::ExecuteQuery($sql);
    echo '<script>alert("Cập nhật thành công!")</script>';
}
?>

<a class="btn btn-primary" href="quanlybaihoc.php">Quay lại</a>
<?php 
$result = DataProvider::GetOneRow("select * from baihoc where bh_ID = {$id}");
?>
<form class="form-horizontal" role="form" action="" method="post" enctype="multipart/form-data">
  <fieldset>
  <legend>Detail User</legend>
  <div class="form-group">
    <label class="col-sm-2 control-label">Tên bài học</label>
    <div class="col-sm-10">
      <input name="txtTenBaiHoc" type="text" class="form-control" required="required" value="<?php 
echo $result[1];
?>
">
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label">Loại bài học</label>
    $hoten = $_REQUEST["txtFullName"];
    $Password = $_REQUEST["txtPassword"];
    if ($_REQUEST["Gender"] == "1") {
        $Gender = "1";
    } else {
        $Gender = "2";
    }
    $TypeUser = $_REQUEST["cbTypeUser"];
    $sql = "UPDATE taikhoan SET tk_MatKhau = '{$Password}', tk_HoTen = '{$hoten}', tk_GioiTinh = '{$Gender}', tk_LoaiNguoiDung = '{$TypeUser}' WHERE tk_ID= '{$id}' ";
    DataProvider::ExecuteQuery($sql);
    echo '<script>alert("Cập nhật thành công!")</script>';
}
?>
<a class="btn btn-primary" href="quanlytaikhoan.php">Back</a>
<?php 
$result = DataProvider::GetOneRow("select * from taikhoan where tk_ID = {$id}");
?>
<form class="form-horizontal" role="form" action="" method="post" enctype="multipart/form-data">
  <fieldset>
  <legend>Detail User</legend>
  <div class="form-group">
    <label class="col-sm-2 control-label">Họ Tên</label>
    <div class="col-sm-10">
      <input name="txtFullName" type="text" class="form-control" required="required" value="<?php 
echo $result[1];
?>
">
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-2 control-label">Tên Tài Khoản</label>