<?php

    session_start();

    include "../db.php";

    date_default_timezone_set('Asia/Kolkata');

    $currentTime = date('M j, Y g:i a');



    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) && !isset($_SESSION['uname']) && !isset($_SESSION['Exam_ref']) )

        header("Location: logout.php");



    $m_sql = "SELECT mocktest_name, id, mock_time FROM mocktest WHERE id = '$_SESSION[mocktest_id]'";

    $m_result = mysqli_query($con, $m_sql);

    $m_row = mysqli_fetch_assoc($m_result);

    $test = "SELECT * FROM examination WHERE exam_ref = '$_SESSION[Exam_ref]'";

    $testresult = mysqli_query($con, $test);

    $cout = mysqli_num_rows($testresult);

    

?>



<!DOCTYPE html>

<html lang="en">



<head>

    <?php include "includes/meta.php"; ?>

    <?php include "includes/css.php"; ?>



    <style>

        .modal.fade .modal-dialog {

            width: 100%;

            margin: 0 auto;

        }



        .mock_container {

            background: #f5f5f5;

            padding-top: 10px;

            padding-left: 100px;

            padding-right: 100px;

        }



        .question_btn {

            font-size: 20px;

            padding-left: 13px;

            padding-right: 13px;

            margin: 7px;

        }

        .tabs ul {

        margin: 0;

        padding: 0;

        }

        .tabs li {

        display: inline-block;

        color: #fefefe;

        border-width: 1px 1px 0 1px;

        margin-right: 5px;

        }

        .tabs a {

        display: block;

        padding: 10px 15px;

        font-weight: bold;

        color: #fff;

        }



        .tabs li.active {

            background: #FFF;

            color: #000;

        }

        .tabs-content div:not(:first-child) {

        display: none;

        }

    </style>

</head>



<body id="page-top" class="mt-55">



    <div style="margin-top: 70px;"></div>



    <?php include "includes/header2.php"; ?>

    <div class="mock_container" style="background: #f5f5f5;">

        <div class="row">

            <div class="col-md-12 bg-dark text-light">Welcome: <span><?php echo $_SESSION['Exam_ref'];?></span></div>

        </div>

        <div class="row my-5">

            <div class="col-md-12 text-danger">

                <h3> Test Name: <?php echo $m_row['mocktest_name'];?></h3>

            </div>

        </div>

        <div class="row">

            <table class="table table-striped">

                <tr class="bg-white" style="border: 1px solid #ddd;">

                    <td width="45%">Total Questions − <?php echo $cout;?></td>

                    <td width="10%" class="text-center" style="border: 1px solid #ddd;">19:05:06</td>

                    <td width="45%" class="text-right">Max Time − <?php echo $m_row['mock_time'];?> Min</td>

                </tr>

            </table>

        </div>

        <div class="row">

            <div class="col-md-7 pl-0">

                <div class="card px-4 py-2">

                <section class="tabs-content">

                    <?php 

                    foreach($testresult as $Qkey => $questions){

                        $getQuestions = "SELECT * FROM question WHERE id='$questions[question_id]'";

                        $run = mysqli_query($con, $getQuestions);

                        $questionsResult = mysqli_fetch_assoc($run);

                    ?>

                    <div id="tab<?php echo $Qkey+1;?>">

                        <h4><strong>Question No: <?php echo $Qkey+1;?></strong></h4>

                       <?php 

                       if(isset($questionsResult['question_name'])){?>

                        <p><?php echo $questionsResult['question_name'];?></p>

                        <?

                       }else{?>

                        <img src="./upload/question/<?php echo $questionsResult['question_image'];?>" alt="" width="100%">

                        <?php

                       }

                       ?>

                    </div>

                    <?php

                    }

                    ?>

                    

                    <!-- <div id="tab2">

                    <h4><strong>Question No: 2</strong></h4>

                        <p>We don't have anything but happy trees here. See. We take the corner of the brush and let it

                            play back-and-forth. You can work and carry-on and put lots of little happy things in here.

                            Without washing the brush, I'm gonna go right into some Van Dyke Brown, some Burnt Umber,

                            and a little bit of Sap Green. This is a fantastic little painting. The first step to doing

                            anything is to believe you can do it. See it finished in your mind before you ever start.

                        </p>

                    </div> -->

                </section>

                </div>

            </div>

            <div class="col-md-5 pr-0">

                <div class="card p-2">

                    <div class="tabs">

                        <ul>

                            <?php 

                            foreach($testresult as $Qkey => $questions){

                            ?>

                                <li class="active"><a href="#tab<?php echo $Qkey+1;?>" class="btn btn-primary question_btn" data-toggle="tab"><?php echo $Qkey+1;?></a></li>

                            <?php }?>

                        </ul>

                    </div>

                </div>

            </div>

            <?php include "includes/ft.php"; ?>

            <?php include "includes/js.php"; ?>

        </div>

    </div>

    </div>

</body>

<script>

    $(function () {

        $('.tabs a').click(function () {

            // Check for active

            $('.tabs li').removeClass('active');

            $(this).parent().addClass('active');

            // Display active tab

            let currentTab = $(this).attr('href');

            $('.tabs-content div').hide();

            $(currentTab).show();

            return false;

        });

    });

</script>



</html>