File: /var/www/content-sp/work-sp/nqb_add_question.php
<?php
include_once('header.php');
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$fileName = str_replace('.php', '', basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']));
//check edit permissions
if (in_array($fileName, $pageArray)) {
/***define tables */
$SP_MEDIUM = 'csp_sp_medium';
$SP_QUESTION = 'csp_sp_question';
$TT_PREVIOUS_EXAM_TABLE = 'csp_sp_previous_exam';
$SP_MASTER_LEVEL = 'csp_sp_master_level';
$SP_QUESTION_DIFFICULTY = 'csp_sp_question_difficulty';
$SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
$SP_QUES_HISTORY = 'csp_sp_question_history';
$curDate = date('Y-m-d H:i:s');
/**request param */
$subject_id = $_REQUEST['subject_id'];
$topic_id = $_REQUEST['topic_id'];
$sub_topic_id = $_REQUEST['sub_topic_id'];
$master_id = $_REQUEST['master_id'];
$mType = $_REQUEST['mType'];
$srcMedium = isset($_SESSION['SRC_MED']) ? $_SESSION['SRC_MED'] : '1';
$targetMedium = isset($_SESSION['TAR_MED']) ? $_SESSION['TAR_MED'] : '1';
/**question related sql queries */
$allMedium = $conn->query("SELECT medium_id,medium_name from $SP_MEDIUM order by medium_id asc");
$allPreExams = $conn->query("SELECT id, exam_name, status from $TT_PREVIOUS_EXAM_TABLE where status = '1' ");
$allLevel = $conn->query("SELECT level_name,description from $SP_MASTER_LEVEL where status='1'");
$allDifficulty = $conn->query("SELECT difficulty,description from $SP_QUESTION_DIFFICULTY where status='1'");
$countGrp = $conn->query("select MAX(question_group) as mgrp from $SP_QUESTION limit 1");
$countQuery = $countGrp->fetch_assoc();
$grpcount = $countQuery['mgrp'];
/***get master and topic name */
if ($subject_id == '0') {
$subquery = "ms.sub_id='$sub_topic_id' and sm.sub_id='$topic_id'";
} else {
$subquery = "ms.sub_id='$sub_topic_id' and sm.sub_id='$topic_id' and sms.sub_id='$subject_id'";
}
$masterDetails = $conn->query("SELECT ms.category_name as subtopic,sm.category_name as topic,sms.category_name as subject FROM $SP_MASTER_STRUCTURE as ms
left join $SP_MASTER_STRUCTURE as sm on sm.sub_id=ms.parent_id
left join $SP_MASTER_STRUCTURE as sms on sms.sub_id=sm.parent_id
where $subquery");
$md = $masterDetails->fetch_assoc();
$subject = $md['subject'];
$topic = $md['topic'];
$sub_topic = $md['subtopic'];
if ($subject_id == '0' || $subject_id == '') {
$subjectid0 = $topic_id;
$topicid0 = $sub_topic_id;
$sub_topic_id0 = '0';
} else {
$subjectid0 = $subject_id;
$topicid0 = $topic_id;
$sub_topic_id0 = $sub_topic_id;
}
/***add question */
if (isset($_REQUEST['btn_add'])) {
$instructionQ = isset($_POST['instruction']) ? (mysqli_real_escape_string($conn, $_REQUEST['instruction'])) : "";
$questionQ = isset($_POST['question']) ? (mysqli_real_escape_string($conn, $_POST['question'])) : "";
$correctAnswer = isset($_POST['radio_ans']) ? $_POST['radio_ans'] : "";
$ans1Q = isset($_POST['ans_1']) ? (mysqli_real_escape_string($conn, $_POST['ans_1'])) : "";
$ans2Q = isset($_POST['ans_2']) ? (mysqli_real_escape_string($conn, $_POST['ans_2'])) : "";
$ans3Q = isset($_POST['ans_3']) ? (mysqli_real_escape_string($conn, $_POST['ans_3'])) : "";
$ans4Q = isset($_POST['ans_4']) ? (mysqli_real_escape_string($conn, $_POST['ans_4'])) : "";
$ans5Q = isset($_POST['ans_5']) ? (mysqli_real_escape_string($conn, $_POST['ans_5'])) : "";
$question_solutionQ = isset($_POST['solution']) ? (mysqli_real_escape_string($conn, $_POST['solution'])) : "";
$prev_exam_name = $_REQUEST['prev_exam_name'];
$prev_exam_year = $_REQUEST['prev_exam_year'];
$prev_exam_shift = $_REQUEST['prev_exam_shift'];
$medium = $_REQUEST['medium'];
$total_option = $_REQUEST['total_option'];
$multi_tags = $_REQUEST['multi_tags'];
$ques_level = $_REQUEST['ques_level'];
$ques_difficulty = $_REQUEST['ques_difficulty'];
$expiry_date = $_REQUEST['expiry_date'];
$translate_ques = isset($_REQUEST['translate_ques']) ? $_REQUEST['translate_ques'] : '';
$ques_of = explode(',', $_REQUEST['ques_of']);
$quesOfjson = json_encode($ques_of, JSON_UNESCAPED_UNICODE);
//if exam bound question
$is_exam = isset($_REQUEST['is_exam']) ? $_REQUEST['is_exam'] : 'N';
if ($is_exam == 'Y') {
$e_exam = $_REQUEST['e_exam'];
$e_sub = $_REQUEST['e_sub'];
$e_topic = $_REQUEST['e_topic'];
} else {
$e_exam = '';
$e_sub = '';
$e_topic = '';
}
$msg = '';
if ($translate_ques == '') {
$question_type = '1';
} else {
$question_type = '0';
}
if ($subject_id == '0' || $subject_id == '') {
$subjectid0 = $topic_id;
$topicid0 = $sub_topic_id;
$sub_topic_id0 = '0';
} else {
$subjectid0 = $subject_id;
$topicid0 = $topic_id;
$sub_topic_id0 = $sub_topic_id;
}
$flag = ",question_flag='1'";
if ($total_option != '2') {
$optionArray = array($ans1Q, $ans2Q, $ans3Q, $ans4Q, $ans5Q);
$newFilteredArray = array_filter($optionArray);
$totalOption = count($newFilteredArray);
$duplicate = count(array_unique($newFilteredArray));
if ($totalOption != $duplicate) {
$addQues = 0;
} else {
$addQues = 1;
}
} else {
$addQues = 1;
}
if ($addQues == 1) {
$sys_id = sprintf('%03d', $master_id) . '-' . sprintf('%04d', $subjectid0) . '-' . sprintf('%05d', $topicid0) . '-' . sprintf('%06d', $sub_topic_id0) . '-' . time() . '-' . rand('1000', '9999');
if ($correctAnswer != '') {
$checkExist = $conn->query("Select count(question_id) as ifexist from $SP_QUESTION where question_statement='$questionQ' and option_1='$ans1Q' and option_2='$ans2Q' and option_3='$ans3Q' and option_4='$ans4Q' and option_5='$ans5Q'");
$existResult = $checkExist->fetch_assoc();
$existRows = $existResult['ifexist'];
if ($existRows == '0') {
if ($master_id != '0' && $master_id != '' && $subjectid0 != '0' && $subjectid0 != '' && $topicid0 != '0' && $topicid0 != '') {
$insertQuery = "INSERT into $SP_QUESTION set master_id='$master_id', subject_id='$subjectid0', topic_id='$topicid0',sub_topic_id='$sub_topic_id0', sys_id='$sys_id', medium_id='$medium', no_of_option='$total_option', question_instruction='$instructionQ', question_statement='$questionQ', option_1='$ans1Q', option_2='$ans2Q', option_3='$ans3Q', option_4='$ans4Q', option_5='$ans5Q', correct_answer='$correctAnswer', question_solution='$question_solutionQ',add_by='$editor_id', add_date='$curDate',status='2', question_of='$quesOfjson',question_tag='$multi_tags',previous_exam_name='$prev_exam_name',previous_exam_year='$prev_exam_year',exam_shift='$prev_exam_shift',question_expiry='$expiry_date',level_name='$ques_level',difficulty='$ques_difficulty',question_type='$question_type',exam_bound='$is_exam',e_id='$e_exam',e_sub_id='$e_sub',e_top_id='$e_topic' $flag";
if ($conn->query($insertQuery)) {
$ques = $conn->insert_id;
//insert for history
$insertHistory = $conn->query("INSERT into $SP_QUES_HISTORY set medium_id='$medium', question_id='$ques',action='2',action_by='$editor_id', action_date='$curDate'");
$msg .= "Question Added successfully";
$msg .= ' <a style="text-decoration:none;" href="/work-sp/nqb_add_question_secondary?quesId=' . $ques . '&mType=' . $mType . '&role=editor&medium=' . $targetMedium . '" target="_blank">(Click here to translate this Question)</a>';
} else {
$msg = "Question not Added" . $conn->error;
}
} else {
$msg = "Something went wrong, detect zero value";
}
} else {
$msg = "This question is already exist";
}
} else {
$msg = "Please Checked Correct answer radio button";
}
} else {
$msg = "Some options have same values";
}
}
?>
<meta http-equiv="Content-Language" content="hi">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src='/tinymce_8/js/tinymce/tinymce.min.js'></script>
<script type="text/javascript">
tinymce.init({
selector: "#instruction",
license_key: 'gpl',
theme: 'silver',
plugins: "save, tiny_mce_wiris, pagebreak, image, lists, table, fullscreen, link, anchor, charmap, code",
toolbar: "save newdocument | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | blocks | fontfamily | fontsize | cut copy paste | bullist numlist | | outdent indent blockquote | undo redo | link unlink anchor | forecolor backcolor | table | hr removeformat | superscript subscript pagebreak | tiny_mce_wiris_formulaEditor tiny_mce_wiris_formulaEditorChemistry charmap image | fullscreen code help | customInsertButton",
invalid_styles: {
'*': 'color background background-color font-family font-size'
},
//paste_as_text: false,
paste_data_images: true,
automatic_uploads: true,
toolbar_mode: 'wrap',
extended_valid_elements: '*[.*]',
convert_urls: false,
images_upload_url: 'nqb_upload_image_new.php?folder=<?php echo $mType; ?>', //php file upload path
images_upload_credentials: true,
setup: function(editor) {
editor.ui.registry.addButton('customInsertButton', {
text: 'Auto Set',
onAction: function() {
let content = editor.getContent();
// Create temporary DOM
let div = document.createElement('div');
div.innerHTML = content;
let lines = [];
// Case 1: Multiple <p> tags
let paragraphs = div.querySelectorAll('p');
if (paragraphs.length > 1) {
paragraphs.forEach(function(p) {
let txt = p.innerHTML.trim();
if (txt !== '') {
lines.push(txt);
}
});
} else {
// Case 2: Single <p> with <br>
let html = div.innerHTML;
html = html
.replace(/<br\s*\/?>/gi, '\n')
.replace(/<\/p>/gi, '\n')
.replace(/<p[^>]*>/gi, '');
let temp = document.createElement('div');
temp.innerHTML = html;
lines = temp.innerText
.split('\n')
.map(x => x.trim())
.filter(x => x != '');
}
// console.log(lines);
var subStr = lines[0];
tinymce.get('question').setContent(subStr);
var subStr1 = lines[1];
tinymce.get('ans_1').setContent(subStr1);
var subStr2 = lines[2];
tinymce.get('ans_2').setContent(subStr2);
var subStr3 = lines[3];
tinymce.get('ans_3').setContent(subStr3);
var subStr4 = lines[4];
tinymce.get('ans_4').setContent(subStr4);
var subStr5 = lines[5];
if (subStr5 != '' && subStr5 != 'undefined' && subStr5 != undefined) {
tinymce.get('ans_5').setContent(subStr5);
}
tinymce.get('instruction').setContent("");
}
});
}
});
tinymce.init({
selector: "textarea",
license_key: 'gpl',
theme: 'silver',
plugins: "save ,tiny_mce_wiris, pagebreak, image, lists, table, fullscreen, link, anchor, charmap, code",
toolbar: "save newdocument | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | blocks | fontfamily | fontsize | cut copy paste | bullist numlist | | outdent indent blockquote | undo redo | link unlink anchor | forecolor backcolor | table | hr removeformat | superscript subscript pagebreak | tiny_mce_wiris_formulaEditor tiny_mce_wiris_formulaEditorChemistry charmap image | fullscreen code help | customInsertButton",
//paste_as_text: false,
paste_data_images: true,
automatic_uploads: true,
toolbar_mode: 'wrap',
extended_valid_elements: '*[.*]',
convert_urls: false,
images_upload_url: 'nqb_upload_image_new.php?folder=<?php echo $mType; ?>', //php file upload path
images_upload_credentials: true,
paste_merge_formats: true,
paste_remove_styles_if_webkit: true,
content_style: `body{line-height:2;} p,span,div,li,td,th{line-height:2;}`,
setup: function(editor) {
editor.on('PastePostProcess', function(e) {
const root = e.node;
root.querySelectorAll('*').forEach(function(el) {
if (el.hasAttribute('style')) {
let style = el.getAttribute('style');
style = style.replace(/mso-[^:]+:[^;]+;?/gi, '');
style = style.replace(/font-family:[^;]+;?/gi, '');
style = style.replace(/font-size:[^;]+;?/gi, '');
style = style.replace(/tab-stops:[^;]+;?/gi, '');
style = style.replace(/text-indent:[^;]+;?/gi, '');
style = style.replace(/page-break-before:[^;]+;?/gi, '');
style = style.replace(/page-break-after:[^;]+;?/gi, '');
style = style.replace(/line-height:[^;]+;?/gi, '');
style = style.replace(/margin-left:[^;]+;?/gi, '');
style = style.replace(/margin-right:[^;]+;?/gi, '');
style = style.replace(/margin-top:[^;]+;?/gi, '');
style = style.replace(/margin-bottom:[^;]+;?/gi, '');
style = style.replace(/text-align:[^;]+;?/gi, '');
style = style.replace(/background[^;]*;?/gi, '');
style = style.replace(/border-image:[^;]+;?/gi, '');
style = style.replace(/;;+/g, ';').trim();
if (style === '' || style === ';') {
el.removeAttribute('style');
} else {
el.setAttribute('style', style);
}
}
});
root.innerHTML = root.innerHTML.replace(
/(?:·|•|·)\s*<span[^>]*>\s*(?: |\s)*<\/span>/gi,
''
);
root.querySelectorAll("o\\:p").forEach(function(el) {
el.remove();
});
root.querySelectorAll('*').forEach(function(el) {
if (el.className && el.className.indexOf('Mso') !== -1) {
el.removeAttribute('class');
}
});
root.querySelectorAll('div[align]').forEach(function(div) {
div.removeAttribute('align');
div.style.textAlign = 'left';
});
root.querySelectorAll('table').forEach(function(table) {
// Remove Word alignment
table.removeAttribute('align');
// Prevent floating
table.style.float = 'none';
table.style.clear = 'both';
// Keep table left aligned
table.style.marginLeft = '0';
table.style.marginRight = '0';
table.style.marginTop = '10px';
table.style.marginBottom = '10px';
table.style.display = 'table';
});
});
}
});
function validateForm() {
if (jQuery("input[name='radio_ans']:checked").length == 0) {
alert("Please select radio button");
return false;
}
if (jQuery("input[name='ques_of']:checked").length == 0) {
alert("Select Question Repository");
return false;
}
if (jQuery('#ques_level').val() == "") {
alert("Select Question Level");
jQuery('#ques_level').focus();
jQuery(":focus").css("background-color", "#f1d9d9");
return false;
}
if (jQuery('#ques_difficulty').val() == "") {
alert("Select Question Difficulty");
jQuery('#ques_difficulty').focus();
jQuery(":focus").css("background-color", "#f1d9d9");
return false;
}
}
</script>
<style>
.modal-backdrop {
z-index: 999 !important;
}
.form-group {
margin-bottom: 10px;
margin-top: 10px;
}
label {
font-size: 16px;
}
.form-control {
font-weight: bold;
}
.radio_ans {
top: -5px;
left: 10px;
height: 25px !important;
width: 25px !important;
background-color: #eee;
border-radius: 50%;
position: relative !important;
opacity: 1 !important;
}
.panel-body #frmaddQues div.form-group div.tox.tox-tinymce {
height: 396px !important;
}
.panel-body #frmaddQues div.form-group div.tox.tox-tinymce.tox-fullscreen {
height: 100% !important;
}
</style>
<div class="page-inner">
<div class="page-title">
<h3>New Question Bank</h3>
<div class="page-breadcrumb">
<ol class="breadcrumb">
<li><a href="dashboard">Home</a></li>
<li class="active">Add Questions</li>
</ol>
</div>
</div>
<div id="main-wrapper">
<div class="row">
<div class="col-md-12">
<div style="text-align: end;">
<a href="nqb_add_multiple_question.php?sub_topic_id=<?php echo $sub_topic_id; ?>&topic_id=<?php echo $topic_id; ?>&subject_id=<?php echo $subject_id; ?>&master_id=<?php echo $master_id; ?>&group_id=<?php echo $grpcount; ?>&mType=<?php echo $mType; ?>" class="btn btn-primary"><i class="fa fa-plus"></i> Add in Group</a>
</div>
</div>
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Add Question
===
<?php echo $subject . ' >> ' . $topic . ' >> ' . $sub_topic; ?>
</h4>
<a style="float: right;color: #000;background: #fff;padding: 6px 10px 6px 8px;
border-radius: 6px;
text-decoration: none;" href="nqb_upload_image?mType=<?php echo $mType; ?>" target="_blank">Upload Image</a>
</div>
<label class="error" style="display: block;float: none;"><?php if (isset($msg)) {
echo $msg;
} ?></label>
<div class="panel-body">
<form id="frmaddQues" method="post" action="" onSubmit="return validateForm();">
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Question Instructions</label>
<div class="col-sm-9">
<textarea name="instruction" id="instruction"><?php if (isset($instructionQ)) {
echo $instructionQ;
} ?></textarea>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Question Statement</label>
<div class="col-sm-9">
<textarea name="question" id="question"></textarea>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Options & Answer</label>
<table border="1" style="text-align: center;vertical-align: top">
<tr>
<td style="text-align: center;">Sl. No</td>
<td style="text-align: center;">Correct Answer</td>
<td style="text-align: center;">Answer</td>
</tr>
<tr>
<td>1</td>
<td><input type="radio" value="1" name="radio_ans" class="radio_ans" /></td>
<td><textarea name="ans_1" id="ans_1"></textarea></td>
</tr>
<tr>
<td>2</td>
<td><input type="radio" value="2" name="radio_ans" class="radio_ans" /></td>
<td><textarea name="ans_2" id="ans_2"></textarea></td>
</tr>
<tr>
<td>3</td>
<td><input type="radio" value="3" name="radio_ans" class="radio_ans" /></td>
<td><textarea name="ans_3" id="ans_3"></textarea></td>
</tr>
<tr>
<td>4</td>
<td><input type="radio" value="4" name="radio_ans" class="radio_ans" /></td>
<td><textarea name="ans_4" id="ans_4"></textarea></td>
</tr>
<tr>
<td>5</td>
<td><input type="radio" value="5" name="radio_ans" class="radio_ans" /></td>
<td><textarea name="ans_5" id="ans_5"></textarea></td>
</tr>
</table>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Question Solution</label>
<div class="col-sm-9">
<textarea name="solution" id="solution"></textarea>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Previous Exam Detail</label>
<div class="col-sm-3">
<select id="prev_exam_name" name="prev_exam_name" class="form-control m-b-sm">
<option value="">--Select Exam--</option>
<?php while ($preExam = $allPreExams->fetch_assoc()) { ?>
<option value="<?php echo $preExam['exam_name'] ?>" <?php if ($preExam['exam_name'] == @$prev_exam_name) {
echo "selected";
} ?>><?php echo $preExam['exam_name']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-sm-3">
<input type="text" value="<?php echo @$prev_exam_year; ?>" name="prev_exam_year" placeholder="Previous Exam Year" class="form-control" />
</div>
<div class="col-sm-3">
<input type="text" value="<?php echo @$prev_exam_shift; ?>" name="prev_exam_shift" placeholder="Any Exam Shift" class="form-control" />
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">No. of Option</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="total_option" value="<?php echo @$total_option; ?>" placeholder="No. of option in question" required />
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Tags</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="multi_tags" value="" placeholder="Tags for question" />
<label id="exampleInputName-error" class="error" for="exampleInputName">(For Multiple Tags Use Comma [Exam,SSC] Seprated Value)</label>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Medium</label>
<div class="col-sm-9">
<select id="medium" name="medium" class="form-control m-b-sm">
<?php while ($md = $allMedium->fetch_assoc()) { ?>
<option value="<?php echo $md['medium_id'] ?>" <?php if ($md['medium_id'] == @$srcMedium) {
echo "selected";
} ?>><?php echo $md['medium_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Level:</label>
<div class="col-sm-9">
<select name="ques_level" id="ques_level" class="form-control">
<option value="">--level--</option>
<?php while ($l = $allLevel->fetch_assoc()) { ?>
<option value="<?php echo $l['level_name']; ?>" <?php if ($l['level_name'] == @$ques_level) {
echo "selected";
} ?>><?php echo $l['description']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Difficulty:</label>
<div class="col-sm-9">
<select name="ques_difficulty" id="ques_difficulty" class="form-control">
<option value="">--difficulty--</option>
<?php while ($d = $allDifficulty->fetch_assoc()) { ?>
<option value="<?php echo $d['difficulty']; ?>" <?php if ($d['difficulty'] == @$ques_difficulty) {
echo "selected";
} ?>><?php echo $d['description']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Question Expire</label>
<div class="col-sm-9">
<input type="date" name="expiry_date" value="" class="form-control" />
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Question Translate</label>
<div class="col-sm-9">
<input type="checkbox" name="translate_ques" value="0" class="form-control" checked />
<br>
<label id="exampleInputName-error" class="error" for="exampleInputName">(If this question is not available in other medium then unchecked the checkbox.)</label>
<label id="exampleInputName-error" class="error" for="exampleInputName">(अगर यह प्रश्न अन्य मीडियम मे उपलब्ध नहीं है तो चेकबॉक्स को अनचेक करें |)</label>
</div>
</div>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Question Repository<span class="badge badge-danger">(required*)</span></label>
<div class="col-sm-3">
<input type="radio" name="ques_of" value="sarkari-pariksha" class="form-control" <?php if ($mType == 'sp') {
echo "checked";
} ?> />
<label class="control-label" for="exampleInputName">Sarkari Pariksha</label>
</div>
<?php if ($editor_role != '5') { ?>
<div class="col-sm-3">
<input type="radio" name="ques_of" value="csc-olympiad" class="form-control" <?php if ($mType == 'oly') {
echo "checked";
} ?> />
<label class="control-label" for="exampleInputName">CSC Olympiad</label>
</div>
<div class="col-sm-3">
<input type="radio" name="ques_of" value="sarkari-pariksha,csc-olympiad" class="form-control" />
<label class="control-label" for="exampleInputName">Both Repository</label>
</div>
<?php } ?>
</div>
<?php if ($editor_role != '5') { ?>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label">Is Exam Bound</label>
<div class="col-sm-3">
<input type="radio" name="is_exam" value="Y" class="form-control" onclick="examBound('Y')" />
<label class="control-label" for="exampleInputName">Yes</label>
</div>
<div class="col-sm-3">
<input type="radio" name="is_exam" value="N" class="form-control" onclick="examBound('N')" />
<label class="control-label" for="exampleInputName">N</label>
</div>
</div>
<div class="form-group" style="float:left; width:100%;display: none;" id="isExam">
<label for="input-Default" class="col-sm-3 control-label">Select Exam:</label>
<div class="col-sm-3">
<select name="e_exam" id="e_exam" class="form-control">
<option value="E">--Exams</option>
</select>
</div>
<div class="col-sm-3">
<select name="e_sub" id="e_sub" class="form-control">
<option value="S">--Subject</option>
</select>
</div>
<div class="col-sm-3">
<select name="e_topic" id="e_topic" class="form-control">
<option value="T">--Topic</option>
</select>
</div>
</div>
<?php } else { ?>
<input type="hidden" name="is_exam" value="N" class="form-control" />
<?php } ?>
<div class="form-group" style="float:left; width:100%;">
<label for="input-Default" class="col-sm-3 control-label"> </label>
<div class="col-sm-9">
<button type="submit" class="btn btn-primary" name="btn_add" value="Add">Add Question</button>
</div>
</div>
</form>
</div>
</div>
<!--panel info-->
</div>
<div class="page-footer">
<p class="no-s">Graposs Connect ©</p>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function examBound(type) {
if (type == 'Y') {
jQuery("#isExam").show(500);
} else if (type == 'N') {
jQuery("#isExam").hide(500);
}
}
jQuery.noConflict();
jQuery(document).ready(function() {
var loadUrl = "https://sarkaripariksha.com/work-sp/api/api_for_csp_exam.php?&type=exam";
var jqxhr = jQuery.get(loadUrl);
jqxhr.success(function(data) {
jQuery("#e_exam").html(data);
});
jQuery('#e_exam').on('change', function() {
var eid = jQuery("#e_exam").val();
var loadUrl = "https://sarkaripariksha.com/work-sp/new_master_examtoexam_get_childs.php?eid=" + eid + "&type=sub";
var jqxhr = jQuery.get(loadUrl);
jqxhr.success(function(data) {
jQuery("#e_sub").html(data);
});
});
jQuery('#e_sub').on('change', function() {
var eid = jQuery("#e_exam").val();
var subId = jQuery("#e_sub").val();
var loadUrl = "https://sarkaripariksha.com/work-sp/new_master_examtoexam_get_childs.php?eid=" + eid + "&subId=" + subId + "&type=top";
var jqxhr = jQuery.get(loadUrl);
jqxhr.success(function(data) {
jQuery("#e_topic").html(data);
});
});
});
</script>
<?php
} else {
echo "<script>alert('You dont have access to add question');</script>";
echo "<script type='text/javascript'>location.href='/work-sp';</script>";
}
include_once('footer.php');
?>