<?php session_start();
unset($_SESSION['StartTime']);
require_once 'config.php';
//require_once '../dompdf/autoload.inc.php'; 
require_once 'auth.php';
$PageName = "Test Series";
$UserId = $_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">
</head>

<body class="body-scroll d-flex flex-column h-100 menu-overlay">
    <main class="flex-shrink-0 main">
        <?php include_once 'back-header.php'; ?> 
        <div class="main-container">
            <div class="container">
                <div class="card mb-4">
                  
                  <div class="card-body px-0 pt-0">
                        <div class="list-group list-group-flush border-top border-color">
                    
                     <?php 
            $i=1;
            $Group_Id = $_GET['Type'];
            $sql3 = "SELECT TestSeriesId FROM tbl_allocate_test_series WHERE DeptId='".$_GET['deptid']."' AND BatchId IN($BatchId) AND TestSeriesId IN($Group_Id)";
                 
                    //echo $sql3;
                    $row3 = getRecord($sql3);
                    $GroupId = $row3['TestSeriesId'];
                    if($GroupId!=''){
                    $sql2 = "SELECT GROUP_CONCAT(TestSeriesId) AS TestSeriesId FROM tbl_allocate_ts_groups WHERE GroupId IN($GroupId)"; 
                    $row2 = getRecord($sql2);
                    $TestSeriesId = $row2['TestSeriesId'];

                    $sql3 = "SELECT * FROM tbl_test_series WHERE id IN($TestSeriesId)";
                    $res2 = getList($sql3);
                    foreach($res2 as $row){ 

                      $TestId = $row['id'];
              $sql = "SELECT * FROM tbl_result WHERE TestId='$TestId' AND UserId='$user_id'";
              $rncnt = getRow($sql);


                      ?>
                      
                      <div class="list-group-item list-group-item-action border-color">
                                <div class="row">
                                    <div class="col-auto">
                                        <div class="avatar avatar-50 bg-default-light text-default rounded">
                                     <?php if($result["Photo"] == '') {?>
                                      <img src="no_image.jpg" style="width: 50px;height: 50px;"> 
                                      <?php } else {?>
                                      <img src="../uploads/<?php echo $result["Photo"];?>" style="width: 50px;height: 50px;">
                                      <?php }  ?>
                                    
                                        </div>
                                    </div>
                                    <div class="col align-self-center pl-0">
                                        <h6 class="mb-1"> <?php echo $row['TestName']; ?></h6>
                                    </div>
                                    <div class="col-auto" style="padding-top:10px;">
                                       <?php 
                                $FileUrl = $SiteUrl."app/".$FileUrl;
                if($rncnt > 0){?>
                  <a href="view-result.php?testid=<?php echo $row['id']; ?>" class="btn btn-success btn-finish">View Result</a>
              <?php } else{?>
                 <a href="start-test.php?testid=<?php echo $row['id']; ?>&deptid=<?php echo $_GET['deptid'];?>&courseid=<?php echo $_GET['courseid'];?>&page=test-series&tblname=tbl_test_series" class="btn btn-primary btn-finish">Start Test</a>
              <?php } ?>
                                    </div>
                                </div>
                            </div>
                            
                   
                    <?php $i++;}} else{?>
                        <h3 style="color:red;padding-left: 10px;font-size: 20px;">No Test Series Found</h3>
                    <?php }  ?>
                    
                </div>
                       
                </div>
            </div>
        </div>
    </main>
 <?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>
<script>
    function onDownloadFileFromUrl(url,filename){
        //alert(url);alert(filename);exit();
         Android.onDownloadFileFromUrl(''+url+'',''+filename+'');
    }
</script>
</body>
</html>
