| Server IP : 104.21.80.248 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/training/user/ |
Upload File : |
<?php
include("../session.php");
if ($role != 'user') {
header("Location: ../index.php");
exit;
}
include("../db.php");
// ตรวจสอบว่ามีการส่ง result ที่ต้องการหรือไม่
if (!isset($_GET['result'])) {
header("Location: dashboard.php");
exit;
}
// ถอดรหัส result ID
$result_id = base64_decode($_GET['result']);
// ดึงข้อมูลผลการสอบ
$user_id = $_SESSION['user_id'];
$result_query = mysqli_query($conn, "SELECT er.*, s.name as subject_name, s.pass_percentage
FROM exam_results er
JOIN subjects s ON er.subject_id = s.id
WHERE er.id = $result_id AND er.user_id = $user_id");
if (!$result = mysqli_fetch_assoc($result_query)) {
header("Location: dashboard.php");
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ผลการสอบ - <?php echo htmlspecialchars($result['subject_name']); ?></title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<style>
.result-panel {
margin-top: 30px;
}
.result-header {
padding: 20px;
text-align: center;
margin-bottom: 20px;
}
.result-details {
font-size: 18px;
line-height: 1.8;
}
</style>
</head>
<body>
<div class="container">
<h3 class="text-center">ผลการสอบวิชา: <?php echo htmlspecialchars($result['subject_name']); ?></h3>
<p class="text-right">
<a href="dashboard.php" class="btn btn-default btn-sm">← กลับหน้าหลัก</a>
</p>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default result-panel">
<div class="result-header <?php echo $result['passed'] ? 'bg-success' : 'bg-danger'; ?>">
<h3 style="color: #fff;">
<?php if ($result['passed']): ?>
<span class="glyphicon glyphicon-ok-circle"></span> สอบผ่าน
<?php else: ?>
<span class="glyphicon glyphicon-remove-circle"></span> สอบไม่ผ่าน
<?php endif; ?>
</h3>
</div>
<div class="panel-body">
<div class="result-details">
<p><strong>วิชา:</strong> <?php echo htmlspecialchars($result['subject_name']); ?></p>
<p><strong>คะแนนที่ได้:</strong> <?php echo $result['score']; ?> คะแนน</p>
<p><strong>เปอร์เซ็นต์ที่ได้:</strong> <?php echo $result['percentage']; ?>%</p>
<p><strong>เกณฑ์ผ่าน:</strong> <?php echo $result['pass_percentage']; ?>%</p>
<p><strong>วันที่สอบ:</strong> <?php echo date('d/m/Y H:i', strtotime($result['test_date'])); ?> น.</p>
</div>
<hr>
<div class="text-center">
<a href="dashboard.php" class="btn btn-primary">กลับหน้าหลัก</a>
<?php if ($result['passed']): ?>
<a href="generate_certificate.php?subject=<?php echo base64_encode($result['subject_id']); ?>" class="btn btn-success" target="_blank">
<span class="glyphicon glyphicon-download-alt"></span> ดาวน์โหลดเกียรติบัตร
</a>
<?php else: ?>
<a href="take_exam.php?exam=<?php echo base64_encode($result['subject_id']); ?>" class="btn btn-warning">สอบใหม่อีกครั้ง</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>