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

Ac 7 examination #1674

Merged
merged 3 commits into from
Dec 25, 2024
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/examination/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
path('generate_pdf/',views.generate_pdf,name='generate_pdf'),
path('generate-result/',views.generate_result,name='generate_pdf'),
# path('get_courses/',views.get_courses,name='get_courses'),

# path('checkresult/',views.checkresult,name='checkresult'),
# path('grades_report/',views.grades_report,name='grades_report'),
]
93 changes: 89 additions & 4 deletions FusionIIIT/applications/examination/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def exam(request):
return HttpResponseRedirect("/examination/updateGrades/")
elif request.session.get("currentDesignationSelected") == "Dean Academic":
return HttpResponseRedirect("/examination/verifyGradesDean/")

# elif request.session.get("currentDesignationSelected") == "student":
# return HttpResponseRedirect("/examination/checkresult/")
return HttpResponseRedirect("/dashboard/")


Expand Down Expand Up @@ -1718,13 +1719,18 @@ def generate_result(request):
return JsonResponse({'error': 'Semester not found'}, status=404)
# print(batch, branch)
course_slots = CourseSlot.objects.filter(semester_id=semester_info)
course_ids = course_slots.values_list('courses', flat=True)
course_ids_from_slots = course_slots.values_list('courses', flat=True)
course_ids_from_grades = Student_grades.objects.filter(
batch=batch,
semester=semester
).values_list('course_id_id', flat=True)
course_ids = set(course_ids_from_slots).union(set(course_ids_from_grades))
courses = Courses.objects.filter(id__in=course_ids)
courses_map={}
for course in courses:
courses_map[course.id]=(course.credit)
students = Student.objects.filter(batch=batch, specialization=branch).order_by('id')
print(students.first().id_id,"studejt id")
# print(students.first().id_id,"studejt id")

wb = Workbook()
ws = wb.active
Expand Down Expand Up @@ -1786,7 +1792,7 @@ def generate_result(request):
ws.cell(row=row_idx, column=1).alignment = Alignment(horizontal="center", vertical="center")
ws.cell(row=row_idx, column=2).alignment = Alignment(horizontal="center", vertical="center")
student_grades = Student_grades.objects.filter(
roll_no=student.id_id, course_id_id__in=course_ids
roll_no=student.id_id, course_id_id__in=course_ids, semester=semester
)

grades_map = {}
Expand Down Expand Up @@ -1855,3 +1861,82 @@ def generate_result(request):


return JsonResponse({'error': 'Invalid request method'}, status=405)

def checkresult(request):
des = request.session.get("currentDesignationSelected")
if des == "student":
pass
else:
if request.is_ajax(): # For AJAX or JSON requests
return JsonResponse({"success": False, "error": "Access denied."}, status=403)
else: # For non-AJAX requests
return HttpResponseRedirect('/dashboard/')
return render(request, "../templates/examination/check_result.html")


def grades_report(request):
if request.method == 'POST':
des = request.session.get("currentDesignationSelected")
if des == "student":
pass
else:
if request.is_ajax(): # For AJAX or JSON requests
return JsonResponse({"success": False, "error": "Access denied."}, status=403)
else: # For non-AJAX requests
return HttpResponseRedirect('/dashboard/')
roll_number=request.user.username
semester=request.POST.get('semester')
grades_info=Student_grades.objects.filter(roll_no=roll_number,semester=semester).select_related('course_id')
gained_credit=0
total_credit=0
all_credits=0
for grades in grades_info:
credits=grades.course_id.credit
grade=grades.grade
if grade=="O" or grade=="A+":
gained_credit+=1*credits
total_credit+=credits
elif grade=="A":
gained_credit+=0.9*credits
total_credit+=credits
elif grade=="B+":
gained_credit+=0.8*credits
total_credit+=credits
elif grade=="B":
gained_credit+=0.7*credits
total_credit+=credits
elif grade=="C+":
gained_credit+=0.6*credits
total_credit+=credits
elif grade=="C":
gained_credit+=0.5*credits
total_credit+=credits
elif grade=="D+":
gained_credit+=0.4*credits
total_credit+=credits
elif grade=="D":
gained_credit+=0.3*credits
total_credit+=credits
elif grade=="F":
gained_credit+=0.2*credits
total_credit+=credits
all_credits+=credits
spi = 10*(gained_credit/total_credit) if total_credit > 0 else 0
all_grades = Student_grades.objects.filter(roll_no=roll_number)
total_units = sum(grade.course_id.credit for grade in all_grades)
student_user = request.user.first_name+' '+request.user.last_name
student = Student.objects.filter(id=roll_number).first()
# count=Student.objects.filter(id=roll.id).count()
# student=students.count()

context = {
'student': student,
'student_user': student_user,
'grades': grades_info,
'spi': round(spi, 2),
'semester_units': all_credits,
'total_units': total_units,
}
return render(request, '../templates/examination/grades_report.html', context)


30 changes: 30 additions & 0 deletions FusionIIIT/templates/examination/check_result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends 'examination/base.html' %}
{% block sidetabmenu %}
<div class="ui medium fluid vertical pointing menu" style="max-width: 320px;">
<a class="active item" href="{% url 'examination:checkresult' %}"><B>Check Result</B>
<i class="right floated chevron right icon"></i>
</a>
</div>
{% endblock %}
{% block content %}
<div class="ui container" style="padding-top: 2em;">
<h2 class="ui header">Student Grade Report</h2>
<form class="ui form" method="POST" action="{% url 'examination:grades_report' %}">
{% csrf_token %}
<div class="field">
<label>Semester</label>
<select class="ui dropdown" name="semester" required>
<option value="">Select Semester</option>
{% for i in "12345678" %}
<option value="{{ i }}">Semester {{ i }}</option>
{% endfor %}
</select>
</div>
<button class="ui primary button" type="submit">View Grades</button>
</form>
</div>
<script>
$('.ui.dropdown').dropdown();
</script>

{% endblock %}
64 changes: 64 additions & 0 deletions FusionIIIT/templates/examination/grades_report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{% extends 'examination/base.html' %}
{% block sidetabmenu %}
<div class="ui medium fluid vertical pointing menu" style="max-width: 320px;">
<a class="item" href="{% url 'examination:checkresult' %}">Check Result
<i class="right floated chevron right icon"></i>
</a>
</div>
{% endblock %}
{% block content %}
<div class="ui container" style="padding: 2em;">
<div class="ui segment">
<h2 class="ui header">Grade Report</h2>
<div class="ui grid">
<div class="eight wide column">
<p><strong>Roll No:</strong> {{ student.id_id }}</p>
<p><strong>Name:</strong> {{ student_user }}</p>
</div>
<div class="eight wide column">
<p><strong>Discipline:</strong> {{ student.specialization }}</p>
</div>
</div>

<table class="ui celled table">
<thead>
<tr>
<th>Course Code</th>
<th>Course Name</th>
<th>Credits</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
{% for grade in grades %}
<tr>
<td>{{ grade.course_id.code }}</td>
<td>{{ grade.course_id.name }}</td>
<td>{{ grade.course_id.credit }}</td>
<td>{{ grade.grade }}</td>
</tr>
{% endfor %}
</tbody>
</table>

<div class="ui statistics">
<div class="statistic">
<div class="value">{{ spi }}</div>
<div class="label">SPI</div>
</div>
<div class="statistic">
<div class="value">{{ semester_units }}</div>
<div class="label">SU</div>
</div>
<div class="statistic">
<div class="value">{{ total_units }}</div>
<div class="label">TU</div>
</div>
</div>

<p class="ui tiny header">Note: This is system generated, there is no need for signature.</p>


</div>
</div>
{% endblock %}
Loading