From d4da4bd6ca1888f04ca2f35e1ce836334227c3bd Mon Sep 17 00:00:00 2001 From: Akash Kumar Sah Date: Mon, 21 Oct 2024 20:01:00 +0530 Subject: [PATCH] feat(AC2): Added support for elective preregistration and corrected pre registration process --- .../applications/academic_procedures/views.py | 6 +- .../auto_pre_registration.html | 144 ++++++++++++------ 2 files changed, 99 insertions(+), 51 deletions(-) diff --git a/FusionIIIT/applications/academic_procedures/views.py b/FusionIIIT/applications/academic_procedures/views.py index 5b2ea0f20..0e17ef96d 100644 --- a/FusionIIIT/applications/academic_procedures/views.py +++ b/FusionIIIT/applications/academic_procedures/views.py @@ -1474,14 +1474,14 @@ def auto_pre_registration(request): course_slot_id = course_slot_id_for_model, priority = priority_of_current_course ) - f =FinalRegistration(student_id=current_user ,course_slot_id=course_slot_id_for_model , course_id=course_id_for_model ,semester_id=sem_id) - final_reg_curr.append(f) + # f =FinalRegistration(student_id=current_user ,course_slot_id=course_slot_id_for_model , course_id=course_id_for_model ,semester_id=sem_id) + # final_reg_curr.append(f) reg_curr.append(p) existing_entries.add(current_combination) try: InitialRegistration.objects.bulk_create(reg_curr) - FinalRegistration.objects.bulk_create(final_reg_curr) + # FinalRegistration.objects.bulk_create(final_reg_curr) registration_check = StudentRegistrationChecks( student_id = current_user, pre_registration_flag = True, diff --git a/FusionIIIT/templates/academic_procedures/auto_pre_registration.html b/FusionIIIT/templates/academic_procedures/auto_pre_registration.html index b9129ca23..033c468fe 100644 --- a/FusionIIIT/templates/academic_procedures/auto_pre_registration.html +++ b/FusionIIIT/templates/academic_procedures/auto_pre_registration.html @@ -95,6 +95,7 @@ Course Code Course Name Credits + Priority @@ -121,6 +122,12 @@
{% endfor %} + + {% for course in courses %} + {{course.priority}} +
+ {% endfor %} + {% endfor %} @@ -144,6 +151,7 @@ Slot type Semester Credits + Priority Select @@ -152,34 +160,57 @@ {% for course_slot in next_sem_registration_courses %} {% if course_slot.type == "Swayam" %} - {% with "x"|ljust:swayam_courses_count as dummy_range %} - {% for _ in dummy_range %} - - - {{ forloop.counter0|add:forloop.parentloop.counter0|add:"+1" }}. - {{course_slot.name}} - {{course_slot.type}} - {{next_sem.semester_no}} - - - {{course_slot.courses.all.0.credit}} - -
- -
- - - - {% endfor %} - {% endwith %} + + + {{ forloop.counter }}. + {{course_slot.name}} + {{course_slot.type}} + {{next_sem.semester_no}} + + + {{course_slot.courses.all.0.credit}} + +
+ +
+ + + + {% elif course_slot.type == "Optional Elective" %} + {% for course in course_slot.courses.all %} + + + {{ forloop.parentloop.counter }}. + {{ course_slot.name }} + {{ course_slot.type }} + {{ next_sem.semester_no }} + + + {{ course.credit }} + {{ forloop.counter }} + +
+ +
+ + + {% endfor %} {% else %} 1) { - var selectedOption = dropdown.querySelector('select').value; + var selectedOption = selectElement.value; // console.log(dropdown) if (selectedOption !== "NULL") { var selectedCourseName = dropdown.querySelector('select option:checked').text; @@ -405,17 +433,37 @@ var courseSlotId = dropdown.querySelector('select').getAttribute("name").split('-')[1]; if (confirm("Are you sure you want to register for " + selectedCourseName + "?")) { // handleDropdownChangePreRegistrationEvent = false; - addCourse(dropdown , courseSlotId, function(response) { - if(response.message === 'Course not added because seats are full!'){ - // console.log(selectedOptionElement) - selectedOptionElement.remove(); - }else{ - // console.log("credits : " + credit); - credit += selectedCourseCredit; - dropdown.classList.add("disabled-dropdown"); - // alert(response.message); + // addCourse(dropdown , courseSlotId, function(response) { + // if(response.message === 'Course not added because seats are full!'){ + // // console.log(selectedOptionElement) + // selectedOptionElement.remove(); + // }else{ + // // console.log("credits : " + credit); + // credit += selectedCourseCredit; + // dropdown.classList.add("disabled-dropdown"); + // // alert(response.message); + // } + // }); + var suffix = selectedOption.split('-')[1]; + var prefix = selectedOption.split('-')[0]; + console.log(suffix); + var allSelects = document.querySelectorAll('select[name="' + selectElement.getAttribute("name") + '"]'); + // console.log(allSelects); + allSelects.forEach(function (currentSelectElement) { + // Skip the current dropdown where the selection was made + if (currentSelectElement !== selectElement) { + var optionToDisable = currentSelectElement.querySelector('option[value$="-' + suffix + '"]'); + console.log(currentSelectElement, optionToDisable); + if (optionToDisable) { + optionToDisable.remove(); + } } }); + if (prefix == '1') { + credit += selectedCourseCredit; + // console.log(credit); + } + dropdown.classList.add("disabled-dropdown"); } else { // Reset the dropdown to its initial state if user cancels dropdown.querySelector('select').selectedIndex = 0;