
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
$function = new FUNCTIONS();
if(empty($_SESSION['adminId'])){
header("Location: ../index.php");
exit();
}
$quizQuestionlist = $function->getQuizQuestion($qid=NULL,$isActive=1,$status='Active',$orderBy='ASC');
//print_r($quizQuestionlist);
//delete latest news
if(!empty($_GET['id']) && ($_GET['action']=='Del')) {
//print_r($_GET['id']); exit;
$id=$_GET['id'];
$pdodb = PDODB::getInstance();
$sql = "UPDATE `quiz_questions` SET isActive=0 WHERE qid = '".$id."'";
//print_r($sql); exit;
$result = $pdodb->query($sql);
PDODB::closeInstance();
if(!empty($result)){
echo '<script type="text/javascript">location.replace("index.php");</script>';
}
}
if (isset($_POST["selected_status"]) && isset($_POST["new_status"])) {
$selectedStatus = $_POST["selected_status"];
$newStatus = $_POST["new_status"];
// Update the status of selected questions
foreach ($selectedStatus as $statusId) {
// Assuming there is a function or method to update the status
$pdodb = PDODB::getInstance();
$sqlinstlmnt = "UPDATE `quiz_questions` SET `status`='".$newStatus."' WHERE `quiz_questions`.`qid` ='".$statusId."'";
$resultinstlmnt = $pdodb->query($sqlinstlmnt);
}
//exit;
$quizQuestionlist = $function->getQuizQuestion($id=NULL,$isActive=1,$status='Active',$orderBy='ASC');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Coforge Techcon | Admin panel</title>
<?php include_once '../layout/style.php'; ?>
<style>
.dataTables-example thead th.sorting,
.dataTables-example thead th.sorting_asc,
.dataTables-example thead th.sorting_desc {
background-image: none !important;
}
</style>
</head>
<body>
<div id="wrapper">
<?php $currentPage = 'quiz-active'; include_once '../layout/side-bar.php'; ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once '../layout/header.php'; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-8">
<h2>Active Quiz Questions list</h2>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="table-responsive">
<form method="post" action="" id="statusForm"> <!-- Add this new status dropdown at the top -->
<div class="form-group" style="margin-bottom: 15px;">
<label for="new_status_top">Change Status To:</label>
<select name="new_status" id="new_status_top" class="form-control" style="width: auto; display: inline-block;">
<option value="Finish">Finish</option>
</select>
<button type="submit" name="btnUpdt" class="btn btn-primary">Update Status</button>
</div>
<table class="table table-striped table-bordered table-hover dataTables-example">
<thead>
<tr>
<th>Select <br>All <br><input type="checkbox" class="select_all"></th>
<th>S.No</th>
<th>Question</th>
<th>Option A</th>
<th>Option B</th>
<th>Option C</th>
<th>Option D</th>
<th>Correct Answer </th>
<th>Status</th>
<!--<th>Action</th>-->
</tr>
</thead>
<tbody>
<?php
for($i=0;$i<count($quizQuestionlist);$i++){
?>
<tr>
<td><input type="checkbox" class="status_checkbox" name="selected_status[]" value="<?=$quizQuestionlist[$i]['qid'];?>"></td>
<td><?=$i+1;?></td>
<td class="center"><?=$quizQuestionlist[$i]['question'];?></td>
<td class="center"><?=$quizQuestionlist[$i]['ans1'];?></td>
<td class="center"><?=$quizQuestionlist[$i]['ans2'];?></td>
<td class="center"><?=$quizQuestionlist[$i]['ans3'];?></td>
<td class="center"><?=$quizQuestionlist[$i]['ans4'];?></td>
<td class="center"><?=$quizQuestionlist[$i]['correct_answer'];?></td>
<td class="center"><?=$quizQuestionlist[$i]['status'];?></td>
<!--<td class="center">
<a class="btn btn-danger btn-xs" href="index.php?id=<?=$quizQuestionlist[$i]['qid'];?>&action=Del" onclick=" return confirm('Do you really want to delete!')"><i class="fa fa-trash"></i> Delete</a></td>
</td>-->
</tr>
<?php } ?>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once '../layout/script.php'; ?>
<!-- Page-Level Scripts -->
<script>
$(document).ready(function(){
// Select all functionality
$(document).on('change', ".select_all", function() {
$(".status_checkbox").prop('checked', $(this).prop("checked"));
});
// Form submission handler
$('#statusForm').on('submit', function(e) {
// Check if at least one checkbox is selected
if($('.status_checkbox:checked').length === 0) {
alert('Please select at least one to update');
e.preventDefault();
return false;
}
// You can add additional validation here if needed
return true;
});
$('.dataTables-example').DataTable({
dom: '<"html5buttons"B>lTfgitp',
buttons: [
{ extend: 'copy' },
{ extend: 'csv' }
],
ordering: false // Disable sorting for all columns
});
/*var table = $('.dataTables-example').DataTable({
dom: '<"html5buttons"B>lTfgitp',
buttons: [
{ extend: 'copy' },
{ extend: 'csv' }
]
});
table.on('draw.dt', function () {
$('.dataTables-example thead th:first')
.removeClass('sorting sorting_asc sorting_desc');
});*/
});
</script>
</body>
</html>


PK 99