File: /var/www/content-sp/work-sp/master_wise_grouped_questions.php
<?php
include_once('nqb_master_section.php');
include_once('sp_config.php');
error_reporting(0);
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$adminId = $editor_id;
$curDate = date('Y-m-d H:i:s');
$toDate = date('Y-m-d');
//check edit permissions
$mId = '';
$fileName = str_replace('.php', '', basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']));
if (in_array($fileName, $pageArray)) {
$SP_QUESTION = 'csp_sp_question';
$SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';
$SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
$SP_MASTER_CATEGORY = 'csp_sp_master_category';
$pagination_link = 'master_wise_grouped_questions';
include_once 'pagination.php';
$allMaster = $conn->query("SELECT mc.master_id, mc.master_name, mc.source from $SP_MASTER_CATEGORY as mc order by mc.master_id asc");
if (isset($_POST['submit'])) {
unset($_SESSION['masterID']);
unset($_SESSION['subjectID']);
$master = $_REQUEST['master'];
$subject = $_REQUEST['subject'];
$_SESSION['masterID'] = $master;
$_SESSION['subjectID'] = $subject;
}
if (isset($_SESSION['masterID']) && $_SESSION['masterID'] != '') {
$mId = $_SESSION['masterID'];
$sId = $_SESSION['subjectID'];
$limit = 100;
$pageNo = isset($_GET['pageN']) ? $_GET['pageN'] : 1;
$indexN = ($pageNo - 1) * $limit;
$countQuery = $conn->query("SELECT q.question_group, count(q.question_id) as qidd FROM $SP_QUESTION as q WHERE q.question_group!='0' and q.master_id='$mId' and q.subject_id='$sId' group by q.question_group");
// $cQuery = $countQuery->fetch_assoc();
$count = mysqli_num_rows($countQuery);
$noOfPages = ceil($count / $limit);
/***grouped questions by master */
$getGroupques = "SELECT q.question_group, count(q.question_id) as qidd FROM $SP_QUESTION as q WHERE q.question_group!='0' and q.master_id='$mId' and q.subject_id='$sId' group by q.question_group order by q.question_group asc limit $indexN, $limit";
$getGrpData = $conn->query($getGroupques);
$ifData = mysqli_num_rows($getGrpData);
}
?>
<style>
table {
font-size: 13px;
}
.loading_image {
display: block;
position: fixed;
z-index: 1000;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba(255, 255, 255, .8) url('/work-sp/assets/images/reload.GIF') 50% 50% no-repeat;
}
.modal-backdrop.in {
opacity: 0.9 !important;
z-index: 9 !important;
}
</style>
<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/jquery-2.1.3.min.js"></script>
<script src="assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<link href="assets/plugins/datatables/css/jquery.datatables.min.css" rel="stylesheet">
<link href="assets/plugins/datatables/css/responsive.datatables.min.css" rel="stylesheet">
<script src="assets/plugins/datatables/js/jquery.datatables.min.js"></script>
<script src="assets/plugins/datatables/js/jquery.datatables.js"></script>
<script src="assets/plugins/datatables/js/datatables.responsive.min.js"></script>
<link href="assets/plugins/select2/css/select2.min.css" rel="stylesheet">
<script src="assets/plugins/select2/js/select2.min.js"></script>
<script type="text/javascript">
var jq = jQuery.noConflict();
jq(document).ready(function() {
jq('#repques_table').dataTable({
"bPaginate": false,
bFilter: false,
"responsive": true
});
jq("#date").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
jq("#todate").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
jq("#fromdate").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd-mm-yy'
});
jq('.editors-dropdown').select2();
});
function dataTableLoad() {
jq('#repques_table_list').dataTable({
"bPaginate": false,
bFilter: false,
"responsive": true
});
}
</script>
<div class="row">
<div class="col-md-12">
<div class="panel panel-white">
<div class="panel-heading clearfix">
<h4 class="panel-title">Select Master
</h4>
</div>
<div class="panel-body">
<form class="form-inline" method="post">
<div class="form-group" style="width: 30%;">
<select name="master" class="form-control" id="master" style="width: 100%;">
<option value="">--Master--</option>
<?php while ($ms = $allMaster->fetch_assoc()) { ?>
<option value="<?php echo $ms['master_id']; ?>" <?php if ($mId == $ms['master_id']) echo "selected"; ?>><?php echo $ms['master_name'] . '-' . $ms['source']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<select name="subject" class="form-control" id="subject">
<option value="">--Select Subject--</option>
<?php if (isset($_SESSION['masterID'])) {
$getSubject = $conn->query("SELECT sub_id,category_name from $SP_MASTER_STRUCTURE where master_id='" . $_SESSION['masterID'] . "' and parent_id=0 order by category_name asc");
foreach ($getSubject as $sb) {
?>
<option value="<?php echo $sb['sub_id']; ?>" <?php if (@$_SESSION['subjectID'] == $sb['sub_id']) { echo "selected"; } ?>><?php echo $sb['category_name']; ?></option>
<?php }
} ?>
</select>
</div>
<input class="btn btn-info" type="submit" value="Submit" name="submit" />
</form>
</div>
</div>
</div>
<?php //if (!empty($_SESSION['report_subQuery'])) {
?>
<?php if ($ifData > 0) { ?>
<div class="col-md-4">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Master/Subject wise grouped questions</h4>
</div>
<div class="spacer"></div>
<div class="panel-body">
<div class="table-responsive">
<table id="repques_table" class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Group Id</th>
<th>Ques Count</th>
<th>View</th>
</tr>
</thead>
<tbody>
<?php
$i = 1 + $indexN;
while ($ggd = $getGrpData->fetch_assoc()) {
?>
<tr id="tr_<?php echo $ggd['question_group']; ?>">
<td><?php echo $i; ?></td>
<td><?php echo $ggd['question_group']; ?></td>
<td><?php echo $ggd['qidd']; ?></td>
<td style="cursor:pointer;font-size:22px;color:darkslategray;" onclick="viewList('<?php echo $ggd['question_group']; ?>')">
<span class="glyphicon glyphicon-tasks"></span>
</td>
</tr>
<?php $i++;
} ?>
</tbody>
</table>
</div>
</div>
</div>
<?php echo pagination($limit, $pageNo, $pagination_link . "?pageN=", $count); ?>
</div>
<?php } ?>
<div class="col-md-8">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Group wise Questions List</h4>
</div>
<div class="spacer"></div>
<div class="panel-body" id="view_list">
</div>
</div>
</div>
</div>
<div class="page-footer">
<p class="no-s">Graposs Connect ©</p>
</div>
</div><!-- Page Inner -->
<script type="text/javascript">
jQuery.noConflict();
jQuery('#master').on('change', function() {
var mid = jQuery("#master").val();
var loadUrl = "ajax_call/nqb_master_topics.php?eid=" + mid + "&type=master";
var jqxhr = jQuery.get(loadUrl);
jqxhr.success(function(data) {
jQuery("#subject").html(data);
});
});
function viewList(qgrp) {
jQuery("#repques_table").find(".danger").removeClass("danger");
jQuery("#tr_" + qgrp).addClass("danger");
jQuery("#loading").addClass("loading_image");
var site = "/work-sp/ajax_call/master_wise_grouped_questions_view_group_id.php?grp_id=" + qgrp + "&mType=sp";
jQuery.ajax({
url: site,
type: 'POST',
data: 'html',
success: function(data) {
jQuery("#loading").removeClass("loading_image");
document.getElementById("view_list").innerHTML = data;
dataTableLoad();
}
});
}
</script>
<?php
} else {
echo "<script type='text/javascript'>alert('You dont have access of proofread');</script>";
echo "<script type='text/javascript'>location.href='/work-sp';</script>";
}
include_once('footer.php');
?>