<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{


?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

   <!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        <header id="header" class="header">

          

        </header><!-- /header -->
        <!-- Header-->

        

        <div class="content mt-3">

           


          
<div class="col-md-12">
                        <div class="card">
                          
<strong class="card-title"> <center> <img src="logo1.jpg" align="middle" /></center></strong>
                                <strong class="card-title"> <center> <h1><? echo "" . $_SESSION["userid"]; ?></h1></center></strong>
								 <strong class="card-title"><center>Test Wise Class Performance Result Report</center></strong>
								  
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';

$sess1=$_POST["sess1"];
$userid=$_SESSION["userid"];
 $sql1 = "SELECT * FROM term where  user_id='$userid'";
$result1=$conn->query($sql1);
while($row1 = $result1->fetch_assoc())
 
  {
  $tname=$row1['tname'] ;
  echo "<table border=1 width=100%>";
                                       echo "<tr>";
echo "<th colspan=4 bgcolor=#0099FF><center> $tname  </center> </th>";

echo "<th colspan=3 bgcolor=#0099FF><center> $sess1 </center> </th>";
echo "</tr>";
$sql2 = "SELECT * FROM addclass where  user_id='$userid'";
$result2=$conn->query($sql2);
while($row2 = $result2->fetch_assoc())
 
  {
  
  $cname=$row2['cname'] ;
  $tobtmark=0;
$ttotalmark=0;
$trecord=0;
   echo "<table border=1 width=100%>";
   echo "<tr>";
echo "<th colspan=7 bgcolor=#0099FF> $cname </th>";
echo "</tr>";
 
echo "<tr>";
echo "<th bgcolor=#000066><font face=arial size=3 color=white><center> Total Students</center></font></th>";
echo "<th bgcolor=#000066><font face=arial size=3 color=white><center> Total Mark</center></font></th>";
echo "<th bgcolor=#000066><font face=arial size=3 color=white><center> Obt Mark</center></font></th>";
echo "<th bgcolor=#000066><font face=arial size=3 color=white><center> Per%</center></font></th>";
echo "<th bgcolor=#000066><font face=arial size=3 color=white><center> Status</center></font></th>";
echo "<th bgcolor=#000066><font face=arial size=3 color=white><center> Grade</center></font></th>";
echo "<th bgcolor=#000066><font face=arial size=3 color=white> Remarks</font></th>";
echo "</tr>";
 
  $sql = "SELECT * FROM mtest where  term='$tname' and sess1='$sess1' and class_name='$cname' and user_id='$userid'";
  $result=$conn->query($sql);
while($row = $result->fetch_assoc())
{



echo "</tr>";

                                      
  $id = $row['id'];	
  
$tobtmark=$tobtmark + $row['obtmark'];
$ttotalmark=$ttotalmark + $row['totalmark'];
$trecord=$trecord + 1;
 
  }
		
 


	 $per = $tobtmark / $ttotalmark * 100;
if ($per >= 90)
{
$grd="A+";
$remk="Exceptional, Exceeds expectations with the quality of his /her work & Keep it up.";
}
elseif ($per >= 80)
{
$grd="A";
$remk="Excellent, Admirable progress in all academic area";
}
elseif ($per >= 70)
{
$grd="B+";
$remk="Very Good, Making Steady Progress Academically";
}
elseif ($per >= 60)
{
$grd="B";
$remk="Good,  Needs to pay attention for the quality of work";
}
elseif ($per >= 50)
{
$grd="C+";
$remk="Fair,Needs to increase skills in all written work & reading";
}
elseif ($per >= 40)
{
$grd="C";
$remk="Undertaking,Needs to demonstrate improvement in academic work ";
}
elseif ($per >= 33)
{
$grd="D";
$remk="Result is Unsatisfactory & the student is required to work hard";
}

else
{
$grd="E";
$remk="Fail";
}

	   echo "<tr>";
	echo "<td bgcolor=#000066 align=center><font face=arial size=3 color=white><b>" . $trecord ."</b></font></td>";
		
		echo "<td bgcolor=#000066 align=center><font face=arial size=3 color=white><b>" .$ttotalmark  . "</b></font></td>";
		echo "<td bgcolor=#000066 align=center><font face=arial size=3 color=white><b>" .$tobtmark  . "</b></font></td>";
		echo "<td bgcolor=#000066 align=center><font face=arial size=3 color=white><b>" . round($per,2) ."</b></font></td>";
		echo "<td bgcolor=#000066 align=center><font face=arial size=3 color=white></font></td>";
		echo "<td bgcolor=#000066 align=center><font face=arial size=3 color=white><b>" .$grd  . "</b></font></td>";
		echo "<td bgcolor=#000066 align=left><font face=arial size=3 color=white><b>" .$remk  . "</b></font></td>";
		echo "</tr>";
		echo "</table>";
		
		
  }
  
  }



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


        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
?>