Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrections for open ellective allocation #1645

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FusionIIIT/applications/academic_information/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
url(r'^api/',include('applications.academic_information.api.urls')),
url(r'^view_all_student_data', views.view_all_student_data, name='view_all_student_data'),
url(r'^generateStudentSheet$',views.generatestudentxlsheet, name = 'generatestudentxlsheet'),
url(r'^course_allocated_students$',views.get_excel, name = 'course_allocated_students'),
]
22 changes: 11 additions & 11 deletions FusionIIIT/applications/academic_information/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ def allocate(request) :
unique_course_name = []
try:
with transaction.atomic() :
for course_slot in unique_course_slot :
course_slot_object = CourseSlot.objects.get(id=course_slot)
if course_slot_object.type == "Professional Elective": # Runs only for open elective course slots
if course_slot_object.name not in unique_course_name:
stat = random_algo(batch,sem,year,course_slot_object.name)
unique_course_name.append(course_slot_object.name)
if(stat == -1) :
raise Exception("seats not enough for course_slot"+str(course_slot_object.name))
for course_slot in unique_course_slot :
course_slot_object = CourseSlot.objects.get(id=course_slot)
if course_slot_object.type == "Open Elective": # Runs only for open elective course slots
if course_slot_object.name not in unique_course_name:
stat = random_algo(batch,sem,year,course_slot_object.name)
unique_course_name.append(course_slot_object.name)
if(stat == -1) :
print(course_slot_object.name)
raise Exception("seats not enough for course_slot"+str(course_slot_object.name))

return JsonResponse({'status': 1 , 'message' : "course allocation successful"})
except:
return JsonResponse({'status': -1 , 'message' : "seats not enough for course_slot"+str(course_slot_object.name) })


return JsonResponse({'status': -1 , 'message' : "seats not enough for some course_slot"})

def view_alloted_course(request) :
batch = request.POST.get('batch')
sem = request.POST.get('sem')
Expand Down
45 changes: 45 additions & 0 deletions FusionIIIT/applications/academic_information/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,52 @@ def generate_preregistration_report(request):
st = 'attachment; filename = ' + batch.name + batch.discipline.acronym + str(batch.year) + '-preresgistration.xlsx'
response['Content-Disposition'] = st
return response

@login_required
def get_excel(request):
batch = request.POST.get('batch-check-view')
sem = request.POST.get('semester-check-view')
year = request.POST.get('year-check-view')
course = request.POST.get('Course-check-view')
registrations = course_registration.objects.filter(Q(student_id__batch = batch) & Q(working_year = year) & Q(semester_id__semester_no = sem) & Q(course_id__code = course))
return_list = []
for registration in registrations:
return_list.append(registration.student_id.id.id)

return_list.sort()
output = BytesIO()

book = Workbook(output,{'in_memory':True})
title = book.add_format({'bold': True,
'font_size': 22,
'align': 'center',
'valign': 'vcenter'})
subtitle = book.add_format({'bold': True,
'font_size': 15,
'align': 'center',
'valign': 'vcenter'})
normaltext = book.add_format({'bold': False,
'font_size': 15,
'align': 'center',
'valign': 'vcenter'})
sheet = book.add_worksheet()
sheet.set_default_row(25)
sheet.write_string('A1','Student Roll no',subtitle)
sheet.write_string('B1','Student name',subtitle)
k=2
for no in return_list :
student= User.objects.get(username=no)
sheet.write_string('A'+str(k),no,normaltext)
sheet.write_string('B'+str(k),student.first_name+student.last_name,normaltext)
k+=1

book.close()
output.seek(0)

response = HttpResponse(output.read(),content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response['Content-Disposition'] = 'attachment; filename='+ course +'_student_list.xlsx'
response['Content-Transfer-Encoding'] = 'binary'
return response

@login_required
def add_new_profile (request):
Expand Down
10 changes: 9 additions & 1 deletion FusionIIIT/templates/ais/start_elective_allocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>
<div class="ui tab segment " data-tab="view-allocation">
<div class="ui vertical segment">
<form class="ui form" method="post" id="allocation-check">
<form class="ui form" method="post" id="allocation-check" action="/aims/course_allocated_students">
{% csrf_token %}
<div class="field">
<label>Batch</label>
Expand All @@ -72,6 +72,11 @@
View allocation
</button>
</div>
<div class="field">
<button id="download-allocation-view" type="submit" class="ui fluid primary button">
download allocation list
</button>
</div>
</form>
<div>
<table>
Expand Down Expand Up @@ -138,6 +143,9 @@
if(data.status == -1){
alert("not enough seats to allocate students")
}
else{
alert("allocation done")
}
}
})
})
Expand Down
Loading