<?php
ob_start();
require_once('operations.php');
session_start();
$db = new Operations();
$db2 = new Operations();

$examcode = $_SESSION['examcode'];
$countExam = $db->checkExamsCode($examcode);

//echo $examcode;

//$name = $_SESSION['name'];

$db->findExamsById($examcode);

$duration = $db->duration;

$statement = $db2->getQuestionsByExamID($examcode);

$statement2 = $db2->getQuestionsByExamID($examcode);

/*

if($countExam < 1) {
  ?>
  <script>
  alert('exam code does not exist');
window.location.href='firstPageExam.php';

</script>
  <?php
}

else {

$countQuestion = $db->getCountQuestionsByExamID($examcode);

if($countQuestion < 1) {

  ?>
  <script>
  alert('questions are not ready for this exams');
window.location.href='firstPageExam.php';

</script>
  <?php
  
}

else {

 


   $db->findSubjectById($db->subject_id);

  // echo $db->subject_id;


}



}
*/
if (isset($_POST['submit'])){
	
    $examcode = strtouppe(strip_tags($_POST['username']));
    
    $_SESSION["examcode"] = $examcode;
    header("Location: secondPageExam.php");

    }
    ?>

?>
<!--
=========================================================
* Argon Dashboard - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/argon-dashboard

* Copyright  Creative Tim (http://www.creative-tim.com)
* Coded by www.creative-tim.com
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-->
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="cbt app">
  <meta name="author" content="Creative Tim">
  <title>CBT APP</title>
  <!-- Favicon 
  <link rel="icon" href="../assets/img/brand/favicon.png" type="image/png">
  -->
  <!-- Fonts -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700">
  <!-- Icons -->
  <link rel="stylesheet" href="assets/vendor/nucleo/css/nucleo.css" type="text/css">
  <link rel="stylesheet" href="assets/vendor/@fortawesome/fontawesome-free/css/all.min.css" type="text/css">
  <!-- Argon CSS -->
  <link rel="stylesheet" href="assets/css/argon.css?v=1.2.0" type="text/css">
</head>

<body class="bg-default">
  <!-- Navbar -->
  
  <!-- Main content -->
  <div style="font-weight: bold; background-color:white;" id="quiz-time-left"></div>

  <script type="text/javascript">
var max_time = <?php echo $duration ?>;
var c_seconds  = 0;


var total_seconds =60*max_time;
max_time = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds%60);
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
function init(){
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
setTimeout("CheckTime()",999);
}
function CheckTime(){
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds' ;
if(total_seconds <=0){
setTimeout('document.form.submit()',1);
   
    } else
    {
total_seconds = total_seconds -1;
max_time = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds%60);
setTimeout("CheckTime()",999);
}

}
init();


</script>
<style>
#quiz-time-left{
	color:black;
	padding:5px;
	font-size:18px;
	
	}
</style>

  <div class="main-content">
    <!-- Header -->
    <div class="header bg-gradient-primary py-7 py-lg-8 pt-lg-9">
      <div class="container">
        <div class="header-body text-center mb-7">
          <div class="row justify-content-center">
            <div class="col-xl-5 col-lg-6 col-md-8 px-5"  style = "margin-top:5px;">
              
              <p class="text-lead text-white">Name : <?php echo $_SESSION["name"]. "    Class: ".$_SESSION["class"];  ?></p>
              <p class="text-lead text-white">Exams Code : <?php echo $examcode ." "."Subject :". $_SESSION["subject"];   ?></p>

              <p class="text-lead text-white">Questions</p>


   <!-- start ques -->
  

   <!-- end question -->


<!--  table starts -->
<div class = " row align-items-center py-4">
<div class="col-xl-12">

<!-- div class="table-responsive"> -->
    














    <div>
        <table class="table align-items-center table-dark" align = "center" style = "width:100%;">
            <thead class="thead-dark">
                <tr>
                    <th scope="col" class="sort" data-sort="name">S/N</th>
                    <th scope="col" class="sort" data-sort="budget">questions</th>
                    <th scope="col" class="sort" data-sort="budget">options</th>
                    
                    
                   
                    
                    
               
                    
                </tr>
            </thead>
            <tbody class="list">
    <?php
    $rowCount1 = 0;
            while ($row = $statement2->fetch(PDO::FETCH_ASSOC)){
                extract($row);
            $rowCount1++;
    
            ?>
                
                <tr>
                    <td>
                       <?php  echo  $rowCount1;  ?> 
                    </td>
                    <td>
                    <?php  echo $row['question'] ?>  
                    <input type="hidden" name="id[<?php echo $rowCount1 ?>]" value="<?php echo $row['id'];?>" />
                    </td>
    
                    <td>
                    <div class="col-md-12"><input class="radios" type="radio"   name="choices[<?php echo $rowCount1 ?>]" value="A"/>  <?php echo "A"." ". $row['optionA']; ?></div>
<div class="col-md-12"><input class="radios" type="radio"   name="choices[<?php echo $rowCount1 ?>]" value="B"/>  <?php echo "B"." ". $row['optionB']; ?></div>
<div class="col-md-12"><input class="radios" type="radio"   name="choices[<?php echo $rowCount1 ?>]" value="C"/> <?php echo "C"." ". $row['optionC']; ?></div>
<div class="col-md-12"><input class="radios" type="radio"  name="choices[<?php echo $rowCount1 ?>]" value="D"/>  <?php echo "D"." ". $row['optionD']; ?></div>  
                    </td>
    
                   
    
    </tr>
    <?php } ?>
    </tbody>
    </table>
    </div>
</div> <!-- row ends -->
<!-- table ends -->


              
             
            </div>
          </div>
        </div>
      </div>
      <!--
      <div class="separator separator-bottom separator-skew zindex-100">
        <svg x="0" y="0" viewBox="0 0 2560 100" preserveAspectRatio="none" version="1.1" xmlns="http://www.w3.org/2000/svg">
          <polygon class="fill-default" points="2560 0 2560 100 0 100"></polygon>
        </svg>
      </div>
      -->
    </div>
   
  <!-- Footer -->
  <footer class="py-5" id="footer-main">
    <div class="container">
      <div class="row align-items-center justify-content-xl-between">
        <div class="col-xl-6">
          <div class="copyright text-center text-xl-left text-muted">
            &copy; <?php echo date("Y") ?> <a href="#" class="font-weight-bold ml-1" target="_blank">Dcube-International</a>
          </div>
        </div>
        <div class="col-xl-6">

          
        </div>
      </div>
    </div>
  </footer>
  <!-- Argon Scripts -->
  <!-- Core -->
  <script src="assets/vendor/jquery/dist/jquery.min.js"></script>
  <script src="assets/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/js-cookie/js.cookie.js"></script>
  <script src="assets/vendor/jquery.scrollbar/jquery.scrollbar.min.js"></script>
  <script src="assets/vendor/jquery-scroll-lock/dist/jquery-scrollLock.min.js"></script>
  <!-- Argon JS -->
  <script src="assets/js/argon.js?v=1.2.0"></script>
</body>

</html>