<?php require_once "../include/config.php"; // Start a session to manage user authentication session_start(); // Check if the user is not authenticated (no session variable) if (!isset($_SESSION["authenticated"]) || $_SESSION["authenticated"] !== true) { // Redirect to the login page header("Location: index.php"); exit; } // Create a database connection $conn = new mysqli($host, $username, $password, $database); // Check the connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //check for session if ($_SERVER["REQUEST_METHOD"] == "POST") { // Retrieve JSON data from the form submission $jsonAnswers = $_POST["jsonAnswers"]; $hashValue = $_POST["hash"]; echo $jsonAnswers; echo $hashValue; // exit(); // Insert the JSON data into your MySQL table $sql = "UPDATE assessment_by_assessor SET status =2, data=? WHERE hash = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("ss", $jsonAnswers, $hashValue); if ($stmt->execute()) { $stmt->close(); $conn->close(); header("Location: " . $_SERVER["HTTP_REFERER"]); exit; // Make sure to exit the script after redirection } else { echo "Error: " . $stmt->error; $stmt->close(); $conn->close(); } } else { // GET PROJECT DATA $sql = "SELECT name, nama, username FROM project where id = ".$_SESSION["project_id"]; $project_data = $conn->query($sql); $row = $project_data->fetch_assoc(); $projectname = $row["name"]; $projectnama = $row["nama"]; $projectusername = $row["username"]; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1.0" name="viewport"> <title>Competency Assessment</title> <meta content="" name="description"> <meta content="" name="keywords"> <!-- Favicons --> <link href="assets/img/favicon.png" rel="icon"> <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon"> <!-- Google Fonts --> <link href="https://fonts.gstatic.com" rel="preconnect"> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet"> <!-- Vendor CSS Files --> <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet"> <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet"> <link href="assets/vendor/quill/quill.snow.css" rel="stylesheet"> <link href="assets/vendor/quill/quill.bubble.css" rel="stylesheet"> <link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet"> <link href="assets/vendor/simple-datatables/style.css" rel="stylesheet"> <!-- Template Main CSS File --> <link href="assets/css/style.css" rel="stylesheet"> </head> <body> <!-- ======= Header ======= --> <header id="header" class="header fixed-top d-flex align-items-center"> <div class="d-flex align-items-center justify-content-between"> <a href="index.html" class="logo d-flex align-items-center"> <img src="assets/img/logo.png" alt=""> <span class="d-none d-lg-block">Competency Assessment</span> </a> <i class="bi bi-list toggle-sidebar-btn"></i> </div><!-- End Logo --> <div class="search-bar"> <form class="search-form d-flex align-items-center" method="POST" action="#"> <input type="text" name="query" placeholder="Search" title="Enter search keyword"> <button type="submit" title="Search"><i class="bi bi-search"></i></button> </form> </div><!-- End Search Bar --> <nav class="header-nav ms-auto"> <ul class="d-flex align-items-center"> <li class="nav-item d-block d-lg-none"> <a class="nav-link nav-icon search-bar-toggle " href="#"> <i class="bi bi-search"></i> </a> </li><!-- End Search Icon--> <li class="nav-item dropdown pe-3"> <a class="nav-link nav-profile d-flex align-items-center pe-0" href="#" data-bs-toggle="dropdown"> <img src="assets/img/avatar.jpg" alt="Profile" class="rounded-circle"> <span class="d-none d-md-block dropdown-toggle ps-2"><?php echo ucfirst($projectusername); ?></span> </a><!-- End Profile Iamge Icon --> <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow profile"> <li class="dropdown-header"> <h6>Competency Assessment</h6> <span>Administrator</span> </li> <li> <hr class="dropdown-divider"> </li> <li> <a class="dropdown-item d-flex align-items-center" href="logout.php"> <i class="bi bi-box-arrow-right"></i> <span>Sign Out</span> </a> </li> </ul><!-- End Profile Dropdown Items --> </li><!-- End Profile Nav --> </ul> </nav><!-- End Icons Navigation --> </header><!-- End Header --> <?php require_once "../include/sidebar.php"; ?> <main id="main" class="main"> <!-- <div class="pagetitle"> <h1>Assessors List</h1> <nav> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="index.html">Assessments</a></li> <li class="breadcrumb-item active">List</li> </ol> </nav> </div> --> <section class="section"> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-body"> <h5 class="card-title">Candidates Data for <?php echo $projectname;?></h5> <p>The candidates listed here are completed assessments. The purpose of this <code>list</code> is to display the data in a way that can be utilized by the Power BI Dashboard for reporting purposes. <br><code><a href="getalldata.php">Download all data into Excel</a></code>! </p> <!-- Table with stripped rows --> <table id="myTable"> <thead> <tr> <th scope="col">#</th> <th scope="col">Position</th> <th scope="col">Candidate</th> <th scope="col">Assessor</th> <th scope="col">Assessment Type</th> <th scope="col">Data</th> <!--<th scope="col">Action 2</th>--> </tr> </thead> <tbody> <?php // Check the connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //$sql = "SELECT * FROM assessment_by_assessor as aa inner join assessment as a ON aa.assessment_id = a.id where aa.hash = '".$hash_value."' "; $sql = "SELECT aa.*, a.name as position, p.name as project_name FROM assessment_by_assessor as aa inner join assessment as a ON aa.assessment_id = a.id inner join project as p on a.project_id = p.id where status = 2 and p.id = {$_SESSION["project_id"]} order by a.name asc"; $result = $conn->query($sql); // Display assessment data for ($i = 1; $i <= $result->num_rows; $i++) { $rows = $result->fetch_assoc(); ?> <tr> <th scope="row"><?php echo $i?></th> <td scope="row"><?php echo $rows["position"]?></td> <td scope="row"><?php echo $rows["for_candidate_name"]?></td> <td scope="row"><?php echo $rows["name"]?></td> <td scope="row"><?php echo ($rows["self_or_ext"] == 1) ? "Self Assessment" : "External Assessment"; ?></td> <td scope="row"><a href="getexceldata.php?h=<?php echo $rows["hash"]?>">View in Excel</a></td> <!--<td><?php echo "Send Email"?></td>--> </tr> <?php } ?> </tbody> </table> <!-- End Table with stripped rows --> </div> </div> </div> </div> </section> </main><!-- End #main --> <!-- ======= Footer ======= --> <footer id="footer" class="footer"> </footer><!-- End Footer --> <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a> <!-- Vendor JS Files --> <script src="assets/vendor/apexcharts/apexcharts.min.js"></script> <script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="assets/vendor/chart.js/chart.umd.js"></script> <script src="assets/vendor/echarts/echarts.min.js"></script> <script src="assets/vendor/quill/quill.min.js"></script> <script src="assets/vendor/simple-datatables/simple-datatables.js"></script> <script src="assets/vendor/tinymce/tinymce.min.js"></script> <script src="assets/vendor/php-email-form/validate.js"></script> <!-- Template Main JS File --> <script src="assets/js/main.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { let options = { perPage: 100 }; let dataTable = new simpleDatatables.DataTable('#myTable', options); document.querySelector('#myTable').classList.add('table-striped'); }); </script> </body> </html>