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

<?php
$chapterIds=explode(",",$_REQUEST['chapters']);


       $branch=$_SESSION['branch'];
       $class=$_REQUEST['class_id'];
       $subject=$_REQUEST['subject_id'];
      

 

$sql = "SELECT * FROM  eduportal_mcq_question_pool  WHERE branch_id='$branch' and class_id='$class' and subject_id='$subject' AND ( ";

 $chap=" ";

        $counter=1;
        $size=count($chapterIds);
        foreach ($chapterIds as $chapterId) {

        if ($counter==$size) {
        
        $chap=$chap." chapter_id=".$chapterId; 

        } else {
        $counter++;
        $chap=$chap." chapter_id=".$chapterId." OR";
        }
                 
        }
    $sql .= $chap.") ";
  $WorkAssignListings = $m->query($sql);
//print_r($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">
            <div class="row" style="background-color: white;">
  

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

<h1>Select Manual Questions</h1> 

<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data">

<input type="hidden" name="action" value="InsertManualQuestions"  />

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


<div style="">

  <input type="submit" name="submit" 
             class="btn btn-primary pull-right"  value="Save Manual Questions"  />

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

              
                <th width="">S.No</th>
                <th width="">Class</th>
                <th width="">Subject</th>
                <th width=""> Chapter </th>
                <th width=""> Questions </th>
                <th width="5%">

              <label class="container1"><input  type="checkbox" id="checkAll"/><span class="checkmark" style="margin-top: -17px;"></span></label>
              
               </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("subject_id", $WorkAssignListVal['subject_id']);
        $subject=$m->get("eduportal_subject_config");

        $m->where("chapter_id", $WorkAssignListVal['chapter_id']);
        $chapter=$m->get("edu_create_subject_chapters");
        
        $m->where("question_id", $WorkAssignListVal['question_id']);
        $options=$m->get("eduportal_mcq_question_options");
      ?>

        <tr>

          <td style="text-align:center; padding: 4px;"><?php echo $count++;?></td>        
          <td style="padding: 4px;" ><?php echo $class[0]['Class_Name'];?></td>
          <td style="padding: 4px;" ><?php echo $subject[0]['subject'];?></td>
          <td style="padding: 4px;" ><?php echo $chapter[0]['chapter_Name'];?></td>   
          <td style="padding: 4px;" ><?php echo $WorkAssignListVal['questions'];?></td>
         
    <td style="padding: 4px;">
              <label class="container1">
                <input type="checkbox" name="questions[]" value="<?php echo $WorkAssignListVal['question_id'];?>"><span class="checkmark"></span>
              </label>

            </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>
