    $(document).ready(function () {
      
        var campus = $("#autoSizingSelect option:selected").val();
        var institution = $("#institutionid_header").val();
        var userID = $('#user_id_teacher').val();
        var usertype = $('#user_type_holder').val();
       
         proslosloadclasshereprogressreport(campus,userID,institution, usertype);
    
    });
    
    function proslosloadclasshereprogressreport(campus,userID,institution,usertype)
    {
        
        
        
                      $('#emma_display_section_for_display_class').html('<option>  <span class="visually-hidden">Loading...</span></option>'); 
    
                        $.ajax({
                            type: "POST",
                            url: "../../controller/scripts/teacher/progressreport/prosloaprogressclassnew.php",
                            data: {
                                userID: userID,
                                  campus: campus,
                                  usertype:usertype
                            },
                        
                            success: function (output) { 
                                
                               
                                $("#emma_display_section_for_display_class").html(output);
                        
                            }
                        });
                    
                        $.ajax({
                            type: "POST",
                            url: "../../controller/scripts/teacher/assignment/ekene_select_termalias.php",
                            data: {
                            
                                  campus: campus
                               
                            },
                        
                            success: function (output) { 
                                
                               
                                $("#emma_display_section_for_display_term").html(output);
                        
                            }
                        });
                            
        
    }





$('body').on('change','#emma_display_section_for_display_class',function(){

    var class_id = $(this).val();
    var campus = $("#autoSizingSelect option:selected").val();
    var institution = $("#institutionid_header").val();
    var userID = $('#user_id_teacher').val();
    var usertype = $('#user_type_holder').val();
     

  $('#emma_display_section_for_display_subject').html('<option>  <span class="visually-hidden">Loading...</span></option>'); 
    
    $.ajax({
        type: "POST",
        url: "../../controller/scripts/teacher/progressreport/prosloadsubjectforprogress.php",
        data: {
            class_id: class_id,
            userID: userID,
              campus: campus,
            usertype:usertype
        },
    
        success: function (output) { 
          
           
            $("#emma_display_section_for_display_subject").html(output);
    
        }
    });

   

});

$('body').on('click', '#emma_load_assignment_question', function () {
    var subject = $('#emma_display_section_for_display_subject option:selected').val();
    var campus = $('#autoSizingSelect option:selected').val();
    var classid = $('#emma_display_section_for_display_class option:selected').val();
    var term = $('#emma_display_section_for_display_term option:selected').val();

            $('#display_progress_report').html('<div class="text-center p-5 "> <span class="spinner-border spinner-border-lg" role="status" aria-hidden="true" style="color:#007ffb;"></span></div>');

    $.ajax({
        type: "POST",
        url: "../../controller/scripts/teacher/progressreport/ekene_select_topic.php",
        data: {
            campus: campus,
            classid: classid,
            term: term,
              subject: subject
           
        },
    
        success: function (output) { 
          
           
            $("#display_progress_report").html(output);
    
        }
    });

});



$('body').on('click', '#submit_topic_ekene', function () {
    
    
    
    
    $('.submit_topic_ekene').html(`<div class="spinner-border spinner-border-sm" role="status">
      <span class="visually-hidden">Loading...</span>
    </div>
    <div class="spinner-grow spinner-grow-sm" role="status">
      <span class="visually-hidden">Loading...</span>
    </div>`);
    
    var userID = $('#user_id_teacher').val();
    var subject = $('#emma_display_section_for_display_subject option:selected').val();
    var campus = $('#autoSizingSelect option:selected').val();
    var classid = $('#emma_display_section_for_display_class option:selected').val();
    var term = $('#emma_display_section_for_display_term option:selected').val();
    // var subject = $('#emma_display_section_for_display_subject option:selected').val();
    // var campus = $('#emma_display_section_for_display_campus option:selected').val();
    // var classid = $('#emma_display_section_for_display_class option:selected').val();
    // var term = $('#emma_display_section_for_display_term option:selected').val();
    var CurriculumTopicIDnew = [];
    
        var topicnamenew = [];
        var termidnew = [];
        var classidnew = [];
        var campusidnew = [];
        var subjectidnew = [];

    $.each($(".ekenecheckeboxtopic:checked"), function () {
       
        var CurriculumTopicID = $(this).data("topicid");
        var topicname = $(this).data("topic");
        var termid = $(this).data("term");
        var classid = $(this).data("classid");
        var campusid = $(this).data("camid");
        var subjectid = $(this).data("subjectid");
       
        CurriculumTopicIDnew.push(CurriculumTopicID);
        topicnamenew.push(topicname);
        termidnew.push(termid);
        classidnew.push(classid);
        campusidnew.push(campusid);
        subjectidnew.push(subjectid);
        
       
      
     
    });
   
if (CurriculumTopicIDnew.length > 0) {
    CurriculumTopicIDnew = CurriculumTopicIDnew.toString();
    topicnamenew = topicnamenew.toString();
    termidnew = termidnew.toString();
    classidnew = classidnew.toString();
    campusidnew = campusidnew.toString();
    subjectidnew = subjectidnew.toString();

    $.ajax({
        type: "POST",
        url: "../../controller/scripts/teacher/progressreport/ekene_inserttopic.php",
        data: {
            CurriculumTopicIDnew: CurriculumTopicIDnew,
            topicnamenew: topicnamenew,
            termidnew: termidnew,
            userID: userID,
            classidnew: classidnew,
            campusidnew: campusidnew,
            subjectidnew: subjectidnew
        },
        success: function (output) {
            if (output == 4) {
                $.wnoty({
                    type: 'success',
                    message: "Submitted succesfully..",
                    autohideDelay: 5000
                });
                $.ajax({
                    type: "POST",
                    url: "../../controller/scripts/teacher/progressreport/ekene_select_topic.php",
                    data: {
                        campus: campus,
                        classid: classid,
                        term: term,
                          subject: subject
                       
                    },
                
                    success: function (output) { 
                        
                        
                         $('.submit_topic_ekene').html('Done');
                                                  
                       
                        $("#display_progress_report").html(output);
                
                    }
                });
            }
        }
    });
} else {
    $.wnoty({
        type: 'warning',
        message: "Choose A Topic",
        autohideDelay: 5000
    });
}

});