OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
quiz
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
06/17/2025 10:17:24 AM
rwxrwxr-x
📄
admin.php
2.97 KB
05/19/2025 10:07:16 AM
rw-r--r--
📁
adminProcess
-
05/19/2025 10:07:16 AM
rwxr-xr-x
📁
assets
-
02/15/2025 11:20:33 AM
rwxr-xr-x
📁
backup
-
05/19/2025 10:07:16 AM
rwxr-xr-x
📄
editData.php
16.75 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
editQuestion.php
8.03 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
editQuiz.php
8.3 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
footer.php
1.86 KB
05/19/2025 10:07:16 AM
rw-r--r--
📁
forms
-
05/19/2025 10:07:16 AM
rwxr-xr-x
📄
go_back.php
2.96 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
index.php
12.68 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
login.php
4.34 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
nav_scripts.php
1.96 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
navbar.php
2.41 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
navbar_login.php
2.34 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
payment.php
12.06 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
quiz.php
20.67 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
quizControl.php
8.4 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
quizQuestions.php
8.85 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
quizSubmitPage.php
39 bytes
05/19/2025 10:07:16 AM
rw-r--r--
📄
register.php
21.65 KB
05/19/2025 10:07:16 AM
rw-r--r--
📁
test
-
02/15/2025 11:20:34 AM
rwxr-xr-x
📁
test1
-
05/19/2025 10:07:16 AM
rwxr-xr-x
📁
yt_subscription
-
05/19/2025 10:07:16 AM
rwxr-xr-x
Editing: quiz.php
Close
<? include('assets/php/db_config.php'); include('assets/php/validate.logged.php'); if (isset($_GET['quiz'])) { $quizId = $_GET['quiz']; } else { echo "no quiz found"; } function checkConcent($quiz_id) { global $conn, $gUserId; $query = "SELECT startTime FROM quiz_status WHERE user_id=$gUserId AND quiz_id = $quiz_id"; $stmt = $conn->prepare($query); $stmt->execute(); // Get result set $result = $stmt->get_result(); // Fetch all rows as an associative array if ($result->num_rows > 0) { $row = $result->fetch_assoc(); if ($row['startTime'] == null) return true; } else { return true; } } function fetch_remaining_time($quizId) { global $conn; // Prepare and execute the query $query = "SELECT end_time FROM quizes WHERE id = ?"; $stmt = $conn->prepare($query); $stmt->bind_param("i", $quizId); $stmt->execute(); // Fetch the result $result = $stmt->get_result(); // Check if a result was returned if ($result->num_rows > 0) { $row = $result->fetch_assoc(); // The end_time is in the format 'YYYY-MM-DD HH:MM:SS' $endTime = strtotime($row['end_time']); // Convert to Unix timestamp $timeNow = new DateTime('now', new DateTimeZone('UTC')); // Get current time in UTC $timeNow->setTimezone(new DateTimeZone('Asia/Kolkata')); // Convert to Indian Standard Time (IST) $currentTime = strtotime($timeNow->format('Y-m-d H:i:s')); // Calculate the remaining time in seconds $remainingTime = $endTime - $currentTime; // If the remaining time is negative, it means the quiz has ended if ($remainingTime < 0) { $remainingTime = 0; // Set to 0 if the quiz has ended } return $remainingTime; } else { // Return 0 if no quiz was found with the given ID return 0; } } function fetch_temp_option($questionId) { global $conn, $gUserId; $query = "SELECT answer FROM temp_answer WHERE que_id=$questionId AND user_id = $gUserId"; $stmt = $conn->prepare($query); $stmt->execute(); // Get result set $result = $stmt->get_result(); // Fetch all rows as an associative array if ($result->num_rows > 0) { $row = $result->fetch_assoc(); return $row['answer']; } else { return null; } } $remainingTime = fetch_remaining_time($quizId); function displayQuestions($quizId) { global $conn; $query = "SELECT * FROM questions where quiz_id='$quizId'"; $stmt = $conn->prepare($query); $stmt->execute(); // Get result set $result = $stmt->get_result(); // Fetch all rows as an associative array $questions = []; while ($row = $result->fetch_assoc()) { $questions[] = $row; } ?> <?php $count = 1; foreach ($questions as $question) { $tempAnswer = fetch_temp_option($question['id']); ?> <div id="quizId" value="<?= $question['id'] ?>"> <p><?= $count . ". " . $question['question'] ?></p> <input type="radio" name="<?= $question['id'] ?>" value="<?= $question['option1'] ?>" <?= ($tempAnswer === $question['option1']) ? 'checked' : '' ?>> <?= $question['option1'] ?><br> <input type="radio" name="<?= $question['id'] ?>" value="<?= $question['option2'] ?>" <?= ($tempAnswer === $question['option2']) ? 'checked' : '' ?>> <?= $question['option2'] ?><br> <input type="radio" name="<?= $question['id'] ?>" value="<?= $question['option3'] ?>" <?= ($tempAnswer === $question['option3']) ? 'checked' : '' ?>> <?= $question['option3'] ?><br> <input type="radio" name="<?= $question['id'] ?>" value="<?= $question['option4'] ?>" <?= ($tempAnswer === $question['option4']) ? 'checked' : '' ?>> <?= $question['option4'] ?><br><br> </div> <? $count++; } ?> <input type="submit" value="Submit Quiz"> <div id="responseMessage"></div> <!-- This will display the result of the submission --> <? } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Quiz</title> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="assets/css/styles.css"> <!-- Bootstrap JS and Popper.js --> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> let timerDuration = <?= $remainingTime ?>; $(document).ready(function() { $('#agreeCheckbox').change(function() { const agreeButton = $('#agreeButton'); // Enable the button if the checkbox is checked agreeButton.prop('disabled', !this.checked); }); }); // Trigger fullscreen when the user agrees // Modified showQuiz function to properly handle fullscreen function showQuiz() { // Hide consent form and show quiz document.getElementById('consentForm').style.display = 'none'; document.getElementById('quizSection').style.display = 'block'; // Request fullscreen as direct response to user action enterFullscreen(); // Start the timer after entering fullscreen startTimer(); // Add event listeners for fullscreen changes document.addEventListener('fullscreenchange', onFullscreenChange); document.addEventListener('webkitfullscreenchange', onFullscreenChange); document.addEventListener('mozfullscreenchange', onFullscreenChange); document.addEventListener('MSFullscreenChange', onFullscreenChange); // Add visibility change listener document.addEventListener('visibilitychange', handleVisibilityChange); } // Function to handle visibility changes (tab switching) function handleVisibilityChange() { if (document.hidden) { alert("Warning: Please stay on the quiz tab!"); } } // Function to enter fullscreen with proper error handling function enterFullscreen() { try { const elem = document.documentElement; if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); } } catch (err) { console.error('Fullscreen request failed:', err); alert('Unable to enter fullscreen mode. Please ensure you are using a supported browser.'); } } // Improved fullscreen change handler function onFullscreenChange() { if (!document.fullscreenElement && !document.webkitFullscreenElement && !document.mozFullScreenElement && !document.msFullscreenElement) { // Check if quiz section is visible (quiz has started) if (document.getElementById('quizSection').style.display === 'block') { // Show Bootstrap modal for better UI const modalHtml = ` <div class="modal fade show" id="fullscreenWarning" tabindex="-1" style="display: block;"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Warning</h5> </div> <div class="modal-body"> <p>Please return to fullscreen mode to continue the quiz.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" onclick="handleFullscreenReturn()"> Return to Fullscreen </button> </div> </div> </div> </div> <div class="modal-backdrop fade show"></div> `; // Remove existing warning if present const existingModal = document.getElementById('fullscreenWarning'); if (existingModal) { existingModal.remove(); } // Add new modal document.body.insertAdjacentHTML('beforeend', modalHtml); } } } // Improved fullscreen return handler function handleFullscreenReturn() { enterFullscreen(); // Remove the modal and backdrop const modal = document.getElementById('fullscreenWarning'); const backdrop = document.querySelector('.modal-backdrop'); if (modal) modal.remove(); if (backdrop) backdrop.remove(); } function startTimer() { let timerElement = $('#timer'); // jQuery selection let timeLeft = timerDuration; const timerInterval = setInterval(() => { let minutes = Math.floor(timeLeft / 60); let seconds = timeLeft % 60; timerElement.text(`${minutes}:${seconds < 10 ? '0' : ''}${seconds}`); if (timeLeft == 600) { alert("You have last 10 minutes remaining after that quiz will automatically get submitted!"); } if (timeLeft == 60) { alert("Last 60 seconds remaining after that the quiz will automatically get submitted!"); } if (timeLeft <= 0) { clearInterval(timerInterval); alert("Time's up! Your quiz will be submitted automatically."); $('#quizForm').submit(); // Automatically submit the form using jQuery } timeLeft--; }, 1000); } $(document).ready(function() { $('#quizForm').submit(function(e) { e.preventDefault(); // Prevent the default form submission const quizId = $('#quizId').attr('value'); const userId = <?= $gUserId ?>; $.ajax({ url: 'assets/process/quiz_submit_test.php', type: 'POST', data: { quiz_id: quizId, user_id: userId, }, success: function(response) { const result = JSON.parse(response); if (result.status === 'success') { alert(result.message); window.location.href = 'quizSubmitPage.php'; // Redirect after successful submission } else { alert(result.message); } }, error: function() { alert('Error submitting the quiz. Please try again later.'); }, }); }); }); // $(document).ready(function() { // $('#quizForm').submit(function(e) { // e.preventDefault(); // var formData = {}; // var quizId = $('#quizId').attr('value'); // console.log(quizId); // $('input[type=radio]:checked').each(function() { // var questionId = $(this).attr('name'); // var selectedOption = $(this).val(); // formData[questionId] = selectedOption; // }); // $.ajax({ // url: 'assets/process/quiz_submit.php', // type: 'POST', // data: { // formData: JSON.stringify(formData), // quizId: quizId // }, // success: function(response) { // $('#responseMessage').html(response); // alert('You have successfully submitted the quiz!!'); // window.location.href = 'quizSubmitPage.php' // }, // error: function(xhr, status, error) { // $('#responseMessage').html('<p>Error submitting quiz. Please try again later.</p>'); // } // }); // }); // }); </script> <script> $(document).on('change', 'input[type=radio]', function() { const questionId = $(this).attr('name'); // Question ID from the "name" attribute const selectedOption = $(this).val(); // Selected option value var quizId = $('#quizId').attr('value'); $.ajax({ url: 'assets/process/temp_answer.php', type: 'POST', data: { question_id: questionId, selected_option: selectedOption, quiz_id: quizId, }, success: function(response) { const result = JSON.parse(response); if (result.status === 'success') { console.log(result.message); } else { console.error(result.message); } }, error: function() { console.error('Error saving/updating answer.'); }, }); }); </script> <style> body { padding: 0px; } #quizSection { display: none; } .registration-container { max-width: 800px; margin: 0 auto; background-color: #fff; padding: 20px; border: 1px solid #ddd; border-radius: 5px; } h2 { margin-bottom: 20px; } .btn { margin-top: 10px; } #timer { font-size: 20px; font-weight: bold; } .timerContainer { justify-content: end; /* position:fixed; right: 10px; background-color: white; */ font-size: 20px; } #otpSection { display: none; } .consentStyle { width: 60vw; margin: 100px; margin-left: 20%; } </style> <style> /* General Styles */ body { font-family: Arial, sans-serif; background-color: #f8f9fa; color: #202124; padding: 0; margin: 0; } /* Navbar */ .navbar { background-color: white; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); padding: 15px 20px; } /* Quiz Container */ .quiz-container { max-width: 600px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); margin: 40px auto; } /* Question Styling */ p { font-size: 18px; font-weight: 500; margin-bottom: 10px; } /* Radio Buttons */ input[type="radio"] { appearance: none; width: 18px; height: 18px; border: 2px solid #5f6368; border-radius: 50%; outline: none; margin-right: 8px; vertical-align: middle; cursor: pointer; transition: all 0.2s ease-in-out; } input[type="radio"]:checked { background-color: #1a73e8; border: 5px solid white; box-shadow: 0px 0px 0px 2px #1a73e8; } /* Timer Display */ .timerContainer { font-size: 20px; font-weight: bold; color: #d93025; text-align: right; padding: 10px; } /* Submit Button */ input[type="submit"] { display: block; width: 100%; background-color: #1a73e8; color: white; font-size: 16px; font-weight: bold; padding: 12px; border: none; border-radius: 6px; cursor: pointer; transition: background-color 0.3s ease-in-out; } input[type="submit"]:hover { background-color: #185abc; } /* Consent Form */ .consentStyle { max-width: 500px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); margin: 40px auto; text-align: center; } /* Checkbox Styling */ input[type="checkbox"] { transform: scale(1.2); margin-right: 8px; cursor: pointer; } /* Button */ button { background-color: #1a73e8; color: white; font-size: 16px; font-weight: bold; padding: 12px; border: none; border-radius: 6px; cursor: pointer; transition: background-color 0.3s ease-in-out; } button:disabled { background-color: #ccc; cursor: not-allowed; } button:hover:enabled { background-color: #185abc; } /* Footer */ .footer { background-color: white; text-align: center; padding: 15px; box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1); } </style> </head> <body> <!-- Navbar --> <nav class="navbar navbar-light bg-light shadow-sm"> <div class="container-fluid container-xl position-relative d-flex align-items-center"> <a href="index.php" class="logo d-flex align-items-center me-auto"> <img src="assets/img/logo_new.png" alt="" width="173" height="97" /></a> <nav id="navmenu" class="navmenu"> <!-- <ul> <li> <a href="index.php">Home<br /></a> </li> <li><a href="about_quiz.php">About</a></li> <li><a href="contact.php">Contact</a></li> </ul> --> <!-- <i class="mobile-nav-toggle d-xl-none bi bi-list"></i> --> <div class="flex timerContainer">Time Left- <div id="timer">00:00</div> </div> </nav> </div> </nav> <div id="remainingTime" style="display:none;"><?= $remainingTime ?></div> <? if(checkConcent($quizId)){?> <div id="consentForm" class="consentStyle"> <h1>Consent Form</h1> <p>Welcome to the quiz. Before you begin, please read the following:</p> <p> By proceeding with this quiz, you consent to participate voluntarily. The answers you provide will be stored and analyzed for educational purposes. </p> <!-- Checkbox for agreement --> <label> <input type="checkbox" id="agreeCheckbox"> I have read all the content above </label><br><br> <button onclick="showQuiz()" disabled id="agreeButton">I Agree</button> </div> <?}?> <div class="quiz-container" id="quizSection"> <h1 class="text-center">Quiz</h1> <!-- <div class="flex timerContainer">Time Left- <div id="timer">00:00</div> </div> --> <form id="quizForm" method="post"> <? displayQuestions($quizId); ?> </form> </div> </body> </html>