Skip to content

Commit

Permalink
Merge pull request #131 from SriHarshaGajavalli/student
Browse files Browse the repository at this point in the history
Student - All bugs fixed
  • Loading branch information
hardlyhuman authored Dec 3, 2017
2 parents 2b273a7 + 1d5bc96 commit 9801eed
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 100 deletions.
4 changes: 2 additions & 2 deletions SE2017/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': 'localhost',
'NAME': 'se',
'NAME': 'se2017',
'USER': 'root',
'PASSWORD': 'PASSWORD',
'PASSWORD': '5qlDevelop#r',

}

Expand Down
12 changes: 10 additions & 2 deletions home/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
<link rel="icon" href="../../favicon.ico">

<title>SAMS Attendance</title>

<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="{% static 'home/bootstrap/dist/css/bootstrap.min.css' %}" rel="stylesheet">
<script src="{% static 'home/bootstrap/dist/js/bootstrap.min.js'%}"></script>-->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<link href="{% static 'home/bootstrap/dist/css/bootstrap.min.css' %}" rel="stylesheet">
<script src="{% static 'home/bootstrap/dist/js/bootstrap.min.js'%}"></script>

<link href="{% static 'home/sticky-footer-navbar.css'%}" rel="stylesheet">
</head>
<body style="margin-bottom: 150px; margin-top:50px">
Expand Down Expand Up @@ -118,8 +125,9 @@
{% endblock %}
</div>


<link href="{% static 'home/bootstrap/dist/css/bootstrap.min.css' %}" rel="stylesheet">
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<script src="{% static 'home/bootstrap/dist/js/bootstrap.min.js'%}"></script>

Expand Down
Binary file added students/.views.py.swn
Binary file not shown.
Binary file added students/.views.py.swo
Binary file not shown.
Binary file not shown.
23 changes: 5 additions & 18 deletions students/templates/student/ViewAttendance.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
{% extends 'home/index.html' %}
{% block content %}

<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<!-- <meta content="text/html;charset=utf-8" http-equiv="Content-Type">-->
<meta content="utf-8" http-equiv="encoding">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<title>Attendance Register</title>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Raleway:400,500,800">
<style type="text/css">
@import url('https://fonts.googleapis.com/css?family=Open+Sans');
body
Expand Down Expand Up @@ -65,27 +66,13 @@ <h4 class="modal-title">Absent Days</h4>
<div class="col-md-12 ">
<h1>Attendace Register</h1>

<!--<div class="row">
<div class="form-group col-md-2">
<label for="sel1">Course</label>
<select class="form-control" id="sel1" onchange="getData()">
<option value="default">Select a course</option>
{% for i in CourseAttendanceContext %}
<option value="{{i.course.Course_ID.Course_Name}}">{{i.course.Course_ID.Course_Name}}</option>
{% endfor %}
</select>
</div>
</div>
<div class="panel-head"> Attendance </div>
<div class="info-box col-md-4" style="height:50vh; width:70%">
</div>-->





<div class="info-box col-md-4" style="width:100vh;height:60vh; position: absolute;left:450px;top:200px;margin:0px auto" >
<div class="info-box col-md-4" style="width:100vh;height:60vh; position: relative; margin:0px aut; margin-right: auto; margin-left: aut" >



<br />
Expand Down
14 changes: 8 additions & 6 deletions students/templates/student/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Raleway:400,500,800">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<style>
@import 'https://fonts.googleapis.com/css?family=Lato:300,400';

* {
margin: 0;
padding: 0;
}
body, html {
font-family: 'Lato', sans-serif;
font-size: 1.5vw;


height: 100vh;
overflow-x: hidden;
}
Expand Down Expand Up @@ -222,8 +222,6 @@

<!-- ICONS -->



<div class="page-header">
<h1>Welcome {{user.first_name}}</h1>
</div>
Expand All @@ -242,8 +240,11 @@ <h1>Welcome {{user.first_name}}</h1>
<tr>
<th>Course</th>


<th>Attendance(Overall)</th>
<th>Attendance(Month)</th> </tr></thead>
<th>Attendance(Month)</th>

</tr></thead>
{% for course in attendanceContext.CourseAttendanceContext %}
<tr>
<td>
Expand Down Expand Up @@ -298,4 +299,5 @@ <h1>Welcome {{user.first_name}}</h1>
</div>
<script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>


{% endblock %}
137 changes: 65 additions & 72 deletions students/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
from __future__ import unicode_literals

from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.utils import timezone
from home.models import *
from django.core.urlresolvers import reverse


@login_required(login_url="/login/")
Expand All @@ -25,54 +26,53 @@ def dashboard(request):
This function finds out the summary reports of attendance and Pending assignments
'''

user = request.user
userPersonnelObj = Personnel.objects.filter(LDAP=user)
MyCourses = Students_Courses.objects.filter(Student_ID=userPersonnelObj[0].Person_ID)
CourseAttendanceContext = []
AttendanceSessions = Attendance_Session.objects.all()

try:
user = request.user
userPersonnelObj = Personnel.objects.filter(LDAP=user)
MyCourses = Students_Courses.objects.filter(Student_ID=userPersonnelObj[0].Person_ID)
CourseAttendanceContext = []
for course in MyCourses:

for course in MyCourses:
AttendanceSessions = Attendance_Session.objects.filter(Course_Slot=course.Course_ID.Course_ID)
classesPresent = 0
totalClasses = 0
absentDays = []
totalClassesIncurrentMonth = 0
totalClassesPresentInCurrentMonth = 0
for sessions in AttendanceSessions:
try:
attendanceObject = Attendance.objects.filter(Student_ID=userPersonnelObj[0].Person_ID).filter(
classesPresent = 0
totalClasses = 0
absentDays = []
totalClassesIncurrentMonth = 0
totalClassesPresentInCurrentMonth = 0
for sessions in AttendanceSessions:

if str(sessions.Course_Slot.Course_ID.Course_Name) == str(course.Course_ID):
attendanceObject = Attendance.objects.filter(Student_ID=userPersonnelObj[0].Person_ID).filter(
ASession_ID=sessions.Session_ID)

totalClasses += 1
totalClasses += 1

if (attendanceObject[0].Marked == 'P'):
classesPresent += 1
if (datetime.datetime.now().month == attendanceObject[0].Date_time.month):
totalClassesIncurrentMonth += 1
totalClassesPresentInCurrentMonth += 1
if (attendanceObject[0].Marked == 'P'):
classesPresent += 1
if (datetime.datetime.now().month == attendanceObject[0].Date_time.month):
totalClassesIncurrentMonth += 1
totalClassesPresentInCurrentMonth += 1


elif (attendanceObject[0].Marked == 'A'):
absentDays.append(attendanceObject[0].Date_time)
if (datetime.datetime.now().month == attendanceObject[0].Date_time.month):
totalClassesIncurrentMonth += 1

except:
pass
if (totalClasses == 0):
retObj = dict(course=course, totalAttendance="N.A", monthAttendance="N.A")
elif (totalClassesIncurrentMonth == 0):
retObj = dict(course=course, totalAttendance=(classesPresent * 100.0 / totalClasses),
elif (attendanceObject[0].Marked == 'A'):
absentDays.append(attendanceObject[0].Date_time)
if (datetime.datetime.now().month == attendanceObject[0].Date_time.month):
totalClassesIncurrentMonth += 1


if (totalClasses == 0):
retObj = dict(course=course, totalAttendance="N.A", monthAttendance="N.A")
elif (totalClassesIncurrentMonth == 0):
retObj = dict(course=course, totalAttendance=(classesPresent * 100.0 / totalClasses),
monthAttendance="N.A")
else:
retObj = dict(course=course, totalAttendance=(classesPresent * 100.0 / totalClasses),
else:
retObj = dict(course=course, totalAttendance=(classesPresent * 100.0 / totalClasses),
monthAttendance=(totalClassesPresentInCurrentMonth * 100.0 / totalClassesIncurrentMonth))
CourseAttendanceContext.append(retObj)
attendanceContext = dict(CourseAttendanceContext=CourseAttendanceContext)
except:
attendanceContext = dict(ErrorMessage="No Registered Classes")
CourseAttendanceContext.append(retObj)
attendanceContext = dict(CourseAttendanceContext=CourseAttendanceContext)


pendingAssignments = []
StudentObject = Personnel.objects.filter(LDAP=user.id)
CoursesByStudent = Students_Courses.objects.filter(Student_ID=StudentObject[0].Person_ID)
Expand All @@ -94,51 +94,45 @@ def dashboard(request):

@login_required(login_url="/login/")
def viewattendance(request):
#print("HErE")
try:


user = request.user # getting data of the username
userPersonnelObj = Personnel.objects.filter(LDAP=user) # getting the data from the table Personnel where LDAP is the username that we got earlier

#the userPersonnelObj contains Person_ID, LDAP, Role

MyCourses = Students_Courses.objects.filter(Student_ID=userPersonnelObj[0].Person_ID)

#we now are taking data from Students_Courses table using the Person_ID that we got in the userPersonnelObj and putting it in MyCourses
#MyCourses contains Student_ID, Course_ID, Reg_Date

AttendanceSessions = Attendance_Session.objects.all()
CourseAttendanceContext = []
classesPresent = 0
#print(MyCourses)

for course in MyCourses:

AttendanceSessions = Attendance_Session.objects.all()#(Course_Slot=course.Course_ID.Course_ID)
print(AttendanceSessions)
#We are taking data from Attendance_Session table using the course_ID that we got earlier.
classesPresent = 0
totalClasses = 0
absentDays = []
for sessions in AttendanceSessions: #looping in AttendanceSessions
print(sessions.Course_Slot.Course_ID.Course_ID)
print(course.Course_ID)
try:
attendanceObject = Attendance.objects.filter(Student_ID=userPersonnelObj[0].Person_ID).filter(
ASession_ID=sessions.Session_ID)
# print (attendanceObject)
#Select alll the data in Attendance table where Sudent_ID is the Person_ID that is available in UserPersonnelObj and ASession_ID is the Session_ID s that are available in AttendanceSessions
# print(attendanceObject[0])
totalClasses += 1

for sessions in AttendanceSessions:

if str(sessions.Course_Slot.Course_ID.Course_Name) == str(course.Course_ID):

attendanceObject = Attendance.objects.filter(Student_ID=userPersonnelObj[0].Person_ID).filter(ASession_ID=sessions.Session_ID)
totalClasses += 1

if (attendanceObject[0].Marked == 'P'):
classesPresent += 1
elif (attendanceObject[0].Marked == 'A'):
absentDays.append(attendanceObject[0].Date_time)

except:
pass
retObj = dict(course=course, present=classesPresent, total=totalClasses, absentDays=absentDays, absent = totalClasses-classesPresent, percent = (classesPresent/totalClasses)*100)

percent = 0
if totalClasses:
percent = classesPresent*100/totalClasses
retObj = dict(course=course, present=classesPresent, total=totalClasses, absentDays=absentDays, absent = totalClasses-classesPresent, percent=percent)
CourseAttendanceContext.append(retObj)

context = dict(CourseAttendanceContext=CourseAttendanceContext)
except:
context = dict(ErrorMessage="No Registered Classes")
return render(request, "student/ViewAttendance.html", context) #rendering the attendance page from templates def AssgnSubStatusPending(request):

return render(request, "student/ViewAttendance.html", context) #rendering the attendance page from templates

def AssgnSubStatusPending(request):
'''
Expand Down Expand Up @@ -230,7 +224,7 @@ def registerCourses(request):
'''
This function allows add/drop a course for a student
'''
print (request.POST)

user = request.user
StudentObject = Personnel.objects.filter(LDAP=user.id)
courses = Courses.objects.all()
Expand All @@ -241,15 +235,14 @@ def registerCourses(request):
registerStudent = CourseByStudent.create(Student_ID=StudentObject[0], Course_ID=course,
Reg_Date=datetime.datetime.now())
registerStudent.save()
print(registerStudent)

elif (CourseByStudent.count() != 0 and not request.POST.get(str(course.Course_ID))):
CourseByStudent.delete()
# registerStudent = CourseByStudent.create(Student_ID=StudentObject[0], Course_ID=course,
# Reg_Date=datetime.datetime.now())

return render(request, "student/index.html", {})

@login_required(login_url="/login/")
return redirect(reverse('students:index'))

@login_required
def upcoming_events(request):
'''
This function lists all the events
Expand Down

0 comments on commit 9801eed

Please sign in to comment.