HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/selfanalyse/counselor/users-test-taken.php
<?php
include_once('header.php');

$PSY_TEST_GEN_TEST_TAKEN = $wpdb->prefix . PSY_TEST_GEN_TEST_TAKEN;
$PSY_USERS_DETAILS = $wpdb->prefix . PSY_USERS_DETAILS;
$PSY_EXAMS = $wpdb->prefix . PSY_EXAMS;

if (isset($_REQUEST['search_data'])) {
	$es_stname = $_REQUEST['es_stname'];
	$es_ondate = $_REQUEST['es_ondate'];
	$es_fromdate = $_REQUEST['es_fromdate'];
	$es_todate = $_REQUEST['es_todate'];

	if ($es_stname != '') {
		$subQuery .= "and u.first_name LIKE '%$es_stname%' ";
	}
	if ($es_ondate != '') {
		$q_date = date('Y-m-d', strtotime($es_ondate));
		$subQuery .= "and date(t.start_date)='$q_date'";
	}
	if ($es_fromdate != '' && $es_todate != '') {
		$fromDate = date('Y-m-d', strtotime($es_fromdate));
		$toDate = date('Y-m-d', strtotime($es_todate));
		$subQuery .= "and (date(t.start_date) BETWEEN '$fromDate' AND '$toDate')";
	}
	$_SESSION['sfp_subQuery'] = $subQuery;
?>
	<script>
		window.location.href = "users-test-taken"
	</script>
<?php
}
if (!empty($_SESSION['sfp_subQuery'])) {
	$mergeFilter = $_SESSION['sfp_subQuery'];
} else {
	$mergeFilter = "";
}

$thisPage = 'users-test-taken';
if (isset($_REQUEST['page'])) {
	$pageno = $_REQUEST['page'];
} else {
	$pageno = 1;
}
$no_of_records_per_page = 20;
$offset = ($pageno - 1) * $no_of_records_per_page;

$i = $offset + 1;

$countQuery = "SELECT count(t.test_taken_id) FROM $PSY_TEST_GEN_TEST_TAKEN as t LEFT JOIN $PSY_USERS_DETAILS as u ON u.user_id=t.user_id LEFT JOIN $PSY_EXAMS as e ON e.exam_category_id=t.exam_category_id where t.status='Y' $mergeFilter";

$total_rows = $wpdb->get_var($countQuery);
$total_pages = ceil($total_rows / $no_of_records_per_page);

$getTestQuery = "SELECT t.test_taken_id, t.user_id, t.exam_category_id, t.total_questions, t.answer_selected, t.time_taken_in_seconds, t.start_date, t.test_type, u.first_name, u.mobile_number, u.email_address, e.category_name FROM $PSY_TEST_GEN_TEST_TAKEN as t LEFT JOIN $PSY_USERS_DETAILS as u ON u.user_id=t.user_id LEFT JOIN $PSY_EXAMS as e ON e.exam_category_id=t.exam_category_id where t.status='Y' $mergeFilter order by t.test_taken_id desc limit $offset,$no_of_records_per_page";
$getTestData = $wpdb->get_results($getTestQuery);

?>

<style>
	.modal-backdrop {
		z-index: 999 !important;
	}

	table.dataTable.nowrap th,
	table.dataTable.nowrap td {
		white-space: nowrap !important;
	}

	.page-title {
		float: left;
		width: 100%;
	}
</style>
<div class="page-inner">
	<div class="page-title">
		<div class="col-md-4">
			<h3>Users MIS</h3>
			<div class="page-breadcrumb">
				<ol class="breadcrumb">
					<li><a href="dashboard">Home</a></li>
					<li class="active">Test Taken</li>
				</ol>
			</div>
		</div>
		<div class="col-md-8">
			<div class="navbar-right">
				<ul class="navul">
					<!--<li><a href="apt-class">Class List</a></li>-->

				</ul>
			</div>
		</div>
	</div>

	<div id="main-wrapper">
		<div class="col-md-12">
			<div class="panel panel-info">
				<div class="panel-heading clearfix">
					<h4 class="panel-title">Search Filter</h4>
				</div>
				<div class="spacer"></div>
				<div class="panel-body">
					<form class="form-horizontal" method="post">
						<div class="form-group">
							<label for="date" class="col-sm-2">Student Name</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" name="es_stname" id="es_stname" placeholder="Enter student name">
							</div>
						</div>
						<div class="form-group">
							<label for="date" class="col-sm-2">Tests On Date</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" name="es_ondate" id="date" placeholder="On Date">
							</div>
						</div>
						<div class="form-group">
							<label for="date" class="col-sm-2">Tests From/To Date</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" name="es_fromdate" id="fromdate" placeholder="From Date">
							</div>
							<div class="col-sm-4">
								<input type="text" class="form-control" name="es_todate" id="todate" placeholder="To Date">
							</div>
						</div>
						<div class="form-group">
							<input type="submit" class="btn btn-primary" value="Search" name="search_data">
						</div>
					</form>
				</div>
			</div>
		</div>
		<div class="col-md-12" style="padding:0;">
			<div class="panel panel-info">
				<div class="panel-heading clearfix">
					<h4 class="panel-title">All Completed Test List</h4>
				</div>
				<div class="panel-body">
					<div class="table-responsive">
						<table class="display " id="userList" style="font-size: 13px;">
							<thead>
								<tr>
									<th>Id</th>
									<th>TestId</th>
									<th>Name</th>
									<th>Email</th>
									<th>Mobile</th>
									<th>Test Name</th>
									<th>Time(Sec)</th>
									<th>Test Date</th>
									<th>Action</th>
								</tr>
							</thead>
							<tbody>
								<?php
								$i = 1;
								foreach ($getTestData as $tst) {
									if ($tst->test_type == 'APT') {
										$link = 'aptitude-test-report';
									} else if ($tst->test_type == 'PER') {
										$link = 'personality-test-report';
									} else if ($tst->test_type == 'INT') {
										$link = 'interest-test-report';
									} else if ($tst->test_type == 'SS') {
										$link = 'selfstr-test-report';
									}
								?>
									<tr>
										<td><?php echo $i; ?></td>
										<td><?php echo $tst->test_taken_id; ?></td>
										<td><?php echo $tst->first_name; ?></td>
										<td><?php echo $tst->email_address; ?></td>
										<td><?php echo $tst->mobile_number; ?></td>
										<td><?php echo $tst->category_name; ?></td>
										<td><?php echo $tst->time_taken_in_seconds; ?></td>
										<td><?php echo $tst->start_date; ?></td>
										<td>
											<a href="<?php echo $link; ?>?testId=<?php echo $tst->test_taken_id; ?>" target="_blank">
												<i class="fa fa-eye" title="View Test Report" style="cursor:pointer;"></i>
											</a>
										</td>
									</tr>
								<?php $i++;
								} ?>
							</tbody>
						</table>
						<div class="btn-group" role="group" aria-label="First group" style="float: right;">
							<?php
							$k = (($pageno + 4 > $total_pages) ? $total_pages - 4 : (($pageno - 4 < 1) ? 5 : $pageno));
							if ($pageno >= 2) {
								echo "<a class='btn btn-default' href='$thisPage?page=1'> &laquo; </a>";
								echo "<a class='btn btn-default' href='$thisPage?page=" . ($pageno - 1) . "'> Prev </a>";
							}
							for ($j = -4; $j <= 4; $j++) {

								if (($k + $j) > 0) {
									if ($k + $j == $pageno)
										$pagLink .= "<a href='$thisPage?page=" . ($k + $j) . "' class='btn btn-default active'>" . ($k + $j) . "</a>";
									else
										$pagLink .= "<a class='btn btn-default' href='$thisPage?page=" . ($k + $j) . "'>" . ($k + $j) . "</a>";
								}
							};
							echo $pagLink;
							if ($pageno < $total_pages) {
								echo "<a class='btn btn-default' href='$thisPage?page=" . ($pageno + 1) . "'> Next </a>";
								echo "<a class='btn btn-default' href='$thisPage?page=" . $total_pages . "'> &raquo; </a>";
							}
							echo '<a class="btn btn-default">| Page: ' . $total_pages . '</a><a class="btn btn-default"> | Total Data: ' . $total_rows . '</a>';
							?>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div><!-- Main Wrapper -->

	<div class="page-footer">
		<p class="no-s">selfanalyse.com</p>
	</div>
</div><!-- Page Inner -->


<script type="text/javascript" charset="utf-8">
	jQuery.noConflict();
	jQuery(function($) {
		$('#userList').dataTable({
			"bPaginate": true,
			"iDisplayLength": 50,
			"lengthMenu": [
				[10, 20, 50, 100, 500, 1000],
				[10, 20, 50, 100, 500, 1000]
			],
			"order": [
				[1, "desc"]
			]
		});
		$("#date").datepicker({
			changeMonth: true,
			changeYear: true
		});
		$("#todate").datepicker({
			changeMonth: true,
			changeYear: true
		});
		$("#fromdate").datepicker({
			changeMonth: true,
			changeYear: true
		});
	});

	function submitAprForm() {
		if (document.getElementById("descr").value == '') {
			alert("Description can not empty");
			document.getElementById("descr").focus();
			event.preventDefault();
			return false;
		}
	}
</script>
<link href="assets/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="assets/css/responsive.dataTables.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
<script src="assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/dataTables.responsive.min.js"></script>

<?php
include_once('footer.php');
?>