<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>

<?php

     /* code for advance Search*/

$branch=$_SESSION['branch'];
$section_id=$_REQUEST['section'];
$class_id=$_REQUEST['class_id'];
$test_id=$_REQUEST['test_id'];

if($_REQUEST['class_id']!=NULL){ 
$sql = "SELECT * FROM  edu_student_details as std, LMS_students_test as stdT  WHERE std.branch_id='$branch' and std.section_id='$section_id' and std.class_id='$class_id' and stdT.test_id='$test_id' and std.student_id=stdT.student_id group by stdT.student_id";

        
 // echo $sql;

  $WorkAssignListings = $m->query($sql);
} else {

  $sql = "SELECT * FROM  edu_student_details as std, LMS_students_test as stdT  WHERE std.branch_id='$branch' and stdT.test_id='$test_id' and std.student_id=stdT.student_id group by stdT.student_id";
 $WorkAssignListings = $m->query($sql); 
}

 ?>

<!DOCTYPE html>
<html lang="en">
  <head>
   
    <title> View Students | EduPortal </title>
     <?php include('RootMe/css_links.php');?> 
  </head>
  


  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
            <div class="right_col" role="main">

               <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
              Test Marks Report
          <br><br>
          
            <div class="row" style="background-color: white;">
  

<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">



 <div class="" style="margin-top:10px;">



      <form class="" action="result_report.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">
          <div class="panel-heading"><?php echo count($WorkAssignListings);?> Students Records <span style="float:right;margin-top: -7px;">

          <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />


        <div class="pull-right">  


               <?php 

 if($_REQUEST['class_id']!=NULL){

?>


  <a  href="print_marks_report.php?test_id=<?php echo $_REQUEST['test_id'];?>&class_id=<?php echo $_REQUEST['class_id'];?>&section=<?php echo $_REQUEST['section'];?>" class="btn btn-primary">Print Result Sheet</a>

<?php 
   }
?>       

          <a onClick="$('#advanceSearch').toggle('blind')" class=" btn btn-primary" style="cursor:pointer;float: right;">Advance Search</a>
      
        </div>







          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            <div class="col-md-12" id="advanceSearch" style="display:none;">

                <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Test</label>

            
                    <select name="test_id" class="form-control" >
                     <option value="All">Select Test</option> 
                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("eduportal_create_test");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['test_id']==$WorkAssignListVal['test_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['test_id']; ?>"><?php echo $WorkAssignListVal['title']; ?></option>


                            <?php
                    } ?>

                    </select>

                  
                </div>
              </div>
            
              <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Class</label>

            
                    <select name="class_id" onChange="getsec(this.value)" class="form-control" >
                     <option value="All">All</option> 
                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("edu_class_config");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>


                            <?php
                    } ?>

                    </select>

                  
                </div>
              </div>
              
              
              <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Section</label>
                    <select name="section" id="txt_section" class="form-control" >
                      
                   <?php
                              if($_REQUEST['section']!='')
                              { 

                              $m->where("class_id", $_REQUEST['class_id']);    

                              $secondLevel = $m->get("edu_adm_section_detail");
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>
                                <option <?php if($_REQUEST['section']==$secondLevel_val['section_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['section_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['section_name'])); ?></option>

                              <?php }   ?>
                                
                          <?php } ?>

                    </select>

                  
                </div>
              </div> 

               <div class="col-md-3 pull-right" style="padding:2px;">
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="float: right;">Search</button>
                </div>
              </div>

             
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

     
          
          <?php  if(isset($_SESSION['addsuccess'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student record is added successfully...
            </div>
          <?php  unset($_SESSION['addsuccess']); }?>

      
          
          <?php  if(isset($_SESSION['reEnroll'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student has been re-enrolled successfully...
            </div>
          <?php  unset($_SESSION['reEnroll']); }?>



          
          <?php  if(isset($_SESSION['upsuccess'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student record is updated successfully...
            </div>


          <?php  unset($_SESSION['upsuccess']); }
          ?>

 

<form action="manage_students.php" enctype="multipart/form-data" method="post">


<input type="hidden" value="<?php echo $_REQUEST['class_id']; ?>" name="class_id" />
<input type="hidden" value="<?php echo $_REQUEST['section']; ?>" name="section" />


<div style="">

<table id="listofstudents" class="table table-striped table-bordered" style="width:100%">

  
   
        <thead>
            <tr>

              
                <th width="5%">S.No</th>
                <th width="20%">Student Name</th>
                <th width="10%">Father Name</th>
                <th width="10%"> Cell </th>
                <th width="10%"> Total </th>
                <th width="8%">Obtaiend </th>
                <th width="8%">Detaild </th>
                

              
                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 
$count=1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $m->where("class_id", $WorkAssignListVal['class_id']);
        $class=$m->get("edu_class_config");

        $m->where("section_id", $WorkAssignListVal['section_id']);
        $section=$m->get("edu_adm_section_detail");

        /*$m->where("student_id", $WorkAssignListVal['student_id']);
        $studentData=$m->get("edu_student_details");
        */
      ?>

        <tr>

          <td style="text-align:center; padding: 2px;"><?php echo $count++;?></td>        
          <td style="padding: 2px;" ><?php echo $WorkAssignListVal['first_name'];?></td>
          <td style="padding: 2px;" ><?php echo $WorkAssignListVal['last_name'];?></td>
          <td style="padding: 2px;"> <?php echo $WorkAssignListVal['cell_no'];?> </td>
          <td style="padding: 2px;"> <?php echo $WorkAssignListVal['test_total_marks'];?> </td>
          <td style="padding: 2px;"> <?php echo $WorkAssignListVal['test_obtaiend_marks'];?> </td>       
                  
                   


                <td style="padding: 2px;">

            <a class="btn btn-success" style="padding: 0px 5px; font-size:14px;color:white;" data-toggle="modal" data-target="#OnlineTest<?php echo $WorkAssignListVal['student_id'];?>" >View More </a>

             <!-- Student Lecture popup start -->


      <div id="OnlineTest<?php echo $WorkAssignListVal['student_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog" style="">

          <!-- Modal content-->
          <div class="modal-content" style="">
            <div class="modal-header" style="border-bottom:none;">
              
              <h4 class="modal-title" style="text-align:center;"> <?php echo $WorkAssignListVal['first_name'];?> Results </h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>

            <div class="modal-body">


              
                   
                  <div class="col-md-12 col-sm-12 col-xs-12" style="padding:8px;"  id="">

                           <table class="table display data-table text-nowrap">
                                <thead>
                                    <tr>
                                       
                                        <th width="">Subject</th>
                                        <th width="">Duration-Mint</th>
                                        <th width="">Questions</th> 
                                        <th width="">Total</th>
                                        <th width="">Obt</th>
                                        <th width="">Del</th>
                                     
                                   
                                
                                    </tr>
                                </thead>
                                <tbody>
<?php
$test=$WorkAssignListVal['test_id'];
$query1="SELECT * FROM eduportal_LMS_test_subject_details where test_id='$test' and class_id='$class_id' and branch_id='$branch'";
//print_r($query1);
$testSubDetails = $m->query($query1);
foreach ($testSubDetails as $testSubDetail) {
    
  $m->where("subject_id", $testSubDetail['subject_id']);
  $subject=$m->get("eduportal_subject_config");

 $m->where("subject_id", $testSubDetail['subject_id']);
 $m->where("test_id", $testSubDetail['test_id']);
 $m->where("student_id", $WorkAssignListVal['student_id']);
 $testresult=$m->get("LMS_students_test"); 


?>

        <tr>
            <td><?php echo $subject[0]['subject'];?></td>
            <td><?php echo $testSubDetail['duration'];?></td>
            <td><?php echo $testSubDetail['number_of_questions'];?></td>
            <td><?php echo $testresult[0]['test_total_marks'];?></td>
            <td><?php echo $testresult[0]['test_obtained_marks'];?></td>
            <td>
              <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?student_id=<?php echo $WorkAssignListVal['student_id'];?>&test_id=<?php echo $testSubDetail['test_id'];?>&subject_id=<?php echo $testSubDetail['subject_id'];?>&action=DeleteStudentSubjectTest" style="padding: 0px 5px; font-size:14px;" onClick="return confirm('Are you sure you want to delete this record');"  class="btn btn-danger"><i class="fa fa-remove"></i> </a>
            </td>
            
           
               <?php }  ?>
           
            

           
            
        </tr>
       
                                            
                                                
                                            </tbody>
                                        </table>
                  </div>

                                
      
            <div class="modal-footer">

                      


            </div>



                 

          </div>

          </div>

        </div>
      </div>

      <!-- Student Lecture popup ending -->
          
                  </td>



              </tr>





              <?php
      } ?>
 
        </tbody>
        
    </table>

  </div>

    </form>

    <br><br>


  </div>
  <div class="clearfix"></div>
</section>

        </div> 
        </div>


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


     
        <!-- /page content -->


 <!-- jQuery -->
    <script src="js/ajax_functions.js"></script>
  <?php include('RootMe/js_linksscript.php');?> 
  <!-- Links for Datatable-->

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
 <script>
        
  $(document).ready(function() {
    $('#listofstudents').DataTable({
      "pageLength": 100
    });
    } 
  );

  $("#checkAll").change(function () {

      $("input:checkbox").prop('checked', $(this).prop("checked"));
  });


</script>
  
  </body>
</html>
