V1rus Private
User / IP
:
216.73.217.108
Host / Server
:
190.92.174.125 / aerosofthealthcare.com
System
:
Linux s3739.bom1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64
Cmd
|
Upload
|
Mass Deface
|
Create
|
Sym
:
/
home
/
aerosoft
/
public_html
/
exam
/
Viewing: exam_result.php
<?php include 'config.php'; if (!isset($_SESSION['student_id'])) { header("Location: login.php"); exit(); } $exam_id = $_GET['exam_id'] ?? null; if (!$exam_id) { header("Location: student_dashboard.php"); exit(); } // Get exam details with category and student info $stmt = $pdo->prepare("SELECT e.*, c.name as category_name, c.passing_marks, s.name as student_name FROM exams e JOIN categories c ON e.category_id = c.id JOIN students s ON e.student_id = s.id WHERE e.id = ? AND e.student_id = ?"); $stmt->execute([$exam_id, $_SESSION['student_id']]); $exam = $stmt->fetch(); if (!$exam) { header("Location: student_dashboard.php"); exit(); } // Get detailed results $stmt = $pdo->prepare("SELECT q.*, ea.selected_option, (ea.selected_option = q.correct_option) as is_correct FROM exam_answers ea JOIN questions q ON ea.question_id = q.id WHERE ea.exam_id = ?"); $stmt->execute([$exam_id]); $detailed_results = $stmt->fetchAll(); // Calculate statistics $correct_answers = 0; $wrong_answers = 0; $unanswered = $exam['total_marks'] - count($detailed_results); foreach ($detailed_results as $result) { if ($result['is_correct']) { $correct_answers++; } else { $wrong_answers++; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Exam Result - <?php echo $exam['category_name']; ?></title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"> <style> .result-card { border: none; box-shadow: 0 5px 15px rgba(0,0,0,0.1); } .score-circle { width: 150px; height: 150px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: bold; margin: 0 auto; } .passed { background: #d4edda; color: #155724; border: 5px solid #c3e6cb; } .failed { background: #f8d7da; color: #721c24; border: 5px solid #f1b0b7; } .stat-card { transition: transform 0.3s ease; } .stat-card:hover { transform: translateY(-5px); } .question-review { border-left: 4px solid #007bff; } .correct-answer { background: #d4edda; border-left: 4px solid #28a745; } .wrong-answer { background: #f8d7da; border-left: 4px solid #dc3545; } </style> </head> <body> <nav class="navbar navbar-light bg-light"> <div class="container"> <a class="navbar-brand" href="student_dashboard.php"> <i class="fas fa-arrow-left"></i> Back to Dashboard </a> <span class="navbar-text"> Welcome, <?php echo $_SESSION['student_name']; ?> </span> </div> </nav> <div class="container mt-4"> <div class="row justify-content-center"> <div class="col-md-10"> <!-- Result Summary --> <div class="card result-card mb-4"> <div class="card-header bg-primary text-white text-center"> <h4 class="mb-0"><i class="fas fa-chart-bar"></i> Exam Result Summary</h4> </div> <div class="card-body"> <div class="row align-items-center"> <div class="col-md-4 text-center"> <div class="score-circle <?php echo $exam['status'] == 'passed' ? 'passed' : 'failed'; ?>"> <?php echo $exam['percentage']; ?>% </div> <h5 class="mt-3 <?php echo $exam['status'] == 'passed' ? 'text-success' : 'text-danger'; ?>"> <i class="fas fa-<?php echo $exam['status'] == 'passed' ? 'trophy' : 'times-circle'; ?>"></i> <?php echo ucfirst($exam['status']); ?> </h5> </div> <div class="col-md-8"> <h5><?php echo $exam['category_name']; ?></h5> <div class="row mt-4"> <div class="col-md-3 mb-3"> <div class="card stat-card text-center"> <div class="card-body"> <h3 class="text-success"><?php echo $correct_answers; ?></h3> <small class="text-muted">Correct</small> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="card stat-card text-center"> <div class="card-body"> <h3 class="text-danger"><?php echo $wrong_answers; ?></h3> <small class="text-muted">Wrong</small> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="card stat-card text-center"> <div class="card-body"> <h3 class="text-warning"><?php echo $unanswered; ?></h3> <small class="text-muted">Unanswered</small> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="card stat-card text-center"> <div class="card-body"> <h3 class="text-info"><?php echo $exam['time_taken']; ?>s</h3> <small class="text-muted">Time Taken</small> </div> </div> </div> </div> </div> </div> </div> </div> <!-- Performance Metrics --> <div class="card result-card mb-4"> <div class="card-header bg-info text-white"> <h6 class="mb-0"><i class="fas fa-chart-line"></i> Performance Analysis</h6> </div> <div class="card-body"> <div class="row"> <div class="col-md-6"> <h6>Score Distribution</h6> <div class="progress mb-2" style="height: 25px;"> <div class="progress-bar bg-success" style="width: <?php echo ($correct_answers/$exam['total_marks'])*100; ?>%"> Correct (<?php echo $correct_answers; ?>) </div> <div class="progress-bar bg-danger" style="width: <?php echo ($wrong_answers/$exam['total_marks'])*100; ?>%"> Wrong (<?php echo $wrong_answers; ?>) </div> <div class="progress-bar bg-warning" style="width: <?php echo ($unanswered/$exam['total_marks'])*100; ?>%"> Unanswered (<?php echo $unanswered; ?>) </div> </div> </div> <div class="col-md-6"> <h6>Passing Requirements</h6> <div class="d-flex justify-content-between mb-1"> <span>Your Score: <?php echo $exam['percentage']; ?>%</span> <span>Required: <?php echo $exam['passing_marks']; ?>%</span> </div> <div class="progress" style="height: 20px;"> <div class="progress-bar <?php echo $exam['status'] == 'passed' ? 'bg-success' : 'bg-danger'; ?>" style="width: <?php echo $exam['percentage']; ?>%"> </div> </div> <div class="text-center mt-2"> <small class="text-muted"> <?php echo $exam['status'] == 'passed' ? 'Congratulations! You passed the exam.' : 'Keep practicing! You need more ' . ($exam['passing_marks'] - $exam['percentage']) . '% to pass.'; ?> </small> </div> </div> </div> </div> </div> <!-- Detailed Question Review --> <div class="card result-card"> <div class="card-header bg-warning text-dark"> <h6 class="mb-0"><i class="fas fa-list-ol"></i> Detailed Question Review</h6> </div> <div class="card-body"> <?php foreach ($detailed_results as $index => $result): ?> <div class="question-review card mb-3 <?php echo $result['is_correct'] ? 'correct-answer' : 'wrong-answer'; ?>"> <div class="card-body"> <div class="d-flex justify-content-between align-items-start mb-2"> <h6 class="mb-0">Question <?php echo $index + 1; ?></h6> <span class="badge <?php echo $result['is_correct'] ? 'bg-success' : 'bg-danger'; ?>"> <?php echo $result['is_correct'] ? 'Correct' : 'Wrong'; ?> </span> </div> <p class="fw-bold"><?php echo $result['question_text']; ?></p> <div class="options"> <?php for ($i = 1; $i <= 4; $i++): ?> <?php $optionClass = ''; if ($i == $result['correct_option']) { $optionClass = 'text-success fw-bold'; } elseif ($i == $result['selected_option'] && !$result['is_correct']) { $optionClass = 'text-danger fw-bold'; } ?> <div class="form-check"> <input class="form-check-input" type="radio" disabled <?php echo $i == $result['selected_option'] ? 'checked' : ''; ?>> <label class="form-check-label <?php echo $optionClass; ?>"> <strong><?php echo chr(64 + $i); ?>.</strong> <?php echo $result['option' . $i]; ?> <?php if ($i == $result['correct_option']): ?> <i class="fas fa-check-circle text-success"></i> <?php endif; ?> </label> </div> <?php endfor; ?> </div> <?php if (!$result['is_correct']): ?> <div class="mt-2"> <small class="text-muted"> <strong>Your Answer:</strong> <?php echo chr(64 + $result['selected_option']); ?><br> <strong>Correct Answer:</strong> <?php echo chr(64 + $result['correct_option']); ?> </small> </div> <?php endif; ?> </div> </div> <?php endforeach; ?> </div> </div> <!-- Action Buttons --> <div class="text-center mt-4"> <?php if ($exam['status'] == 'passed'): ?> <a href="generate_certificate.php?exam_id=<?php echo $exam_id; ?>" class="btn btn-success btn-lg"> <i class="fas fa-download"></i> Download Certificate </a> <?php else: ?> <a href="exam_landing.php?category_id=<?php echo $exam['category_id']; ?>" class="btn btn-primary btn-lg"> <i class="fas fa-redo"></i> Retake Exam </a> <?php endif; ?> <a href="student_dashboard.php" class="btn btn-secondary btn-lg"> <i class="fas fa-home"></i> Back to Dashboard </a> </div> </div> </div> </div> </body> </html>
Coded With 💗 by
HanzOFC