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

<?php

$pageName = basename($_SERVER['PHP_SELF']);

 $m->where("page_name", $pageName);
 $pageNameAccess=$m->get("eduportal_modules_pages_detail");


$m->where("user_id", $_SESSION['user_id']);
$m->where ("branch_id", $_SESSION['branch']);
$m->where("page_id", $pageNameAccess[0]['page_id']);
$access = $m->get("users_privilege_detail");




       $branch=$_SESSION['branch'];
       
       $classes = $m->query("select * from edu_class_config where branch_id=".$branch." order by class_id asc limit 1");
       // print_r($classes);

$sql = "SELECT * FROM  eduportal_mcq_question_pool  WHERE branch_id='$branch'";

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

    if($_REQUEST['class_id']=="All"){
      $sql;
    } else {
    $sql .= " AND class_id = '" .$_REQUEST['class_id']. "' ";

    }

  if($_REQUEST['subject_id']!=''){
      $sql .= " AND subject_id ='" . $_REQUEST['subject_id']. "' ";
 }


 // echo $sql;

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

  $sql = "SELECT * FROM  eduportal_mcq_question_pool  WHERE branch_id='$branch'";
 $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; 
             Question Bank
             <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="mcqs.php" enctype="multipart/form-data" method="get">
         
                       
              <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Class</label>

            
                    <select name="class_id" 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">Subject</label>

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

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


                                <?php
                        } ?>

                    </select>

                  
                </div>
              </div>
              

               <div class="col-md-3 " style="">
                <div class="form-group ">
                  <button type="submit" class="btn btn-primary" style="margin-top: 31px;">Search</button>
                </div>
              </div>
  
           
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

     
 

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

<input type="hidden" name="action_call" value="DeleteSelectedQuestions"  />

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

<input onClick="return confirm('Are you sure you want to Delete Records?');" class="btn btn-danger pull-right" type="submit" name="deleteDiary" value=" Delete Selected Questions">

<div style="">

<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=""> Options </th>
                <th width="9%">Action </th>
                <th width="3%">

              <label class="container1"><input  type="checkbox" id="checkAll"/><span style="margin-top: -20%;border: 1px solid gray;" class="checkmark" ></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: 2px;"><?php echo $count++;?></td>        
          <td style="padding: 2px;" ><?php echo $class[0]['Class_Name'];?></td>
          <td style="padding: 2px;" ><?php echo $subject[0]['subject'];?></td>
          <td style="padding: 2px;" ><?php echo $chapter[0]['chapter_Name'];?></td>   
          <td style="padding: 2px;" ><?php echo $WorkAssignListVal['questions'];?></td>
          <td style="padding: 2px;" ><a data-toggle="modal" data-target="#Qoption<?php echo $WorkAssignListVal['question_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-success">Options</a> </td>     
             
            <!-- Employee Pay Salary Popup start -->


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

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

            <div class="modal-body">

<form class="form-style-7" action="" method="post"  enctype="multipart/form-data">

          
         
                      <div class="col-md-12">  
                        <?php foreach ($options as $option) {
                          echo $option['optionABCD']."    =    ".$option['option_details']."<br>";
                        } ?>

                    </div>


                    <div class="col-md-12" >
                          <div class="form-group" >
                            
                            <label>  Answer </label>
                            
                              <input style="height:40px;padding-left:1%;" type="text"  value="<?php echo $WorkAssignListVal['answer']; ?>"  class="form-control field" name="tdeduc" readonly/>
                          </div>
                    </div>


            <div class="modal-footer">

            <button type="submit" class="btn btn-primary" name="submit" >Submit </button>
              


            </div>



                 </form>

          </div>

          </div>

        </div>
      </div>

      <!-- Employee Pay Salary popup ending -->     
                  
                               
                 


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

      <?php if ($access[0]['edit_access']!=NULL) { ?>

      <a data-toggle="modal" data-target="#EditQuestion<?php echo $WorkAssignListVal['question_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-success">
                 <i class="fa fa-pencil" aria-hidden="true"></i>
                 </a>
      <?php } ?>

      <?php if ($access[0]['delete_access']!=NULL) { ?>

     <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?question=<?php echo $WorkAssignListVal['question_id'];?>&action=DeleteQuestion" 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>

      <?php } ?>
         


       <!-- Employee Edit Salary Popup start -->


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

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header" style="border-bottom:none;">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title" style="text-align:center;"> Edit Question</h4>
            </div>

            <div class="modal-body">

<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="EditMCQsQuestion"> 
          
           <input type="hidden" id="date"  name="question_id" value="<?php echo $WorkAssignListVal['question_id']; ?>" />
         
         
                         
                         

                <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  Questions </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $WorkAssignListVal['questions'];?>"  class="form-control field"  name="questions"/>
                      </div>
                </div>

                <?php foreach ($options as $optionanl) {?>
                 <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  <?php echo $optionanl['optionABCD'];?> </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $optionanl['option_details'];?>"  class="form-control field"  name="option_details[]"/>
                      </div>
                </div>
              <? } ?>

                <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  Answer </label>
                          <select id="" name="answer" class="form-control">

                          <option value="">Ans</option>
                          <option <?php if($WorkAssignListVal['answer']=="A"){echo "Selected";} ?> value="A">A</option>
                          <option <?php if($WorkAssignListVal['answer']=="B"){echo "Selected";} ?> value="B">B</option>  
                          <option <?php if($WorkAssignListVal['answer']=="C"){echo "Selected";} ?> value="C">C</option>
                          <option <?php if($WorkAssignListVal['answer']=="D"){echo "Selected";} ?> value="D">D</option>                  
                                                                
                        </select>
                      </div>
                </div>

            <div class="modal-footer">

            <button type="submit" style="margin: 30px;" class="btn btn-primary" name="submit" >Submit </button>
              


            </div>


                 </form>

          </div>

          </div>

        </div>
      </div>

      <!-- Employee Edit Salary popup ending -->




                  </td>

           <td style="padding: 2px;">
                <label class="container1">
            <input type="checkbox"  name="quest[]" value="<?php echo $WorkAssignListVal['question_id'];?>"><span style="border: 1px solid gray;" 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>
