Skip to content
Snippets Groups Projects
Commit 8a8cbfbc authored by Pendyala Phani Chaitanya's avatar Pendyala Phani Chaitanya
Browse files

First Commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 407 additions and 0 deletions
File added
File added
File added
File added
from django.db import models
# Create your models here.
class Professor_Tables(models.Model):
username = models.CharField(max_length = 10 , unique = True)
Name = models.CharField(max_length=50)
password = models.CharField(max_length=15)
designation = models.CharField(max_length=30)
date_of_birth = models.DateField()
def __str__(self):
return self.username
class Courses_Table(models.Model):
course_id = models.CharField(max_length = 6,unique = True)
course_name = models.CharField(max_length=50)
course_credits = models.IntegerField()
course_alias = models.CharField(max_length = 15,default = "None")
def __str__(self):
return self.course_name
class Students_Table(models.Model):
student_dept = models.CharField(max_length = 3)
student_year = models.CharField(max_length=4)
student_section = models.CharField(max_length=1)
student_rollno = models.CharField(max_length = 2)
student_name = models.CharField(max_length=50)
class Meta:
unique_together = ['student_dept','student_year','student_section','student_rollno']
def __str__(self):
return self.student_rollno
class Teacher_Course(models.Model):
prof = models.ForeignKey(Professor_Tables,on_delete=models.CASCADE)
courses_taken = models.ForeignKey(Courses_Table,on_delete=models.CASCADE)
batch = models.CharField(max_length=4)
section = models.CharField(max_length=1)
class Meta:
unique_together = ['prof','courses_taken','batch','section']
def __str__(self):
return str(self.prof) + ":" + str(self.courses_taken)
class Student_course(models.Model):
student = models.ForeignKey(Students_Table,on_delete=models.CASCADE)
course = models.ForeignKey(Courses_Table,on_delete=models.CASCADE)
class Meta:
unique_together = ['student','course']
def __str__(self):
return str(self.student) + " " + str(self.course)
class Student_attendance(models.Model):
student_course = models.OneToOneField(Student_course,on_delete=models.CASCADE)
classes_held = models.IntegerField(default = 0)
classes_attended = models.IntegerField(default = 0)
attendance_persentage = models.FloatField(default = 0.0)
def __str__(self):
return str(self.student_course) + ":" + str(self.attendance_persentage)
class Date_wise_attendance(models.Model):
student_attendance = models.ForeignKey(Student_attendance,on_delete=models.CASCADE)
date = models.DateField()
status = models.CharField(max_length = 8,default = "Absent")
number_of_hours = models.IntegerField(default=1)
def __str__(self):
return str(self.student_attendance) + ":" + str(self.date)
class periodicals_marks(models.Model):
student_course = models.OneToOneField(Student_course,on_delete=models.CASCADE)
periodicals_1 = models.FloatField(default=0.0)
periodicals_2 = models.FloatField(default=0.0)
def __str__(self):
return str(Student_course)
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from django.contrib import admin
from . import views
urlpatterns = [
url(r'^$',views.index),
url(r'^get_course_list$',views.Get_Course_List),
url(r'^get_complete_student_list$',views.get_complete_student_list),
url(r'^update_attendance$',views.update_attendance),
url(r'^update_marks$',views.update_marks),
url(r'^complete_mark_report$',views.complete_mark_report),
url(r'^complete_attendance_report$',views.complete_attendance_report),
]
from django.shortcuts import render,HttpResponse
from .models import Professor_Tables,Students_Table,Courses_Table,Teacher_Course,Student_course,Student_attendance,Date_wise_attendance,periodicals_marks
from django.views.decorators.csrf import csrf_exempt
# Create your views here.
@csrf_exempt
def index(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
try:
user = Professor_Tables.objects.get(username = username)
except (Professor_Tables.DoesNotExist,Professor_Tables.MultipleObjectsReturned):
user = None
return HttpResponse("false")
if (user != None):
if (user.username == username and user.password == password):
return HttpResponse("true")
else:
return HttpResponse("false")
else:
return HttpResponse("<h1>Get a Life!!!<br/>Ochi sanka naakura puka</h1>")
@csrf_exempt
def Get_Course_List(request):
if request.method == 'POST':
prof_name = request.POST['prof_name']
prof = Professor_Tables.objects.get(username = prof_name)
courses = Teacher_Course.objects.filter(prof = prof)
a = ""
for x in courses:
a += (x.courses_taken.course_id + ":" + x.courses_taken.course_alias + ":" + x.batch + ":" + x.section)
a += ";"
return HttpResponse(a)
else:
return HttpResponse("<h1>Get a Life!!!<br/>Ochi sanka naakura puka</h1>")
@csrf_exempt
def get_complete_student_list(request):
if request.method == 'POST':
complete = request.POST['complete_string']
array = complete.split(":")
course = Courses_Table.objects.get(course_id = array[0])
student = Students_Table.objects.filter(student_year = array[2],student_section = array[3])
student_list = []
obj = []
for i in student:
obj = Student_course.objects.filter(student = i,course = course)
if obj.exists():
student_list.append(obj[0])
else:
continue
a = ""
for x in student_list:
a += x.student.student_dept + x.student.student_rollno + ":" + x.student.student_name
a += ';'
return HttpResponse(a)
else:
return HttpResponse("<h1>Get a Life!!!<br/>Ochi sanka naakura puka</h1>")
@csrf_exempt
def update_attendance(request):
if request.method == 'POST':
roll_no = request.POST['roll_name'].split(":")[0]
name = request.POST['roll_name'].split(":")[1]
course_id = request.POST['course'].split(":")[0]
batch = request.POST['course'].split(":")[2]
section = request.POST['course'].split(":")[3]
date = request.POST['date']
reason = request.POST['reason']
status = request.POST['status']
student = Students_Table.objects.get(student_dept = roll_no[:3],student_year = batch,student_section = section,student_rollno = roll_no[3:5],student_name = name)
course = Courses_Table.objects.get(course_id = course_id)
student_course = Student_course.objects.get(student = student,course = course)
student_attendance = Student_attendance.objects.filter(student_course = student_course)
if len(student_attendance) == 0:
student_att = Student_attendance(student_course = student_course,classes_held = 0,classes_attended = 0,attendance_persentage = 0)
student_att.save()
else:
student_att = student_attendance[0]
date_wise = Date_wise_attendance.objects.filter(student_attendance = student_att,date = date)
if len(date_wise) == 0:
date_w = Date_wise_attendance(student_attendance = student_att,date = date,status = status)
date_w.save()
student_att.classes_held += 1
if status == "Present" or status == "OD":
student_att.classes_attended += 1
student_att.attendance_persentage = (student_att.classes_attended/student_att.classes_held)*100
student_att.save()
else:
student_att.attendance_persentage = (student_att.classes_attended/student_att.classes_held)*100
student_att.save()
else:
if status == "Present" or status == "OD":
if date_wise[0].status == "Absent":
student_att.classes_attended += 1
student_att.attendance_persentage = (student_att.classes_attended/student_att.classes_held)*100
student_att.save()
date_wise[0].status = status
date_wise[0].save()
else:
pass
else:
if date_wise[0].status == "Present":
student_att.classes_attended -= 1
student_att.attendance_persentage = (student_att.classes_attended/student_att.classes_held)*100
student_att.save()
date_wise[0].status = status
date_wise[0].save()
return HttpResponse("true")
else:
return HttpResponse("<h1>Get a Life!!!<br/>Ochi sanka naakura puka</h1>")
@csrf_exempt
def update_marks(request):
if request.method == 'POST':
roll_no = request.POST['roll_name'].split(":")[0]
name = request.POST['roll_name'].split(":")[1]
array = request.POST['course'].split(":")
periodical = request.POST['periodicals']
marks = int(request.POST['marks'])
course = Courses_Table.objects.get(course_id = array[0])
student = Students_Table.objects.get(student_dept = roll_no[:3],student_year = array[2],student_section = array[3],student_rollno = roll_no[3:5],student_name = name)
student_course = Student_course.objects.get(student = student,course = course)
student_marks = periodicals_marks.objects.filter(student_course = student_course)
if len(student_marks) == 0:
student_m = periodicals_marks(student_course = student_course)
if periodical == "Periodicals 1":
student_m.periodicals_1 = marks
else:
student_m.periodicals_2 = marks
student_m.save()
else:
if periodical == "Periodicals 1":
student_marks[0].periodicals_1 = marks
else:
student_marks[0].periodicals_2 = marks
student_marks[0].save()
return HttpResponse("true")
else:
return HttpResponse("<h1>Get a Life!!!<br/>Ochi sanka naakura puka</h1>")
@csrf_exempt
def complete_mark_report(request):
if request.method == 'POST':
array = request.POST['course'].split(':')
course = Courses_Table.objects.get(course_id = array[0])
students = Students_Table.objects.filter(student_section = array[3],student_year = array[2])
all_Students = []
for i in students:
s = Student_course.objects.filter(student = i,course = course)
if len(s) != 0:
all_Students.append(s[0])
final_string = ""
for i in all_Students:
k = periodicals_marks.objects.filter(student_course = i)
if len(k) != 0:
final_string += (k[0].student_course.student.student_dept + str(k[0].student_course.student.student_rollno) + ":" + str(k[0].student_course.student.student_name) + "/" + str(k[0].periodicals_1) + "/" + str(k[0].periodicals_2) + ";")
print(final_string)
return HttpResponse(final_string)
else:
return HttpResponse("<h1>Get a Life!!!<br/>Ochi sanka naakura puka</h1>")
@csrf_exempt
def complete_attendance_report(request):
if request.method == 'POST':
array = request.POST['course'].split(':')
course = Courses_Table.objects.get(course_id = array[0])
students = Students_Table.objects.filter(student_section = array[3],student_year = array[2])
all_Students = []
for i in students:
s = Student_course.objects.filter(student = i,course = course)
if len(s) != 0:
all_Students.append(s[0])
final_string = ""
for i in all_Students:
k = Student_attendance.objects.filter(student_course = i)
if len(k) != 0:
final_string += k[0].student_course.student.student_dept + str(k[0].student_course.student.student_rollno) + ":" + str(k[0].student_course.student.student_name) + "/" + str(k[0].attendance_persentage) + ";"
print(final_string)
return HttpResponse(final_string)
else:
return HttpResponse("<h1>Get a Life!!!<br/>Ochi sanka naakura puka</h1>")
File added
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AUPMS.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Project.iml" filepath="$PROJECT_DIR$/Project.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
/build
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment