<?php session_start();
require_once 'config.php';
$PageName = "Exam Result"; ?>
<!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>

    <!-- manifest meta -->
    <meta name="apple-mobile-web-app-capable" content="yes">

    <!-- Favicons -->
    <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">

    <!-- Material icons-->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

    <!-- Google fonts-->
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&amp;display=swap" rel="stylesheet">

    <!-- swiper CSS -->
    <link href="vendor/swiper/css/swiper.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/style.css" rel="stylesheet" id="style">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
</head>

<body class="body-scroll d-flex flex-column h-100 menu-overlay">
    <!-- screen loader -->
   
     
  


    <!-- Begin page content -->
    <main class="flex-shrink-0 main">
        <!-- Fixed navbar -->
        <?php include_once 'back-header.php'; ?>
        <!-- page content start -->
        <div class="main-container">
            <div class="container">
                <form action="#" method="POST">
                   <?php 
                    $id = $_GET['id'];
                    $LessonId = $_GET['id'];
                    $CourseId = $_GET['cid'];
                    $User_Id = $_SESSION['User']['id'];
                    $sql55 = "SELECT SUM(Marks) As Tot_Marks FROM tbl_question_answer WHERE Status=1 AND CourseId='$CourseId' AND LessonId='$id'";
                    $row55 = getRecord($sql55);

                    $sql22 = "SELECT SUM(Marks) As Get_Marks FROM tbl_given_exam_details WHERE UserId='$User_Id' AND LessonId='$LessonId' AND CourseId='$CourseId'";
                      $row22 = getRecord($sql22);
                    ?>
                  <span style="color: blue;">Total Marks :</span> <?php echo $row55['Tot_Marks']; ?>
                  <span style="color: green;float: right;">Marks : <?php echo $row22['Get_Marks']; ?></span> 
                  <br><br>
                <?php 
                    
                    $i = 1;
                    $sql44 = "SELECT * FROM tbl_question_answer WHERE Status=1 AND CourseId='$CourseId' AND LessonId='$id'";
                    $row44 = getList($sql44);
                    foreach($row44 as $result){
                      $QuesId = $result['id'];
                      $sql33 = "SELECT * FROM tbl_given_exam_details WHERE UserId='$User_Id' AND LessonId='$LessonId' AND CourseId='$CourseId' AND QuesId='$QuesId'";
                      $row33 = getRecord($sql33);
                      $GivenAns = $row33['Answer'];
                      $CorrectAns = $result['Answer'];
                      if($CorrectAns == 1){
                        $Correct_Ans = $result['Option1'];
                      }
                      else if($CorrectAns == 2){
                        $Correct_Ans = $result['Option2'];
                      }
                      else if($CorrectAns == 3){
                        $Correct_Ans = $result['Option3'];
                      }
                      else if($CorrectAns == 4){
                        $Correct_Ans = $result['Option4'];
                      }

                      if($GivenAns == 1){
                        $Given_Ans = $result['Option1'];
                      }
                      else if($GivenAns == 2){
                        $Given_Ans = $result['Option2'];
                      }
                      else if($GivenAns == 3){
                        $Given_Ans = $result['Option3'];
                      }
                      else if($GivenAns == 4){
                        $Given_Ans = $result['Option4'];
                      }

                      if($CorrectAns == $GivenAns){
                        $Message = "<div class='alert alert-success'>Correct Answer</div>";
                      }
                      else{
                        $Message = "<div class='alert alert-danger'>Incorrect Answer</div>";
                      }
                 ?>
                <div class="card mb-4">
                    <div class="card-header">
                        <h6 class="mb-0"><small class="text-secondary">Q<?php echo $i;?>. <?php echo $result['Question']; ?></small></h6>
                    </div>
                     <input type="hidden" name="id[<?php echo $result["id"]; ?>]" value="<?php echo $result["id"]; ?>">
                      <input type="hidden" name="CorrectAns[<?php echo $result["id"]; ?>]" value="<?php echo $result["Answer"]; ?>">
                    <div class="card-body">
                        <span style="color: green;">Correct Answer :</span><br>
                        <p><?php echo $Correct_Ans; ?></p><hr>
                        <span style="color: orange;">Given Answer :</span><br>
                        <p><?php echo $Given_Ans; ?></p><hr>
                        <?php echo $Message; ?>
                    </div>
                </div>
            <?php $i++;} ?>
             <div class="form-row" style="padding-left: 10px;">
                    
                        <a href="lesson-details.php?id=<?php echo $LessonId; ?>&cid=<?php echo $CourseId; ?>" class="mb-2 btn btn-primary">Back</a>
      </div>
        </form>
            <br><br><br><br>
            </div>
        </div>
    </main>


    <!-- Required jquery and libraries -->
    <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>

    <!-- cookie js -->
    <script src="js/jquery.cookie.js"></script>

    <!-- Swiper slider  js-->
    <script src="vendor/swiper/js/swiper.min.js"></script>

    <!-- Customized jquery file  -->
    <script src="js/main.js"></script>
    <script src="js/color-scheme-demo.js"></script>


    <!-- page level custom script -->
    <script src="js/app.js"></script>
    
</body>

</html>
