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

NEW : course drop and swayam registration #1689

Merged
merged 3 commits into from
Jan 14, 2025
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
3 changes: 2 additions & 1 deletion FusionIIIT/applications/academic_procedures/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
url(r'^stu/view_offered_courses' , views.view_offered_courses , name = 'student_view_offered_courses'),
# url(r'^stu/backlog_courses', views.student_backlog_courses , name = 'student_backlog_courses'),
url(r'^stu/add_course' , views.add_course , name ='add_course') ,
url(r'^stu/drop_course' , views.drop_course , name = 'drop_course'),
url(r'^stu/drop_course/$' , views.drop_course , name = 'drop_course'),
url(r'^stu/swayam_add_course/', views.student_swayam_add_course, name = 'student_swayam_add_course'),
# url(r'^stu/replaceCourse' , views.replaceCourse , name = 'replaceCourse')


Expand Down
58 changes: 47 additions & 11 deletions FusionIIIT/applications/academic_procedures/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,26 +475,62 @@ def add_course(request):
return Response(data = str(e) , status= status.HTTP_500_INTERNAL_SERVER_ERROR)


@api_view(['POST'])
@api_view(['GET'])
def drop_course(request):
if not request.user.is_authenticated:
return Response({'message': 'Login required '}, status=status.HTTP_400_BAD_REQUEST)
data = request.GET.get('id')
reg_id = int(data)
current_user = request.user
current_user = ExtraInfo.objects.all().filter(user=current_user).first()
current_user = Student.objects.all().filter(id = current_user.id).first()

courses = request.data['courses']

for course in courses:
try:
course_id = Courses.objects.all().filter(id=course).first()
course_registration.objects.filter(course_id = course_id, student_id = current_user).delete()
except Exception as e:
resp = {"message" : "Course drop failed", "error" : str(e)}
return Response(data = resp, status = status.HTTP_400_BAD_REQUEST)
try:
course_registration.objects.filter(id = reg_id, student_id = current_user).delete()
except Exception as e:
resp = {"message" : "Course drop failed", "error" : str(e)}
return Response(data = resp, status = status.HTTP_400_BAD_REQUEST)

resp = {"message" : "Course successfully dropped"}
return Response(data = resp , status = status.HTTP_200_OK)


@api_view(['POST'])
def student_swayam_add_course(request):
if not request.user.is_authenticated:
return JsonResponse({'message': 'Login required '}, status=401)
try:
current_user = request.user
current_user = ExtraInfo.objects.all().filter(user=current_user).first()
current_user = Student.objects.all().filter(id = current_user.id).first()
course_id = request.POST["course_id"]
courseslot_id = request.POST["courseslot_id"]
registration_type = request.POST["registration_type"]
if (not course_id) or (not courseslot_id) or (not registration_type):
return JsonResponse({'message': 'Enter Complete Form Details '}, status=400)
course = Courses.objects.get(id=course_id)
courseslot = CourseSlot.objects.get(id=courseslot_id)
semester_no = current_user.curr_semester_no
curr_id = current_user.batch_id.curriculum
semester = Semester.objects.get(curriculum = curr_id, semester_no = semester_no)
try:
course_registration.objects.get(course_slot_id = courseslot, student_id = current_user)
return JsonResponse({'message': 'already registered a course in course slot'}, status=400)
except:
pass
try:
course_registration.objects.get(course_id = course, student_id = current_user)
return JsonResponse({'message': 'already registered a particular course'}, status=400)
except:
pass
cr = course_registration(
course_slot_id=courseslot, course_id=course, student_id=current_user, semester_id=semester , working_year = datetime.datetime.now().year, registration_type=registration_type)
cr.save()
return JsonResponse({'message': 'Successfully added swayam course' }, status=200)
except Exception as e:
print(str(e))
return JsonResponse({'message': 'Error adding course '}, status=500)


# simple api for getting to know the details of user who have logined in the system
@api_view(['GET'])
def get_user_info(request):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 3.1.5 on 2025-01-14 03:26

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('academic_procedures', '0005_auto_20241202_1439'),
]

operations = [
migrations.AlterField(
model_name='assistantshipclaim',
name='year',
field=models.IntegerField(choices=[(2025, 2025), (2024, 2024)]),
),
migrations.AlterField(
model_name='course_registration',
name='registration_type',
field=models.CharField(choices=[('Audit', 'Audit'), ('Improvement', 'Improvement'), ('Backlog', 'Backlog'), ('Regular', 'Regular'), ('Extra Credits', 'Extra Credits'), ('Replacement', 'Replacement')], default='Regular', max_length=20),
),
migrations.AlterField(
model_name='course_registration',
name='working_year',
field=models.IntegerField(blank=True, choices=[(2025, 2025), (2024, 2024)], null=True),
),
migrations.AlterField(
model_name='finalregistrations',
name='batch',
field=models.IntegerField(default=2025),
),
migrations.AlterField(
model_name='messdue',
name='year',
field=models.IntegerField(choices=[(2025, 2025), (2024, 2024)]),
),
migrations.AlterField(
model_name='register',
name='year',
field=models.IntegerField(default=2025),
),
]
2 changes: 2 additions & 0 deletions FusionIIIT/applications/academic_procedures/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ class course_registration(models.Model):
('Improvement', 'Improvement'),
('Backlog', 'Backlog'),
('Regular', 'Regular'),
('Extra Credits', 'Extra Credits'),
('Replacement', 'Replacement'),
]
registration_type = models.CharField(
max_length=20,
Expand Down
38 changes: 34 additions & 4 deletions FusionIIIT/applications/academic_procedures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def academic_procedures_student(request):
final_registration_date_flag = get_final_registration_eligibility(current_date)
add_or_drop_course_date_flag = get_add_or_drop_course_date_eligibility(current_date)
swayam_registration_flag = get_swayam_registration_eligibility(current_date, user_sem, year)
print("Swayam Registration: ", user_sem, swayam_registration_flag)
drop_date_flag = get_drop_course_date_eligibility(current_date, year)
pre_registration_flag = False
final_registration_flag = False

Expand Down Expand Up @@ -552,6 +552,12 @@ def academic_procedures_student(request):

# Mess_bill = Monthly_bill.objects.filter(student_id = obj)
# Mess_pay = Payments.objects.filter(student_id = obj)
swayam_course_slots = get_current_semester_swayam_course_slots(curr_sem_id=curr_sem_id)
swayam_courses = []
try:
swayam_courses = swayam_course_slots[0].courses.all()
except:
pass
Mess_bill = []
Mess_pay = []
# Branch Change Form save
Expand Down Expand Up @@ -608,10 +614,12 @@ def academic_procedures_student(request):
'prd_start_date': prd_start_date,
'frd': final_registration_date_flag,
'adc_date_flag': add_or_drop_course_date_flag,
'drop_date_flag' : drop_date_flag,
'pre_registration_flag' : pre_registration_flag,
'final_registration_flag': final_registration_flag,
'swayam_registration_flag': swayam_registration_flag,
'swayam_courses_count':swayam_courses_count,
'swayam_courseslots':swayam_course_slots,
# 'final_r': final_register_1,

'teaching_credit_registration_course' : teaching_credit_registration_course,
Expand All @@ -633,6 +641,7 @@ def academic_procedures_student(request):
'BranchFlag':branchchange_flag,
'assistantship_flag' : student_status,
'notifications': notifs,
'swayam_courses' : swayam_courses,
}
)

Expand Down Expand Up @@ -953,6 +962,8 @@ def dropcourseadmin(request):
rid - Registration ID of Registers table
response_data - data to be responded.
'''
if user_check(request):
return HttpResponseRedirect('/academic-procedures/main')
data = request.GET.get('id')
# data = data.split(" - ")
reg_id = int(data)
Expand Down Expand Up @@ -1118,6 +1129,8 @@ def verify_course(request):
# view to add Course for a student
def acad_add_course(request):
if(request.method == "POST"):
if user_check(request):
return HttpResponseRedirect('/academic-procedures/main')
course_id = request.POST["course_id"]
courseslot_id = request.POST["courseslot_id"]
course = Courses.objects.get(id=course_id)
Expand Down Expand Up @@ -1426,7 +1439,6 @@ def get_course_verification_date_eligibilty(current_date):
def get_swayam_registration_eligibility(current_date, user_sem, year):
try:
swayam_registration_date = Calendar.objects.all().filter(description=f"Swayam Registration {user_sem} {year}").first()
print(swayam_registration_date, user_sem, year)
swayam_start_date = swayam_registration_date.from_date
swayam_end_date = swayam_registration_date.to_date
if current_date>=swayam_start_date and current_date<=swayam_end_date:
Expand All @@ -1435,6 +1447,18 @@ def get_swayam_registration_eligibility(current_date, user_sem, year):
return False
except Exception as e:
return False

def get_drop_course_date_eligibility(current_date, year):
try:
drop_course_date = Calendar.objects.all().filter(description=f"drop course date {year}").first()
drop_start_date = drop_course_date.from_date
drop_end_date = drop_course_date.to_date
if current_date>=drop_start_date and current_date<=drop_end_date:
return True
else :
return False
except Exception as e:
return False

def get_user_branch(user_details):
return user_details.department.name
Expand Down Expand Up @@ -2045,7 +2069,7 @@ def get_add_course_options(branch_courses, current_register, batch):
if courseslot not in slots:
lis = []
for course in courseslot.courses.all():
print(course)
# print(course)
if course_registration.objects.filter(student_id__batch_id__year = batch, course_id = course).count() < max_limit:
lis.append(course)
course_option.append((courseslot, lis))
Expand Down Expand Up @@ -4237,4 +4261,10 @@ def register_backlog_course(request):
return JsonResponse({'message': 'Error Registering course ' + str(e)}, status=500)
except Exception as e:
print(str(e))
return JsonResponse({'message': 'Adding Backlog Failed ' +str(e)}, status=500)
return JsonResponse({'message': 'Adding Backlog Failed ' +str(e)}, status=500)


def get_current_semester_swayam_course_slots(curr_sem_id):
courseslot_list = CourseSlot.objects.filter(semester = curr_sem_id, name__startswith='SW')
return courseslot_list

58 changes: 28 additions & 30 deletions FusionIIIT/templates/academic_procedures/academic.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@
<a class=" item" data-tab="swayam_registration" style="width: 20%;">
Swayam-Registration
</a>
<a class="item" data-tab="add_drop_course" style="width: 20%;" >
drop courses
</a>
</div>

<div class="ui active tab segment" data-tab="next_courses" >
Expand All @@ -194,9 +197,29 @@
<div class="ui tab segment" data-tab="swayam_registration">
{% include 'academic_procedures/swayamregister.html' %}
</div>
<div class="ui tab segment" data-tab="add_drop_course" style="width: 100%">
<div class="ui pointing secondary menu">
<!-- <a class="active item" data-tab="add_courses" style="width: 37%;">
<p style="margin-left: 30%;">Add Course</p>
</a> -->
<a class="active item" data-tab="drop_courses" style="width: 38%;">
<p style="margin-left: 35%;">Drop Course</p>
</a>
<!-- <p class="item" style="width: 25%;text-align: right; font-weight:bold;color:green">
Current Credits : {{current_credits}}
</p> -->
</div>
<!-- <div class="ui active tab segment" data-tab="add_courses" >
{% include 'academic_procedures/addCourse.html' %}
</div> -->
<div class="ui active tab segment" data-tab="drop_courses">
{% include 'academic_procedures/dropCourse.html' %}
</div>
</div>
</div>

<!-- <div class="ui tab segment" data-tab="Miscellaneous" style="width: 110%" >
{% comment %}
<div class="ui tab segment" data-tab="Miscellaneous" style="width: 110%" >
<div class="ui pointing secondary menu">
<a class=" active item" data-tab="miscellaneous_2" >
Check Dues
Expand All @@ -207,9 +230,6 @@
<a class="item" data-tab="miscellaneous_4">
Check Attendance
</a>
<a class="item" data-tab="miscellaneous_5" >
Add/drop courses
</a>
<a class="item" data-tab="miscellaneous_6" >
Backlogs
</a>
Expand Down Expand Up @@ -261,34 +281,14 @@
<div class="ui tab segment" data-tab="miscellaneous_4" >
{% include 'academic_procedures/check_attendance.html' %}
</div>

<div class="ui tab segment" data-tab="miscellaneous_5" style="width: 100%">
<div class="ui pointing secondary menu">
<a class="active item" data-tab="add_courses" style="width: 37%;">
<p style="margin-left: 30%;">Add Course</p>
</a>
<a class="item" data-tab="drop_courses" style="width: 38%;">
<p style="margin-left: 35%;">Drop Course</p>
</a>
<p class="item" style="width: 25%;text-align: right; font-weight:bold;color:green">
Current Credits : {{current_credits}}
</p>
</div>
<div class="ui active tab segment" data-tab="add_courses" >
{% include 'academic_procedures/addCourse.html' %}
</div>
<div class="ui tab segment" data-tab="drop_courses">
{% include 'academic_procedures/dropCourse.html' %}
</div>
</div>
<div class="ui tab segment" data-tab="miscellaneous_6" >
{% include 'academic_procedures/backlog.html' %}
</div>
<div class="ui tab segment" data-tab="miscellaneous_7" >
{% include 'academic_procedures/replace.html' %}
</div>

</div> -->
</div> {% endcomment %}


<div class="ui tab segment" data-tab="four">
Expand Down Expand Up @@ -393,9 +393,7 @@
{% endblock %}

{% block javascript %}
<script>
<script src="https://cdn.rawgit.com/mdehoog/Semantic-UI/6e6d051d47b598ebab05857545f242caf2b4b48c/dist/semantic.min.js"></script>
<script type="text/javascript" src="{% static 'globals/js/datepicker.js' %}"></script>
<script type="text/javascript" src="{% static 'globals/js/tablesort.js' %}"></script>
</script>
<script src="https://cdn.rawgit.com/mdehoog/Semantic-UI/6e6d051d47b598ebab05857545f242caf2b4b48c/dist/semantic.min.js"></script>
<script type="text/javascript" src="{% static 'globals/js/datepicker.js' %}"></script>
<script type="text/javascript" src="{% static 'globals/js/tablesort.js' %}"></script>
{% endblock %}
Loading