File: /var/www/selfanalyse/aptitude-test/test_instruction.php
<?php
/**
*
* Title : Test Instruction Page
* Developer : Gulfam Ali, Rohit Kashyap, Sumit Singh Rawat (Designer)
* Date : 04 Mar,2020
* Description : First page for instruction of test (Mock test or Practice test)
*
*/
?>
<!-- <body oncontextmenu="return false;"> -->
<body oncontextmenu="return false;">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<?php
// ini_set('display_error', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
?>
<?php
include_once('../wp-config.php');
global $wpdb;
$PSY_EXAMS = $wpdb->prefix . PSY_EXAMS;
$PSY_SUBSCRIPTION = $wpdb->prefix . PSY_SUBSCRIPTION;
$PSY_TEST_GEN_TEST_TAKEN = $wpdb->prefix . PSY_TEST_GEN_TEST_TAKEN;
$subscriptionId = $_POST['sID'];
$class_id = $_POST['class_id'];
$testType = 'new';
$view = $_REQUEST['view'];
$pending_test_id = $_REQUEST['pending_test_id'];
global $current_user;
if (is_user_logged_in()) {
get_currentuserinfo();
$user_id = $current_user->ID; // print session USER_ID
$validSubscription = $wpdb->get_row("SELECT subscription_id, exam_id, test_type FROM $PSY_SUBSCRIPTION where subscription_id='$subscriptionId'");
if ($validSubscription > 0) {
if ($validSubscription->test_type == 'APT') {
$exam_id = $validSubscription->exam_id;
$examDetail = $wpdb->get_row("SELECT is_negative_marking,negative_marking_percent,question_weight,subject_choice,app_status,bilingual,section_bound,total_no_of_questions_in_exam,total_exam_time_in_minute,category_name FROM $PSY_EXAMS where exam_category_id='$exam_id'");
$is_negative_marking = $examDetail->is_negative_marking;
$negative_marking_percent = $examDetail->negative_marking_percent / 100;
$quesWeight = $examDetail->question_weight;
$subjectChoice = $examDetail->subject_choice;
$app_status = $examDetail->app_status;
$section_time_wise = $examDetail->section_bound;
$totalQuestinInExam = $examDetail->total_no_of_questions_in_exam;
$totalTimeForExam = $examDetail->total_exam_time_in_minute;
$examName = $examDetail->category_name;
$examStructure = $wpdb->get_results("select parent_id,exam_category_id,category_name, no_of_questions_to_display,subject_choice from $PSY_EXAMS where parent_id='$exam_id' order by display_order");
}
$totalMinute = $totalTimeForExam;
$DisplayTime = $totalTimeForExam;
$dispHr = floor($DisplayTime / 60);
$dispmins = $DisplayTime % 60;
if ($dispmins > 0) {
$dispmin = $dispmins . ' minutes';
} else {
$dispmin = "";
}
if ($dispHr > 1) {
$DisptimeInHour = $dispHr . ' hours ' . $dispmin;
} else {
$DisptimeInHour = $dispHr . ' hour ' . $dispmin;
}
if ($testType == "new" && $testTakenId == 0) // if test is new test
{
$totalDONE = $wpdb->get_var("SELECT count(*) from $PSY_TEST_GEN_TEST_TAKEN where user_id='$user_id' and exam_category_id='$exam_id'");
/*------------ set the timer -------------*/
$dateFormat = "d F Y -- g:i a";
$targetDate = time() + ($totalMinute * 60); //Change the $totalMinute to however many minutes you want to countdown
$actualDate = time();
$secondsDiff = $targetDate - $actualDate;
$remainingDay = floor($secondsDiff / 60 / 60 / 24);
$remainingHour = floor(($secondsDiff - ($remainingDay * 60 * 60 * 24)) / 60 / 60);
$remainingMinutes = floor(($secondsDiff - ($remainingDay * 60 * 60 * 24) - ($remainingHour * 60 * 60)) / 60);
$remainingSeconds = floor(($secondsDiff - ($remainingDay * 60 * 60 * 24) - ($remainingHour * 60 * 60)) - ($remainingMinutes * 60));
$totalTimeSpent = 0;
}
//$testIndex = array_search($testTakenId, $CompletedTest);
//$totalDONE = $testIndex;
// end calculation
$hours = floor($totalTimeForExam / 60);
$minutes = $totalTimeForExam % 60;
if ($minutes > 0) {
$minute = $minutes . ' minutes';
} else {
$minute = "";
}
if ($hours > 1) {
$timeInHour = $hours . ' hours ' . $minute;
} else {
$timeInHour = $hours . ' hour ' . $minute;
}
$typeExam = "Test";
?>
<input type="hidden" value="<?php echo $remainingHour ?>" name="tt_hour" id="tt_hour" />
<input type="hidden" value="<?php echo $remainingMinutes; ?>" name="tt_minute" id="tt_minute" />
<input type="hidden" value="<?php echo $remainingSeconds; ?>" name="tt_second" id="tt_second" />
<input type="hidden" value="<?php echo $totalTimeSpent; ?>" name="totalTimeSpent" id="totalTimeSpent" />
<input type="hidden" name="subjectChoice" value="<?php echo $subjectChoice; ?>" id="subjectChoice">
<input type="hidden" name="test_type" value="<?php echo $testType; ?>" id="test_type">
<link rel="stylesheet" type="text/css" href="tet_assign_test.css?v=<?php echo date('dmyhis'); ?>">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,900|Roboto:300,400,500,700,900&display=swap" title="default">
<script src="js/jquery-1.12.4.js"></script>
<script src="tet_assign_test.js?v=<?php echo date('dmyhis'); ?>"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" type="" href="css/toastr.min.css">
<script src="js/toastr.min.js"></script>
<input type="hidden" value="<?php echo ROOT_LINK; ?>" name="siteUrl" id="siteUrl" />
<input type="hidden" value="<?php echo $app_status; ?>" id="app_status" />
<!-- INSTRUCTION PAGE SECTION -->
<section>
<div class="container">
<div class="center" id="center" style="display: block;">
<div class="col-md-12 col-sm-12 col-xs-12 exam_name">
<h4 class="exam_title_dash" id="xam1">Test Name :
<span style="font-weight: 500;" id="name_eng">
<?php echo $examName; ?>
</span>
</h4>
</div>
<div id="tet_loading_img" style="display: none;margin-top: 125px;text-align: center;">
<img src="<?php echo get_bloginfo('url') . '/aptitude-test/fancybox_loading.gif'; ?>" /><br>
<?php echo 'Loading...'; ?>..
</div>
<div class="col-md-12 col-sm-12 col-xs-12" id="instruction_area1">
<div id="eng">
<h4 class="gen_ins">General Instructions </h4>
<ol>
<li>There are multiple answer options for each questions.<br>
</li>
<li>Please choose your option by clicking the mouse.<br>
</li>
<li>There are three buttons / keys at the bottom.<br>
</li>
<li><button class="clr"> Clear Option </button> button will clear the selected option for that question.<br>
</li>
<li><button class="prv"> Previous </button> button will take you to the previous question.<br>
</li>
<li><button class="nxt"> Next </button> button will take you to the next question.<br>
</li>
<li><button class="rprt"> <i class="fa fa-exclamation-triangle"></i> </button> Report a Problem button will be helpful whenever you get stuck anywhere in the Test. Tell us the problem and we will help you.<br>
</li>
<li><button class="sub">Finish & Exit</button> This button will finish the test. Press only when you have completed all 7 sub-tests.<br>
</li>
<li>We have <button class="das"> Questions Dashboard </button> on the right side of the page, once you click on it, you can view all your answered and un-answered questions.<br>
</li>
<li>You can go back or forward by clicking on the serial number of the question displayed on the Dashboard.<br>
</li>
<li>The answered questions will be displayed in green color and the un-answered questions will be displayed in grey color.<br>
</li>
<li>You can see the time clock on the top right corner of the exam page.<br>
</li>
</ol>
<h4 class="gen_ins">Test Specific Instructions</h4>
<ol>
<li>This test has 7 short sub-tests. Complete all 7 sub-tests to get the report.</li>
<li>Each sub-test is a timed test.</li>
<li>Each sub-test has a separate set of instructions to give you an idea about the type of questions asked in the test.</li>
<li>Read instructions for each sub-test carefully.</li>
<li>All questions are multiple choice questions.</li>
<li>There is only 1 correct answer.</li>
<li>There is NO negative marking.</li>
<li>Your answers will be submitted automatically when the time for the sub-test is over and you will be directed to the instructions of the next sub-test.</li>
<li>This test will help you know about your speciifc aptitudes in different areas. Please be honest and complete the test to the best of your ability.</li>
</ol>
</div>
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
<div id="instruction_area2" style="display: none;" class="text-center">
<div style="text-align: center;padding-top: 95px;width: 100%;font-size: 14px;font-weight: bold; line-height: 2em;">
Total allocated time (reading instructions + completing 7 sections of the test) is 60 Minutes.
<br>
To complete 7 sections of the test total time available is 40 Min 30 Sec.
<br>
You must attempt this test in one go for accurate result.
</div>
<div style="text-align: center;padding-top: 10px;width: 100%">
<a id="start_test" class="button noe" style="cursor:pointer;">Start</a>
</div>
</div>
</div>
<div class="container-fluid" id="checkbox_disc">
<div class="row">
<div class="mock_test_footer">
<div class="col-md-12">
<span id="chkMsg" style="color:#cc0000; width: 100%; float: left; font-size:15px;"></span>
<h4 class="int_ti"><input id="chk_accept" class="check" type="checkbox" name="chk_accept" value="1"> <span id="instructions_eng"> I have read all Instructions.</span> <br />
<span id="instructions_hnd" class="hide"> मैंने सभी निर्देश पढ़ लिए है|</span> </h4>
</div>
<div class="col-md-12">
<a id="show_area2" style="cursor:pointer;">
<button class="start_test">
<span id="srt_eng">Start Test</span>
</button>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- END INSTRUCTION PAGE SECTION -->
<!-- QUESTION AND ANSWER PAGE SECTION -->
<section>
<div id="question_div" style="display: none">
<div id="tet_loading_img" style="display: block;margin-top: 125px;text-align: center;">
<img src="<?php echo get_bloginfo('url') . '/aptitude-test/fancybox_loading.gif'; ?>" /><br>
<?php echo 'Loading...'; ?>..
</div>
<input type="hidden" value="<?php echo $exam_id; ?>" name="exam_category_id" id="exam_category_id" />
<input type="hidden" name="class_id" id="class_id" value="<?php echo $class_id; ?>">
<input type="hidden" name="view" id="view" value="<?php echo $view; ?>">
<input type="hidden" name="pending_test_id" id="pending_test_id" value="<?php echo $pending_test_id; ?>">
<input type="hidden" name="test_view_type" id="test_view_type" value="<?php echo $validSubscription->test_type; ?>">
<input type="hidden" name="asign_ref_id" id="asign_ref_id" value="<?php echo $subscriptionId; ?>">
</div>
</section>
<!-- QUESTION AND ANSWER PAGE SECTION -->
<script>
//function for subject choice modal
var checkChoice = document.getElementById("subjectChoice").value;
var test_type = document.getElementById("test_type").value;
if (checkChoice == 'Y' && test_type == 'new') {
jQuery(window).on('load', function() {
jQuery('#subject_choiceModal').modal('show');
});
jQuery("#subject_choicebtn").on('click', function() {
jQuery('#subject_choiceModal').modal('show');
});
function SelectedSub() {
var c_boxesC = document.getElementsByName('subjectC[]');
var lenC = c_boxesC.length;
var selected_subjectsC = [];
for (var i = 0; i < lenC; i++) {
var idC = c_boxesC[i].checked;
if (idC == true) {
selected_subjectsC.push(c_boxesC[i].value);
}
}
var sel_subC = "," + selected_subjectsC;
// choice for status C1 subject
var c_boxesC1 = document.getElementsByName('subjectC1[]');
var lenC1 = c_boxesC1.length;
var selected_subjectsC1 = [];
for (var i = 0; i < lenC1; i++) {
var idC1 = c_boxesC1[i].checked;
if (idC1 == true) {
selected_subjectsC1.push(c_boxesC1[i].value);
}
}
var sel_subC1 = "," + selected_subjectsC1;
if (sel_subC1 == ',') {
var selC1 = '';
} else {
var selC1 = "," + selected_subjectsC1;
}
// choice for status C2 subject
var c_boxesC2 = document.getElementsByName('subjectC2[]');
var lenC2 = c_boxesC2.length;
var selected_subjectsC2 = [];
for (var i = 0; i < lenC2; i++) {
var idC2 = c_boxesC2[i].checked;
if (idC2 == true) {
selected_subjectsC2.push(c_boxesC2[i].value);
}
}
var sel_subC2 = "," + selected_subjectsC2;
if (sel_subC2 == ',') {
var selC2 = '';
} else {
var selC2 = "," + selected_subjectsC2;
}
document.getElementById("selected_subjects").value = sel_subC + selC1 + selC2;
}
}
//function for subject choice modal end
//function for select exam medium
function selectMedium() {
var medium = document.getElementById("language_change").value;
//set medium
document.getElementById("selected_medium").value = medium;
}
//function if exam is section bound
function sectionTime() {
var sectionSelect = document.getElementById("section_time_choice").value;
document.getElementById("time_approve").value = sectionSelect;
}
</script>
<?php
} // end of valid subscription if
else {
?>
<script>window.location.href='/test'</script>
<?php
}
} // end of check login if
else {
echo "Login first to view this page";
}
?>
</body>