File: /var/www/content-sp/work-sp/normal_to_banking_topic_wise.php
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
include_once('nqb_master_section.php');
// include_once('transfer_config.php');
// $fileName = str_replace('.php', '', basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']));
$fileName = 'normal_to_banking_current_affairs';
//check master permissions
if (in_array($fileName, $pageArray)) {
$masterType = 'sp';
$SP_MASTER_CATEGORY = 'csp_sp_master_category';
$SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
$SP_MEDIUM = 'csp_sp_medium';
$SP_QUESTION = 'csp_sp_question';
$SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';
$SP_EDITORS = 'csp_editors';
$from = $_REQUEST['from_id'];
$from_type = $_REQUEST['from_type'];
$to = $_REQUEST['to_id'];
$to_type = $_REQUEST['to_type'];
if (is_numeric($from) && is_numeric($to) && $from != '' && $to != '' && $from != '0' && $to != '0') {
$getTopics1 = $conn->query("SELECT sub_id, parent_id, category_name FROM $SP_MASTER_STRUCTURE where sub_id='$from' order by parent_id, sub_id");
$t = $getTopics1->fetch_assoc();
$getTopics3 = $conn->query("SELECT sub_id, parent_id, category_name FROM $SP_MASTER_STRUCTURE where sub_id='$to' order by parent_id, sub_id");
$t3 = $getTopics3->fetch_assoc();
$curDate = date('Y-m-d H:i:s');
/****get source ids */
if ($from_type == 'st') {
$getTopic = $conn->query("SELECT ms.master_id,ms.parent_id as topic,sm.parent_id as subject FROM $SP_MASTER_STRUCTURE as ms
left join $SP_MASTER_STRUCTURE as sm on sm.sub_id=ms.parent_id
where ms.sub_id='$from'");
$md = $getTopic->fetch_assoc();
$srcMasterId = $md['master_id'];
$srcSubjectId = $md['subject'];
$srcTopicId = $md['topic'];
$srcSubtopic = $from;
$subFromQuery = "sub_topic_id='$from'";
} else if ($from_type == 't') {
$getTopic = $conn->query("SELECT ms.master_id,ms.parent_id as subject FROM $SP_MASTER_STRUCTURE as ms
where ms.sub_id='$from'");
$md = $getTopic->fetch_assoc();
$srcMasterId = $md['master_id'];
$srcSubjectId = $md['subject'];
$srcTopicId = $from;
$srcSubtopic = '0';
$subFromQuery = "topic_id='$from'";
} else {
$subFromQuery = "topic_id='$from'";
}
/****get target ids */
if ($to_type == 'st') {
$getTopic_tar = $conn->query("SELECT ms.master_id,ms.parent_id as topic,sm.parent_id as subject FROM $SP_MASTER_STRUCTURE as ms
left join $SP_MASTER_STRUCTURE as sm on sm.sub_id=ms.parent_id
where ms.sub_id='$to'");
$mdT = $getTopic_tar->fetch_assoc();
$tgtMasterId = $mdT['master_id'];
$tgtSubjectId = $mdT['subject'];
$tgtTopicId = $mdT['topic'];
$tgtSub = $to;
$subToQuery = "sub_topic_id='$to'";
} else if ($to_type == 't') {
$getTopic_tar = $conn->query("SELECT ms.master_id,ms.parent_id as subject FROM $SP_MASTER_STRUCTURE as ms
where ms.sub_id='$to'");
$mdT = $getTopic_tar->fetch_assoc();
$tgtMasterId = $mdT['master_id'];
$tgtSubjectId = $mdT['subject'];
$tgtTopicId = $to;
$tgtSub = '0';
$subToQuery = "topic_id='$to'";
} else {
$subToQuery = "topic_id='$to'";
}
$getCnt = $conn->query("SELECT count(question_id) as tqcnt from $SP_QUESTION where $subFromQuery and question_id NOT IN (SELECT source_id from $SP_QUESTION where master_id='$tgtMasterId' and subject_id='$tgtSubjectId' and source_id IS NOT NULL)");
$getCntT = $getCnt->fetch_assoc();
$getCnt3 = $conn->query("SELECT count(question_id) as tqcnt from $SP_QUESTION where $subToQuery");
$getCntT3 = $getCnt3->fetch_assoc();
// $srcMasterId = 99;
// $srcSubjectId = $from;
// $srcTopicId =0;
// $tgtMasterId = 99;
// $tgtSubjectId = $to;
// $tgtTopicId =0;
if (isset($_POST["trnsfer"])) {
$src_id = $_POST["src_id"];
$tgt_id = $_POST["tgt_id"];
$getQuesQuery = "SELECT question_id,medium_id from $SP_QUESTION where $subFromQuery and question_id NOT IN (select source_id from $SP_QUESTION where master_id='$tgtMasterId' and subject_id='$tgtSubjectId' and source_id IS NOT NULL) limit 50";
$getQuesData = $conn->query($getQuesQuery);
$i = 1;
foreach ($getQuesData as $sq) {
$qidd = $sq['question_id'];
$medium_id = $sq['medium_id'];
if($medium_id == 2) {
$opt5_h = '<p>None of the above</p>';
$opt5_e = '<p>उपर्युक्त में से कोई नहीं</p>';
} else if($medium_id == 1) {
$opt5_e = '<p>None of the above</p>';
$opt5_h = '<p>उपर्युक्त में से कोई नहीं</p>';
}
$flag = '1';
$insertPrimaryQ = "INSERT INTO $SP_QUESTION (`oly_id`, `old_question_id`, `master_id`, `subject_id`, `topic_id`, `sub_topic_id`, `sys_id`, `level_name`, `difficulty`, `medium_id`, `question_group`, `no_of_option`, `question_instruction`, `question_statement`, `option_1`, `option_2`, `option_3`, `option_4`, `option_5`, `correct_answer`, `question_hint`, `question_solution`, `active_solution`, `previous_exam_name`, `previous_exam_year`, `exam_shift`, `question_expiry`, `source_id`, `add_by`, `add_date`, `last_update_on`, `last_update_by`, `last_proofread_by`, `last_proofread_date`, `status`, `question_type`, `question_of`, `question_flag`, `exam_bound`, `e_id`, `e_sub_id`, `e_top_id`) SELECT `oly_id`, `old_question_id`, $tgtMasterId, $tgtSubjectId, $tgtTopicId, $tgtSub, `sys_id`, `level_name`, `difficulty`, `medium_id`, `question_group`, `no_of_option`, `question_instruction`, `question_statement`, `option_1`, `option_2`, `option_3`, `option_4`, '$opt5_e', `correct_answer`, `question_hint`, `question_solution`, `active_solution`, `previous_exam_name`, `previous_exam_year`, `exam_shift`, `question_expiry`, $qidd, `add_by`, '$curDate', '$curDate', $editor_id, `last_proofread_by`, `last_proofread_date`, `status`, `question_type`, `question_of`, '$flag', `exam_bound`, `e_id`, `e_sub_id`, `e_top_id` FROM $SP_QUESTION WHERE question_id='$qidd'";
$conn->query($insertPrimaryQ);
echo $conn->error;
$quesId = $conn->insert_id;
// echo "<br>";
if ($quesId != '' && $quesId != 0) {
$insertSecQ = "INSERT INTO $SP_QUESTION_MEDIUM_WISE (`question_id`, `oly_id`, `medium_id`, `question_instruction`, `question_statement`, `option_1`, `option_2`, `option_3`, `option_4`, `option_5`, `question_hint`, `question_solution`, `active_solution`, `source_id`, `add_by`, `add_date`, `last_update_on`, `last_update_by`, `last_proofread_date`, `last_proofread_by`, `status`) SELECT $quesId, `oly_id`, `medium_id`, `question_instruction`, `question_statement`, `option_1`, `option_2`, `option_3`, `option_4`, '$opt5_h', `question_hint`, `question_solution`, `active_solution`, `source_id`, `add_by`, '$curDate', '$curDate', $editor_id, `last_proofread_date`, `last_proofread_by`, `status` FROM $SP_QUESTION_MEDIUM_WISE WHERE question_id='$qidd'";
$conn->query($insertSecQ);
// echo "<br>";
}
$i++;
}
}
?>
<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;
}
.topic {
width: 20%;
float: left;
font-size: 14px;
margin: 0 0 0 0;
}
.sub_topic {
width: 26%;
float: left;
font-size: 14px;
margin: 0 0 0 -19px;
}
li {
list-style: none;
margin: 5px 0px 5px 0px;
}
.trfButton {
position: fixed;
top: 80%;
left: 50%;
}
.woldCA {
padding-left: 50px;
}
</style>
<?php if (isset($msg)) { ?>
<div class="row">
<div class="col-sm-12">
<?php echo $msg; ?>
</div>
</div>
<?php } ?>
<div class="row">
<div class="col-md-12">
<div class="panel panel-white">
<div class="panel-heading clearfix">
<h4 class="panel-title">Current Affairs Questions Transfer [SSC To Banking]</h4>
</div>
<form name="submitform" method="post">
<div class="panel-body">
<h4 class="panel-title">Current Affairs [ SSC ]</h4>
<div class="row">
<div class="col-md-6">
<ul>
<?php
?>
<li title="<?php echo $t['sub_id']; ?>"><input type="radio" name="src_id" value="<?php echo $t['sub_id']; ?>" /><?php echo $t['category_name']; ?> [ <?php echo $getCntT['tqcnt']; ?> ]</li>
</ul>
</div>
<div class="col-md-6">
<h4 class="panel-title">Current Affairs [ Banking ]</h4>
<ul>
<?php
?>
<li title="<?php echo $t3['sub_id']; ?>"><input type="radio" name="tgt_id" value="<?php echo $t3['sub_id']; ?>" /><?php echo $t3['category_name']; ?> [ <?php echo $getCntT3['tqcnt']; ?> ]</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<input type="submit" name="trnsfer" value="Transfer Questions" class="trfButton" />
</div>
</div>
</form>
</div>
</div>
</div>
</div><!-- Main Wrapper -->
<div class="page-footer">
<p class="no-s">Graposs Connect ©</p>
</div>
</div><!-- Page Inner -->
<?php
} else {
echo "from and to id";
}
include_once('footer.php');
} else {
echo "<script>alert('You dont have access for transfer');</script>";
echo "<script type='text/javascript'>location.href='/work-sp';</script>";
}
?>