{% extends "ndf/mis_base_create_edit.html" %} {% load i18n %} {% load ndf_tags %} {% load pagination_tags %} {% block title %} {% trans "Enroll Students in Courses" %} {% endblock %} {% block head %} {{block.super}} {% endblock %} {% block style %} {{block.super}} /* Resetting css-properties for fieldset (also legend, input) */ /* fieldset (padding-bottom) */ fieldset { padding: 1.25rem 1.25rem 1.25rem 1.25rem !important; } /* legend (background-color) */ fieldset legend { background-color: transparent !important; } /* input (margin) */ fieldset input { margin: 0 !important; } /* Setting css-properties for reveal-modal's label */ div.reveal-modal > label { color: white; font-weight: bold; font-size: 1rem; } div.reveal-modal > div.row > div.columns > input.button, input.button { color: white; font-weight: bold; font-size: 14px; margin: 0.8em 0 0 0 !important; } .text-size-15 { font-size: 15px; } /* DataTables css-properties */ .selected { background-color: #D3D3D3 !important; } #lbl_displ, .table_lbl { color: #0b8a91; cursor: default; font-weight: bold; font-size: 1rem; } {% endblock %} {% block body_content %}
{% endblock %} {% block script %} {{block.super}} var sce_gs_id; var ann_course_id_list = []; var acourse_val = []; var sce_dt_var = ""; // Click event: "Student data" Row of DataTable $(document).on( 'click', '#student_data_table tbody tr', function () { $(this).toggleClass('selected'); $("#lbl_displ").text("") }); // Only keeping year's drop-down and hiding other datepicker's elements ------------------------------------------ $(document).on('focus click blur', '.date_year' ,function(){ $(".ui-datepicker-calendar").hide(); $(".ui-datepicker-month").hide(); $(".ui-datepicker-prev").hide(); $(".ui-datepicker-next").hide(); $("#ui-datepicker-div").position({ at: "center bottom", my: "center top", of: $(this) }); }); // On changing filter dropdown $("select#student_filter").on("change", function() { selected_option_id = $(this).find('option:selected').attr('id') if(selected_option_id == "year_of_study_opt"){ $("#year_of_study_div").removeClass("hide") } else if(selected_option_id == "stream_opt"){ $("#stream_div").removeClass("hide") } }) // On click of Find (Setup Ajax call) ---------------------------------------------------------------------- $("#btnFindES").click(function(event) { // Forcefully blur all input elements, so that mandatory fields become data-invalid if not fill $("#form-edit-node").find(':input[required]').blur(); if($("#form-edit-node").find(':input[data-invalid]').length == 0){ registration_year = $("#datepicker_year").val() var success_state = false; var non_enrolled_students = 0; var degree_name = ""; var degree_year = ""; var all_students = $("#all_students").prop("checked"); if($("select#degree_name option:selected").index() > 0) { degree_name = $("select#degree_name").val() } if($("select#degree_year option:selected").index() > 0) { degree_year = $("select#degree_year").val() } $("#acourse_list li").each(function() { acourse_val.push($(this).attr("id")); }); $.ajax({ url: "{% url 'get_anncourses_allstudents' group_id %}", data: { sce_gs_id: sce_gs_id, registration_year: $("#datepicker_year").val() , acourse_val: acourse_val, degree_year: degree_year, degree_name: degree_name, all_students: all_students }, type: "GET", dataType: "json", success: function(data){ success_state = data["success"]; if (data["success"]) { // Fill divSt drawer_widget = "" students_data_set = "" nesc = "" esc = "" displ_stat = "" non_enrolled_students = parseInt(data["non_enrolled_stud_count"]); students_data_set = data["students_data_set"]; if (students_data_set.length > 0) { nesc = "No. of students not enrolled in this course : " + data["non_enrolled_stud_count"] + "
" esc = "No. of students enrolled in this course : " + data["enrolled_stud_count"] + "
" if(all_students){ displ_stat = "Displaying enrolled and non-enrolled students
" } else{ displ_stat = "Displaying only non-enrolled students
" } column_headers = data["column_headers"]; dataTable_columns_set = []; // Define table student_data_table = 'No Students registered for this year!!!" + "
" $("#divSt").html(nesc); } } else { $("#alertModal").removeClass("success"); $("#alertModal").addClass("alert"); $("#alertModalLabel").text(data["message"]); $("#alertModal").foundation('reveal', 'open'); } }, complete: function(){ if (success_state) { // If Announced Courese & Students found, // display fieldset (fsSt) & submit buttons (sbtnInProgress & sbtnComplete) // depending upon their visibility state if ((students_data_set.length > 0) && $("#sbtn_div").hasClass("hide")) { $("#sbtn_div").removeClass("hide"); } // Also toggle fieldset (fsSt) if ($("#fsSt").css("display") == "none") { $("#fsSt legend label h5").text("Enroll following listed Student(s):"); $("#fsSt").toggle(); } //$("#btnFindES").attr("disabled", true); } else { // Otherwise, hide submit buttons as well as fieldset if (!$("#sbtn_div").hasClass("hide")) { $("#sbtn_div").addClass("hide"); } // Also toggle fieldset (fsSt) if ($("#fsSt").css("display") != "none") { if ($("#divSt").children().length > 0) { $("#divSt").empty(); } $("#fsSt").toggle(); } } } }); } else{ alert("Please fill required fields"); event.preventDefault(); } }); //On click of select All, highlight all rows $(document).on('click','.select_all_rows',function(){ $(sce_dt_var.fnGetNodes()).addClass('selected') $("#lbl_displ").text("All " + $(sce_dt_var.fnGetNodes()).length + " rows are selected") }); //On click of De-Select All, remove highlight from all rows $(document).on('click','.deselect_all_rows',function(){ $("#lbl_displ").text("All rows are de-selected") $(sce_dt_var.fnGetNodes()).removeClass("selected"); }); // On close evar sce_gs_idvent of reveal-modal (alertModal) = {{ app_set_instance_id }}--------------------- $(document).on('closed.fndtn.reveal', '#alertModal[data-reveal]', function () { if ($(this).hasClass('success')) { // Disable 'Find' button, which gets enable only when any of the input element // of the fieldset (fsSc) is changed $("#btnFindES").attr('disabled', "disabled"); } // Reset reveal-modal content & it's setting $("#alertModalLabel").text(""); $("#alertModal") .removeClass("success").removeClass("warning").removeClass("alert").removeClass("small") .addClass("medium") .find("div.complete_inp_enroll").addClass("hide") }); // On click of InProgress/Complete/Complete-Yes ------------------------------------------------------------ var is_complete_confirm = false; var is_inprogress_confirm = false; $(document).on("click", ".sbtn", function(event) { $("#enrollState").val($(this).val()); if ( !is_inprogress_confirm && !is_complete_confirm) { if($("#enrollState").val() == "In Progress"){ $("#alertModalLabel").text("You can come back to enroll more students to this course again. This will not complete your enrollment task. Do you want to continue?"); } else if($("#enrollState").val() == "Complete"){ $("#alertModalLabel").text("This will not allow further enrollments. Do you want to continue?"); } $("#alertModal") .removeClass("medium").addClass("small") .addClass("alert") .find("div.complete_inp_enroll").removeClass("hide") $("#alertModal").foundation('reveal', 'open'); return false; } // Fetching class name of hidden input element(s) of drawer2 from drawer-widget('student_enroll') var student_enroll_list = []; sce_dt_var.$("tr.selected").each(function () { student_enroll_list.push(this.id); } ); $("#student_enroll_list").val(student_enroll_list); // Setting hidden field's value as the selected value from acourse_list (dropdown) $("#announced_courses_list").val(acourse_val); $('article').block({ message: '