<?php session_start();
require_once 'config.php';
require_once 'auth.php';
$PageName = "View Result";
$user_id = $_SESSION['User']['id'];
 ?>
<!doctype html>
<html lang="en" class="h-100">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="generator" content="">
    <title><?php echo $Proj_Title; ?></title>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <link rel="apple-touch-icon" href="img/favicon180.png" sizes="180x180">
    <link rel="icon" href="img/favicon32.png" sizes="32x32" type="image/png">
    <link rel="icon" href="img/favicon16.png" sizes="16x16" type="image/png">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&amp;display=swap" rel="stylesheet">
    <link href="vendor/swiper/css/swiper.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet" id="style">
    <link rel="stylesheet" type="text/css" href="css/style2.css" />
</head>

<body class="body-scroll d-flex flex-column h-100 menu-overlay" data-page="shop">
    <main class="flex-shrink-0 main">
        <?php include_once 'back-header.php'; ?> 
        
        <?php  
  $TestId = $_GET['testid'];
  $sql = "SELECT tr.*,tu.Fname,tu.Lname,tu.RollNo,td.Name As Department,tc.Name As Course,tts.TestName,tts.StartDate,tts.TestMarks,tts.CorrectMark,tts.IncorrectMark,tts.UnattemptedMark FROM tbl_result tr 
          LEFT JOIN tbl_users tu ON tr.UserId=tu.id 
          LEFT JOIN tbl_departments td ON tr.DeptId = td.id 
          LEFT JOIN tbl_courses tc ON tr.CourseId = tc.id 
          LEFT JOIN tbl_test_series tts ON tr.TestId=tts.id 
          WHERE tr.TestId='$TestId' AND tr.UserId='$user_id'";
  $row = getRecord($sql);
  $ResultId = $row['id'];
  $UserId = $row['UserId'];


   $sql13 = "SELECT UserId,Marks AS marks_var, ( SELECT COUNT(Marks) + 1 FROM tbl_result WHERE (Marks > marks_var) AND TestId='$TestId' ) AS Ranking FROM tbl_result WHERE TestId='$TestId'";
   $rncnt13 = getRow($sql13);
   $row33 = getList($sql13);
      foreach($row33 as $result){
        if($result['UserId'] == $UserId){
          $Rank = $result['Ranking'];
        }
    }
?>

<style>
table, td, th {  
  border: 1px solid #ddd;
  text-align: left;
}
table {
  border-collapse: collapse;
  width: 100%;
}
th, td {
  padding: 10px;
  padding-top: 5px;
}
.button {
  background-color: #008CBA; /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  -webkit-transition-duration: 0.4s; /* Safari */
  transition-duration: 0.4s;
  border-radius: 8px;
}
.button1 {
  box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.button2:hover {
  box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
}
@media print {
  #printPageButton {
    display: none;
  }
    @page {
    margin-top: 30px;
    margin-bottom: 30px;
  }
}
.break_page {page-break-after: always;}
</style>
        <div class="main-container">
            <div class="container">
  
  
   <div class="nav-tabs-top mb-4">
           <div class="swiper-container categories2tab1 text-center" style="padding-top:5px;padding-bottom:10px;">
              
                    <div class="swiper-wrapper" data-aos="flip-up">
                     <div class="swiper-slide">
                            <a href="view-result.php?testid=<?php echo $_GET['testid'];?>&tab=1"
                            <?php if($_GET['tab'] == 1){?>
                            class="btn btn-sm btn-default active rounded"
                            <?php } else { ?>
                            class="btn btn-sm  btn-outline-default active rounded" <?php } ?>>Result</a>
                        </div>
                                            <div class="swiper-slide">
                            <a href="view-result.php?testid=<?php echo $_GET['testid'];?>&tab=2" <?php if($_GET['tab'] == 2){?>
                            class="btn btn-sm btn-default active rounded"
                            <?php } else { ?>
                            class="btn btn-sm  btn-outline-default active rounded" <?php } ?>>Test Summary</a>
                        </div>
                                            <div class="swiper-slide">
                            <a href="view-result.php?testid=<?php echo $_GET['testid'];?>&tab=3" <?php if($_GET['tab'] == 3){?>
                            class="btn btn-sm btn-default active rounded"
                            <?php } else { ?>
                            class="btn btn-sm  btn-outline-default active rounded" <?php } ?>>Subject Summary</a>
                        </div>
                                            <div class="swiper-slide">
                            <a href="view-result.php?testid=<?php echo $_GET['testid'];?>&tab=4" <?php if($_GET['tab'] == 4){?>
                            class="btn btn-sm btn-default active rounded"
                            <?php } else { ?>
                            class="btn btn-sm  btn-outline-default active rounded" <?php } ?>>Top 5 Rankers</a>
                        </div>
                                            <div class="swiper-slide">
                            <a href="view-result.php?testid=<?php echo $_GET['testid'];?>&tab=5" <?php if($_GET['tab'] == 5){?>
                            class="btn btn-sm btn-default active rounded"
                            <?php } else { ?>
                            class="btn btn-sm  btn-outline-default active rounded" <?php } ?>>Recent 5 Test</a>
                        </div>
                        
                         <div class="swiper-slide">
                            <a href="view-result.php?testid=<?php echo $_GET['testid'];?>&tab=6" <?php if($_GET['tab'] == 6){?>
                            class="btn btn-sm btn-default active rounded"
                            <?php } else { ?>
                            class="btn btn-sm  btn-outline-default active rounded" <?php } ?>>Answer Key</a>
                        </div>
                                           
                    </div>
                    <!-- Add Pagination -->
                    <div class="swiper-pagination white-pagination text-left mb-3"></div>
                      </div> 
                      
                       <div class="card">
                        <?php 
    $sql2 = "SELECT * FROM tbl_result_answer WHERE ResultId='$ResultId' AND UserId='$UserId' AND Answer=11";
    $rncnt2 = getRow($sql2);

    $sql5 = "SELECT * FROM tbl_result_answer WHERE ResultId='$ResultId' AND UserId='$UserId' AND Answer!=11";
    $rncnt5 = getRow($sql5);

    $TotCorrAns = 0;
    $sql3 = "SELECT Answer,id FROM tbl_question_answer WHERE TestSeriesId='$TestId'";
    $rncnt3 = getRow($sql3);
    $row3 = getList($sql3);
    foreach($row3 as $result){
      $QuesId = $result['id'];
      $CorrAns = $result['Answer'];
      $sql4 = "SELECT * FROM tbl_result_answer WHERE QuesId='$QuesId' AND ResultId='$ResultId' AND Answer!=11";
      $row4 = getRecord($sql4);
      $GiveAnswer = $row4['Answer'];
       //echo $CorrAns." - ".$GiveAnswer."&nbsp;";
      if($CorrAns == $GiveAnswer){
       
           $TotCorrAns = $TotCorrAns + 1;
      }
    }
     $wrong = $rncnt5 - $TotCorrAns;

     $sql6 = "SELECT * FROM tbl_test_series WHERE id='$TestId'";
     $row6 = getRecord($sql6);
     $CorrectPts = $row6['CorrectMark'];
     $IncorrectPts = $row6['IncorrectMark'];
     $UnattemptedPts = $row6['UnattemptedMark'];
     $tot_result = ($TotCorrAns* $CorrectPts) + ($wrong*$IncorrectPts) + ($rncnt2*$UnattemptedPts);
     $outofmarks = $rncnt3*$CorrectPts;
     $percentage = ($tot_result/$outofmarks) * 100;

     $sql9 = "SELECT MAX(Marks) As MaxMarks FROM tbl_result WHERE TestId='$TestId'";
     $row9 = getRecord($sql9);

     $sql7 = "SELECT MIN(Marks) As MinMarks FROM tbl_result WHERE TestId='$TestId'";
     $row7 = getRecord($sql7);

     $sql8 = "SELECT SUM(Marks) As SumMarks,Count(id) As Studs FROM tbl_result WHERE TestId='$TestId' AND UserId!=0";
     $row8 = getRecord($sql8);
     $AvgMarks = $row8['SumMarks']/$row8['Studs'];
    ?>
                   
                    <div class=" px-0 pt-0">
                        <div class="list-group list-group-flush border-top border-color">
                            <div class="row justify-content-equal no-gutters" style="padding: 10px;">
                                   <?php 
                                   if($_GET['tab'] == 1){?>
                                   <table width="100%">
                                                      
  <tr>
    <td colspan="2"><strong>Roll No : </strong> <?php echo $row['RollNo'];?></td>
    <td colspan="2"><strong>Name : </strong> <?php echo $row['Fname']." ".$row['Lname'];?></td>
    
  </tr>
  <tr>
    <td colspan="2"><strong>Exam : </strong> <?php echo $row['Department'];?></td>
    <td colspan="2"><strong>Test Name : </strong> <?php echo $row['TestName'];?></td>
  </tr>
 <tr>
  <td colspan="2"><strong>Course : </strong> <?php echo $row['Course'];?></td>
     <td colspan="2"><strong>Test Date : </strong> <?php echo date("d-m-Y", strtotime(str_replace('-', '/',$row['TestDate'])));?></td>
  </tr>
  <tr>
    <td colspan="4"><strong>Rank : </strong> <?php echo $Rank."/".$rncnt13;?></td>

  </tr>
  <tr>
        
  </tr>
  <tr>
      <th>Correct</th>
      <th>Incorrect</th>
      <th>Unanswered</th>
      <th>Score</th>
     
  </tr>
  <tr>
      <td><?php echo $TotCorrAns;?></td>
      <td><?php echo $wrong;?></td>
      <td><?php echo $rncnt2;?></td>
      <td><?php echo $tot_result;?></td>
     
  </tr>
  <tr>
       <th>Highest Score</th>
      <th>Top Average</th>
      <th colspan="2">Percentage</th>
  </tr>
  <tr>
       <td><?php echo $row9['MaxMarks'];?></td>
      <td><?php echo number_format($AvgMarks,2); ?></td>
      <td colspan="2"><?php echo number_format($percentage,2);?></td>
  </tr>
  <tr>
      <th>Sr.No</th>
      <th colspan="2">Section Name</th>
      <th>Total Question</th>
      
  </tr>

       <?php 
       $i=1;
  $sql33 = "SELECT tq.*,ts.Name As Subject FROM `tbl_question_answer` tq INNER JOIN tbl_subjects ts ON tq.SubjectId=ts.id WHERE TestSeriesId='$TestId' GROUP BY SubjectId";
  $row33 = getList($sql33);
  foreach($row33 as $result){
    $Subject_Id = $result['SubjectId'];
    $sql44 = "SELECT count(*) As TotQues FROM tbl_question_answer WHERE SubjectId='".$result['SubjectId']."' AND TestSeriesId='$TestId'";
    $row44 = getRecord($sql44);

    $sql2_2 = "SELECT count(*) As AttemptQues FROM tbl_result_answer WHERE ResultId='$ResultId' AND UserId='$UserId' AND Answer!=11 AND SubjectId='".$result['SubjectId']."'";
    $row2_2 = getRecord($sql2_2);

    $sql3_3 = "SELECT * FROM `tbl_result_answer` tr INNER JOIN tbl_question_answer tq ON tr.QuesId=tq.id WHERE tr.Answer=tq.Answer AND tr.TestId='$TestId' AND tr.Answer!=11 AND tr.SubjectId='".$result['SubjectId']."' GROUP BY tr.SubjectId";
    $rncnt3_3 = getRow($sql3_3);

    $Wrong = $row2_2['AttemptQues'] - $rncnt3_3;

    
     $tot_result = ($rncnt3_3* $CorrectPts) + ($Wrong*$IncorrectPts);
    ?>
  <tr>
      <td><?php echo $i;?></td>
  <td colspan="2"><?php echo $result['Subject'];?></td>
  <td><?php echo $row44['TotQues'];?></td>
 
  </tr>
  <?php $i++;} ?>
  
  <tr>
      <th>Attempted</th>
      <th>Correct</th>
      <th>Incorrect</th>
      <th>Marks</th>
  </tr>
  
  <?php 
       $i=1;
  $sql33 = "SELECT tq.*,ts.Name As Subject FROM `tbl_question_answer` tq INNER JOIN tbl_subjects ts ON tq.SubjectId=ts.id WHERE TestSeriesId='$TestId' GROUP BY SubjectId";
  $row33 = getList($sql33);
  foreach($row33 as $result){
    $Subject_Id = $result['SubjectId'];
    $sql44 = "SELECT count(*) As TotQues FROM tbl_question_answer WHERE SubjectId='".$result['SubjectId']."' AND TestSeriesId='$TestId'";
    $row44 = getRecord($sql44);

    $sql2_2 = "SELECT count(*) As AttemptQues FROM tbl_result_answer WHERE ResultId='$ResultId' AND UserId='$UserId' AND Answer!=11 AND SubjectId='".$result['SubjectId']."'";
    $row2_2 = getRecord($sql2_2);

    $sql3_3 = "SELECT * FROM `tbl_result_answer` tr INNER JOIN tbl_question_answer tq ON tr.QuesId=tq.id WHERE tr.Answer=tq.Answer AND tr.TestId='$TestId' AND tr.Answer!=11 AND tr.SubjectId='".$result['SubjectId']."' GROUP BY tr.SubjectId";
    $rncnt3_3 = getRow($sql3_3);

    $Wrong = $row2_2['AttemptQues'] - $rncnt3_3;

    
     $tot_result = ($rncnt3_3* $CorrectPts) + ($Wrong*$IncorrectPts);
    ?>
  <tr>
     
  <td><?php echo $row2_2['AttemptQues'];?></td>
  <th><?php echo $rncnt3_3;?></th>
  <td><?php echo $Wrong;?></td>
  <td><?php echo number_format($tot_result,2);?></td>
  </tr>
  <?php $i++;} ?>

                                                    </table>
                                  
                                  <?php } ?>
                                  
                                  <?php 
                                   if($_GET['tab'] == 2){?>
                                   
                                    <table>
                                                 <tr>
  
    <td colspan="7"><strong style="color: red;">TEST SUMMARY</strong></td>
  </tr><tr>
  <th>Test Summary</th>
  <th>No. of Qs.</th>
  <th>Marks</th>
  
  </tr>
  <tr>
  <td>Correct questions</td>
  <td><?php echo $TotCorrAns;?></td>
  <td><?php echo $TotCorrAns* $CorrectPts; ?></td>
 
  </tr>
  <tr>
  <td>Incorrect questions</td>
  <td><?php echo $wrong;?></td>
  <td><?php echo $wrong*$IncorrectPts; ?></td>
  
  </tr>
  <tr>
  <td>Not attempted</td>
  <td><?php echo $rncnt2;?></td>
  <td><?php echo $rncnt2*$UnattemptedPts; ?></td>
 
  </tr>
  
  <tr>
  <td>Total</td>
  <td><?php echo $TotCorrAns+$wrong+$rncnt2; ?></td>
  <td><?php echo ($TotCorrAns* $CorrectPts)+($wrong*$IncorrectPts)+($rncnt2*$UnattemptedPts);?></td>
 
  </tr> 
  
  <tr>
      <th>Total Marks</th>
  <td>:</td>
  <td><?php echo $tot_result." out of ".$outofmarks;?></td>
  </tr>
  
  <tr>
       <th>Percentage</th>
  <td>:</td>
  <td><?php echo number_format($percentage,2);?></td>
  </tr>
  
  <tr>
       <th>Max Marks</th>
  <td>:</td>
  <td><?php echo $row9['MaxMarks']; ?></td>
  </tr>
  
  <tr>
       <th>Min Marks</th>
  <td>:</td>
  <td><?php echo $row7['MinMarks']; ?></td>
  </tr>
  
  <tr>
       <th>Avg Marks</th>
  <td>:</td>
  <td><?php echo number_format($AvgMarks,2); ?></td>
  </tr>
                                            </table>
                                   <?php } ?>
                                   
                                   
                                   <?php 
                                   if($_GET['tab'] == 3){?>
                                   
                                    <table>
 
 

    <tr>
   <td colspan="7"><strong style="color: red;">SUBJECT SUMMARY</strong></td>
  </tr>
  <tr>
  <th>Subject</th>
  <th>No. of Ques.</th>
  <th>Attempted</th>

  
  </tr>
  <?php 
  $sql33 = "SELECT tq.*,ts.Name As Subject FROM `tbl_question_answer` tq INNER JOIN tbl_subjects ts ON tq.SubjectId=ts.id WHERE TestSeriesId='$TestId' GROUP BY SubjectId";
  $row33 = getList($sql33);
  foreach($row33 as $result){
    $Subject_Id = $result['SubjectId'];
    $sql44 = "SELECT count(*) As TotQues FROM tbl_question_answer WHERE SubjectId='".$result['SubjectId']."' AND TestSeriesId='$TestId'";
    $row44 = getRecord($sql44);

    $sql2_2 = "SELECT count(*) As AttemptQues FROM tbl_result_answer WHERE ResultId='$ResultId' AND UserId='$UserId' AND Answer!=11 AND SubjectId='".$result['SubjectId']."'";
    $row2_2 = getRecord($sql2_2);

    $sql3_3 = "SELECT * FROM `tbl_result_answer` tr INNER JOIN tbl_question_answer tq ON tr.QuesId=tq.id WHERE tr.Answer=tq.Answer AND tr.TestId='$TestId' AND tr.Answer!=11 AND tr.SubjectId='".$result['SubjectId']."' GROUP BY tr.SubjectId";
    $rncnt3_3 = getRow($sql3_3);

    /*$sql3_4 = "SELECT * FROM `tbl_result_answer` tr INNER JOIN tbl_question_answer tq ON tr.Answer!=tq.Answer WHERE tr.TestId='$TestId' AND tr.Answer!=11 AND tr.SubjectId='".$result['SubjectId']."'  GROUP BY tr.QuesId";
    $rncnt3_4 = getRow($sql3_4);*/
    $Wrong = $row2_2['AttemptQues'] - $rncnt3_3;

    
     $tot_result = ($rncnt3_3* $CorrectPts) + ($Wrong*$IncorrectPts);
    ?>
  <tr>
  <td><?php echo $result['Subject'];?></td>
  <td><?php echo $row44['TotQues'];?></td>
  <td><?php echo $row2_2['AttemptQues'];?></td>
 
 
  </tr>
  <?php } ?>

 <tr>
       <th>Correct</th>
     <th>Wrong</th>
  <th>Marks</th>
 </tr>
 
 <?php 
  $sql33 = "SELECT tq.*,ts.Name As Subject FROM `tbl_question_answer` tq INNER JOIN tbl_subjects ts ON tq.SubjectId=ts.id WHERE TestSeriesId='$TestId' GROUP BY SubjectId";
  $row33 = getList($sql33);
  foreach($row33 as $result){
    $Subject_Id = $result['SubjectId'];
    $sql44 = "SELECT count(*) As TotQues FROM tbl_question_answer WHERE SubjectId='".$result['SubjectId']."' AND TestSeriesId='$TestId'";
    $row44 = getRecord($sql44);

    $sql2_2 = "SELECT count(*) As AttemptQues FROM tbl_result_answer WHERE ResultId='$ResultId' AND UserId='$UserId' AND Answer!=11 AND SubjectId='".$result['SubjectId']."'";
    $row2_2 = getRecord($sql2_2);

    $sql3_3 = "SELECT * FROM `tbl_result_answer` tr INNER JOIN tbl_question_answer tq ON tr.QuesId=tq.id WHERE tr.Answer=tq.Answer AND tr.TestId='$TestId' AND tr.Answer!=11 AND tr.SubjectId='".$result['SubjectId']."' GROUP BY tr.SubjectId";
    $rncnt3_3 = getRow($sql3_3);

    /*$sql3_4 = "SELECT * FROM `tbl_result_answer` tr INNER JOIN tbl_question_answer tq ON tr.Answer!=tq.Answer WHERE tr.TestId='$TestId' AND tr.Answer!=11 AND tr.SubjectId='".$result['SubjectId']."'  GROUP BY tr.QuesId";
    $rncnt3_4 = getRow($sql3_4);*/
    $Wrong = $row2_2['AttemptQues'] - $rncnt3_3;

    
     $tot_result = ($rncnt3_3* $CorrectPts) + ($Wrong*$IncorrectPts);
    ?>
  <tr>
  <th><?php echo $rncnt3_3;?></th>
  <td><?php echo $Wrong;?></td>
  <td><?php echo number_format($tot_result,2);?></td>
  </tr>
  <?php } ?>
</table>
                                   <?php } ?>
                                   
                                   <?php if($_GET['tab'] == 4){?>
                                     <table>
                                               <tr>
  <td colspan="7"><strong style="color: red;">TOP 5 Rankers</strong></td>
  </tr>
   <tr>
  <th>Rank</th>
  <th>Name</th>
  <th>Marks</th>
 
  </tr>
  <?php 
  $i = 1;
  $sql11 = "SELECT tr.*,tu.Fname,tu.Lname FROM tbl_result tr LEFT JOIN tbl_users tu ON tr.UserId = tu.id WHERE tr.TestId='$UserId' ORDER BY tr.Marks DESC LIMIT 5";
  $row11 = getList($sql11);
  foreach($row11 as $result){
  ?>
  <tr>
    <td>&nbsp;<?php echo $i;?>. </td>
    <td>&nbsp;<?php echo $result['Fname']." ".$result['Lname'];?></td>
    <td>&nbsp;<?php echo $result['Marks'];?></td>
  
  </tr>
<?php $i++;} ?>
<tr>
     <th>Out of Marks</th>
  <th>Percentage</th>
  <th>Venue</th>
</tr>
 <?php 
  $i = 1;
  $sql11 = "SELECT tr.*,tu.Fname,tu.Lname FROM tbl_result tr LEFT JOIN tbl_users tu ON tr.UserId = tu.id WHERE tr.TestId='$UserId' ORDER BY tr.Marks DESC LIMIT 5";
  $row11 = getList($sql11);
  foreach($row11 as $result){
  ?>
  <tr>
  
    <td>&nbsp;<?php echo $result['OutOfMarks'];?></td>
    <td>&nbsp;<?php echo $result['Percentage'];?>%</td>
    <td>&nbsp;Nagpur</td>
  </tr>
<?php $i++;} ?>


                                           </table>
                                   <?php } ?>
                                   
                                   <?php if($_GET['tab'] == 5){?>
                                   <table>
                                                 <tr>
  <td colspan="7"><strong style="color: red;">Your Performance in recent 5 tests</strong></td>
  </tr>
  <tr>
  <th>Test Date</th>
  <th colspan="2">Test Name</th>
 
  </tr>
  <?php 
  $i = 1;
  $sql12 = "SELECT tr.*,tu.TestName FROM tbl_result tr LEFT JOIN tbl_test_series tu ON tr.TestId = tu.id WHERE tr.UserId='$TestId' ORDER BY tr.TestDate DESC LIMIT 5";
  $row12 = getList($sql12);
  foreach($row12 as $result){
  ?>
  <tr>
        <td>&nbsp;<?php echo date("d-m-Y", strtotime(str_replace('-', '/',$result['TestDate'])));?></td>
        <td colspan="2">&nbsp;<?php echo $result['TestName'];?></td>
       
      </tr>
<?php } ?>

<tr>
     <th>Marks</th>
  <th>Out of Marks</th>
  <th>Percentage</th>
</tr>

<?php 
  $i = 1;
  $sql12 = "SELECT tr.*,tu.TestName FROM tbl_result tr LEFT JOIN tbl_test_series tu ON tr.TestId = tu.id WHERE tr.UserId='$TestId' ORDER BY tr.TestDate DESC LIMIT 5";
  $row12 = getList($sql12);
  foreach($row12 as $result){
  ?>
  <tr>
     
        <td>&nbsp;<?php echo $result['Marks'];?></td>
        <td>&nbsp;<?php echo $result['OutOfMarks'];?></td>
       <td>&nbsp;<?php echo $result['Percentage'];?></td>
      </tr>
<?php } ?>
                                           </table>
                                   <?php } ?>
                                   
                                   <?php if($_GET['tab'] == 6){?>
                                   <div class="scp-quizzes-main">
<?php 
$testid = $_GET['testid'];
$i=1;
$sql = "SELECT * FROM tbl_question_answer WHERE TestSeriesId='$testid'";
$result = getList($sql);
foreach($result as $row){
  $qid = $row['id'];
$sql2 = "SELECT Answer FROM tbl_result_answer WHERE TestId='$testid' AND QuesId='$qid'";
$row2 = getRecord($sql2);
if($row['Type'] == 'Text'){

$Myans = $row2['Answer'];
//$row['Answer'];
if($row['Answer'] == 1){
  $AnsOpt = $row['Option1'];
  $YourOpt1 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
$YourOpt2 = "";
  $YourOpt3 = "";
  $YourOpt4 = "";
}
if($row['Answer'] == 2){
  $AnsOpt = $row['Option2'];
  $YourOpt2 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
 $YourOpt1 = "";
  $YourOpt3 = "";
  $YourOpt4 = "";
}
if($row['Answer'] == 3){
  $AnsOpt = $row['Option3'];
  $YourOpt3 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
 $YourOpt2 = "";
  $YourOpt1 = "";
  $YourOpt4 = "";
}
if($row['Answer'] == 4){
  $AnsOpt = $row['Option4'];
  $YourOpt4 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
$YourOpt2 = "";
  $YourOpt3 = "";
  $YourOpt1 = "";
}
if($Myans == 1){
  if($Myans == $row['Answer']){
    $YourOpt1 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
  }
  else{
    $YourOpt1 = "background-image: none;background-color: #ff0404;color: #fff;border: 1px solid #ff0404 !important;";
  }
}

if($Myans == 2){
  if($Myans == $row['Answer']){
    $YourOpt2 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
  }
  else{
    $YourOpt2 = "background-image: none;background-color: #ff0404;color: #fff;border: 1px solid #ff0404 !important;";
  }
}

if($Myans == 3){
  if($Myans == $row['Answer']){
    $YourOpt3 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
  }
  else{
    $YourOpt3 = "background-image: none;background-color: #ff0404;color: #fff;border: 1px solid #ff0404 !important;";
  }
}

if($Myans == 4){
  if($Myans == $row['Answer']){
    $YourOpt4 = "background-image: none;background-color: #0C0;color: #fff;border: 1px solid #0C0 !important;";
  }
  else{
    $YourOpt4 = "background-image: none;background-color: #ff0404;color: #fff;border: 1px solid #ff0404 !important;";
  }
}

//echo $YourOpt1;
  ?>

 <div class="scp-quizzes-data">
   <?php if($row['Type'] == 'Text'){?>
  <h3 style="font-size: 15px;text-align:justify;"><?php echo $i.") ".$row['Question']; ?></h3>
<?php } else{?>
   <img src="../uploads/<?php echo $row['Photo']; ?>" style="height: 250px;">
<?php } ?>
    <input type="radio" id="inculdefile1<?php echo $row["id"]; ?>" disabled>
    <label for="inculdefile1<?php echo $row["id"]; ?>" style="<?php echo $YourOpt1;?>">1. <?php echo $row['Option1']; ?></label>
    <br/>

    <input type="radio"  id="inculdefile2<?php echo $row["id"]; ?>" disabled>
    <label for="inculdefile2<?php echo $row["id"]; ?>" style="<?php echo $YourOpt2;?>">2. <?php echo $row['Option2']; ?></label>
  
   <br/>

    <input type="radio" id="inculdefile3<?php echo $row["id"]; ?>" disabled>
       <label for="inculdefile3<?php echo $row["id"]; ?>" style="<?php echo $YourOpt3;?>">3. <?php echo $row['Option3']; ?></label>
    
        <br/>

    <input type="radio" id="inculdefile4<?php echo $row["id"]; ?>" disabled>
     <label for="inculdefile4<?php echo $row["id"]; ?>" style="<?php echo $YourOpt4;?>">4. <?php echo $row['Option4']; ?></label>
    
 </div>

<!-- <p>Ans :- <strong style="font-size: 17px;">(<?php echo $row['Answer']; ?>) - 
          <?php echo $AnsOpt;?></strong></p> -->
  <p style="font-size: 18px;"><strong>Explaination :- </strong> <?php echo $row['Explaination'];?></p>        
<?php }
else{?>
    <p><img src="../uploads/<?php echo $row['Photo']; ?>" style="width: 500px;height: 250px;"></p>
<hr>
<p>Ans :- <strong style="font-size: 30px;font-style: italic;">(<?php echo $row['Answer']; ?>) </strong></p>
<p><strong>Explaination :- </strong> <?php echo $row['Explaination'];?></p>
<?php } ?><hr>
<?php $i++;}
?>
</div>   
                                   <?php } ?>
                            </div>
                          
                        </div>
                    </div>
                    </div>
                    
                       
               
            </div>
        </div>
    </main><br><br><br>
 <?php include_once 'footer.php'; ?>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="vendor/swiper/js/swiper.min.js"></script>
<script src="js/main.js"></script>
<script src="js/color-scheme-demo.js"></script>
<script src="js/app.js"></script>

</body>
</html>
