
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
require_once 'admin/includes/settings/PDODB.php';
include 'admin/includes/modules/functions.php';
$function = new FUNCTIONS();
if(empty($_SESSION['userId'])){
header("Location: index.php");
exit();
}
$user = $function->getUsers($_SESSION['userId'],NULL,NULL,1);
?>
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Coforge</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <meta http-equiv="refresh" content="50"> -->
<link rel='stylesheet' href='css/bootstrap.min.css'>
<link rel='stylesheet' href='css/style.css'>
<link href="images/favicon.png" rel="shortcut icon" type="image/png">
<style type="text/css">
body { background-color: #082340;}
.error {color: red;}
.navbar{
background: rgb(8 34 64);
box-shadow: rgba(33, 35, 38, 0.1) 0px 10px 10px -10px;
}
ul.join-social {
margin: 0;
padding: 0;
}
ul {
list-style: none;
width: auto;
display: inline-block;
vertical-align: middle;}
.join-social li {
display: inline-block;
margin-left: 7px;
vertical-align: middle;
}
.frame{
padding: 3px 15px;
background: #f15b40;
border-radius: 2px;
text-align: left;
color: #fff;
letter-spacing: 1.5px;
font-size: 16px;
font-weight: bold;
line-height: 24px;
}
.comment-form{
background: #e7e7e7;
padding:1%;
margin-bottom: 1%;
}
.poll-question{
background: #e7e7e7;
padding:1%;
}
.quiz-question{
background: #e7e7e7;
padding:1%;
}
.feedbackform{
background: #e7e7e7;
padding:2%;
}
.form-control {
border-color: #e7e7e7;
}
.form-check-input {
}
input:checked {
background: #a69837;
}
label{
}
.nav-tabs{
background: #f15b40;
color: #ffffff;
}
.nav-link{
color: #ffffff;
}
#feedback-form-wrapper #floating-icon > button {
position: fixed;
right: 0;
top: 50%;
transform: rotate(-90deg) translate(50%, -50%);
transform-origin: right;
}
#feedback-form-wrapper .rating-input-wrapper input[type="radio"] {
display: none;
}
#feedback-form-wrapper .rating-input-wrapper input[type="radio"] ~ span {
cursor: pointer;
}
#feedback-form-wrapper .rating-input-wrapper input[type="radio"]:checked ~ span {
background-color: #4261dc;
color: #fff;
}
#feedback-form-wrapper .rating-labels > label{
font-size: 14px;
color: #777;
}
</style>
</head>
<body>
<div class="container-fluid py-5">
<div class="row my-2">
<div class="col-6"> </div>
<div class="col-6">
<a style="float: right; margin-right: 10px;" class="logout-btn pull-right float-right" href="logout.php">Logout</a>
</div>
</div>
<div class="row justify-content-center">
<div class="col-md-8">
<div class="ratio ratio-16x9">
<iframe src="https://player.castr.com/live_ed443440425811efb232999121a03e72" title="Multistreaming with Restream.io" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
</div>
<div class="col-md-4">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Ask Question</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Poll</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Feedback</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="quiz-tab" data-bs-toggle="tab" data-bs-target="#quiz" type="button" role="tab" aria-controls="quiz" aria-selected="false">Quiz</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<!-- <div class="frame">ASK QUESTIONS</div>-->
<form class="comment-form" id="askQstndForm" method="POST" action="">
<div class="mb-3">
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="question" name="question" style="height: 130px"></textarea>
<label for="question">Type your comments</label>
</div>
</div>
<div id="message"></div>
<center>
<!-- <button type="submit" id="askQuestionBtn" name="askQuestionBtn" onclick="askQForm();" class="btn btn-lg">Submit</button> -->
<input class="btn btn-lg" type="button" onclick="askQForm();" name="save_contact" value="Submit" />
</center>
</form>
</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
<?php
$pollQuestion = $function->getPollQuestion($id=NULL,$isActive=1);
if (!empty($pollQuestion)) {
$question = $pollQuestion[0]['title'];
$max_vote = $pollQuestion[0]['max_vote'];
$questionOptiondata = $function->getQuestionOption($id=NULL,$q_id=$pollQuestion[0]['id'],$isActive=1);
$pollingdata = $function->getPolllinglist($id=NULL,$uid=$_SESSION['userId'],$q_id=$pollQuestion[0]['id'],$isActive=1);
//print_r($pollingdata[0]['option_id']); //exit;
if ($pollingdata == true) { ?>
<form class="poll-question" style="min-height: 200px;" id="pollForm">
<h4 class="question"><?=(!empty($question))?$question:'';?></h4>
<div class="mb-3">
<?php for($i=0;$i<count($questionOptiondata);$i++){ ?>
<div class="form-check">
<input class="form-check-input" disabled type="radio" name="polloption" id="polloption" value="<?=$questionOptiondata[$i]['id'];?>" <?=($questionOptiondata[$i]['id']==$pollingdata[0]['option_id'])?'checked':'';?>>
<label class="form-check-label" for="exampleRadios1">
<?=$questionOptiondata[$i]['description']." (".$questionOptiondata[$i]['vote_count'].")";?>
</label>
<progress id="file" value="<?=$questionOptiondata[$i]['vote_count'];?>" max="<?=$max_vote;?>"> <?=$questionOptiondata[$i]['vote_count'];?> </progress>
</div>
<?php } ?>
</div>
<h5 class="question">You have already voted for this Poll.</h5>
</form>
<?php } else { ?>
<form class="poll-question" method="POST" id="pollForm">
<h4 class="question"><?=(!empty($question))?$question:'';?></h4>
<div class="mb-3">
<?php for($i=0;$i<count($questionOptiondata);$i++){ ?>
<div class="form-check">
<input class="form-check-input" type="radio" name="polloption" id="polloption" value="<?=$questionOptiondata[$i]['id'];?>">
<label class="form-check-label" for="exampleRadios1">
<?=$questionOptiondata[$i]['description'];?>
</label>
</div>
<?php } ?>
</div>
<p style="color:red; text-align: center;"><?=(!empty($poll_msg))?$poll_msg:'';?></p>
<input type="hidden" value="<?=$pollQuestion[0]['id'];?>" id="q_id" name="q_id" />
<input type="hidden" value="<?=$_SESSION['userId'];?>" id="uid" name="uid" />
<div id="pollQmessage"></div>
<center><button type="submit" name="pollQuestionBtn" class="btn btn-lg" onclick="pollQForm(event);">Submit</button></center>
</form>
<?php } ?>
<?php }else { ?>
<form class="poll-question" style="min-height: 200px;">
<h4 class="question"></h4>
</form>
<?php } ?>
</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
<div id="session-info-container">
<div class="alert alert-info" id="session-info" style="display: none;">
You're providing feedback for: <strong id="current-session-name"></strong>
</div>
<div class="alert alert-warning" id="no-session-info" style="display: none;">
No active session found to provide feedback for.
</div>
</div>
<form class="feedbackform" method="POST" action="" id="feedbackForm" style="display: none;">
<input type="hidden" name="event_name" id="event-name-input">
<div class="form-group">
<label for="exampleFormControlTextarea1" class="form-label">How likely you would like to rate this session?</label><br>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="1">
<label class="form-check-label" for="rating">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="2">
<label class="form-check-label" for="rating">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="3">
<label class="form-check-label" for="rating">3</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="4">
<label class="form-check-label" for="rating">4</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="5">
<label class="form-check-label" for="rating">5</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="6">
<label class="form-check-label" for="rating">6</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="7">
<label class="form-check-label" for="rating">7</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="8">
<label class="form-check-label" for="rating">8</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="9">
<label class="form-check-label" for="rating">9</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="10">
<label class="form-check-label" for="rating">10</label>
</div>
</div>
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Would you like to say something?</label>
<textarea class="form-control" name="comment" id="comment" rows="3"></textarea>
</div>
<div id="feedbackmessage"></div>
<center><input class="btn btn-lg" type="button" onclick="feedBForm();" name="feedBackBtn" value="Submit" /></center>
</form>
</div>
<!-- <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
<form class="feedbackform" method="POST" action="" id="feedbackForm">
<div class="form-group">
<label for="exampleFormControlTextarea1" class="form-label">How likely you would like to rate this session?</label><br>
<label for="exampleFormControlTextarea1" class="form-label"></label><br>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="1">
<label class="form-check-label" for="rating">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="2">
<label class="form-check-label" for="rating">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="3">
<label class="form-check-label" for="rating">3</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="4">
<label class="form-check-label" for="rating">4</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="5">
<label class="form-check-label" for="rating">5</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="6">
<label class="form-check-label" for="rating">6</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="7">
<label class="form-check-label" for="rating">7</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="8">
<label class="form-check-label" for="rating">8</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="9">
<label class="form-check-label" for="rating">9</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rating" id="rating" value="10">
<label class="form-check-label" for="rating">10</label>
</div>
</div>
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Would you like to say something?</label>
<textarea class="form-control" name="comment" id="comment" rows="3"></textarea>
</div>
<div id="feedbackmessage"></div>
<center><input class="btn btn-lg" type="button" onclick="feedBForm();" name="feedBackBtn" value="Submit" /></center>
</form>
</div> -->
<div class="tab-pane fade" id="quiz" role="tabpanel" aria-labelledby="quiz-tab">
<div id="quiz-container">
<!-- Question will be loaded here via AJAX -->
<div class="text-center py-5 text-white">
<!-- <div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div> -->
<p>Please wait for quiz ...</p>
</div>
</div>
<div id="quiz-results"></div>
<div class="quiz-navigation d-flex justify-content-between mt-3">
<button id="prev-question" class="btn btn-secondary" disabled>Previous</button>
<span id="question-counter" style="color: white;">Question 1 of <span id="total-questions">0</span></span>
<button id="next-question" class="btn btn-primary">Next</button>
<button id="submit-quiz" class="btn btn-success d-none">Submit Quiz</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- partial -->
<script type='text/javascript' src='//code.jquery.com/jquery-1.8.3.js'></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<script type='text/javascript' src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.js"></script>
<script type='text/javascript' src="//jqueryvalidation.org/files/dist/additional-methods.min.js"></script>
<script src='js/bootstrap.bundle.min.js'></script>
<!-- ajax start -->
<script type="text/javascript">
$(document).ready(function() {
function askQForm() {
var question = $('textarea[name=question]').val().trim();
if (question !== '') {
var formData = {question: question};
$('#message').html('<span style="color: red">Processing form. . . please wait. . .</span>');
$.ajax({
url: "post.php",
type: 'POST',
data: formData,
success: function(response) {
try {
var res = JSON.parse(response);
if (res.success == true) {
document.getElementById("askQstndForm").reset();
$('#message').html('<span id="successmsg" style="color: green">Submitted successfully</span>');
$("#successmsg").delay(5000).fadeOut(); // Will hide after 5 seconds
} else {
$('#message').html('<span id="failmsg" style="color: red">Form not submitted. Some error in running the database query.</span>');
$("#failmsg").delay(5000).fadeOut(); // Will hide after 5 seconds
}
} catch (e) {
$('#message').html('<span id="failmsg" style="color: red">Error processing response</span>');
$("#failmsg").delay(5000).fadeOut(); // Will hide after 5 seconds
}
},
error: function() {
$('#message').html('<span id="failmsg" style="color: red">Error submitting the form. Please try again later.</span>');
$("#failmsg").delay(5000).fadeOut(); // Will hide after 5 seconds
}
});
} else {
$('#message').html('<span id="requiredmsg" style="color: red">Please type your feedback</span>');
$("#requiredmsg").delay(5000).fadeOut();
}
}
window.askQForm = askQForm; // Ensure the function is available globally
});
</script>
<!-- Feedback -->
<script>
$(document).ready(function() {
// Fetch active session when the tab is shown
$('#contact-tab').on('shown.bs.tab', function() {
fetchActiveSession();
});
// Also fetch when page loads if this tab is active
if($('#contact-tab').hasClass('active')) {
fetchActiveSession();
}
});
function fetchActiveSession() {
$.ajax({
url: 'get_active_session.php',
type: 'GET',
dataType: 'json',
success: function(response) {
if(response.success) {
$('#current-session-name').text(response.event_name);
$('#event-name-input').val(response.event_name);
$('#session-info').show();
$('#no-session-info').hide();
$('#feedbackForm').show();
} else {
$('#session-info').hide();
$('#no-session-info').show();
$('#feedbackForm').hide();
}
},
error: function() {
$('#session-info').hide();
$('#no-session-info').text('Error fetching session information').show();
$('#feedbackForm').hide();
}
});
}
function feedBForm() {
var comment = $('textarea[name=comment]').val();
var rating = $('input[name=rating]:checked').val();
var event_name = $('#event-name-input').val();
if(comment != '' && rating!= '') {
var formData = {
comment: comment,
rating: rating,
event_name: event_name
};
$('#feedbackmessage').html('<span style="color: red">Processing form. . . please wait. . .</span>');
$.ajax({
url: "post.php",
type: 'POST',
data: formData,
success: function(response) {
var res = JSON.parse(response);
if(res.success == true){
document.getElementById("feedbackForm").reset();
$('#feedbackmessage').html('<span id="successmsg" style="color: green">Your Feedback successfully submitted</span>');
$("#successmsg").delay(5000).fadeOut();
} else {
$('#feedbackmessage').html('<span id="failmsg" style="color: red">Form not submitted. Some error in running the database query.</span>');
$("#failmsg").delay(5000).fadeOut();
}
}
});
}
else {
$('#feedbackmessage').html('<span id="reuiredmsg" style="color: red">Please type your question</span>');
$("#reuiredmsg").delay(5000).fadeOut();
}
}
// Call loadPollQuestion every 10 seconds
setInterval(fetchActiveSession, 2000);
</script>
<!-- Polling -->
<script type="text/javascript">
function pollQForm(event) {
event.preventDefault();
var q_id = $('input[name=q_id]').val();
var polloption = $('input[name=polloption]:checked').val();
if(q_id != '' && polloption!= '') {
var formData = {q_id: q_id, polloption: polloption};
$('#pollQmessage').html('<span style="color: red">Processing form. . . please wait. . .</span>');
$.ajax({
url: "post.php",
type: 'POST',
data: formData,
success: function(response) {
var res = JSON.parse(response);
if(res.success == true) {
$('#pollQmessage').html('<span id="successmsg" style="color: green">Your Feedback successfully submitted</span>');
$("#successmsg").delay(5000).fadeOut();
// Reload the poll question
loadPollQuestion();
} else {
$('#pollQmessage').html('<span id="failmsg" style="color: red">Form not submitted. Some error in running the database query.</span>');
$("#failmsg").delay(5000).fadeOut();
}
}
});
} else {
$('#pollQmessage').html('<span id="reuiredmsg" style="color: red">Please select an option</span>');
$("#reuiredmsg").delay(5000).fadeOut();
}
}
function loadPollQuestion() {
$.ajax({
url: 'get_poll_question.php',
type: 'GET',
success: function(response) {
var res = JSON.parse(response);
if (res.success) {
$('#profile').html(res.html);
} else {
$('#profile').html('<form class="poll-question" style="min-height: 200px;"><h4 class="question"></h4></form>');
}
}
});
}
// Call loadPollQuestion every 10 seconds
setInterval(loadPollQuestion, 5000);
</script>
<!-- Quiz -->
<script>
//quiz ajax
document.addEventListener('DOMContentLoaded', function() {
let currentQuestion = 0;
let totalQuestions = 0;
const quizContainer = document.getElementById('quiz-container');
const prevBtn = document.getElementById('prev-question');
const nextBtn = document.getElementById('next-question');
const submitBtn = document.getElementById('submit-quiz');
const questionCounter = document.getElementById('question-counter');
const totalQuestionsSpan = document.getElementById('total-questions');
// Load a question by index
function loadQuestion(index) {
fetch(`get_quiz_question.php?question_id=${index}`)
.then(response => response.json())
.then(data => {
if (data.success) {
totalQuestions = data.total;
totalQuestionsSpan.textContent = totalQuestions;
currentQuestion = data.current - 1; // Convert to 0-based index
// Update the UI
renderQuestion(data.question);
updateNavigation();
} else {
console.error('Error loading question:', data.message);
}
})
.catch(error => {
console.error('Fetch error:', error);
});
}
// Render question HTML
function renderQuestion(question) {
quizContainer.innerHTML = `
<form class="quiz-question" method="POST">
<label class="form-label question">${question.question}</label><br>
<div class="mb-3">
${['ans1', 'ans2', 'ans3', 'ans4'].map((ans, i) => `
<div class="form-check">
<input class="form-check-input" type="radio" name="quizoption"
id="quizoption-${currentQuestion}-${i}" value="${question[ans]}"
${getStoredAnswer(currentQuestion) === question[ans] ? 'checked' : ''}>
<label class="form-check-label" for="quizoption-${currentQuestion}-${i}">
${question[ans]}
</label>
</div>
`).join('')}
</div>
</form>
`;
// Update radio buttons to store answers when changed
const radioButtons = quizContainer.querySelectorAll('input[type="radio"]');
radioButtons.forEach(radio => {
radio.addEventListener('change', function() {
storeAnswer(currentQuestion, this.value);
});
});
}
// Update navigation buttons state
function updateNavigation() {
questionCounter.textContent = `Question ${currentQuestion + 1} of ${totalQuestions}`;
prevBtn.disabled = currentQuestion === 0;
if (currentQuestion === totalQuestions - 1) {
nextBtn.classList.add('d-none');
submitBtn.classList.remove('d-none');
} else {
nextBtn.classList.remove('d-none');
submitBtn.classList.add('d-none');
}
}
// Store answers in localStorage
function storeAnswer(questionIndex, answer) {
const answers = JSON.parse(localStorage.getItem('quizAnswers') || '{}');
answers[questionIndex] = answer;
localStorage.setItem('quizAnswers', JSON.stringify(answers));
}
// Get stored answer from localStorage
function getStoredAnswer(questionIndex) {
const answers = JSON.parse(localStorage.getItem('quizAnswers') || '{}');
return answers[questionIndex] || null;
}
// Event listeners for navigation
prevBtn.addEventListener('click', function() {
if (currentQuestion > 0) {
currentQuestion--;
loadQuestion(currentQuestion);
}
});
nextBtn.addEventListener('click', function() {
if (currentQuestion < totalQuestions - 1) {
currentQuestion++;
loadQuestion(currentQuestion);
}
});
// Load first question initially
loadQuestion(0);
});
</script>
<script>
async function submitQuiz() {
const submitBtn = document.getElementById('submit-quiz');
const answers = JSON.parse(localStorage.getItem('quizAnswers')) || {};
if (Object.keys(answers).length === 0) {
alert('Please answer at least one question before submitting.');
return;
}
submitBtn.disabled = true;
submitBtn.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Submitting...';
try {
const response = await fetch('submit_quiz.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify({
answers: answers,
userId: <?= $_SESSION['userId'] ?? 0 ?>,
csrfToken: '<?= $_SESSION['csrf_token'] ?? '' ?>'
})
});
// **DEBUGGING STEP**: Get the raw text from the response first.
const responseText = await response.text();
console.log("Raw server response:", responseText); // Check browser console for this output
// Check if the response was successful and not empty
if (!response.ok) {
// Try to parse error as JSON, but fall back to the raw text if it fails
let errorMessage = `HTTP error! Status: ${response.status}`;
try {
const errorData = JSON.parse(responseText);
errorMessage = errorData.message || responseText;
} catch (e) {
errorMessage = responseText || errorMessage;
}
throw new Error(errorMessage);
}
console.log(responseText);
if (!responseText) {
throw new Error('Server returned an empty response.');
}
// **SAFE PARSING**: Now, parse the text that you know is not empty.
const data = JSON.parse(responseText);
if (!data.success) {
throw new Error(data.message || 'Submission failed according to server.');
}
localStorage.removeItem('quizAnswers');
window.location.href = `results.php?session=${data.sessionId}&score=${data.score}`;
} catch (error) {
console.error('Submission error:', error);
const errorContainer = document.getElementById('quiz-results'); // Use the results div for errors
errorContainer.innerHTML = `
<div class="alert alert-danger alert-dismissible fade show">
<strong>Error!</strong> ${error.message}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
`;
} finally {
submitBtn.disabled = false;
submitBtn.textContent = 'Submit Quiz';
}
}
// Ensure the event listener is attached
const submitButton = document.getElementById('submit-quiz');
if (submitButton) {
submitButton.addEventListener('click', submitQuiz);
}
</script>
</body>
</html>


PK 99