File: /var/www/content-sp/work-sp/nqb_olympiad_exam_questions_count.php
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
include_once('nqb_master_section_oly.php');
$fileName = str_replace('.php', '', basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']));
# tables use
$SP_EXAM_QUESTION_LINKAGE = 'shineoly_2022.wp_shine_sp_exam_question_linkage';
$TT_EXAM_CATEGORIES_TABLE = 'shineoly_2022.wp_shine_tt_exam_categories';
$SP_QUESTION = 'csp_sp_question';
$SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';
$SP_MEDIUM = 'csp_sp_medium';
$getMediums = $conn->query("SELECT medium_id,medium_name FROM $SP_MEDIUM where medium_id NOT IN(1,2) order by medium_id");
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$root_link = $protocol . $_SERVER['HTTP_HOST'] . '/';
include_once 'pagination.php';
$pagination_link = $_SERVER['PHP_SELF'];
/**live config */
include_once '../cron/config.php';
/**limit and ques query */
$limit = 10;
$pageNo = isset($_GET['pageN']) ? $_GET['pageN'] : 1;
$indexN = ($pageNo - 1) * $limit;
$countQuery = $live->query("SELECT count(e.exam_category_id) as total from $TT_EXAM_CATEGORIES_TABLE as e Inner join shineoly_2022.wp_shine_tt_all_exams as ae on ae.exam_category_id=e.exam_category_id where ae.status='1' order by e.category_name asc");
$cQuery = $countQuery->fetch_assoc();
$count = $cQuery['total'];
$noOfPages = ceil($count / $limit);
$allExam = $live->query("SELECT e.exam_category_id, e.category_name,e.app_status from $TT_EXAM_CATEGORIES_TABLE as e Inner join shineoly_2022.wp_shine_tt_all_exams as ae on ae.exam_category_id=e.exam_category_id where ae.status='1' order by e.category_name asc limit $indexN, $limit");
?>
<style>
.table-hover th,
td {
font-size: 13px;
}
.redClass {
background-color: #ff6d6d !important;
}
.orangeClass {
background-color: #ff7607 !important;
}
.modal-backdrop.in {
opacity: 0.9 !important;
z-index: 9 !important;
}
</style>
<div class="row">
<div class="col-md-12">
<div class="panel panel-white">
<div class="panel-heading clearfix">
<h4 class="panel-title">
Select Third Medium
</h4>
</div>
<div class="panel-body">
<form class="form-inline" method="post">
<div class="form-group">
<select name="thrd_med" class="form-control" required>
<option value="">--Third Medium Count--</option>
<?php foreach ($getMediums as $md) {
?>
<option value="<?php echo $md['medium_id']; ?>"><?php echo $md['medium_name']; ?> </option>
<?php } ?>
</select>
</div>
<input class="btn btn-info" type="submit" value="Select Master" name="all_exam_counts" />
</form>
</div>
</div>
</div>
<?php if (isset($_SESSION['thrdMed'])) {
#medium
$findMed = $_SESSION['thrdMed'];
$thrdMedium = $conn->query("SELECT medium_name FROM $SP_MEDIUM where medium_id='$findMed'");
$thM = $thrdMedium->fetch_assoc();
?>
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title" style="width: 100%;">Exam Count</h4>
</div>
<div class="spacer"></div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<table class="table table-hover tableFixHead">
<thead>
<tr>
<th>#</th>
<th>Topic Name</th>
<th>T.ques</th>
<th>English</th>
<th>Hindi</th>
<th><?php echo $thM['medium_name']; ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
foreach ($allExam as $t) {
$topic_id = $t['exam_category_id'];
$totalQuestion = $live->query("SELECT count(e.id) as topic_ques FROM $SP_EXAM_QUESTION_LINKAGE as e LEFT JOIN $SP_QUESTION as sp on sp.question_id=e.question_id where e.exam_type_id='$topic_id'");
$topic_ques = $totalQuestion->fetch_assoc();
# english
$engCount = $live->query("SELECT (
SELECT count(sq.question_id) as c FROM $SP_EXAM_QUESTION_LINKAGE as e LEFT JOIN $SP_QUESTION as sq on sq.question_id=e.question_id WHERE e.exam_type_id='$topic_id' and sq.medium_id='1')+
(
SELECT count(sq.question_id) as c FROM $SP_EXAM_QUESTION_LINKAGE as e LEFT JOIN $SP_QUESTION_MEDIUM_WISE as sq on sq.question_id=e.question_id WHERE e.exam_type_id='$topic_id' and sq.medium_id='1'
) as total
");
$sh_eng = $engCount->fetch_assoc();
$engTotal = $sh_eng['total'];
# hindi
$hndCount = $live->query("SELECT (
SELECT count(sq.question_id) as c FROM $SP_EXAM_QUESTION_LINKAGE as e LEFT JOIN $SP_QUESTION as sq on sq.question_id=e.question_id WHERE e.exam_type_id='$topic_id' and sq.medium_id='2')+
(
SELECT count(sqm.question_id) as c FROM $SP_EXAM_QUESTION_LINKAGE as e LEFT JOIN $SP_QUESTION as sq on sq.question_id=e.question_id LEFT JOIN $SP_QUESTION_MEDIUM_WISE as sqm on sqm.question_id=sq.question_id WHERE e.exam_type_id='$topic_id' and sqm.medium_id='2'
) as total
");
$sh_hnd = $hndCount->fetch_assoc();
$hndTotal = $sh_hnd['total'];
# third medium
$thrdMedCount = $live->query("SELECT (
SELECT count(sq.question_id) as c FROM $SP_EXAM_QUESTION_LINKAGE as e LEFT JOIN $SP_QUESTION as sq on sq.question_id=e.question_id WHERE e.exam_type_id='$topic_id' and sq.medium_id='$findMed')+
(
SELECT count(sqm.question_id) as c FROM $SP_EXAM_QUESTION_LINKAGE as e LEFT JOIN $SP_QUESTION as sq on sq.question_id=e.question_id LEFT JOIN $SP_QUESTION_MEDIUM_WISE as sqm on sqm.question_id=sq.question_id WHERE e.exam_type_id='$topic_id' and sqm.medium_id='$findMed'
) as total
");
$sh_thr = $thrdMedCount->fetch_assoc();
$thrTotal = $sh_thr['total'];
?>
<tr>
<th><?php echo $i + $indexN; ?></th>
<th title="<?php echo $t['exam_category_id']; ?>"><i class="fa fa-book"></i> <?php echo $t['category_name']; ?></th>
<th>[<?php echo $topic_ques['topic_ques']; ?>]</th>
<th>[<?php echo $engTotal; ?>]</th>
<th>[<?php echo $hndTotal != '' ? $hndTotal : '0'; ?>]</th>
<th>[<?php echo $thrTotal != '' ? $thrTotal : '0'; ?>]</th>
</tr>
<?php $i++;
} ?>
</tbody>
</table>
</div>
</div>
<!-- Pagination -->
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<?php echo pagination($limit, $pageNo, $pagination_link . "?pageN=", $count); ?>
</div>
</div>
<!-- end question loop repeat -->
</div>
</div>
</div>
<?php } ?>
</div>
</div><!-- Main Wrapper -->
<div class="page-footer">
<p class="no-s">Graposs Connect ©</p>
</div>
</div><!-- Page Inner -->
<?php
include_once('footer.php');
?>