<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class autopaper extends CI_Controller {

    private $userInfo = array();

    public function __construct()
    {
        parent::__construct();
      $this->load->library('session');
        $this->load->model("user_model");
        $this->load->model("autopaper_model");
        $this->user_model->check_login("admin");
        $this->load->library("pagination");
        $this->userInfo = $this->user_model->userInfo("first_name,last_name");
    }

                /*==========================================================*/
    public function question_type($p=1)
     {
      $this->user_model->check_permissions("autopaper/question_type");
         $data['is_super'] = $this->user_model->is_super();
         $data['menu'] = $this->load_model->menu();
         $branch=$this->user_model->getbranch();
            if($this->user_model->is_super())
                $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
            else
                $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
         $total = $this->db->query("SELECT count(*) as total FROM `question_type` where is_delete='0'")->result_array()[0]['total'];
         $per_page = 10;
         $offset = ($p - 1) * $per_page;
           if(!$this->user_model->is_super())
           {
                 $this->db->where('branch',$branch);

           }
         $this->db->where('is_delete','0');
         $this->db->select("*"); 
         $this->db->from('question_type');
         $this->db->limit($per_page,$offset);
         $query = $this->db->get();
         $data['base_url'] = base_url();
         $data['userInfo'] = $this->userInfo;
         $data['question'] = $query->result_array();
         $data['total'] = ceil($total / $per_page);
         $this->load->view('header',$data);
         $this->load->view('sidebar',$data);
         $this->load->view('autopaper/questionType',$data);
    }

    public function save_question_type()
    {
      if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_question_type($data);
        redirect("autopaper/question_type","refresh");
    }
    else{
        redirect("autopaper/question_type","refresh");

    }
  }
  
    public function yes()
    {
      $datt=$this->input->post("answer");
      
      $branch=$this->user_model->getBranch();
     //var_dump($data['data']);
     //die();

     // var_dump();
     // die();
      
      
      
          
      $data =json_decode($datt);
    
   // var_dump(json_decode($data));   
    //var_dump($data);
      //die();
      
    // $this->load->view('header',$data);
    // $this->load->view('sidebar',$data);
    $this->load->view('autopaper/paper_print_answer',$data);     
        
    }

    public function delete_question_type()
    {
        if($this->uri->segment(3))
        {
            $id=$this->uri->segment(3);
            $this->autopaper_model->delete_question_type($id);
           redirect("autopaper/question_type","refresh");

        }
        else
        {
           redirect("autopaper/question_type","refresh");

        }
    }
  public function  edit_question_type()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_question_type($id);
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_questionType',$data);    
    }
  }
  public function update_question_type()
  {
      if($this->input->post())
      {
        $data = $this->input->post();
        $this->autopaper_model->update_question_type($data);
        redirect("autopaper/question_type","refresh");
      }
    else{
        redirect("autopaper/question_type","refresh");
    }
  }
/*=================================Custom Pagination style==========================*/

// public function chapter($q="all",$p=1)
// {
//        $this->user_model->check_permissions("autopaper/chapter");

//          $data['is_super'] = $this->user_model->is_super();
//          $data['menu'] = $this->load_model->menu();
//          $branch=$this->user_model->getbranch();
//             if($this->user_model->is_super())
//                 $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
//             else
//                 $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
//         $per_page = 10;
//         $offset = ($p - 1) * $per_page;
//         $q = urldecode($q);
//         $p = $p<1?1:$p;
//         $per_page = 10;
//         $offset = ($p - 1) * $per_page;
//         $sq1 = "";
//         if($q!="all")
//         {
//             $sq1 .= "AND (subject.name like '%".$q."%' OR ";
//             $sq1 .= "chapters.name like '%".$q."%' OR ";
//             $sq1 .= "class_name like '%".$q."%' OR "; 
//             $sq1 .= "chapterNo like '%".$q."%' )";
//         }
//         $total = $this->db->query("SELECT count(*) as total   FROM `chapters` inner join `class` on class.class_id=chapters.class_id inner join `subject` on subject.id=chapters.subject_id  where chapters.is_delete='0' $sq1 LIMIT 0, $per_page")->result_array()[0]['total'];
//          if($total<=$offset)
//          {
//                 $query = $this->db->query("SELECT chapters.id,subject.name as sub,chapters.name as cha,class.class_name,chapters.chapterNo  FROM `chapters` inner join `class` on class.class_id=chapters.class_id inner join `subject` on subject.id=chapters.subject_id where chapters.is_delete='0' $sq1 LIMIT 0, $per_page");
//                 $p=1;
//                 }else
//         $query = $this->db->query("SELECT chapters.id,subject.name as sub,chapters.name as cha,class.class_name,chapters.chapterNo  FROM `chapters` inner join `class` on class.class_id=chapters.class_id inner join `subject` on subject.id=chapters.subject_id  where chapters.is_delete='0' $sq1 LIMIT $offset, $per_page");
//          $data['q'] = $q;
//          $data['curr'] = $p;
//          $data['searchq'] = $q;         
//          $data['base_url'] = base_url();
//          $data['userInfo'] = $this->userInfo;
//          $data['question'] = $query->result_array();
//          $data['end'] = ceil($total / $per_page);
//          $this->load->view('header',$data);
//          $this->load->view('sidebar',$data);
//          $this->load->view('autopaper/chapters',$data);
// }
//==================================================================================================================

//===============================================New Controler for view of chapter function================================
public function chapter()
{
       $this->user_model->check_permissions("autopaper/chapter");
         $data['is_super'] = $this->user_model->is_super();
         $data['menu'] = $this->load_model->menu();
         $branch=$this->user_model->getbranch();
            if($this->user_model->is_super()){
                $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
            }else{
                $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
                $query = $this->db->query("SELECT chapters.id,subject.name as sub,chapters.name as cha,class.class_name,chapters.chapterNo  FROM `chapters` inner join `class` on class.class_id=chapters.class_id inner join `subject` on subject.id=chapters.subject_id  
                                           where chapters.is_delete='0' and chapters.branch=$branch");
                }
                
         $data['base_url'] = base_url();
         $data['userInfo'] = $this->userInfo;
         $data['question'] = $query->result_array();
         $this->load->view('header',$data);
         $this->load->view('sidebar',$data);
         $this->load->view('autopaper/chapters',$data);
}

public function chapter_undo()
{
   $this->user_model->check_permissions("autopaper/chapter");
         $data['is_super'] = $this->user_model->is_super();
         $data['menu'] = $this->load_model->menu();
         $branch=$this->user_model->getbranch();
            if($this->user_model->is_super()){
                $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
            }else{
                $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
                $query = $this->db->query("SELECT chapters.id,subject.name as sub,chapters.name as cha,class.class_name,chapters.chapterNo  FROM `chapters` inner join `class` on class.class_id=chapters.class_id inner join `subject` on subject.id=chapters.subject_id  where chapters.is_delete='1' and chapters.perm_delete='0' and chapters.branch=$branch");
                }
         $data['base_url'] = base_url();
         $data['userInfo'] = $this->userInfo;
         $data['question'] = $query->result_array();
         $this->load->view('header',$data);
         $this->load->view('sidebar',$data);
         $this->load->view('autopaper/chapters_undo',$data); 
}


//===================================================undo view of chapter====================================
public function delete_chapter_undo()
{
  $id=$this->uri->segment(3);
   $done=$this->db->where('id',$id)->update('chapters',array('is_delete'=>0));
   if($done)
   {
    $this->session->set_flashdata('msg','Chapter is deleted Successfully!');
    redirect('autopaper/chapter_undo');
   }
   else{
    echo 'not Undo';
   }

}
public function perm_delete_chapter_undo()
{
  $id=$this->uri->segment(3);
   $done=$this->db->where('id',$id)->update('chapters',array('perm_delete'=>1));
   if($done)
   {
    $this->session->set_flashdata('msg','Chapter is deleted Successfully!');
    redirect('autopaper/chapter_undo');
   }
   else{
    echo 'not Undo';
   }

}

//===================================================delete view of chapter====================================
public function delete_chapter()
{
  $id=$this->uri->segment(3);
   $done=$this->db->where('id',$id)->update('chapters',array('is_delete'=>1));
   if($done)
   {
    $this->session->set_flashdata('msg','Chapter is deleted Successfully!');
    redirect('autopaper/chapter');
   }
   else{
    echo 'not delete';
   }

}

public function edit_ho()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edithomo',$data);    
    }
  }

//===================================================edit view of chapter====================================
public function  edit_chapter()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"chapters");
      //var_dump($data['val']);die();
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/chapter_edit',$data);    
    }
  }


//================================Save edit data of chapter===========================
public function save_edit_chapter()
{
     if($this->input->post()){
        $data = $this->input->post();
        //var_dump($data);die();
        $db_insert = $this->autopaper_model->save_edit_chapter($data);
        redirect("autopaper/chapter","refresh");
    }
    else{
        redirect("autopaper/chapter","refresh");
    }  
}

//==========================Save Chapter=================================
public function save_chapter()
{
     if($this->input->post()){
        $data = $this->input->post();
        //var_dump($data);die();
        $db_insert = $this->autopaper_model->save_chapter($data);
        redirect("autopaper/chapter","refresh");
    }
    else{
        redirect("autopaper/chapter","refresh");
    }  
}
/*======================================================================*/
public function question()
{
         $this->user_model->check_permissions("autopaper/question");
         $data['is_super'] = $this->user_model->is_super();
         $data['menu'] = $this->load_model->menu();
         $branch=$this->user_model->getbranch();
            if($this->user_model->is_super())
                $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
            else
                $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
         $data['base_url'] = base_url();
         $data['userInfo'] = $this->userInfo;
         $this->load->view('header',$data);
         $this->load->view('sidebar',$data);
         $this->load->view('autopaper/questions',$data);
}
//=============================show data regarding question preview===================================
public function get_question()
{
      if($this->session->flashdata('id')){
                     
                     $get_id=$this->session->flashdata('id');
                      $data['is_super'] = $this->user_model->is_super();
                       $data['menu'] = $this->load_model->menu();
                     $branch=$this->user_model->getbranch();
                 if($this->user_model->is_super())
                     $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
                else
                     $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
                     $data['base_url'] = base_url();
                     $data['userInfo'] = $this->userInfo;
          if($get_id==1)
           {
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/mcq_question',$data);
           }
          elseif($get_id==2)
          {
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/short_question',$data);
          } 
          elseif($get_id==3)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/long_question',$data);
          }
          elseif($get_id==4)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/fill_blanks',$data);
          }
          elseif($get_id==5)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/paragraph_question',$data);
          }
          elseif($get_id==6)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/letter_question',$data);
          }
          elseif($get_id==7)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/application_question',$data);
          }
          elseif($get_id==8)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/summary_question',$data);
          }
          elseif($get_id==9)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/essay_question',$data);
          }
          elseif($get_id==10)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/poem_question',$data);
          }
          elseif($get_id==11)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/singular_plural_question',$data);
          }
          elseif($get_id==12)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/oppsites_question',$data);
          }
          elseif($get_id==13)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/centeralidea',$data);
          }
          elseif($get_id==14)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/translateintoeng',$data);
          }
          elseif($get_id==15)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/makesentence',$data);
          }
          elseif($get_id==16)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/wordsmeanings',$data);
          }
          elseif($get_id==17)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/superlative',$data);
          }
          elseif($get_id==18)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/ideoms',$data);
          }
          elseif($get_id==19)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/truefalse',$data);
          }elseif($get_id==20)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/grammer',$data);
          }elseif($get_id==21)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/masculine_feminine',$data);
          } elseif($get_id==22)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/words_synonyms',$data);
          } elseif($get_id==23)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/words_antonyms',$data);
          }elseif($get_id==24)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/Rearrange_sentence',$data);
          }elseif($get_id==25)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/verbs',$data);
          }elseif($get_id==26)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/underline_words',$data);
          }elseif($get_id==27)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/match_column',$data);
          }elseif($get_id==28)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/match_words',$data);
          }
          elseif($get_id==29)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/rhymingwords',$data);
          } elseif($get_id==30)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/active_wise',$data);
          }elseif($get_id==31)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/passive_wise',$data);
          }elseif($get_id==32)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/direct_sentence',$data);
          }elseif($get_id==33)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/indirect_sentence',$data);
          }elseif($get_id==34)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/remove_sentence',$data);
          }elseif($get_id==35)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/mark_sign',$data);
          }
          
          elseif($get_id==36)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/homephone',$data);
          }
          elseif($get_id==37)
          {
             // var_dump("hello");die();
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/drawing',$data);
          }
          
           
           
                     
       }// end if flash data
      else{
          $value=$this->input->post('question');
          $data['is_super'] = $this->user_model->is_super();
          $data['menu'] = $this->load_model->menu();
          $branch=$this->user_model->getbranch();
            if($this->user_model->is_super())
                $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
            else
                $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
                $data['base_url'] = base_url();
                $data['userInfo'] = $this->userInfo;
         if($value==1)
           {
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/mcq_question',$data);
           }
          elseif($value==2)
          {
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/short_question',$data);
          } 
          elseif($value==3)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/long_question',$data);
          }
          elseif($value==4)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/fill_blanks',$data);
          }
          elseif($value==5)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/paragraph_question',$data);
          }
          elseif($value==6)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/letter_question',$data);
          }
          elseif($value==7)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/application_question',$data);
          }
          elseif($value==8)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/summary_question',$data);
          }
          elseif($value==9)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/essay_question',$data);
          }
          elseif($value==10)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/poem_question',$data);
          }
          elseif($value==11)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/singular_plural_question',$data);
          }
          elseif($value==12)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/oppsites_question',$data);
          }
          elseif($value==13)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/centeralidea',$data);
          }
          elseif($value==14)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/translateintoeng',$data);
          }
          elseif($value==15)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/makesentence',$data);
          }
          elseif($value==16)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/wordsmeanings',$data);
          }
          elseif($value==17)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/superlative',$data);
          }
          elseif($value==18)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/ideoms',$data);
          }
          elseif($value==19)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/truefalse',$data);
          }elseif($value==20)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/grammer',$data);
          }elseif($value==21)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/masculine_feminine',$data);
          } elseif($value==22)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/words_synonyms',$data);
          } elseif($value==23)
          {
            $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/words_antonyms',$data);
          }elseif($value==24)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/Rearrange_sentence',$data);
          }elseif($value==25)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/verbs',$data);
          }elseif($value==26)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/underline_words',$data);
          }elseif($value==27)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/match_column',$data);
          }elseif($value==28)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/match_words',$data);
          }
          elseif($value==29)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/rhymingwords',$data);
          } elseif($value==30)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/active_wise',$data);
          }elseif($value==31)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/passive_wise',$data);
          }elseif($value==32)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/direct_sentence',$data);
          }elseif($value==33)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/indirect_sentence',$data);
          }elseif($value==34)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/remove_sentence',$data);
          }elseif($value==35)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/mark_sign',$data);
          }
           elseif($value==36)
          {
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/homephone',$data);
          }
            elseif($value==37)
          {
             // var_dump("helloasd"); die();
             $this->load->view('header',$data);
            $this->load->view('sidebar',$data);
            $this->load->view('autopaper/drawing',$data);
          }
          
           else
          {
            redirect('autopaper/question','refresh');
          }
  }// end else of flash data
          
}
//=================================save short question=====================================
public function save_short_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $count=count($que);
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question' =>htmlspecialchars($que[$i]),
            );
            //var_dump(htmlspecialchars($que[$i]));
           // die();
     $this->autopaper_model->save_short_question($Name);
    }
    redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Short Questions====================================
public function  edit_shortquestions()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"short_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_shortquestion',$data);    
    }
  }
//================================Save edit data of Short Questions===========================
public function save_edit_short()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_short($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}
//==================================save long question===========================


public function save_long_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $count=count($que);
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question' =>htmlspecialchars($que[$i]),
            );
             $this->db->insert('long_questions',$Name);
             
        }
         $this->db->query("UPDATE  long_questions
         SET `question` = REPLACE(`question`, '&amp;lt;', '<')
                  WHERE `question` LIKE '%&amp;lt;%'"); 
                  
                  $this->db->query("UPDATE  long_questions
         SET `question` = REPLACE(`question`, '&amp;gt;', '>')
                  WHERE `question` LIKE '%&amp;gt;%'");
                  
                  $sub='"';
                   $this->db->query("UPDATE  long_questions
         SET `question` = REPLACE(`question`, '&qout;','$sub')
                  WHERE `question` LIKE '%&qout;%'");
                  
                   $this->db->query("UPDATE  long_questions
         SET `question` = REPLACE(`question`, '&lt;', '<')
                  WHERE `question` LIKE '%&lt;%'");
                  
                   $this->db->query("UPDATE  long_questions
         SET `question` = REPLACE(`question`, '&gt;', '>')
                  WHERE `question` LIKE '%&gt;%'");
                  
            redirect('autopaper/question','refresh');
  }
  else{
             redirect('autopaper/question','refresh');
      }
}





//===================================================edit view of Long Questions====================================
public function  edit_longquestion()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"long_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_longquestions',$data);    
    }
  }
//================================Save edit data of long Questions===========================
public function save_edit_long()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_long($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}




public function save_homophone()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
       $que2=$this->input->post('question2');
      $count=count($que);
      $type="36";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'homo_word1' => $que[$i],
                          'homo_word2'=> $que1[$i],
                          'homo_word3'=> $que2[$i],
            );
   
     $this->db->insert('general_questions',$Name);
    }
    $this->session->set_flashdata('id',36);
   redirect('autopaper/get_question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}




//==================================save msqs======================================
public function save_mcq_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
            
            $o1=$this->input->post('options1');
            $o2=$this->input->post('options2');
            $o3=$this->input->post('options3');
            $o4=$this->input->post('options4');
            $correct=$this->input->post('correct');
//   var_dump('<pre>',$correct);
//         die();   
       $count=count($que);
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question' => $que[$i],
                          'option1' => $o1[$i],
                          'option2' => $o2[$i],
                          'option3' => $o3[$i],
                          'option4' => $o4[$i],
                          'correct_answer' => $correct[$i][0],
            );
          $this->db->insert('mcq_questions',$Name);
    }
 $this->session->set_flashdata('id',1);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of MCQ's====================================
public function  edit_mcq()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"mcq_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_mcq',$data);    
    }
  }
//================================Save edit data of MCQ's===========================
public function save_edit_mcq()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_mcq($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//========================================save general questions(Fill in Blanks)====================================
public function GeneralQuestion()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $correct=$this->input->post('correct');
      $count=count($que);
      $type="4";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'fill_blank_question' => $que[$i],
                          'fill_blank_ans' => $correct[$i],
            );
          $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',4);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of MCQ's====================================
public function  edit_fill()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_fill',$data);    
    }
  }
//================================Save edit data of MCQ's===========================
public function save_edit_fill()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_fill($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}
//=================================save Paragraph question=====================================
public function save_paragraph_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $count=count($que);
      $type="5";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'paragraph' => $que[$i],
                          
            );
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',5);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Paragraph Questions====================================
public function  edit_paragraph()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_paragraph',$data);    
    }
  }
//================================Save edit data of Paragraph Questions===========================
public function save_edit_paragraph()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_paragraph($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}
//=================================save Letter question=====================================
public function save_Letter_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump($data);die();
      $que=$this->input->post('question');
      $count=count($que);
      $type="6";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'letter' => $que[$i],
                          
            );
           // var_dump($Name);die();
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',6);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save drawing question=====================================

 private function do_uploads()
    {
        $type = explode('.', $_FILES["img"]["name"]);
        $type = $type[count($type)-1];
        $url = "./images/".uniqid(rand()).'.'.$type;
        if (in_array($type, array("png","jpg","jpeg","gif")))
            if(move_uploaded_file($_FILES["img"]["tmp_name"], $url))
                return $url;
        return ""; 
    }
    
public function save_drawing_question()
{
    //var_dump($this->input->post()); die();
  if($this->input->post())
    {
        $images=$this->paths();
     // var_dump($done); die();
      $data=$this->input->post();
      //var_dump($data);die();
     // $url=$this->do_upload();
      $que=$this->input->post('question');
      $img=$this->input->post('img');
    // var_dump($img); die();
      $count=count($que);
      
foreach($que as $key => $value)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question' => $que[$key],
                          'image' => $images[$key],
                          'is_delete'=>'0'
            );
         // var_dump('<pre>',$Name);     
     $this->db->insert('drawing_question',$Name);
    }
   // die(); 
     $this->session->set_flashdata('id',37);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}


public function paths() 
{
    $this->load->library('upload');
  $dataInfo = array();
  $images= array();
  $files = $_FILES;
  //var_dump($files); die();
  $cpt = count($_FILES['img']['name']);
  for($i=0; $i<$cpt; $i++)
  {           
   $_FILES['img']['name']= $files['img']['name'][$i];
   $_FILES['img']['type']= $files['img']['type'][$i];
   $_FILES['img']['tmp_name']= $files['img']['tmp_name'][$i];
   $_FILES['img']['error']= $files['img']['error'][$i];
   $_FILES['img']['size']= $files['img']['size'][$i];    
   $this->upload->initialize($this->set_upload_options());
   $res = $this->upload->do_upload('img');
   if(!$res){
    var_dump('<pre>',$this->upload->display_errors());die();
   }
       $images[] = "./imgs/".$this->upload->data()['file_name'];
  }
    return $images;
}

 function set_upload_options()
 { 
 // upload an image options
     $config = array();
     $config['upload_path'] = './imgs/'; //give the path to upload the image in folder
     $config['allowed_types'] = 'gif|jpg|png';
     $config['remove_spaces']=TRUE;
     $config['encrypt_name'] = TRUE; // for encrypting the name
     $config['allowed_types'] = 'gif|jpg|png';
     $config['max_size'] = '10000';
     $config['overwrite'] = FALSE;
     return $config;
 }
  



//===================================================edit view of letter Questions====================================
public function  edit_letter()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_letter',$data);    
    }
  }
//================================Save edit data of Letter Questions===========================
public function save_edit_letter()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_letter($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}


//=================================save Application question=====================================
public function save_Application_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $count=count($que);
      $type="7";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'application' => $que[$i],
                          
            );
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',7);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Application Questions====================================
public function  edit_application()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_application',$data);    
    }
  }
//================================Save edit data of Letter Questions===========================
public function save_edit_application()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_application($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//=================================save Summary question=====================================
public function save_Summary_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $count=count($que);
      $type="8";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'summary' => $que[$i],
                          
            );
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',8);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Summary Questions====================================
public function  edit_summary()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_summary',$data);    
    }
  }
//================================Save edit data of Letter Questions===========================
public function save_edit_summary()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_summary($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//=================================save Essay question=====================================
public function save_Essay_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump($data);die();
      $que=$this->input->post('question');
      $count=count($que);
      $type="9";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'essay' => $que[$i],
                          
            );
           // var_dump($Name);die();
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',9);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Essay Questions====================================
public function  edit_essay()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_essay',$data);    
    }
  }
//================================Save edit data of Letter Questions===========================
public function save_edit_essay()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_essay($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//=================================save Poem question=====================================
public function save_Poem_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump($data);die();
      $que=$this->input->post('question');
      $count=count($que);
      $type="10";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'poem' => $que[$i],
                          
            );
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',10);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Poem Questions====================================
public function  edit_poem()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_poem',$data);    
    }
  }
//================================Save edit data of Letter Questions===========================
public function save_edit_poem()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_poem($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//=================================save Singular and Plural question=====================================
public function save_Singular_Plural_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump("<pre>",$data);die();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      //var_dump("<pre>",$que,$que1);die();
      $count=count($que);
      $type="11";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'singular' => $que[$i],
                          'plural' => $que1[$i],
            );
           // var_dump($Name);die();
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',11);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of sp====================================
public function edit_sp()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_sp',$data);    
    }
  }
//================================Save edit data of Ideoms===========================
public function save_edit_sp()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_sp($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}
//=================================save Opposites question=====================================
public function save_Opposites_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump("<pre>",$data);die();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      //var_dump("<pre>",$que,$que1);die();
      $count=count($que);
      $type="12";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'opposites' => $que[$i],
                          'opposites_ans' => $que1[$i],
            );
           // var_dump($Name);die();
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',12);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Opposites====================================
public function edit_opposites()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_opposites',$data);    
    }
  }
//================================Save edit data of Opposites===========================
public function save_edit_opposites()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_opposites($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}
//==================================save Centeral Idea question===========================
public function save_centeral_idea()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
       $count=count($que);
       $type="13";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'centeral_idea' => $que[$i],
            );
            //var_dump($Name);die();
      $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',13);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//==================================save mark_sign question===========================
public function save_mark_sign()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
       $count=count($que);
       $type="35";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'mark_sign' => $que[$i],
            );
            //var_dump($Name);die();
      $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',35);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//===================================================edit view of Centeral Idea====================================
public function edit_centeralidea()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_centeralidea',$data);    
    }
  }
//===================================================edit view of mark_sign====================================
public function edit_mark_sign()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_mark_sign',$data);    
    }
  }

//================================Save edit data of Centeral Idea===========================
public function save_edit_centeralidea()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_centeralidea($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}


//================================Save edit data of mark the sign===========================
public function save_edit_mark_sign()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_mark_sign($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//==================================save Translate into eng===========================
public function save_translate_eng()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
       $count=count($que);
       $type="14";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'translate_english' => $que[$i],
            );
            //var_dump($Name);die();
      $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',14);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Translate into Eng====================================
public function edit_translateintoeng()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_translateintoeng',$data);    
    }
  }
//================================Save edit data of Translate Into English===========================
public function save_edit_eng()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_eng($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//==================================save Word for making sentence===========================
public function save_wordforsentence()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
       $count=count($que);
       $type="15";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'wordforsentence' => $que[$i],
            );
            //var_dump($Name);die();
      $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',15);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of Sentence====================================
public function edit_sentence()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_sentence',$data);    
    }
  }
//================================Save edit data of Make Sentence to Words===========================
public function save_edit_sentence()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_sentence($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//=================================save Words question=====================================
public function save_words_meanings()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      $count=count($que);
      $type="16";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'words' => $que[$i],
                          'meanings' => $que1[$i],
            );

     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',16);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of WM====================================
public function edit_wm()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_wm',$data);    
    }
  }

//===================================================edit view of Masculine====================================
public function edit_mf()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_mf',$data);    
    }
  }

//===================================================edit view of verb====================================
public function edit_vrb()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_vrb',$data);    
    }
  }
  
//===================================================edit view of Wsysnoms====================================
public function edit_wsys()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_wsys',$data);    
    }
  }

//===================================================edit view of Wsysnoms====================================
public function edit_wd_ant()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_wd_ant',$data);    
    }
  }


//===================================================edit view of Wsysnoms====================================
public function edit_re()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_re',$data);    
    }
  }


//===================================================edit view of underline====================================
public function edit_un()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_un',$data);    
    }
  }


//===================================================edit view of matchcolumn====================================
public function edit_match_column()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_match_column',$data);    
    }
  }


//===================================================edit view of active wise====================================
public function edit_active_wise()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_active_wise',$data);    
    }
  }

//===================================================edit view of direct sentence====================================
public function edit_direct_sentence()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_direct_sentence',$data);    
    }
  }


//===================================================edit view of indirect sentence====================================
public function edit_indirect_sentence()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_indirect_sentence',$data);    
    }
  }


//===================================================edit view of passive wise====================================
public function edit_passive_wise()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_passive_wise',$data);    
    }
  }


//===================================================edit view of match word====================================
public function edit_match_word()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_match_word',$data);    
    }
  }


//================================Save edit data of Opposites===========================
public function save_edit_wm()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_wm($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}


//================================Save edit data of Rearrange===========================
public function save_edit_re()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_re($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}


//================================Save edit data of masculine===========================
public function save_edit_mf()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_mf($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}


//================================Save edit data of underline===========================
public function save_edit_un()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_un($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of matchcolumn===========================
public function save_edit_matchcolumn()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_matchcolumn($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of active wise===========================
public function save_edit_active_wise()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_active_wise($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of direct sentence===========================
public function save_edit_direct_sentence()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_direct_sentence($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of indirect sentence===========================
public function save_edit_indirect_sentence()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_indirect_sentence($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}


//================================Save edit data of remove sentence===========================
public function save_edit_remove_sentence()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_remove_sentence($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of passive wise===========================
public function save_edit_passive_wise()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_passive_wise($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}



//================================Save edit data of matchcwords===========================
public function save_edit_matchword()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_matchword($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of sysnonms===========================
public function save_edit_wsys()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_wsys($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of antonynms===========================
public function save_edit_wanto()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_wanto($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//================================Save edit data of verbs===========================
public function save_edit_verb()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_verb($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}
//=================================save Superlative question=====================================
public function save_superlative()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
     $que2=$this->input->post('question2');
      $count=count($que);
      $type="17";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'postive' => $que[$i],
                           'coparative' => $que[$i],
                          'superlative' => $que1[$i],
            );
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',17);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of sd====================================
public function edit_sd()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_sd',$data);    
    }
  }
//================================Save edit data of Opposites===========================
public function save_edit_sd()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_sd($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//=================================save Ideoms question=====================================
public function save_ideoms_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump($data);die();
      $que=$this->input->post('question');
      $count=count($que);
      $type="18";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'ideoms' => $que[$i],
                          
            );
           // var_dump($Name);die();
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',18);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save Rhyming question=====================================
public function save_Rhyming_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump($data);die();
      $que=$this->input->post('question');
      $count=count($que);
      $type="29";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'ideoms' => $que[$i],
                          
            );
           // var_dump($Name);
           // die();
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',29);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
  //echo "not done ";
 // die();
    redirect('autopaper/question','refresh');
  }
}



//===================================================edit view of Ideoms====================================
public function edit_ideoms()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_ideoms',$data);    
    }
  }
//================================Save edit data of Ideoms===========================
public function save_edit_ideoms()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_ideoms($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//=================================save True false question=====================================
public function save_truefalse()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      //var_dump("<pre>",$data);die();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      //var_dump("<pre>",$que1);die();
      $count=count($que);
      $type="19";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          //'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'true_words' => $que[$i],
                          'false_words' => $que1[$i][0],
            );
           // var_dump($Name);die();
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',19);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}
//===================================================edit view of tf====================================
public function edit_tf()
  {
    if($this->uri->segment(3))
    {
      $id=$this->uri->segment(3);
      $data['val']=$this->autopaper_model->edit_chapter($id,"general_questions");
      $data['class']=$this->autopaper_model->all("class");
      $data['subject']=$this->autopaper_model->all("subject");
      $data['chapter']=$this->autopaper_model->all("chapters");
      $data['is_super'] = $this->user_model->is_super();
      $data['menu'] = $this->load_model->menu();
      $branch=$this->user_model->getbranch();
      if($this->user_model->is_super())
              $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
      else
              $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
              $data['base_url'] = base_url();
              $data['userInfo'] = $this->userInfo;
              $this->load->view('header',$data);
              $this->load->view('sidebar',$data);
              $this->load->view('autopaper/edit_tf',$data);    
    }
  }
//================================Save edit data of Opposites===========================
public function save_edit_tf()
{
     if($this->input->post()){
        $data = $this->input->post();
        $db_insert = $this->autopaper_model->save_edit_tf($data);
        redirect("autopaper/question","refresh");
    }
    else{
        redirect("autopaper/question","refresh");
    }  
}

//======================================question selection====================================
public function  question_selection()
{
        //$this->user_model->check_permissions("autopaper/chapter");
         $data['is_super'] = $this->user_model->is_super();
         $data['menu'] = $this->load_model->menu();
         $branch=$this->user_model->getbranch();
            //if($this->user_model->is_super())
                $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
            //else
            //    $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
         $data['base_url'] = base_url();
         $data['userInfo'] = $this->userInfo;
         $this->load->view('header',$data);
         $this->load->view('sidebar',$data);
         $this->load->view('autopaper/question_selection',$data);
}

  public function get_question_print()
  {
    if($this->input->post())
    {  
         $chapter = $this->input->post('chapter');
         if(!empty($chapter))
         {
      $branch=$this->user_model->getBranch();
      $data['data']=$this->input->post();
     
    // var_dump($chapter);
    // die();
      $class=$this->input->post('class');
      $subject=$this->input->post('subject');
      $exam=$this->input->post('exam');
      
      $data['exam']=$this->db->query("SELECT `name` FROM `exam` WHERE `id`='$exam'")->row();
      
      $data['b_header']= $this->db->query("SELECT * FROM `branch` WHERE is_delete='0' AND id='$branch'")->row_array();
      $data['classes']= $this->db->query("SELECT class_name FROM `class`  WHERE class.is_delete='0'  AND class_id=$class")->row_array();
      $data['subject']= $this->db->query("SELECT name FROM `subject`  WHERE subject.is_deleted='0'  AND id=$subject")->row_array();
      //var_dump($data['exam']);
      //die();
      $this->load->view('autopaper/paper_print',$data);
         }
         else
         {
            
             redirect('autopaper/question_selection','refresh');
            
            
         }
    }
    else
    {
      redirect('autopaper/question_selection','refresh'); 
    }
  }
  
  //======================================question selection====================================
public function  question_drawing_selection()
{
        //$this->user_model->check_permissions("autopaper/chapter");
         $data['is_super'] = $this->user_model->is_super();
         $data['menu'] = $this->load_model->menu();
         $branch=$this->user_model->getbranch();
            //if($this->user_model->is_super())
                $data['branch'] = $this->db->select("name,id")->from("branch")->get()->result();
            //else
            //    $data['branch'] = $this->db->select("name,id")->from("branch")->where("id",$branch)->get()->result();
         $data['base_url'] = base_url();
         $data['userInfo'] = $this->userInfo;
         $this->load->view('header',$data);
         $this->load->view('sidebar',$data);
         $this->load->view('autopaper/drawing_select_quest',$data);
}
  
   public function get_Draw_question_print()
  {
    if($this->input->post())
    {  
         $chapter = $this->input->post('chapter');
         if(!empty($chapter))
         {
      $branch=$this->user_model->getBranch();
      $data['data']=$this->input->post();
     
    // var_dump($chapter);
    // die();
      $class=$this->input->post('class');
      $subject=$this->input->post('subject');
      $data['b_header']= $this->db->query("SELECT * FROM `branch` WHERE is_delete='0' AND id='$branch'")->row_array();
      $data['classes']= $this->db->query("SELECT class_name FROM `class`  WHERE class.is_delete='0'  AND class_id=$class")->row_array();
      $data['subject']= $this->db->query("SELECT name FROM `subject`  WHERE subject.is_deleted='0'  AND id=$subject")->row_array();
      //var_dump($data);
      //die();
      $this->load->view('autopaper/paper_draw_print',$data);
         }
         else
         {
            
             redirect('autopaper/question_drawing_selection','refresh');
            
            
         }
    }
    else
    {
      redirect('autopaper/question_drawing_selection','refresh'); 
    }
  }
  
  
  
  
  
  
  
  
/*======================================================================*/

public function delete_question($tbl="",$id=0)

	{
	//var_dump($tbl,$id);die();
	$this->db->where('id', $id);
	$b= $this->db->delete("$tbl");	
	if($b==TRUE){
	redirect('autopaper/question','refresh'); 
	}
	
	
	}
	//=================================save Words question=====================================
public function save_grammer()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $count=count($que);
      $type="20";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'grammer' => $que[$i],
  
            );

     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',20);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save masculine and feminine question=====================================
public function save_masculine_feminine()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      $count=count($que);
      $type="21";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'masculine' => $que[$i],
                          'feminine' => $que1[$i],
            );
    
     $this->db->insert('general_questions',$Name);
    }
      $this->session->set_flashdata('id',21);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save words and synonyms question=====================================
public function save_words_synonyms()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      $count=count($que);
      $type="22";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'wordsforsynonyms' => $que[$i],
                          'synonyms' => $que1[$i],
            );
    
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',22);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

     //=================================save words and antonyms question=====================================
public function save_words_antonyms()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      $count=count($que);
      $type="23";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'wordsforantonyms' => $que[$i],
                          'antonyms' => $que1[$i],
            );
    
     $this->db->insert('general_questions',$Name);
    }
      $this->session->set_flashdata('id',23);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

   
     //=================================save_rearrange_sentence question=====================================
public function save_rearrange_sentence()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
      $count=count($que);
      $type="24";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'Rearrange_Sentence' => $que[$i],
                          'Arrange_Sentence' => $que1[$i],
            );

    
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',24);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save_verb question=====================================
public function save_verb_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
      $que1=$this->input->post('question1');
     $que2=$this->input->post('question2');
      $count=count($que);
      $type="25";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'verb' => $que[$i],
                          '2nd_form' => $que1[$i],
                          '3rd_form' => $que2[$i]
            );

    
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',25);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}


//=================================save_underline  question=====================================
public function save_underline_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     
      $count=count($que);
      $type="26";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'underline_word' => $que[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
      $this->session->set_flashdata('id',26);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save_matchcolumn  question=====================================
public function save_matchcolumn_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     $que1=$this->input->post('question1');
     
      $count=count($que);
      $type="27";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'match_column_1' => $que[$i],
                          'match_column_2' => $que1[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
    
     $this->session->set_flashdata('id',27);
       redirect('autopaper/get_question');
      // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save_active wise  question=====================================
public function save_active_wise_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     $que1=$this->input->post('question1');
     
      $count=count($que);
      $type="30";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'active_wise' => $que[$i],
                          'passive_wise' => $que1[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
    $this->session->set_flashdata('id',30);
       redirect('autopaper/get_question');
   //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}


//=================================save direct  question=====================================
public function save_direct_sentence_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     $que1=$this->input->post('question1');
    
      $count=count($que);
      $type="32";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'direct_sentence' => $que[$i],
                          'indirect_sentence' => $que1[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
     $this->session->set_flashdata('id',32);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save indirect  question=====================================
public function save_indirect_sentence_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     $que1=$this->input->post('question1');
    
      $count=count($que);
      $type="33";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'indirect_sentence' => $que[$i],
                          'direct_sentence' => $que1[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
 $this->session->set_flashdata('id',33);
       redirect('autopaper/get_question');
   // redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

//=================================save remove  question=====================================
public function save_remove_sentence_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     $que1=$this->input->post('question1');
    
      $count=count($que);
      $type="34";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'remove_sentence' => $que[$i],
                          'removed_sentence' => $que1[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
      $this->session->set_flashdata('id',34);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
 
    redirect('autopaper/question','refresh');
  }
}

//=================================save_passive wise  question=====================================
public function save_passive_wise_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     $que1=$this->input->post('question1');
     
      $count=count($que);
      $type="31";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'passive_wise' => $que[$i],
                          'active_wise' => $que1[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
 $this->session->set_flashdata('id',31);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}



//=================================save_matchwords  question=====================================
public function save_matchwords_question()
{
  if($this->input->post())
    {
      $data=$this->input->post();
      $que=$this->input->post('question');
     $que1=$this->input->post('question1');
     
      $count=count($que);
      $type="28";
      for($i=0;$i<$count;$i++)
        {
          $Name = array(
                          'branch' => $data['branch'],
                          'class' => $data['class'],
                          'section' => $data['section'],
                          'subject' => $data['subject'],
                          'chapter' => $data['chapter'],
                          'level' => $data['level'],
                          'question_type' => $type,
                          'match_word_1' => $que[$i],
                          'match_word_2' => $que1[$i],
                         
            );

    
     $this->db->insert('general_questions',$Name);
    }
 $this->session->set_flashdata('id',28);
       redirect('autopaper/get_question');
    //redirect('autopaper/question','refresh');
  }
  else
  {
    redirect('autopaper/question','refresh');
  }
}

}
