/final.php
PHP | 220 lines | 190 code | 18 blank | 12 comment | 58 complexity | 8355506010e1b63d737f50eebb66b9b4 MD5 | raw file
- <?php
- require_once("includes/function.php");
- require_once("includes/db_con.php");
- require_once("includes/heder.php");
- $test = $_SESSION['test'];
- //echo "test variable : " . $test ;
- $sec=1;
- //INSERT INTO `student_results` (`student_id`, `student_name`, `test_no`, `results_1`, `results_2`, `results_3`, `results_4`, `results_analytical`,)
- //VALUES ('3', 'student@student.com', '1', '12', '23', '56', '67', '43')
- ?>
- <div class="container">
- <div class="container">
- <div class="col-md-12-result">
- <a class="btn btn-lg btn-success" href="gre.php" title="Back to GRE Test">Back to GRE Test</a>
- <h4> Your Total Score is: <?php echo $_SESSION['result_one']+$_SESSION['result_three']+$_SESSION['result_tow']+$_SESSION['result_four']+260; ?> </h4>
- <h4> Your Verbal Score is: <?php echo $_SESSION['result_one']+$_SESSION['result_three']+130; ?></h4>
- <h4> Your Quantitative Score is: <?php echo $_SESSION['result_tow']+$_SESSION['result_four']+130; ?></h4>
- <?php
-
-
- $student_id = $_SESSION["admin_id"];
- $student_name = $_SESSION["username"];
- $test_no = $_SESSION['test'];
- $results_1 = $_SESSION['result_one'];
- $results_2 = $_SESSION['result_tow'];
- $results_3 = $_SESSION['result_three'];
- $results_4 = $_SESSION['result_four'];
- $results_analytical = "12";
-
- $query = "INSERT INTO `student_results` ";
- $query .= "(`student_id`, `student_name`, `test_no`, `test_token`, `results_1`, `results_2`, `results_3`, `results_4`, `results_analytical`) ";
- $query .= " VALUES ";
- $query .= "('{$student_id}', '{$student_name}', '{$test_no}', '{$_SESSION["token"]}', '{$results_1}', '{$results_2}', '{$results_3}', '{$results_4}', '{$results_analytical}')";
- $admin_set = mysql_query($query);
- //$admin = mysql_fetch_assoc($admin_set);
-
- ?>
-
-
- </div>
- </div>
- <div class="col-md-12"><a class="btn btn-lg btn-success" href="gre.php" title="Back to GRE Test">Back to GRE Test</a></div>
- <div class="col-md-12">
- <?php
- for($sec=1;$sec<5;$sec++){
- if(isset($_SESSION['ques_list_'.$sec])){
- $secArray = array();
- $secArray = $_SESSION['ques_list_'.$sec];
- /*echo '<pre>';
- print_r($secArray);
- echo '</pre>';*/
- echo '<h2 class="text-center">Section '.$sec.'</h2>';
- $i=0;
- if(!empty($secArray['ques_id'])){
- for($i=0;$i<count($secArray['ques_id']);$i++){
- $id = $secArray['ques_id'][$i];
- $ques_type = $secArray['ques_type'][$i];
- if($ques_type == 'mul'){
- $ans_given = array();
- }
- $ans_given = $secArray['ques_ans'][$i];
-
- $query = mysql_query("SELECT * FROM gre WHERE `test`= $test AND `section` = $sec AND `id` = $id");
- while($result = mysql_fetch_array($query)){
- echo '<div class="col-md-12">';
-
- // if question is single
- if($ques_type == 'sin'){
- $question_body = $result['question_body'];
- if($result['qtype'] == 'sentence_eq' && empty($question_body)){
- if(!empty($result['body_img'])){
- $question_body = '<img src="img/'.$result['body_img'].'" />';
- }
- }
- echo '<p><span>'.($i+1).'. </span>'.$question_body.'</p>';
- if($result['qtype'] == 'menual_input'){
- if(($result['ans1']) != 0){
- if($result['ans1'] == $ans_given){
- echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$ans_given.'</div>';
- }
- else {
- echo '<div class="red-bg"><strong>Your Answer:</strong> '.$ans_given.'</div>';
- echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['ans1'].'</div>';
- }
- }
- if($result['single_blank-1'] != 0){
- if($result['single_blank-1'] == $ans_given){
- echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$ans_given.'</div>';
- }
- else {
- echo '<div class="red-bg"><strong>Your Answer:</strong> '.$ans_given.'</div>';
- echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['single_blank-1'].'</div>';
- }
- }
- }
-
- else {
- if($result['ans1'] == $ans_given){
- echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
- }
- else {
- echo '<div class="red-bg"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
- echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['single_blank-'.$result['ans1']].'</div>';
- }
- }
- }
-
- // if question is double
- else if($ques_type == 'dub'){
- $answer = array();
- $answer = explode(',', $ans_given);
- echo '<p><span>'.($i+1).'. </span>'.$result['question_body'].'</p>';
- if($result['ans1'] == $answer[0]){
- echo '<div class="green-bg"><strong>Your Answer (i):</strong> '.$result['single_blank-'.$answer[0]].'</div>';
- }
- else {
- echo '<div class="red-bg"><strong>Your Answer (i):</strong> '.$result['single_blank-'.$answer[0]].'</div>';
- echo '<div class="green-bg"><strong>Correct Answer (i):</strong> '.$result['single_blank-'.$result['ans1']].'</div>';
- }
- if($result['ans2'] == $answer[1]){
- echo '<div class="green-bg margin-btm"><strong>Your Answer (ii):</strong> '.$result['single_blank-'.$answer[1]].'</div>';
- }
- else {
- echo '<div class="red-bg"><strong>Your Answer (ii):</strong> '.$result['single_blank-'.$answer[1]].'</div>';
- echo '<div class="green-bg margin-btm"><strong>Correct Answer (ii):</strong> '.$result['single_blank-'.$result['ans2']].'</div>';
- }
- }
-
- // if question is triple
- else if($ques_type == 'thr'){
- $answer = array();
- $answer = explode(',', $ans_given);
- echo '<p><span>'.($i+1).'. </span>'.$result['question_body'].'</p>';
-
- $count = 1;
- for($a = 0; $a < 3; $a++){
- if($result['ans'.$count] == $answer[$a]){
- echo '<div class="green-bg"><strong>Your Answer '.$count.':</strong> '.$result['single_blank-'.$answer[$a]].'</div>';
- }
- else {
- echo '<div class="red-bg"><strong>Your Answer '.$count.':</strong> '.$result['single_blank-'.$answer[$a]].'</div>';
- echo '<div class="green-bg"><strong>Correct Answer '.$count.':</strong> '.$result['single_blank-'.$result['ans'.$count]].'</div>';
- }
- $count++;
- }
- }
-
- // if question is multiple
- else if($ques_type == 'mul'){
- echo '<p><span>'.($i+1).'. </span>'.$result['question_body'].'</p>';
- $numOfAns = 0;
- $numOfAnsGiven = sizeof($ans_given);
- $answer = array();
-
- if($result['ans1'] !=0){
- $answer[] = $result['ans1'];
- $numOfAns += 1;
- }
- if($result['ans2'] !=0){
- $answer[] = $result['ans2'];
- $numOfAns += 1;
- }
- if($result['ans3'] !=0){
- $answer[] = $result['ans3'];
- $numOfAns += 1;
- }
- echo '<strong>Your Answer:</strong>';
- foreach($ans_given as $value){
-
- if(in_array($value, $answer)){
- echo '<div class="green-bg">'.$result['single_blank-'.$value].'</div>';
- }
- else {
- echo '<div class="red-bg">'.$result['single_blank-'.$value].'</div>';
- }
- }
- echo '<strong>Correct Answer:</strong>';
- foreach($answer as $value){
- echo '<div class="green-bg">'.$result['single_blank-'.$value].'</div>';
- }
- }
- // if question is body_choice
- if($ques_type == 'bod'){
- if($result['ans1'] == $ans_given){
- echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
- }
- else {
- echo '<div class="red-bg"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
- echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['single_blank-'.$result['ans1']].'</div>';
- }
- }
-
- echo '</div>';
- }
- }
- }
- }
- }
- ?>
- </div>
- </div>
- <?php // exit(); ?>
- <div class="container">
- <div class="col-md-12">
- <h4> Your Verbal Score is: <?php echo $_SESSION['result_one']+$_SESSION['result_three']+130; ?></h4>
- <h4> Your Quantitative Score is: <?php echo $_SESSION['result_tow']+$_SESSION['result_four']+130; ?></h4>
- </div>
- </div>
- <?php
- $now = time(); // checking the time now when home page starts
- if($now > $_SESSION['expire'])
- {
- session_destroy();
- echo "<script>alert(<div class='login_result'>Your session has expire ! <a href='login.php'>Click Here to Login</a></div>)</script>";
- }
- ?>
- </body>
- </html>