 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">Add New Question</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">Question</a></li>
              <li class="breadcrumb-item active">Add New Question</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    
    <section class="content">
      <div class="container-fluid">

        <div class="row">
          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h3 class="card-title">Add Question</h3>
                <div class="card-tools">
                  <a href="<?php echo base_url()?>/admin/question/view_all_question" class="btn btn-primary btn-sm"><i class="fa fa-eye" aria-hidden="true"></i> View All Question</a>
                </div>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <?php echo form_open(base_url().'admin/question/add_question');?>
                <div class="row">

                  <div class="col-md-4">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Select Subject <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <select class="form-control" name="q_subject" onchange="get_subject_chapter(this.value)" placeholder="Enter Notice Content" required="required" >
                            <option value="">Select</option>
                            <?php 
                            $all_subject = $this->db->get('course_subject')->result();
                            foreach ($all_subject as $subject): ?>
                              <option value="<?php echo $subject->subject_id; ?>"><?php echo $subject->subject_name; ?></option>
                            <?php endforeach ?>
                          </select>
                       </div>
                    </div>
                  </div>

                  <div class="col-md-4">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Select Chapter </label>
                       <div class="col-sm-12">
                          <select class="form-control" name="q_subject_chapter" placeholder="Enter Notice Content" id="subject_chapter">
                            <option value="">Select</option>
                          </select>
                       </div>
                    </div>
                  </div>

                  <div class="col-md-2">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Course Level <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <select class="form-control" name="q_course_level" placeholder="Enter Notice Content" required="required">
                            <option value="">Select</option>
                            <option value="beginner">Beginner</option>
                            <option value="advanced">Advanced</option>
                            <option value="intermediate">Intermediate</option>
                          </select>
                       </div>
                    </div>
                  </div>

                  <div class="col-md-2">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Question Type <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <select class="form-control" onchange="hide(this.value)" name="q_type" placeholder="Enter Course Price" required="required">
                            <option value="">Select</option>
                            <option value="1">Objective</option>
                            <option value="2">True / False</option>
                          </select>
                       </div>
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Question <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="q_question" placeholder="Enter Question" required="required">
                       </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Option A <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="q_ans_a" placeholder="Enter Option A" required>
                       </div>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Option B <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="q_ans_b" placeholder="Enter Option B" required>
                       </div>
                    </div>
                  </div>
                  <div class="col-md-6 hide-filed">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Option C </label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="q_ans_c" placeholder="Enter Option C">
                       </div>
                    </div>
                  </div>
                  <div class="col-md-6 hide-filed">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Option D </label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="q_ans_d" placeholder="Enter Option D">
                       </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Correct Answer <span class="required">*</span> <small><b>(If the correct answer is Option A, then write only "a" same as if answer is Option B then "b")</b></small></label>
                       <div class="col-sm-12">
                          <input class="form-control"  name="q_ans_correct" placeholder="Enter Correct Answer" required>
                       </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <div class="form-group">
                       <button name="form1" style="float: right" type="submit" class="btn btn-success">Add</button>
                    </div>
                  </div>
                </div>
                <?php echo form_close();?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
<script type="text/javascript">
function hide(e) 
{
  if(e == 1)
  {
    $('.hide-filed').show();
  }
  else
  {
    $('.hide-filed').hide();
  }
}
function get_subject_chapter(e) 
{
  $.ajax({
    beforeSend: function() {
       $(".loader").show();
    },
    type: "GET",
    //dataType:"JSON",
    async: true,
    url: '<?php echo base_url(); ?>admin/course/get_subject_chapter_by_sub_id/'+e,
    success: function (data) 
    {
        $('#subject_chapter').html(data);
        $(".loader").hide();
    },
    error: function (e) {
      console.log(e.responseText)
      $(".loader").hide();
    }
  });
}

</script>
