File: /var/www/content-sp/work-sp/pyp_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';
$replaceArray = array(" & ", "+");
$spaceArray = array(" and ", "plus");
$year = $_REQUEST['year'];
$exam = $_REQUEST['exam'];
$shift = str_replace($spaceArray, $replaceArray, $_REQUEST['shift']);
$sec_med_code = isset($_REQUEST['viewIn']) ? $_REQUEST['viewIn'] : "HI";
if ($sec_med_code == 'HI') {
$medQuery = "and qt.medium_id IN(1,2)";
$tmedium = '1';
} else {
$secMedium = $conn->query("SELECT medium_id FROM $SP_MEDIUM where medium_code='$sec_med_code'");
$secM = $secMedium->fetch_assoc();
$tmedium = $secM['medium_id'];
$medQuery = "and qt.medium_id='$tmedium'";
}
$preExam = str_replace($spaceArray, $replaceArray, $exam);
if ($shift != '') {
$qryShift = " and sq.exam_shift='$shift'";
} else {
$qryShift = " and sq.exam_shift=''";
}
?>
<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, sq.previous_exam_year, sq.previous_exam_name, sq.exam_shift, sq.question_expiry, sq.question_type, sq.add_date, sq.status, sq.last_proofread_by, sq.last_proofread_date, md.medium_name, ms.category_name FROM $SP_QUESTION as sq left join $SP_MEDIUM as md on md.medium_id=sq.medium_id LEFT JOIN $SP_MASTER_STRUCTURE as ms ON ms.sub_id=sq.subject_id where sq.previous_exam_name='$preExam' and sq.previous_exam_year='$year' $qryShift order by sq.subject_id, sq.question_id";
//$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 = $year . "-pyp-questions-primary";
$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) {
$qId = $q['question_id'];
$instructions = str_replace('"../', $root_link, $q['question_instruction']);
$instructions = str_replace('"/', $root_link, $instructions);
$instructions = str_replace($spaceArray, $replaceSpaceArray, $instructions);
$questions = str_replace('"../', $root_link, $q['question_statement']);
$questions = str_replace('"/', $root_link, $questions);
$questions = str_replace($spaceArray, $replaceSpaceArray, $questions);
$solution = str_replace('"../', $root_link, $q['question_solution']);
$solution = str_replace('"/', $root_link, $solution);
$solution = str_replace($spaceArray, $replaceSpaceArray, $solution);
$option1 = str_replace('"../', $root_link, $q['option_1']);
$option1 = str_replace('"/', $root_link, $option1);
$option1 = str_replace($spaceArray, $replaceSpaceArray, $option1);
$option2 = str_replace('"../', $root_link, $q['option_2']);
$option2 = str_replace('"/', $root_link, $option2);
$option2 = str_replace($spaceArray, $replaceSpaceArray, $option2);
$option3 = str_replace('"../', $root_link, $q['option_3']);
$option3 = str_replace('"/', $root_link, $option3);
$option3 = str_replace($spaceArray, $replaceSpaceArray, $option3);
$option4 = str_replace('"../', $root_link, $q['option_4']);
$option4 = str_replace('"/', $root_link, $option4);
$option4 = str_replace($spaceArray, $replaceSpaceArray, $option4);
$option5 = str_replace('"../', $root_link, $q['option_5']);
$option5 = str_replace('"/', $root_link, $option5);
$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);
$getEntity = $conn->query("select m.master_name, s.category_name as subject, t.category_name as topic, st.category_name as subtopic from $SP_QUESTION as q LEFT JOIN $SP_MASTER_CATEGORY as m ON m.master_id=q.master_id LEFT JOIN $SP_MASTER_STRUCTURE as s ON s.sub_id=q.subject_id LEFT JOIN $SP_MASTER_STRUCTURE as t ON t.sub_id=q.topic_id LEFT JOIN $SP_MASTER_STRUCTURE as st ON st.sub_id=q.sub_topic_id where q.question_id='$qId'");
$entData = $getEntity->fetch_assoc();
$dispEnt = $entData['master_name'] . "->" . $entData['subject'] . "->" . $entData['topic'] . "->" . $entData['subtopic'];
?>
<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">
<h5 class="ques-topic-name"><?php echo $dispEnt; ?></h5>
<?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:</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>