
 <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">View Question Paper</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="#">Examination</a></li>
              <li class="breadcrumb-item active">View Question Paper</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">
              
              <!-- /.card-header -->
              <div class="card-body" >
                <div class="row">
                  <div class="col-md-12">
                    <div class="form-group">
                       <label for="inputEmail" class="col-sm-12 col-form-label">Select Course <span class="required">*</span></label>
                       <div class="col-sm-12">
                          <select  class="form-control" onchange="get_subject()" name="paper_course_id" placeholder="Enter Notice Content" required="required" id="fee_student_course">
                            <option value="">Select</option>
                            <?php foreach ($all_course as $course): ?>
                              <option value="<?php echo $course->id; ?>"><?php echo $course->title; ?></option>
                            <?php endforeach ?>
                          </select>
                       </div>
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                       <div class="col-sm-12" >
                          <div class="row" id="subject_table" style="overflow-x:auto;">
                         </div>
                       </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
<style type="text/css">
#btn_add
{
  display: none;
}
</style>
<script type="text/javascript">
var ttl_qns = 0;
function get_subject(e)
{
    var course_id = $('#fee_student_course').val();
  $.ajax({
      beforeSend: function() {
         $(".loader").show();
      },
      type: "POST",
      async: true,
      dataType: "json",
      data : { course_id : course_id},
      url: '<?php echo base_url(); ?>/admin/course/get_subject_for_question_paper_set',
      success: function (data) 
      {
          $('#subject_details').html(data.subject_details);
          $('#subject_table').html(data.subject_table);
          $('#ttl_qns').html('<b>Total Added Question Limit is '+data.total_qns+'</b> | Remaining <b id="remaining">'+data.total_qns+' </b> Question');
          ttl_qns = data.total_qns;
          $(".loader").hide();
      },
      error: function (e) {
        $(".loader").hide();
        console.log(e.responseText)
      }
    });
}
function check_qns(e) 
{
    var inputFields = document.getElementsByClassName("qns_limit");

    // Initialize a variable to hold the total sum
    var totalSum = 0;

    // Loop through the input fields and add up their values
    for (var i = 0; i < inputFields.length; i++) {
        totalSum += parseInt(inputFields[i].value);
    }

    $('#remaining').html(ttl_qns - totalSum);

    if(totalSum == ttl_qns)
    {
      $('#btn_add').show();
    }
    else
    {
      $('#btn_add').hide();
    }
}

</script>
