File: /var/www/selfanalyse/school-admin/aptitude-test.php
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
include('header.php');
?>
<link href="assets/extra-libs/datatables.net-bs4/css/dataTables.bootstrap4.css" rel="stylesheet">
<?php
include('sidebar.php');
include_once('../wp-config.php');
$school_id = $_SESSION['user_id'];
$PSY_EXAMS = $wpdb->prefix . PSY_EXAMS;
$PSY_ABILITY = $wpdb->prefix . PSY_ABILITY;
$PSY_SP_QUESTION = $wpdb->prefix . PSY_SP_QUESTION;
$PSY_USERS_DETAILS = $wpdb->prefix . PSY_USERS_DETAILS;
$PSY_ABILITY_RAW_SCORE = $wpdb->prefix . PSY_ABILITY_RAW_SCORE;
$PSY_TEST_GEN_TEST_TAKEN = $wpdb->prefix . PSY_TEST_GEN_TEST_TAKEN;
$PSY_INTEREST_TEST_OPTION_MEAN = $wpdb->prefix . PSY_INTEREST_TEST_OPTION_MEAN;
$PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER = $wpdb->prefix . PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER;
$getTestQuery = "SELECT t.test_taken_id, t.user_id, t.class_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, u.date_of_birth, u.gender_id,e.parent_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' AND t.test_type='APT' order by t.test_taken_id desc";
$getTestData = $wpdb->get_results($getTestQuery);
?>
<div class="page-wrapper">
<div class="page-breadcrumb">
<div class="row">
<div class="col-12 align-self-center">
<h4 class="page-title text-truncate text-dark font-weight-medium mb-1">Aptitude Test List</h4>
<div class="d-flex align-items-center">
<nav aria-label="breadcrumb">
<ol class="breadcrumb m-0 p-0">
<li class="breadcrumb-item"><a href="dashboard" class="text-muted">Home</a></li>
<li class="breadcrumb-item text-muted active" aria-current="page">Aptitude Test List</li>
<a class="various" data-fancybox-type="iframe" href="http://staging.shinemetrics.com/school/aptitude-test-report?testId=69">Iframe</a>
</ol>
</nav>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<!-- ============================================================== -->
<!-- Start Page Content -->
<!-- ============================================================== -->
<!-- basic table -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="card-title">Student List</h4>
<div class="table-responsive">
<table id="zero_config" class="table table-striped table-bordered no-wrap">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Email</th>
<th>Mobile</th>
<th>D O B</th>
<th>Gender</th>
<th>Test Date</th>
<th>All Ability Score</th>
<th>View</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';
}
$getsubject = $wpdb->get_results("SELECT e.category_name,e.exam_category_id from $PSY_EXAMS as e LEFT JOIN $PSY_ABILITY as ab on ab.ref_id=e.exam_category_id where e.parent_id='$tst->exam_category_id' order by e.exam_category_id");
$rawScore = '';
foreach ($getsubject as $sub) {
$subject = $sub->exam_category_id;
$class_id = $tst->class_id;
$abilityData = $wpdb->get_row("SELECT ability_id,instruction FROM $PSY_ABILITY where ref_id='$subject'");
$ability_id = $abilityData->ability_id;
$getTestSummary = $wpdb->get_row("SELECT count(case when ttqt.correct_answer=ttqat.answer then 1 end) as correctQn, count(case when ttqt.correct_answer!=ttqat.answer and ttqat.answer!=0 then 1 end) as inCorrectQn, count(case when ttqat.answer=0 then 1 end) as unAttemptQn from $PSY_TEST_GEN_TEST_TAKEN_QUESTION_ANSWER as ttqat Inner join $PSY_SP_QUESTION as ttqt on ttqt.question_id = ttqat.test_question_id where ttqat.test_taken_id='$tst->test_taken_id' and ttqat.subject_id='$subject'");
$correctQn = (int) $getTestSummary->correctQn;
$inCorrectQn = $getTestSummary->inCorrectQn;
$unAttemptQn = $getTestSummary->unAttemptQn;
$rawScore += $wpdb->get_var("SELECT sten_score FROM $PSY_ABILITY_RAW_SCORE where $correctQn BETWEEN raw_score_start and raw_score_end and class_id='$class_id' and ability_id='$ability_id'");
}
?>
<tr>
<td><?php echo $i; ?></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->date_of_birth; ?></td>
<td><?php echo $tst->gender_id; ?></td>
<td><?php echo $tst->start_date; ?></td>
<td><?php echo $rawScore; ?></td>
<td> <!-- View -->
<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>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
include('footer.php');
?>
<!--This page plugins -->
<script src="assets/extra-libs/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="dist/js/pages/datatable/datatable-basic.init.js"></script>
<script type="text/javascript">
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
}
function getState(sel) {
$('#citvselect').hide();
$.ajax({
url: "backend/get_cities.php?state_id=" + sel.value,
cache: false,
success: function(html) {
$("#cityDIV").append(html);
}
});
}
</script>
<!-- Add fancyBox -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
<script src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".various").fancybox({
maxWidth : 800,
maxHeight : 600,
fitToView : false,
width : '70%',
height : '70%',
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none'
});
});
</script>