<?php include ("../../controller/session/session-checker-teacher-student-admin-parents.php"); ?>


<?php
@$langold = $_GET['lang'];

if ($langold == '' || $langold == NULL || $langold == 'undefined') {
	$lang = 'english';
} else {
	$lang = $_GET['lang'];
}
include('../../lang/' . $lang . '.php');

?>



<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="author" content="EduMESS" />
        <meta name="description"
            content="EduMESS (Education Management and E-Learning Software Solution) 
            is a leading school management, automation and elearning solution. Since its 
            launch, EduMESS has grown to become a leader. Our clients say that the simplicity 
            of our interface, ease of use, cost effectiveness and excellent customer care is 
            the reason they prefare EduMESS. We have watched schools move from softwares they 
            are using to EduMESS." />
        <meta name="keywords"
            content="Best, School, Management, Best School, Best School Management, 
            Best School Management Software, Free School Management Software, Portal, 
            School Owner, Group of School Owner, Consultants, Brand Promoters | School Portal Generator ">
        <title>EduMESS</title>
            <!-- FAVICON AND TOUCH ICONS -->
        <link rel="shortcut icon" href="../../assets/images/website_images/favicon.png" type="image/x-icon">
        <link rel="icon" href="../../assets/images/website_images/favicon.png" type="image/x-icon">
        <link rel="apple-touch-icon" sizes="152x152" href="../../assets/images/website_images/favicon.png">
        <link rel="apple-touch-icon" sizes="120x120" href="../../assets/images/website_images/favicon.png">
        <link rel="apple-touch-icon" sizes="76x76" href="../../assets/images/website_images/favicon.png">
        <link rel="apple-touch-icon" href="../../assets/images/website_images/favicon.png">
        <link rel="icon" href="../../assets/images/website_images/favicon.png" type="image/x-icon">

        <link href="../../assets/plugins/bootstrap5/css/bootstrap.min.css" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Arvo&display=swap" rel="stylesheet">
        
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Sharp" rel="stylesheet">
        <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'>
        <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

      

        <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Sharp" rel="stylesheet">
        <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'>

        <!-- fontawesome cdn -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <!-- style sheet -->
        <!-- <link rel="stylesheet" href="../../css/user_css/students_css/studentsStyle.css"> -->

     

        <style>



body {
    margin: 0;
    padding: 0;
     font-family: "Poppins", sans-serif;
    box-sizing: border-box;
    background-color: #ebe8ed;
    color: #666666;
    font-size: 13px;
}

            .chiCourseList{
                box-shadow: #4f4f5a1a 0px 0px 16px;
                background-color: #fafffa;
                margin-top: 10px;
                border-radius: 10px;
                border: none;
            
            }

            .tari_start_btn {

                animation: pulse 0.5s infinite ease-in-out alternate;

            }

            @keyframes pulse {
                from {
                    transform: scale(1.0);
                }

                to {
                    transform: scale(1.1);
                }
            }

        </style>


    </head>

    <body>

        <div class="row p-3">
        <?php



         $cbtid = $_GET['cbt_id'];
         $UserID = $_GET['userid'];

          $examtype = $_GET['examtype'];


         if($examtype == 'assignment' )
         {



                    $selectQuery = mysqli_query($link,"SELECT * FROM `assignmentsettings` WHERE AssignmentSettingsID='$cbtid'");

                    $selectQuery = mysqli_query($link,"SELECT * FROM `assignmentsettings` 
                    INNER JOIN `campus` 
                    ON `assignmentsettings`.CampusID = `campus`.CampusID
                    INNER JOIN `section` 
                    ON `assignmentsettings`.SectionID = `section`.SectionID
                    INNER JOIN `subjectorcourse`
                    ON `assignmentsettings`.SubjectOrCourseID = `subjectorcourse`.SubjectOrCourseID
                    INNER JOIN `classordepartment`
                    ON `assignmentsettings`.ClassOrDepartmentID = `classordepartment`.ClassOrDepartmentID
                    WHERE  `assignmentsettings`.AssignmentSettingsID = '$cbtid'
                    ORDER BY `assignmentsettings`.`AssignmentSettingsID`");

         }else
         {

        

               if($examtype == 'admission')
               {


                        $selectQuery = mysqli_query($link,"SELECT * FROM `cbtsetquestionssettings` 
                        INNER JOIN `campus` 
                        ON `cbtsetquestionssettings`.CampusID = `campus`.CampusID
                        INNER JOIN `section` 
                        ON `cbtsetquestionssettings`.SectionID = `section`.SectionID
                        INNER JOIN `subjectorcourse`
                        ON `cbtsetquestionssettings`.SubjectOrCourseID = `subjectorcourse`.SubjectOrCourseID
                        INNER JOIN `classtemplate`
                        ON `cbtsetquestionssettings`.ClassOrDepartmentID = `classtemplate`.ClassTemplateID
                        WHERE  `cbtsetquestionssettings`.cbtsetquestionssettingsID = '$cbtid'
                        ORDER BY `cbtsetquestionssettings`.`cbtsetquestionssettingsID`");
               }else
               {



                            $selectQuery = mysqli_query($link,"SELECT * FROM `cbtsetquestionssettings` 
                            INNER JOIN `campus` 
                            ON `cbtsetquestionssettings`.CampusID = `campus`.CampusID
                            INNER JOIN `section` 
                            ON `cbtsetquestionssettings`.SectionID = `section`.SectionID
                            INNER JOIN `subjectorcourse`
                            ON `cbtsetquestionssettings`.SubjectOrCourseID = `subjectorcourse`.SubjectOrCourseID
                            INNER JOIN `classordepartment`
                            ON `cbtsetquestionssettings`.ClassOrDepartmentID = `classordepartment`.ClassOrDepartmentID
                            WHERE  `cbtsetquestionssettings`.cbtsetquestionssettingsID = '$cbtid'
                            ORDER BY `cbtsetquestionssettings`.`cbtsetquestionssettingsID`");

               }

            }
         


            while($fetch = mysqli_fetch_array($selectQuery))
            {






                if($examtype == 'assignment' )
                {


                                    $subjectName = $fetch['SubjectOrCourseTitle'];

                                    date_default_timezone_set("Africa/Lagos");
                    
                                    $campusName = $fetch['CampusName'];
                                
                                    $title = $fetch['AssignmentTitle'];
                                    $AssesementCategory = '';
                    
                                    $date = $fetch['Startdate'];



                                    $prosgetassignement_question = mysqli_query($link, "SELECT * FROM `assignmentquestion` WHERE `AssignmentSettingsID`='$cbtid'");
                                    $prosgetassignement_question_num_rows = mysqli_num_rows($prosgetassignement_question);




                                  
                                   $questionNumbers = $prosgetassignement_question_num_rows;
                                    
                    
                                    $AssesementStartTime = $fetch['AssignmentStartTime'];
                                    $AssesementEndTime  =  $fetch['AssignmentEndTime'];




                                    $getquestionarray = array();







                                    $prosgetassignement_question_group = mysqli_query($link, "SELECT AssignmentCategory, MAX(AssignmentQuestionID) AS MaxAssignmentQuestionID FROM `assignmentquestion` WHERE `AssignmentSettingsID`='$cbtid' GROUP BY AssignmentCategory");

                                    $prosgetassignement_question_num_rows_group = mysqli_num_rows($prosgetassignement_question_group);
                                   
                                    $prosgetassignement_question_num_rows_group_fetch = mysqli_fetch_assoc($prosgetassignement_question_group); 



                                   


                                    if($prosgetassignement_question_num_rows_group > 0)
                                    {


                                           do{

                                                    $AssignmentCategorynew =  $prosgetassignement_question_num_rows_group_fetch['AssignmentCategory'];

                                                    $getquestionarray[] = $AssignmentCategorynew;

                                           }while( $prosgetassignement_question_num_rows_group_fetch = mysqli_fetch_assoc($prosgetassignement_question_group));



                                    }

                                    $AssesementCategory =   implode(',', $getquestionarray);


                              


                    
                }else
                {



                                $subjectName = $fetch['SubjectOrCourseTitle'];

                                date_default_timezone_set("Africa/Lagos");
                
                                $campusName = $fetch['CampusName'];
                            
                                $title = $fetch['AssesementTitle'];
                                $AssesementCategory = $fetch['AssesementCategory'];
                
                                $date = $fetch['AssesementDate'];
                
                                $question = $fetch['question'];
                                $questiontheory = $fetch['TheoryQuestion'];
                
                                    $ex = explode(",", $question);
                                    $extheory = explode(",",  $questiontheory);
                    
                                    if($AssesementCategory == 'Theory')
                                    {
                
                                        $questionNumbers = count($extheory);
                
                                    }else
                                    {
                                        $questionNumbers = count($ex);
                                    }
                            
                
                                $AssesementStartTime = $fetch['AssesementStartTime'];
                                $AssesementEndTime  =  $fetch['AssesementEndTime'];

                }


                     
               
              

                $timeIn = new DateTime($AssesementStartTime);
                $timeOut = new DateTime($AssesementEndTime);

                // Calculate the time difference
                $duration = $timeIn->diff($timeOut);

                // Format the duration
                $formattedDuration = $duration->format('%h hours and %i minutes');
            

            ?> 

            <div class="card border-0 shadow-sm">
                <div class="card-body">
                    <div class="row d-flex g-0">


                        <?php 
                            $InstituteID = $_GET['institution'];

                            $image = mysqli_query($link, "SELECT * FROM `institution` 
                                                            WHERE `institution`.InstitutionID = '$InstituteID'");
                            $image = mysqli_fetch_assoc($image);
                            $schImage = $image['InstitutionLogo'];
                        ?>
                        <div class="col-lg-1">
                            <img src="<?php echo $schImage ;?>" width="60" class="img-fluid" alt="...">
                        </div>
                        <div class="col-lg-11 mt-4">
                            <p class="fs-5 fw-normal"><?php echo $campusName;?></p>
                        </div>
                    </div>
                        
                    <div class="row">
                        
                        <div class="col-lg-6 col-sm-12">
                            <div class="card  mt-3 border-0">
                                    <?php 
                                    $image = mysqli_query($link, "SELECT * FROM `defaultimages` 
                                                                    WHERE defaultimages.ImageName = 'pros_cbt_onboardingimage'");
                                    $image_fetch = mysqli_fetch_assoc($image);
                                    $cbtImage = $image_fetch['BaseSixtyFour'];
                                    ?>
                                <img src="<?php echo $cbtImage; ?>"  class="img-fluid"  alt="...">
                            </div>
                        </div>

                        <div class="col-lg-6  mt-3">
                            <div class="card chiCourseList">

                                    <div class="row">
                                        <div class="col-12 ms-3 mt-3">
                                            <p class="fs-3 fw-bold"><?php echo $subjectName;?></p>
                                        </div>
                                    </div>

                                    <div class="row mt-5">
                                        <div class="col-lg-12 col-sm-6 ms-3 mt-1 d-flex">
                                            <p class="fw-bold me-2">Assesement Title: </p><span> <?php echo $title;?></span>
                                        </div>
                                        <div class="col-lg-12 col-sm-6 ms-3 mt-1 d-flex">
                                            <p class="fw-bold me-2">Assesement Type: </p><span> <?php echo $AssesementCategory;?></span>
                                        </div>
                                        <div class="col-lg-12 col-sm-6 ms-3 mt-1 d-flex">
                                            <p class="fw-bold me-2">Time Duration: </p><span> <?php echo $formattedDuration;?></span>
                                        </div>
                                        <div class="col-lg-12 col-sm-6 ms-3 mt-1 d-flex">
                                            <p class="fw-bold me-2">Number of Questions: </p><span> <?php echo $questionNumbers;?></span>
                                        </div>
                                    </div>
                                <?php
             }
                                ?>

                                    <div class="row mt-5">
                                        <div class="col-lg-11 col-sm-6 m-3">
                                            <a type="button" href="cbt_assement_page.php?cbt_id=<?php echo urlencode($cbtid); ?>&amp;userid=<?php echo urlencode($UserID); ?>&amp;examtype=<?php echo urlencode($examtype); ?>"
                                                    class="btn btn-success btn-lg float-end tari_start_btn" style="font-size: 18px; background-color: #1abc9c; border: #1abc9c solid 1px; width: 85px; border-radius: 10px;">
                                                Start
                                            </a>
                                        </div>
                                    </div>
                                    
                            </div>
                        </div>

                    </div>
                    
                  

                </div>
            </div>
        </div>


    <!--Custom JS--->
    <script src="../../js/user_js/students_js/studentsScript.js"></script>
    <script src="../../assets/plugins/bootstrap5/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/apexcharts/3.40.0/apexcharts.min.js"></script>


  

</body>

</html>

