HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/content-sp/work-sp/test_ques_edit.php
<?php
include_once('config.php');

$adminId = $editor_id;
$curDate = date('Y-m-d H:i:s');

$SP_MEDIUM = 'csp_sp_medium';
$TT_PREVIOUS_EXAM_TABLE = 'csp_sp_previous_exam';
$SP_MASTER_CATEGORY = 'csp_sp_master_category';
$SP_QUESTION = 'csp_sp_question';
$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';
$SP_EDITORS = 'csp_editors';

$quesId = $_REQUEST['quesId'];
$mType = 'sp';

include 'str_replace_type.php';

$checkAssignedMaster = $conn->query("SELECT q_masters FROM $SP_EDITORS where editor_id='$editor_id'");
$fm = $checkAssignedMaster->fetch_assoc();



$allMedium = $conn->query("SELECT medium_id,medium_name from $SP_MEDIUM");
$allPreExams = $conn->query("SELECT id, exam_name, status from $TT_PREVIOUS_EXAM_TABLE where status = '1' ");
// $allMaster = $conn->query("SELECT mc.master_id, mc.master_name from $SP_MASTER_CATEGORY as mc $mQuery order by mc.master_id");
$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'");

?>
<meta http-equiv="Content-Language" content="hi">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src='/tiny_mce_<?php echo $mType; ?>/jscripts/tiny_mce/tinymce.min.js'></script>

<script type="text/javascript">
	tinymce.init({
		selector: "textarea",
		theme: 'silver',
		plugins: "save ,tiny_mce_wiris, 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 | tiny_mce_wiris_formulaEditor  tiny_mce_wiris_formulaEditorChemistry 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>
<?php
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$root_link = $protocol . $_SERVER['HTTP_HOST'] . '/';

$tinyMcefolder = '../tiny_mce_' . $mType;
$uploadFolder = '../uploads/tet_admin_photos_' . $mType . '/';
/**str eplace for form submit */
$submitSpacearray = array($tinyMcefolder, $uploadFolder, '../old_tinymcesp', "'");
$submitReplace = array("../wp-content/plugins/tet-india/files/tinymce_new", "/wp-content/uploads/tet_admin_photos/", "../wp-content/plugins/tet-india/files/tinymce", "''");

if (isset($_REQUEST['search_question'])) {
	$qid = $_REQUEST['search_term'];
	$hisID = $qid;
	$getDataQuery  = $conn->query("SELECT * FROM $SP_QUESTION where question_id='$qid'");
} else {
	$getDataQuery  = $conn->query("SELECT * FROM $SP_QUESTION where question_id='$quesId'");
	$hisID = $quesId;
}
$allData = $getDataQuery->fetch_assoc();

if ($fm['q_masters'] == '') {
	$mQuery = '';
} else {
	$mastersAsgn = $fm['q_masters'];
	$mQuery = "where mc.master_id IN($mastersAsgn)";
}

$selMaster = $allData['master_id'];
if ($fm['q_masters'] == '') {
	$mQuery = '';
} else {
	if ($selMaster != '' && $selMaster != '0') {
		$showMasters = $fm['q_masters'] . ',' . $selMaster;
	} else {
		$showMasters = $fm['q_masters'];
	}
	$mQuery = "where mc.master_id IN($showMasters)";
}
$allMaster = $conn->query("SELECT mc.master_id, mc.master_name from $SP_MASTER_CATEGORY as mc $mQuery order by mc.master_id");

/***question of which server */
$ft_ques_of = json_decode($allData['question_of']);


?>
<div class="page-inner">
	<div class="page-title">
		<h3>Question Bank</h3>
		
	</div>
	<div id="main-wrapper">
		<div class="row">
			
			<?php
			if ($allData['question_id'] != '') {
			?>
				<div class="col-md-12">
					<div class="panel panel-info">
						
						<div class="panel-body">
							<form id="frmaddQues" method="post" action="" onSubmit="return validateForm();">
								<input type="hidden" id="addQues" name="addQues" value="yes" />
								<input id="site_url" type="hidden" value="<?php echo $_SERVER['HTTP_HOST']; ?>" name="site_url" />
								<input type="hidden" name="question_id" value="<?php echo $allData['question_id']; ?>">
								<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($allData['question_instruction'])) {
												$question_instruction = str_replace('../', $root_link, $allData['question_instruction']);
												$question_instruction = str_replace($spaceArray, $replaceSpaceArray, $question_instruction);
												echo $question_instruction;
											} ?>
										</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">
											<?php
											$question_statement = str_replace('../', $root_link, $allData['question_statement']);
											$question_statement = str_replace($spaceArray, $replaceSpaceArray, $question_statement);
											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 ($allData['correct_answer'] == '1') {
																														echo "checked";
																													} ?> />
											</td>
											<td>
												<textarea name="ans_1" id="ans_1">
													<?php
													$option_1 = str_replace('../', $root_link, $allData['option_1']);
													$option_1 = str_replace($spaceArray, $replaceSpaceArray, $option_1);
													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 ($allData['correct_answer'] == '2') {
																														echo "checked";
																													} ?> />
											</td>
											<td>
												<textarea name="ans_2" id="ans_2">
													<?php
													$option_2 = str_replace('../', $root_link, $allData['option_2']);
													$option_2 = str_replace($spaceArray, $replaceSpaceArray, $option_2);
													echo htmlspecialchars($option_2);
													?>
												</textarea>
											</td>
										</tr>
										<tr>
											<td>3</td>
											<td>
												<input type="radio" value="3" name="radio_ans" class="radio_ans" <?php if ($allData['correct_answer'] == '3') {
																														echo "checked";
																													} ?> />
											</td>
											<td>
												<textarea name="ans_3" id="ans_3">
													<?php
													$option_3 = str_replace('../', $root_link, $allData['option_3']);
													$option_3 = str_replace($spaceArray, $replaceSpaceArray, $option_3);
													echo htmlspecialchars($option_3);
													?>
												</textarea>
											</td>
										</tr>
										<tr>
											<td>4</td>
											<td>
												<input type="radio" value="4" name="radio_ans" class="radio_ans" <?php if ($allData['correct_answer'] == '4') {
																														echo "checked";
																													} ?> />
											</td>
											<td>
												<textarea name="ans_4" id="ans_4">
													<?php
													$option_4 = str_replace('../', $root_link, $allData['option_4']);
													$option_4 = str_replace($spaceArray, $replaceSpaceArray, $option_4);
													echo htmlspecialchars($option_4);
													?>
												</textarea>
											</td>
										</tr>
										<tr>
											<td>5</td>
											<td>
												<input type="radio" value="5" name="radio_ans" class="radio_ans" <?php if ($allData['correct_answer'] == '5') {
																														echo "checked";
																													} ?> />
											</td>
											<td>
												<textarea name="ans_5" id="ans_5">
													<?php
													$option_5 = str_replace('../', $root_link, $allData['option_5']);
													$option_5 = str_replace($spaceArray, $replaceSpaceArray, $option_5);
													echo htmlspecialchars($option_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">
											<?php
											$question_solution = str_replace('../', $root_link, $allData['question_solution']);
											$question_solution = str_replace($spaceArray, $replaceSpaceArray, $question_solution);
											echo htmlspecialchars($question_solution);
											?>
										</textarea>
									</div>
								</div>
								
								
				
						
								<div class="form-group" style="float:left; width:100%;">
									<label for="input-Default" class="col-sm-3 control-label">&nbsp;</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>
			<?php } else {
				echo "NO question found";
			}
			?>
			
		</div>
	</div>
</div>
<script type="text/javascript">
	jQuery.noConflict();
	
</script>