File: /var/www/content-sp/work-sp/nqb_questions_primary_download.php
<meta http-equiv="Content-Language" content="hi">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$mType='sp';
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
include_once 'config.php';
include_once 'functions.php';
//include_once 'str_replace_type.php';
session_start();
$SP_MASTER_STRUCTURE = 'csp_sp_master_structure';
$SP_EDITORS = 'csp_editors';
$SP_QUESTION = 'csp_sp_question';
$SP_MASTER_CATEGORY = 'csp_sp_master_category';
$SP_MEDIUM = 'csp_sp_medium';
$SP_QUESTION_MEDIUM_WISE = 'csp_sp_question_medium_wise';
$SP_QUES_HISTORY = 'csp_sp_question_history';
?>
<script type="text/javascript" src="https://sarkaripariksha.com/wp-content/plugins/tet-india/files/php-treeview/jquery.js"></script>
<?php
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$root_link = $protocol . $_SERVER['HTTP_HOST'] . '/';
$spaceArray = array("<p>", "</p>","<p> </p>", "<br />", "<strong> </strong>", "<strong></strong>", "</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", "wp-content/plugins/tet-india/files/tinymce_new", "https://sarkaripariksha.com/", "/wp-content/uploads/tet_admin_photos/","http://sarkaripariksha.com/","wp-content/plugins/tet-india/files/tinymce","'","http://content.grapossconnect.com//"
);
$replaceSpaceArray = array("", "", "", "", "", "", "", "", "", "</p>", "<p>", "</p>", "", "</p>", "<p>", "", "", "", "", "", "", "", "", "", "", "src=\"https", "tiny_mce_sp", "../", "/uploads/tet_admin_photos_sp/","../","old_tinymcesp","'","http://content.grapossconnect.com/");
$sub_topic_id = $_REQUEST['sub_topic_id'];
$sub_topic_id = 15228;
$query = "SELECT sq.question_id, sq.old_question_id, sq.medium_id, sq.no_of_option, sq.question_instruction, sq.question_statement, sq.option_1, sq.option_2, sq.option_3, sq.option_4, sq.option_5, sq.correct_answer, sq.question_solution,md.medium_name FROM $SP_QUESTION as sq left join $SP_MEDIUM as md on md.medium_id=sq.medium_id
where (subject_id='$sub_topic_id' or topic_id='$sub_topic_id' or sub_topic_id='$sub_topic_id') order by sq.question_id";
$questionList = $conn->query($query);
//$questionList = $wpdb->get_results($query);
$fileName = $sub_topic_id . "-questions";
$originalName = str_replace(",", "", $fileName);
header("Content-type: application/vnd.ms-word");
# And then replacing wordfile.doc with what you need the filename to default to.
//echo "Content-Disposition: attachment;Filename=".$fileName.".doc";
header("Content-Disposition: attachment;Filename=" . $originalName . ".doc");
header("Pragma: no-cache");
header("Expires: 0");
?>
<div class="row">
<?php
$i = 1;
foreach ($questionList as $q) {
$instructions = str_replace('"../', $root_link, $q['question_instruction']);
$instructions = str_replace($spaceArray, $replaceSpaceArray, $instructions);
$questions = str_replace('"../', $root_link, $q['question_statement']);
$questions = str_replace($spaceArray, $replaceSpaceArray, $questions);
$solution = str_replace('"../', $root_link, $q['question_solution']);
$solution = str_replace($spaceArray, $replaceSpaceArray, $solution);
$option1 = str_replace('"../', $root_link, $q['option_1']);
$option1 = str_replace($spaceArray, $replaceSpaceArray, $option1);
$option2 = str_replace('"../', $root_link, $q['option_2']);
$option2 = str_replace($spaceArray, $replaceSpaceArray, $option2);
$option3 = str_replace('"../', $root_link, $q['option_3']);
$option3 = str_replace($spaceArray, $replaceSpaceArray, $option3);
$option4 = str_replace('"../', $root_link, $q['option_4']);
$option4 = str_replace($spaceArray, $replaceSpaceArray, $option4);
$option5 = str_replace('"../', $root_link, $q['option_5']);
$option5 = str_replace($spaceArray, $replaceSpaceArray, $option5);
$correct_answer = $q['correct_answer'];
$varRep = array('{$curnt}' => $i, '{$curnt+1}' => $i + 1, '{$curnt+2}' => $i + 2, '{$curnt+3}' => $i + 3, '{$curnt+4}' => $i + 4, '{$curnt+5}' => $i + 5, '{$curnt+6}' => $i + 6, '{$curnt+7}' => $i + 7, '{$curnt+8}' => $i + 8, '{$curnt+9}' => $i + 9, '{$curnt+10}' => $i + 10, '{$curnt-1}' => $i - 1, '{$curnt-2}' => $i - 2, '{$curnt-3}' => $i - 3, '{$curnt-4}' => $i - 4, '{$curnt-5}' => $i - 5, '{$curnt-6}' => $i - 6, '{$curnt-7}' => $i - 7, '{$curnt-8}' => $i - 8, '{$curnt-9}' => $i - 9, '{$curnt-10}' => $i - 10);
?>
<div style="border-bottom: 2px solid #ddd;padding: 20px 10px;">
<div class="row">
<div style="border-right: 2px solid #ddd;padding-right: 20px;margin:0;" class="column eightcol">
<?php if ($q['question_instruction'] != '') { ?>
<h4 style="font-size: 24px;color: #444;">Instructions: </h4>
<p style="font-size: 18px;"><?php echo $instructions; ?></p>
<?php } ?>
<h4 style="font-size: 20px;color: #444;"><?php echo $i; ?>. Questions #: <?php echo $q['question_id']; ?></h4>
<p style="font-size: 18px;margin-bottom: 10px;"><?php echo strtr((str_replace('"../', $root_link, $questions)), $varRep); ?></p>
<div style="width: 100%;padding-bottom: 20px;">
<div style="width: 100%;">
<span class="tt_ques_lf">
<span class="tt_ques_lf_inn" <?php if ($correct_answer == 1) { ?>style="color:red;" <?php } ?>>(a)</span>
</span>
<label><?php echo $option1; ?></label>
</div>
<div style="width: 100%;">
<span class="tt_ques_lf">
<span class="tt_ques_lf_inn" <?php if ($correct_answer == 2) { ?>style="color:red;" <?php } ?>>(b)</span>
</span>
<label><?php echo $option2; ?></label>
</div>
<?php if ($option3 != "") { ?>
<div style="width: 100%;">
<span class="tt_ques_lf">
<span class="tt_ques_lf_inn" <?php if ($correct_answer == 3) { ?>style="color:red;" <?php } ?>>(c)</span>
</span>
<label><?php echo $option3; ?></label>
</div>
<?php } ?>
<?php if ($option4 != "") { ?>
<div style="width: 100%;">
<span class="tt_ques_lf">
<span class="tt_ques_lf_inn" <?php if ($correct_answer == 4) { ?>style="color:red;" <?php } ?>>(d)</span>
</span>
</label><?php echo $option4; ?>
</div>
<?php } ?>
<?php if ($option5 != "") { ?>
<div style="width: 100%;">
<span class="tt_ques_lf">
<span class="tt_ques_lf_inn" <?php if ($correct_answer == 5) { ?>style="color:red;" <?php } ?>>(e)</span>
</span>
<label><?php echo $option5; ?></label>
</div>
<?php } ?>
</div>
<div style="padding: 8px 10px;background: #eeeeeebd;">
<h4 style="font-size: 24px;">Solution :</h4>
<p style="font-size: 18px;"><?php echo $solution; ?></p>
</div>
</div>
</div>
</div>
<?php
$i++;
}
?>
</div>
<script>
window.close();
</script>