File: /var/www/selfanalyse/counselor/edit-question.php
<?php
include_once('header.php');
global $current_user;
get_currentuserinfo();
$adminId = $current_user->ID;
$curDate = date('Y-m-d H:i:s');
$PSY_SP_QUESTION = $wpdb->prefix . PSY_SP_QUESTION;
$spaceArray = array(
"<p> </p>", "<br />", "<strong> </strong>", "<p></p>", "<p class=\"Style\"> </p>", " </p>", "<p> ",
" <br/><br/></p>", "<p><strong><br/></strong></p>", "<br/><br/></p>", "<p> ", "<p> </p>", "<p><strong></strong></p>",
"<p> </p>", "<p> </p>", "<br>", " ", "<br/>", "<br >", "<p><strong><br /></strong></p>", "font-size: small;", "src=https"
);
$replaceSpaceArray = array("", "", "", "", "", "</p>", "<p>", "</p>", "", "</p>", "<p>", "", "", "", "", "", "", "", "", "", "", "src=\"https");
$quesId = $_REQUEST['quesId'];
$root_link = 'https://selfanalyse.com/';
if(isset($_REQUEST['btn_edit']))
{
$question_id = $_REQUEST['question_id'];
$instruction = $_REQUEST['instruction'];
$question = $_REQUEST['question'];
$ans_1 = $_REQUEST['ans_1'];
$ans_2 = $_REQUEST['ans_2'];
$ans_3 = $_REQUEST['ans_3'];
$ans_4 = $_REQUEST['ans_4'];
$ans_5 = $_REQUEST['ans_5'];
$updateQuestion = "UPDATE $PSY_SP_QUESTION set question_instruction='$instruction', question_statement='$question', option_1='$option_1',option_2='$option_2',option_3='$option_3',option_4='$option_4',option_5='$option_5' correct_answer='$correct_answer' where question_id='$question_id'";
if($wpdb->query($updateQuestion)){
?>
<script>
jQuery(document).ready(function() {
toastr.success("Success")
});
</script>
<?php
} else {
?>
<script>
jQuery(document).ready(function() {
toastr.error("Error")
});
</script>
<?php
}
}
$getQuestionsData = $wpdb->get_row("SELECT sq.question_id,sq.question_instruction,sq.question_statement,sq.option_1,sq.option_2,sq.option_3,sq.option_4,sq.option_5,sq.correct_answer FROM $PSY_SP_QUESTION as sq where sq.question_id='$quesId'");
$correct_answer = $getQuestionsData->correct_answer;
$question_instruction = str_replace('../', $root_link, $getQuestionsData->question_instruction);
$question_instruction = str_replace($spaceArray, $replaceSpaceArray, $question_instruction);
$question_statement = str_replace('../', $root_link, $getQuestionsData->question_statement);
$question_statement = str_replace($spaceArray, $replaceSpaceArray, $question_statement);
$option_1 = str_replace('../', $root_link, $getQuestionsData->option_1);
$option_1 = str_replace($spaceArray, $replaceSpaceArray, $option_1);
$option_2 = str_replace('../', $root_link, $getQuestionsData->option_2);
$option_2 = str_replace($spaceArray, $replaceSpaceArray, $option_2);
$option_3 = str_replace('../', $root_link, $getQuestionsData->option_3);
$option_3 = str_replace($spaceArray, $replaceSpaceArray, $option_3);
$option_4 = str_replace('../', $root_link, $getQuestionsData->option_4);
$option_4 = str_replace($spaceArray, $replaceSpaceArray, $option_4);
$option_5 = str_replace('../', $root_link, $getQuestionsData->option_5);
$option_5 = str_replace($spaceArray, $replaceSpaceArray, $option_5);
?>
<script src='/tinymce_new/jscripts/tiny_mce/tinymce.min.js'></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea",
theme: 'silver',
plugins: "save , pagebreak, image, lists, table, fullscreen, spellchecker, link, anchor, charmap, code, paste",
toolbar: "save newdocument | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | formatselect |fontselect | fontsizeselect | cut copy paste | bullist numlist | | outdent indent blockquote | undo redo | link unlink anchor | forecolor backcolor | table | hr removeformat | superscript subscript spellchecker pagebreak | charmap image | fullscreen code help",
});
</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>Question Edit</h3>
<div class="page-breadcrumb">
<ol class="breadcrumb">
<li><a href="dashboard">Home</a></li>
<li class="active">Edit Questions</li>
</ol>
</div>
</div>
<div id="main-wrapper">
<div class="row">
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Edit Question</h4>
</div>
<div class="panel-body">
<form id="frmaddQues" method="post" action="" onSubmit="return validateForm();">
<input type="hidden" name="question_id" value="<?php echo $getQuestionsData->question_id; ?>">
<?php if ($question_instruction!='') { ?>
<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 echo $question_instruction; ?>
</textarea>
</div>
</div>
<?php } ?>
<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">
<?php
echo htmlspecialchars($question_statement);
?>
</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" <?php if ($correct_answer == '1') { echo "checked"; } ?> />
</td>
<td>
<textarea name="ans_1" id="ans_1">
<?php
echo htmlspecialchars($option_1);
?>
</textarea>
</td>
</tr>
<tr>
<td>2</td>
<td>
<input type="radio" value="2" name="radio_ans" class="radio_ans" <?php if ($correct_answer == '2') { echo "checked"; } ?> />
</td>
<td>
<textarea name="ans_2" id="ans_2">
<?php
echo htmlspecialchars($option_2);
?>
</textarea>
</td>
</tr>
<?php if($option_3!=''){ ?>
<tr>
<td>3</td>
<td>
<input type="radio" value="3" name="radio_ans" class="radio_ans" <?php if ($correct_answer == '3') { echo "checked"; } ?> />
</td>
<td>
<textarea name="ans_3" id="ans_3">
<?php
echo htmlspecialchars($option_3);
?>
</textarea>
</td>
</tr>
<?php } ?>
<?php if($option_4!=''){ ?>
<tr>
<td>4</td>
<td>
<input type="radio" value="4" name="radio_ans" class="radio_ans" <?php if ($correct_answer == '4') { echo "checked"; } ?> />
</td>
<td>
<textarea name="ans_4" id="ans_4">
<?php
echo htmlspecialchars($option_4);
?>
</textarea>
</td>
</tr>
<?php } ?>
<?php if($option_5!=''){ ?>
<tr>
<td>5</td>
<td>
<input type="radio" value="5" name="radio_ans" class="radio_ans" <?php if ($correct_answer == '5') { echo "checked"; } ?> />
</td>
<td>
<textarea name="ans_5" id="ans_5">
<?php
echo htmlspecialchars($option_5);
?>
</textarea>
</td>
</tr>
<?php } ?>
</table>
</div>
<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_edit">Update</button>
</div>
</div>
</form>
</div>
</div>
<!--panel info-->
</div>
</div>
</div>
</div>
<div class="page-footer">
<!-- <p class="no-s">sarkaripariksha.com</p> -->
</div>
<?php
include_once('footer.php');
?>