def processUploadAttendance(request,course_code):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        if request.method == 'POST':
            form1 = read(request.POST, request.FILES)
            total = request.POST['date1']
            course = Course.objects.get(id= course_code)
            if form1.is_valid():
                newdoc = Document1(docfile = request.FILES['docfile'])
                newdoc.save()
                path = os.path.abspath(newdoc.docfile.url[1:])
                mark = np.genfromtxt(path, dtype='str', delimiter=',',unpack='True',skip_header=1)
                for i in range(250):
                    try:
                        # k = mark[1][i]
                        student = Student.objects.get(rollno=int(mark[1][i]))
                        studentInCourse = course.getStudents().filter(rollno=student.id)
                        if studentInCourse:
                            k = str(total).split('/')
                            l = k[2]+"-"+k[1]+'-'+k[0]
                            if mark[2][i][0] == 'P':
                                present = True
                            else:
                                present=False
                            save = AttendanceDaily.objects.create(rollno=student,coursecode=course,date=l,present=present)
                            save.save()
                    except:
                        continue
        return index(request)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 2
0
def courseHome(request, course_code):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_courseHome.html')
        current = AdminStaff.objects.filter(
            username=request.session['username'])[0]
        course = Course.objects.filter(pk=course_code)[0]
        course_semester = course.semester_offered
        if course_semester[0] == "M":
            course_semester = "Monsoon"
        else:
            course_semester = "Spring"
        faculty = course.getFaculty().name
        course = Course.objects.filter(id=course_code)[0]
        #query = "SELECT * FROM Students_record WHERE Students_record.coursecode_id = \'"+str(course.id)+"\' AND Students_record.semester_date = \'"+course.semester_offered[0]+str(course.year)+"\'"
        #ListofStudents = Record.objects.raw(query)
        ListofStudents = Record.objects.filter(coursecode=course.id)
        context = RequestContext(
            request, {
                'current': current,
                'course': course,
                'faculty': faculty,
                'course_semester': course_semester,
                'ListofStudents': ListofStudents
            })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def processUploadMarks(request,course_code):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        if request.method == 'POST':
            form = DocumentForm(request.POST, request.FILES)
            total = request.POST['totalMarks']
            examName = request.POST['examName']
            course = Course.objects.get(id= course_code)
            if form.is_valid():
                newdoc = Document(docfile = request.FILES['docfile'])
                newdoc.save()
                path = os.path.abspath(newdoc.docfile.url[1:])
                mark = np.genfromtxt(path, dtype='str', delimiter=',',unpack='True',skip_header=1)
                # sdfs = mark.ndarray
                for i in range(250):
                    try:
                        if mark[0][i] == "":
                            continue
                        koo = mark[1][i]
                        student = Student.objects.get(rollno=int(mark[1][i]))
                        studentInCourse = course.getStudents().filter(rollno=student.id)
                        if studentInCourse:
                            looo = mark[2][i]
                            # return sdfs
                            save = Marks.objects.create(rollno=student,category=examName,semester_date=course.semester_offered[0] + str(course.year),
                                coursecode=course,marks=int(mark[2][i]),total=int(total))
                            save.save()
                    except:
                        continue
        return index(request)
    return HttpResponseRedirect(redirect)
def viewStudentProfile(request, roll_no):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        template = loader.get_template('faculty/_viewStudent.html')
        current = Faculty.objects.filter(username=request.session['username'])[0]
        return studentViewStudentProfile(request, roll_no, 'faculty/_viewStudent.html', current)
    return HttpResponseRedirect(redirect)
def uploadSeatingChart(request,course_code):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        if request.method == 'POST':   
            date = request.POST['dateOfAttendance']
            chart = request.FILES['seating']
            seats = request.POST.getlist('SD[]')
            newdoc = Document(docfile = chart)
            newdoc.save()
            course = Course.objects.get(id= course_code)
            path = os.path.abspath(newdoc.docfile.url[1:])
            mark = np.genfromtxt(path, dtype='str', delimiter=',',unpack='True',skip_header=1)
            for i in range(250):
                try:
                    # k = mark[1][i]
                    student = Student.objects.get(rollno=int(mark[1][i]))
                    studentInCourse = course.getStudents().filter(rollno=student.id)
                    if studentInCourse:
                        seatnumber = mark[2][i]
                        if str(seatnumber) in seats:
                            present = True
                        else:
                            present = False
                        k = str(date).split('/')
                        l = k[2]+"-"+k[1]+'-'+k[0]
                        save = AttendanceDaily.objects.create(rollno=student,coursecode=course,date=l,present=present)
                        save.save()
                except:
                    continue
        return index(request)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 6
0
def editprofile(request):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        template = loader.get_template('faculty/_editprofile.html')
        current = Faculty.objects.filter(
            username=request.session['username'])[0]
        if request.method == "POST":
            photo = request.FILES['picture']
            current.username.photo = photo
            current.username.save(update_fields=['photo'])
            officeno = request.POST['officeno']
            buildingno = request.POST['buildingno']
            update = current
            update.officeno = officeno
            update.buildingno = buildingno
            update.save(update_fields=['officeno', 'buildingno'])
        email = str(current.username)
        emailSplit = email.split('@')
        context = RequestContext(
            request, {
                'current': current,
                'emailsuffix': emailSplit[1],
                'emailprefix': emailSplit[0]
            })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def upload(request):
	redirect = checkIdentity(request,'ta')
	if redirect == "":
		template = loader.get_template('ta/upload.html')
		current = TA.objects.filter(username=request.session['username'])[0]
		context = RequestContext(request, {'current': current,})
		return HttpResponse(template.render(context))
	return HttpResponseRedirect(redirect)
Ejemplo n.º 8
0
def searchResults(request):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        current = Faculty.objects.filter(
            username=request.session['username'])[0]
        return portalSearchResults(request, 'faculty/_searchResults.html',
                                   'faculty', current)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 9
0
def searchResults(request):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        current = AdminStaff.objects.filter(
            username=request.session['username'])[0]
        return portalSearchResults(request, 'adminStaff/_searchResults.html',
                                   'adminStaff', current)
    return HttpResponseRedirect(redirect)
def private_index(request):
	redirect = checkIdentity(request,'student')
	if redirect == "":
		template = loader.get_template('Students/private_profile.html')
		current = Student.objects.filter(username=request.session['username'])[0]
		context = RequestContext(request, {'current': current,})
		return HttpResponse(template.render(context))
	return HttpResponseRedirect(redirect)
Ejemplo n.º 11
0
def reports(request):
    redirect = checkIdentity(request, 'facultystaff')
    if redirect == "":
        current = FacultyStaff.objects.filter(
            username=request.session['username'])[0]
        return Reports(request, current, 'facultystaff/_reports.html',
                       'facultystaff/_results.html', 'facultystaff')
    return HttpResponseRedirect(redirect)
def index(request):
    redirect = checkIdentity(request,'ta')
    if redirect == "":
        template = loader.get_template('ta/index.html')
        current = TA.objects.filter(username=request.session['username'])[0]
        ListofStudents = Record.objects.filter(coursecode=current.coursecode.id)
        context = RequestContext(request, {'current': current,'ListofStudents': ListofStudents,})
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def index(request):
	redirect = checkIdentity(request,'student')
	if redirect == "":
		template = loader.get_template('Students/index.html')
		current = Student.objects.filter(username=request.session['username'])[0]
		attendance = AttendanceDaily.objects.filter(rollno=current.id,present=False)
		context = RequestContext(request, {'current': current,'attendance':attendance,})
		return HttpResponse(template.render(context))
	return HttpResponseRedirect(redirect)
Ejemplo n.º 14
0
def viewStudentProfile(request, roll_no):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        current = AdminStaff.objects.filter(
            username=request.session['username'])[0]
        return studentViewStudentProfile(request, roll_no,
                                         'adminStaff/_viewStudent.html',
                                         current)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 15
0
def viewStudentProfile(request, roll_no):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        template = loader.get_template('faculty/_viewStudent.html')
        current = Faculty.objects.filter(
            username=request.session['username'])[0]
        return studentViewStudentProfile(request, roll_no,
                                         'faculty/_viewStudent.html', current)
    return HttpResponseRedirect(redirect)
def feedback(request):
	redirect = checkIdentity(request,'student')
	if redirect == "":
		current = Student.objects.filter(username=request.session['username'])[0]
		if request.method == "POST":
			feedback_message = request.POST['feedback_message']
			flag = Feedback(message=feedback_message, fromusername=str(current.username), fromrole='student')
			flag.save()
			return index(request)
	return HttpResponseRedirect(redirect)
Ejemplo n.º 17
0
def upload(request):
    redirect = checkIdentity(request, 'ta')
    if redirect == "":
        template = loader.get_template('ta/upload.html')
        current = TA.objects.filter(username=request.session['username'])[0]
        context = RequestContext(request, {
            'current': current,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 18
0
def private_index(request):
    redirect = checkIdentity(request, 'student')
    if redirect == "":
        template = loader.get_template('Students/private_profile.html')
        current = Student.objects.filter(
            username=request.session['username'])[0]
        context = RequestContext(request, {
            'current': current,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def uploadPicture(request):
    redirect = checkIdentity(request,'facultystaff')
    if redirect == "":
        # template = loader.get_template('facultyStaff/_index.html')
        current = FacultyStaff.objects.filter(username=request.session['username'])[0]
        if request.method == "POST":
            picture = request.FILES['picture']
            if picture:
                current.username.photo = picture
                current.username.save(update_fields=['photo',])
        return new_index(request)
    return HttpResponseRedirect(redirect)
def new_index(request):
    redirect = checkIdentity(request,'facultystaff')
    if redirect == "":
        template = loader.get_template('facultyStaff/_index.html')
        current = FacultyStaff.objects.filter(username=request.session['username'])[0]
        course = current.courseDetails()
        TAs = {}
        if course:
            TAs[course.coursename] = TA.objects.filter(coursecode_id=course.id)
        context = RequestContext(request, {'current': current, 'courses': course, 'TAs': TAs, })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def index(request):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        template = loader.get_template('faculty/_index.html')
        current = Faculty.objects.filter(username=request.session['username'])[0]
        courses = Course.objects.filter(faculty=current.id)
        TAs = {}
        for course in courses:
            TAs[course.coursename] = TA.objects.filter(coursecode_id=course.id)
        context = RequestContext(request, {'current': current, 'courses': courses, 'TAs': TAs, })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 22
0
def feedback(request):
    redirect = checkIdentity(request, 'parent')
    if redirect == "":
        current = Parents.objects.filter(
            username=request.session['username'])[0]
        if request.method == "POST":
            feedback_message = request.POST['feedback_message']
            flag = Feedback(message=feedback_message,
                            fromusername=str(current.username),
                            fromrole='parent')
            flag.save()
            return notifications(request)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 23
0
def index(request):
    redirect = checkIdentity(request, 'ta')
    if redirect == "":
        template = loader.get_template('ta/index.html')
        current = TA.objects.filter(username=request.session['username'])[0]
        ListofStudents = Record.objects.filter(
            coursecode=current.coursecode.id)
        context = RequestContext(request, {
            'current': current,
            'ListofStudents': ListofStudents,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 24
0
def editStudentProfile(request, roll_no):
    redirect = checkIdentity(request, 'student')
    if redirect == "":
        current = Student.objects.filter(
            username=request.session['username'])[0]
        if request.method == "POST":
            fathers_name = request.POST['fathersname']
            mothers_name = request.POST['mothersname']
            roomno = request.POST['roomno']
            private = request.POST.getlist('private[]')
            if "private" in private:
                private = True
            else:
                private = False
            hostel = request.POST['hostel']
            pa_flatno = request.POST['pa_flatno']
            pa_line1 = request.POST['pa_line1']
            pa_line2 = request.POST['pa_line2']
            pa_city = request.POST['pa_city']
            pa_state = request.POST['pa_state']
            pa_country = request.POST['pa_country']
            pa_pincode = request.POST['pa_pincode']
            update = current
            update.fathers_name = fathers_name
            update.mothers_name = mothers_name
            update.roomno = roomno
            update.hostel = hostel
            update.pa_flatno = pa_flatno
            update.pa_line1 = pa_line1
            update.pa_line2 = pa_line2
            update.pa_city = pa_city
            update.pa_state = pa_state
            update.pa_country = pa_country
            update.pa_pincode = pa_pincode
            update.private = private
            update.save(update_fields=[
                'private',
                'fathers_name',
                'mothers_name',
                'roomno',
                'hostel',
                'pa_flatno',
                'pa_line1',
                'pa_line2',
                'pa_city',
                'pa_state',
                'pa_country',
                'pa_pincode',
            ])
            return index(request)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 25
0
def index(request):
    redirect = checkIdentity(request, 'student')
    if redirect == "":
        template = loader.get_template('Students/index.html')
        current = Student.objects.filter(
            username=request.session['username'])[0]
        attendance = AttendanceDaily.objects.filter(rollno=current.id,
                                                    present=False)
        context = RequestContext(request, {
            'current': current,
            'attendance': attendance,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def uploadPicture(request,roll_no):
	redirect = checkIdentity(request,'student')
	if redirect == "":
		template = loader.get_template('Students/index.html')
		current = Student.objects.filter(username=request.session['username'])[0]
		if request.method == "POST":
			picture = request.FILES['picture']
			if picture:
				current.username.photo = picture
				current.username.save(update_fields=['photo',])
		attendance = AttendanceDaily.objects.filter(rollno=current.id,present=False)
		context = RequestContext(request, {'current': current,'attendance':attendance,})
		return HttpResponse(template.render(context))
	return HttpResponseRedirect(redirect)
def uploadPicture(request):
    redirect = checkIdentity(request,'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_index.html')
        current = AdminStaff.objects.filter(username=request.session['username'])[0]
        if request.method == "POST":
            picture = request.FILES['picture']
            if picture:
                current.username.photo = picture
                current.username.save(update_fields=['photo',])
        feedbackList = Feedback.objects.all
        context = RequestContext(request, {'current': current, 'feedbackList': feedbackList, 'sent':"", })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 28
0
def attendance(request):
    redirect = checkIdentity(request, 'parent')
    if redirect == "":
        template = loader.get_template('Parents/attendance.html')
        current = Parents.objects.filter(
            username=request.session['username'])[0]
        dailyAttendance = AttendanceDaily.objects.filter(
            rollno=current.getStudent().id, present=False)
        context = RequestContext(request, {
            'current': current,
            'dailyAttendance': dailyAttendance
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 29
0
def uploadPicture(request):
    redirect = checkIdentity(request, 'facultystaff')
    if redirect == "":
        # template = loader.get_template('facultyStaff/_index.html')
        current = FacultyStaff.objects.filter(
            username=request.session['username'])[0]
        if request.method == "POST":
            picture = request.FILES['picture']
            if picture:
                current.username.photo = picture
                current.username.save(update_fields=[
                    'photo',
                ])
        return new_index(request)
    return HttpResponseRedirect(redirect)
def viewStudentProfile(request,roll_no):
	redirect = checkIdentity(request,'student')
	if redirect == "":
		current = Student.objects.filter(username=request.session['username'])[0]
		student = Student.objects.filter(rollno = roll_no)[0]
		private = student.private
		if student == current:
			private = False
		if private:
			template = loader.get_template('Students/private_profile.html')
			context = RequestContext(request, {'current': current, 'student':student,})
			return HttpResponse(template.render(context))
		else:
			return studentViewStudentProfile(request,roll_no,'Students/viewStudentProfile.html',current)
	return HttpResponseRedirect(redirect)
def addNewMonthlyAttendance(request,course_code):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        if request.method == 'POST':   
            start_date = request.POST['start_date']
            end_date = request.POST['end_date']
            classes_taken_place = request.POST['classes_taken_place']
            course = Course.objects.get(id= course_code)
            try:
                save = AttendanceMonthly.objects.create(start_date=start_date,end_date=end_date,classes_taken_place=classes_taken_place,coursecode=course)
                save.save()
            except:
                pass
        return courseHome(request,course_code)
    return HttpResponseRedirect(redirect)
def index(request):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_index.html')
        current = AdminStaff.objects.filter(username=request.session['username'])[0]
        feedbackList = Feedback.objects.all
        if request.method == 'POST':
            notification_message = request.POST['message']
            sendNotification(request, 'ALL', '', notification_message)
            sent = "Notification sent Successfully"
            context = RequestContext(request, {'current': current, 'feedbackList': feedbackList, 'sent':sent, })
        else:
            context = RequestContext(request, {'current': current, 'feedbackList': feedbackList, 'sent':"", })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def coursesList(request):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_coursesList.html')
        current = AdminStaff.objects.filter(username=request.session['username'])[0]
        if request.method == 'POST':
            course_input = request.POST['course_input']
            query = "SELECT * FROM portal_course WHERE coursename LIKE \'%"+course_input+"%\' OR coursecode LIKE \'%" +course_input+ "%\'"
            courseList = Course.objects.raw(query)
            view_all = "Search Results"
        else:    
            courseList = Course.objects.all
            view_all = "All"
        context = RequestContext(request, {'current': current, 'courseList': courseList, 'all':view_all, })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 34
0
def notifications(request):
    redirect = checkIdentity(request, 'parent')
    if redirect == "":
        template = loader.get_template('Parents/notifications.html')
        current = Parents.objects.filter(
            username=request.session['username'])[0]
        # notifications = Notification.objects.raw("SELECT * FROM portal_notification WHERE to LIKE \'%"+str(current.username)+"\'% OR to = 'ALL' ")
        lab = str(current.username)
        notifications = Notification.objects.filter(
            Q(to__contains=str(current.username)) | Q(to__contains='ALL'))
        context = RequestContext(request, {
            'current': current,
            'notifications': notifications
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 35
0
def new_index(request):
    redirect = checkIdentity(request, 'facultystaff')
    if redirect == "":
        template = loader.get_template('facultyStaff/_index.html')
        current = FacultyStaff.objects.filter(
            username=request.session['username'])[0]
        course = current.courseDetails()
        TAs = {}
        if course:
            TAs[course.coursename] = TA.objects.filter(coursecode_id=course.id)
        context = RequestContext(request, {
            'current': current,
            'courses': course,
            'TAs': TAs,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 36
0
def index(request):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        template = loader.get_template('faculty/_index.html')
        current = Faculty.objects.filter(
            username=request.session['username'])[0]
        courses = Course.objects.filter(faculty=current.id)
        TAs = {}
        for course in courses:
            TAs[course.coursename] = TA.objects.filter(coursecode_id=course.id)
        context = RequestContext(request, {
            'current': current,
            'courses': courses,
            'TAs': TAs,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 37
0
def profile(request):
    redirect = checkIdentity(request, 'parent')
    if redirect == "":
        current = Parents.objects.filter(
            username=request.session['username'])[0]
        if request.method == "POST":
            name = request.POST['name']
            contact_number = request.POST['contact_number']
            plot_no = request.POST['plot_no']
            addr_line1 = request.POST['addr_line1']
            addr_line2 = request.POST['addr_line2']
            city = request.POST['city']
            state = request.POST['state']
            country = request.POST['country']
            pincode = request.POST['pincode']
            update = current
            update.name = name
            update.contact_no = contact_number
            update.plot_flatno = plot_no
            update.addr_line1 = addr_line1
            update.addr_line2 = addr_line2
            update.city = city
            update.state = state
            update.country = country
            update.pincode = pincode
            update.save(update_fields=[
                'name',
                'contact_no',
                'plot_flatno',
                'addr_line1',
                'addr_line2',
                'city',
                'state',
                'country',
                'pincode',
            ])
            # return afsd
            return notifications(request)
        else:
            template = loader.get_template('Parents/editprofile.html')
        context = RequestContext(request, {
            'current': current,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def courseHome(request, course_code):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_courseHome.html')
        current = AdminStaff.objects.filter(username=request.session['username'])[0]
        course = Course.objects.filter(pk=course_code)[0]
        course_semester = course.semester_offered
        if course_semester[0] == "M":
            course_semester = "Monsoon"
        else:
            course_semester = "Spring"
        faculty = course.getFaculty().name
        course = Course.objects.filter(id=course_code)[0]
        #query = "SELECT * FROM Students_record WHERE Students_record.coursecode_id = \'"+str(course.id)+"\' AND Students_record.semester_date = \'"+course.semester_offered[0]+str(course.year)+"\'"
        #ListofStudents = Record.objects.raw(query)
        ListofStudents = Record.objects.filter(coursecode=course.id)
        context = RequestContext(request, {'current': current, 'course': course, 'faculty': faculty, 'course_semester': course_semester, 'ListofStudents': ListofStudents})
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 39
0
def addNewMonthlyAttendance(request, course_code):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        if request.method == 'POST':
            start_date = request.POST['start_date']
            end_date = request.POST['end_date']
            classes_taken_place = request.POST['classes_taken_place']
            course = Course.objects.get(id=course_code)
            try:
                save = AttendanceMonthly.objects.create(
                    start_date=start_date,
                    end_date=end_date,
                    classes_taken_place=classes_taken_place,
                    coursecode=course)
                save.save()
            except:
                pass
        return courseHome(request, course_code)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 40
0
def processUploadMarks(request, course_code):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        if request.method == 'POST':
            form = DocumentForm(request.POST, request.FILES)
            total = request.POST['totalMarks']
            examName = request.POST['examName']
            course = Course.objects.get(id=course_code)
            if form.is_valid():
                newdoc = Document(docfile=request.FILES['docfile'])
                newdoc.save()
                path = os.path.abspath(newdoc.docfile.url[1:])
                mark = np.genfromtxt(path,
                                     dtype='str',
                                     delimiter=',',
                                     unpack='True',
                                     skip_header=1)
                # sdfs = mark.ndarray
                for i in range(250):
                    try:
                        if mark[0][i] == "":
                            continue
                        koo = mark[1][i]
                        student = Student.objects.get(rollno=int(mark[1][i]))
                        studentInCourse = course.getStudents().filter(
                            rollno=student.id)
                        if studentInCourse:
                            looo = mark[2][i]
                            # return sdfs
                            save = Marks.objects.create(
                                rollno=student,
                                category=examName,
                                semester_date=course.semester_offered[0] +
                                str(course.year),
                                coursecode=course,
                                marks=int(mark[2][i]),
                                total=int(total))
                            save.save()
                    except:
                        continue
        return index(request)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 41
0
def viewStudentProfile(request, roll_no):
    redirect = checkIdentity(request, 'student')
    if redirect == "":
        current = Student.objects.filter(
            username=request.session['username'])[0]
        student = Student.objects.filter(rollno=roll_no)[0]
        private = student.private
        if student == current:
            private = False
        if private:
            template = loader.get_template('Students/private_profile.html')
            context = RequestContext(request, {
                'current': current,
                'student': student,
            })
            return HttpResponse(template.render(context))
        else:
            return studentViewStudentProfile(
                request, roll_no, 'Students/viewStudentProfile.html', current)
    return HttpResponseRedirect(redirect)
def editprofile(request):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        template = loader.get_template('faculty/_editprofile.html')
        current = Faculty.objects.filter(username=request.session['username'])[0]
        if request.method == "POST":
            photo = request.FILES['picture']
            current.username.photo = photo
            current.username.save(update_fields=['photo'])
            officeno = request.POST['officeno']
            buildingno = request.POST['buildingno']
            update = current
            update.officeno = officeno
            update.buildingno = buildingno
            update.save(update_fields=['officeno', 'buildingno'])
        email = str(current.username)
        emailSplit = email.split('@')
        context = RequestContext(request, {'current': current, 'emailsuffix':emailSplit[1], 'emailprefix':emailSplit[0]})
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 43
0
def uploadSeatingChart(request, course_code):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        if request.method == 'POST':
            date = request.POST['dateOfAttendance']
            chart = request.FILES['seating']
            seats = request.POST.getlist('SD[]')
            newdoc = Document(docfile=chart)
            newdoc.save()
            course = Course.objects.get(id=course_code)
            path = os.path.abspath(newdoc.docfile.url[1:])
            mark = np.genfromtxt(path,
                                 dtype='str',
                                 delimiter=',',
                                 unpack='True',
                                 skip_header=1)
            for i in range(250):
                try:
                    # k = mark[1][i]
                    student = Student.objects.get(rollno=int(mark[1][i]))
                    studentInCourse = course.getStudents().filter(
                        rollno=student.id)
                    if studentInCourse:
                        seatnumber = mark[2][i]
                        if str(seatnumber) in seats:
                            present = True
                        else:
                            present = False
                        # m = seats.index(str(seatnumber))
                        k = str(date).split('/')
                        l = k[2] + "-" + k[1] + '-' + k[0]
                        save = AttendanceDaily.objects.create(
                            rollno=student,
                            coursecode=course,
                            date=l,
                            present=present)
                        save.save()
                except:
                    continue
        return courseHome(request, course_code)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 44
0
def uploadPicture(request, roll_no):
    redirect = checkIdentity(request, 'student')
    if redirect == "":
        template = loader.get_template('Students/index.html')
        current = Student.objects.filter(
            username=request.session['username'])[0]
        if request.method == "POST":
            picture = request.FILES['picture']
            if picture:
                current.username.photo = picture
                current.username.save(update_fields=[
                    'photo',
                ])
        attendance = AttendanceDaily.objects.filter(rollno=current.id,
                                                    present=False)
        context = RequestContext(request, {
            'current': current,
            'attendance': attendance,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 45
0
def uploadPicture(request):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_index.html')
        current = AdminStaff.objects.filter(
            username=request.session['username'])[0]
        if request.method == "POST":
            picture = request.FILES['picture']
            if picture:
                current.username.photo = picture
                current.username.save(update_fields=[
                    'photo',
                ])
        feedbackList = Feedback.objects.all
        context = RequestContext(request, {
            'current': current,
            'feedbackList': feedbackList,
            'sent': "",
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 46
0
def coursesList(request):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_coursesList.html')
        current = AdminStaff.objects.filter(
            username=request.session['username'])[0]
        if request.method == 'POST':
            course_input = request.POST['course_input']
            query = "SELECT * FROM portal_course WHERE coursename LIKE \'%" + course_input + "%\' OR coursecode LIKE \'%" + course_input + "%\'"
            courseList = Course.objects.raw(query)
            view_all = "Search Results"
        else:
            courseList = Course.objects.all
            view_all = "All"
        context = RequestContext(request, {
            'current': current,
            'courseList': courseList,
            'all': view_all,
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 47
0
def processUploadAttendance(request, course_code):
    redirect = checkIdentity(request, 'ta')
    if redirect == "":
        if request.method == 'POST':
            form1 = read(request.POST, request.FILES)
            total = request.POST['date1']
            course = Course.objects.get(id=course_code)
            if form1.is_valid():
                newdoc = Document1(docfile=request.FILES['docfile'])
                newdoc.save()
                path = os.path.abspath(newdoc.docfile.url[1:])
                mark = np.genfromtxt(path,
                                     dtype='str',
                                     delimiter=',',
                                     unpack='True',
                                     skip_header=1)
                for i in range(250):
                    try:
                        # k = mark[1][i]
                        student = Student.objects.get(rollno=int(mark[1][i]))
                        studentInCourse = course.getStudents().filter(
                            rollno=student.id)
                        if studentInCourse:
                            k = str(total).split('/')
                            l = k[2] + "-" + k[1] + '-' + k[0]
                            if mark[2][i][0] == 'P':
                                present = True
                            else:
                                present = False
                            save = AttendanceDaily.objects.create(
                                rollno=student,
                                coursecode=course,
                                date=l,
                                present=present)
                            save.save()
                    except:
                        continue
        return index(request)
    return HttpResponseRedirect(redirect)
Ejemplo n.º 48
0
def statistics(request):
    redirect = checkIdentity(request, 'parent')
    if redirect == "":
        template = loader.get_template('Parents/statistics.html')
        current = Parents.objects.filter(
            username=request.session['username'])[0]
        cgpalist = []
        colorlist1 = []
        colorlist2 = []
        keylist = []
        k = 6
        while k != 11:
            cgpalist.append(getCGPAByRange(k - 1, k, current))
            colorlist1.append(getRandomColor())
            colorlist2.append(getRandomColor())
            keylist.append("CGPA - " + str(k - 1) + ".0 and " + str(k) + ".0")
            k = k + 1
        cgpalist1 = zip(cgpalist, colorlist1, colorlist2, keylist)
        cgpalist = []
        colorlist1 = []
        colorlist2 = []
        keylist = []
        k = 6
        while k != 11:
            cgpalist.append(getCGPAByRangeAndProgramme(k - 1, k, current))
            colorlist1.append(getRandomColor())
            colorlist2.append(getRandomColor())
            keylist.append("CGPA - " + str(k - 1) + ".0 and " + str(k) + ".0")
            k = k + 1
        cgpalist2 = zip(cgpalist, colorlist1, colorlist2, keylist)
        context = RequestContext(request, {
            'current': current,
            'cgpalist1': cgpalist1,
            'cgpalist2': cgpalist2
        })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def editStudentProfile(request,roll_no):
	redirect = checkIdentity(request,'student')
	if redirect == "":
		current = Student.objects.filter(username=request.session['username'])[0]
		if request.method == "POST":
			fathers_name = request.POST['fathersname']
			mothers_name = request.POST['mothersname']
			roomno = request.POST['roomno']
			private = request.POST.getlist('private[]')
			if "private" in private:
				private = True
			else:
				private = False
			hostel = request.POST['hostel']
			pa_flatno = request.POST['pa_flatno']
			pa_line1 = request.POST['pa_line1']
			pa_line2 = request.POST['pa_line2']
			pa_city = request.POST['pa_city']
			pa_state = request.POST['pa_state']
			pa_country = request.POST['pa_country']
			pa_pincode = request.POST['pa_pincode']
			update = current
			update.fathers_name = fathers_name
			update.mothers_name = mothers_name
			update.roomno = roomno
			update.hostel = hostel
			update.pa_flatno = pa_flatno
			update.pa_line1 = pa_line1
			update.pa_line2 = pa_line2
			update.pa_city = pa_city
			update.pa_state = pa_state
			update.pa_country = pa_country
			update.pa_pincode = pa_pincode
			update.private = private
			update.save(update_fields=['private','fathers_name','mothers_name','roomno','hostel','pa_flatno','pa_line1','pa_line2','pa_city','pa_state','pa_country','pa_pincode',])
			return index(request)
	return HttpResponseRedirect(redirect)
Ejemplo n.º 50
0
def index(request):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        template = loader.get_template('adminStaff/_index.html')
        current = AdminStaff.objects.filter(
            username=request.session['username'])[0]
        feedbackList = Feedback.objects.all
        if request.method == 'POST':
            notification_message = request.POST['message']
            sendNotification(request, 'ALL', '', notification_message)
            sent = "Notification sent Successfully"
            context = RequestContext(request, {
                'current': current,
                'feedbackList': feedbackList,
                'sent': sent,
            })
        else:
            context = RequestContext(request, {
                'current': current,
                'feedbackList': feedbackList,
                'sent': "",
            })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def searchResults(request):
    redirect = checkIdentity(request, 'facultystaff')
    if redirect == "":
        current = FacultyStaff.objects.filter(username=request.session['username'])[0]
        return portalSearchResults(request, 'facultystaff/_searchResults.html', 'facultystaff', current)
    return HttpResponseRedirect(redirect)
def viewStudentProfile(request, roll_no):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        current = AdminStaff.objects.filter(username=request.session['username'])[0]
        return studentViewStudentProfile(request, roll_no, 'adminStaff/_viewStudent.html', current)
    return HttpResponseRedirect(redirect)
def reports(request):
    redirect = checkIdentity(request, 'adminstaff')
    if redirect == "":
        current = AdminStaff.objects.filter(username=request.session['username'])[0]
        return Reports(request, current, 'adminStaff/_reports.html', 'adminStaff/_results.html','adminStaff')
    return HttpResponseRedirect(redirect)
def reports(request):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        current = Faculty.objects.filter(username=request.session['username'])[0]
        return Reports(request, current, 'faculty/_reports.html', 'faculty/_results.html','faculty')
    return HttpResponseRedirect(redirect)
def searchResults(request):
    redirect = checkIdentity(request, 'student')
    if redirect == "":
        current = Student.objects.filter(username=request.session['username'])[0]
        return portalSearchResults(request, 'Students/_searchResults.html', 'student', current)
    return HttpResponseRedirect(redirect)
def grades(request, course_code):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        if request.method == 'POST':
            category = request.POST['category']
            k = []
            if category == 'MidSem1':
                cat = "MD1"
                k = request.POST.getlist('MD1[]')
                k1 = request.POST.getlist('MD1T[]')
            elif category == 'MidSem2':
                cat = "MD2"
                k = request.POST.getlist('MD2[]')
                k1 = request.POST.getlist('MD2T[]')
            else:
                cat = "ESM"
                k = request.POST.getlist('ESM[]')
                k1 = request.POST.getlist('ESMT[]')
            names = request.POST.getlist('rollnos[]')
            UpdateList = zip(names,k,k1)
            course = Course.objects.filter(pk=course_code)[0]
            for name,marks,total in UpdateList:
                try:
                    Students = Marks.objects.get(coursecode=course.id, category=cat,rollno=name)
                    Students.marks = marks
                    Students.total = total
                    marks = marks
                    Students.save(update_fields=['marks','total'])
                except:
                    k = Student.objects.get(id=name)
                    if not marks:
                        marks = 0
                    if not total:
                        total = 0
                    l = Marks.objects.create(rollno=k,coursecode=course,category=cat,marks=float(int(marks)),total=float(int(total)))
                    l.save()
        template = loader.get_template('faculty/_grades.html')
        current = Faculty.objects.filter(username=request.session['username'])[0]
        course = Course.objects.filter(pk=course_code)[0]
        course_semester = course.semester_offered
        if course_semester[0] == "M":
            course_semester = "Monsoon"
        else:
            course_semester = "Spring"
        faculty = course.getFaculty().name
        ListofStudents = course.getStudents()
        StudentName = []
        StudentID = []
        ListofMarks1 = []
        ListofMarks2 = []
        ListofMarks3 = []
        ListofTotal1 = []
        ListofTotal2 = []
        ListofTotal3 = []
        for student in ListofStudents:
            StudentName.append(student.rollno.name)
            StudentID.append(student.rollno.id)
            L1 = Marks.objects.filter(coursecode=course.id, category='MD1', rollno = student.rollno.id)
            L2 = Marks.objects.filter(coursecode=course.id, category='MD2', rollno = student.rollno.id)
            L3 = Marks.objects.filter(coursecode=course.id, category='ESM', rollno = student.rollno.id)
            if L1:
                ListofMarks1.append(L1[0].marks)
                ListofTotal1.append(L1[0].total)
            else:
                ListofMarks1.append([])
                ListofTotal1.append([])
            if L2:
                ListofMarks2.append(L2[0].marks)
                ListofTotal2.append(L2[0].total)
            else:
                ListofMarks2.append([])
                ListofTotal2.append([])
            if L3:
                ListofMarks3.append(L3[0].marks)
                ListofTotal3.append(L3[0].total)
            else:
                ListofMarks3.append([])
                ListofTotal3.append([])
        ListofMarks = zip(StudentID,StudentName,ListofMarks1,ListofTotal1,ListofMarks2,ListofTotal2,ListofMarks3,ListofTotal3)
        form = DocumentForm()
        context = RequestContext(request, {'current': current, 'course': course, 'faculty': faculty, 'course_semester': course_semester, 'ListofMarks': ListofMarks,'form':form})
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def attendance(request, course_code):
    redirect = checkIdentity(request, 'faculty')
    if redirect == "":
        template = loader.get_template('faculty/_attendance.html')
        current = Faculty.objects.filter(username=request.session['username'])[0]
        course = Course.objects.filter(pk=course_code)[0]
        course_semester = course.semester_offered
        if course_semester[0] == "M":
            course_semester = "Monsoon"
        else:
            course_semester = "Spring"
        faculty = course.getFaculty().name
        if request.method == "POST":
            ListofStudents = course.getStudents()
            period = request.POST['periods']
            date = request.POST['date']
            period = AttendanceMonthly.objects.filter(id = int(period))
            if period:
                selectValue = period[0]
                attendance = []
                for student in ListofStudents:
                    l = student.id
                    k = student.rollno
                    total = AttendanceDaily.objects.filter(rollno=student.rollno, coursecode=course.id, present=True, date__range=(period[0].start_date, period[0].end_date))
                    attendance.append(total.count())
                    # return adf
                ListofStudents = zip(ListofStudents,attendance)
                total = period[0].classes_taken_place
                totalList = AttendanceMonthly.objects.filter(coursecode=course.id)
            else:
                selectValue = 0
                attendance = []
                for student in ListofStudents:
                    l = student.id
                    k = student.rollno
                    total = AttendanceDaily.objects.filter(rollno=student.rollno, coursecode=course.id, present=True)
                    attendance.append(total.count())
                    # return adf
                ListofStudents = zip(ListofStudents,attendance)
                total = AttendanceMonthly.objects.filter(coursecode=course.id).aggregate(Sum('classes_taken_place'))
                total = total['classes_taken_place__sum']
                totalList = AttendanceMonthly.objects.filter(coursecode=course.id)
            if date == '1990-01-01':
                DselectValue = 0
            else:
                DselectValue = date
            DtotalList = AttendanceDaily.objects.filter(coursecode=course.id).values_list('date', flat=True).distinct()
            DListofStudents = AttendanceDaily.objects.filter(coursecode=course.id,date=date)
            context = RequestContext(request, {'current': current, 'course': course, 'faculty': faculty,
             'course_semester': course_semester, 'ListofStudents': ListofStudents, 'total': total, 'totalList': totalList, 'DtotalList': DtotalList,'DListofStudents':DListofStudents, 'selectValue': selectValue,'DselectValue': DselectValue})
        else:
            selectValue = 0
            ListofStudents = course.getStudents()
            attendance = []
            for student in ListofStudents:
                l = student.id
                k = student.rollno
                total = AttendanceDaily.objects.filter(rollno=student.rollno, coursecode=course.id, present=True)
                attendance.append(total.count())
                # return adf
            ListofStudents = zip(ListofStudents,attendance)
            total = AttendanceMonthly.objects.filter(coursecode=course.id).aggregate(Sum('classes_taken_place'))
            totalList = AttendanceMonthly.objects.filter(coursecode=course.id)
            # return wers
            form1 = read()
            DtotalList = AttendanceDaily.objects.filter(coursecode=course.id).values_list('date', flat=True).distinct() #AttendanceDaily.objects.filter(coursecode=course.id).distinct('date')
            total = total['classes_taken_place__sum']
            context = RequestContext(request, {'current': current, 'course': course, 'faculty': faculty,
             'course_semester': course_semester, 'ListofStudents': ListofStudents, 'total': total, 'totalList': totalList,'DtotalList': DtotalList, 'selectValue':selectValue,'form1':form1})
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
Ejemplo n.º 58
0
def updateMarks(request, course_code):
    redirect = checkIdentity(request, 'ta')
    if redirect == "":
        if request.method == 'POST':
            category = request.POST['category']
            k = []
            # if category == 'Quiz1':
            # 	cat = "Q1"
            # 	k = request.POST.getlist('Q1[]')
            #     k1 = request.POST.getlist('Q1T[]')
            # if category == 'Quiz2':
            # 	cat = "Q2"
            # 	k = request.POST.getlist('Q2[]')
            #     k1 = request.POST.getlist('Q2T[]')
            # if category == 'Quiz3':
            # 	cat = "Q3"
            # 	k = request.POST.getlist('Q3[]')
            #     k1 = request.POST.getlist('Q3T[]')
            if category == 'MidSem1':
                cat = "MD1"
                k = request.POST.getlist('MD1[]')
                k1 = request.POST.getlist('MD1T[]')
            elif category == 'MidSem2':
                cat = "MD2"
                k = request.POST.getlist('MD2[]')
                k1 = request.POST.getlist('MD2T[]')
            else:
                cat = "ESM"
                k = request.POST.getlist('ESM[]')
                k1 = request.POST.getlist('ESMT[]')
            names = request.POST.getlist('rollnos[]')
            UpdateList = zip(names, k, k1)
            course = Course.objects.filter(pk=course_code)[0]
            # return asf
            for name, marks, total in UpdateList:
                try:
                    Students = Marks.objects.get(coursecode=course.id,
                                                 category=cat,
                                                 rollno=name)
                    Students.marks = marks
                    Students.total = total
                    marks = marks
                    Students.save(update_fields=['marks', 'total'])
                except:
                    k = Student.objects.get(id=name)
                    if not marks:
                        marks = 0
                    if not total:
                        total = 0
                    l = Marks.objects.create(rollno=k,
                                             coursecode=course,
                                             category=cat,
                                             marks=float(int(marks)),
                                             total=float(int(total)))
                    l.save()
                #return ihuh
        template = loader.get_template('ta/_updateMarks.html')
        current = TA.objects.filter(username=request.session['username'])[0]
        course = Course.objects.filter(pk=course_code)[0]
        ListofStudents = course.getStudents()
        StudentName = []
        StudentID = []
        ListofMarks1 = []
        ListofMarks2 = []
        ListofMarks3 = []
        ListofTotal1 = []
        ListofTotal2 = []
        ListofTotal3 = []
        # ListofMarks4 = []
        # ListofMarks5 = []
        # ListofMarks6 = []
        # ListofTotal4 = []
        # ListofTotal5 = []
        # ListofTotal6 = []
        for student in ListofStudents:
            StudentName.append(student.rollno.name)
            StudentID.append(student.rollno.id)
            L1 = Marks.objects.filter(coursecode=course.id,
                                      category='MD1',
                                      rollno=student.rollno.id)
            L2 = Marks.objects.filter(coursecode=course.id,
                                      category='MD2',
                                      rollno=student.rollno.id)
            L3 = Marks.objects.filter(coursecode=course.id,
                                      category='ESM',
                                      rollno=student.rollno.id)
            # L4 = Marks.objects.filter(coursecode=course.id, category='Q1', rollno = student.rollno.id)
            # L5 = Marks.objects.filter(coursecode=course.id, category='Q2', rollno = student.rollno.id)
            # L6 = Marks.objects.filter(coursecode=course.id, category='Q3', rollno = student.rollno.id)
            if L1:
                ListofMarks1.append(L1[0].marks)
                ListofTotal1.append(L1[0].total)
            else:
                ListofMarks1.append([])
                ListofTotal1.append([])
            if L2:
                ListofMarks2.append(L2[0].marks)
                ListofTotal2.append(L2[0].total)
            else:
                ListofMarks2.append([])
                ListofTotal2.append([])
            if L3:
                ListofMarks3.append(L3[0].marks)
                ListofTotal3.append(L3[0].total)
            else:
                ListofMarks3.append([])
                ListofTotal3.append([])
            # if L4:
            #     ListofMarks4.append(L4[0].marks)
            #     ListofTotal4.append(L4[0].total)
            # else:
            #     ListofMarks4.append([])
            #     ListofTotal4.append([])
            # if L5:
            #     ListofMarks5.append(L5[0].marks)
            #     ListofTotal5.append(L5[0].total)
            # else:
            #     ListofMarks5.append([])
            #     ListofTotal5.append([])
            # if L6:
            #     ListofMarks6.append(L6[0].marks)
            #     ListofTotal6.append(L6[0].total)
            # else:
            #     ListofMarks6.append([])
            #     ListofTotal6.append([])
        ListofMarks = zip(
            StudentID, StudentName, ListofMarks1, ListofTotal1, ListofMarks2,
            ListofTotal2, ListofMarks3, ListofTotal3
        )  #,ListofMarks4,ListofTotal4,ListofMarks5,ListofTotal5,ListofMarks6,ListofTotal6)
        form = DocumentForm()
        context = RequestContext(
            request, {
                'current': current,
                'course': course,
                'ListofMarks': ListofMarks,
                'form': form
            })
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)
def updateMarks(request, course_code):
    redirect = checkIdentity(request, 'ta')
    if redirect == "":
        if request.method == 'POST':
            category = request.POST['category']
            k = []
            # if category == 'Quiz1':
            # 	cat = "Q1"
            # 	k = request.POST.getlist('Q1[]')
            #     k1 = request.POST.getlist('Q1T[]')
            # if category == 'Quiz2':
            # 	cat = "Q2"
            # 	k = request.POST.getlist('Q2[]')
            #     k1 = request.POST.getlist('Q2T[]')
            # if category == 'Quiz3':
            # 	cat = "Q3"
            # 	k = request.POST.getlist('Q3[]')
            #     k1 = request.POST.getlist('Q3T[]')
            if category == 'MidSem1':
                cat = "MD1"
                k = request.POST.getlist('MD1[]')
                k1 = request.POST.getlist('MD1T[]')
            elif category == 'MidSem2':
                cat = "MD2"
                k = request.POST.getlist('MD2[]')
                k1 = request.POST.getlist('MD2T[]')
            else:
                cat = "ESM"
                k = request.POST.getlist('ESM[]')
                k1 = request.POST.getlist('ESMT[]')
            names = request.POST.getlist('rollnos[]')
            UpdateList = zip(names,k,k1)
            course = Course.objects.filter(pk=course_code)[0]
            # return asf
            for name,marks,total in UpdateList:
                try:
                    Students = Marks.objects.get(coursecode=course.id, category=cat,rollno=name)
                    Students.marks = marks
                    Students.total = total
                    marks = marks
                    Students.save(update_fields=['marks','total'])
                except:
                    k = Student.objects.get(id=name)
                    if not marks:
                        marks = 0
                    if not total:
                        total = 0
                    l = Marks.objects.create(rollno=k,coursecode=course,category=cat,marks=float(int(marks)),total=float(int(total)))
                    l.save()
                #return ihuh
        template = loader.get_template('ta/_updateMarks.html')
        current = TA.objects.filter(username=request.session['username'])[0]
        course = Course.objects.filter(pk=course_code)[0]
        ListofStudents = course.getStudents()
        StudentName = []
        StudentID = []
        ListofMarks1 = []
        ListofMarks2 = []
        ListofMarks3 = []
        ListofTotal1 = []
        ListofTotal2 = []
        ListofTotal3 = []
        # ListofMarks4 = []
        # ListofMarks5 = []
        # ListofMarks6 = []
        # ListofTotal4 = []
        # ListofTotal5 = []
        # ListofTotal6 = []
        for student in ListofStudents:
            StudentName.append(student.rollno.name)
            StudentID.append(student.rollno.id)
            L1 = Marks.objects.filter(coursecode=course.id, category='MD1', rollno = student.rollno.id)
            L2 = Marks.objects.filter(coursecode=course.id, category='MD2', rollno = student.rollno.id)
            L3 = Marks.objects.filter(coursecode=course.id, category='ESM', rollno = student.rollno.id)
            # L4 = Marks.objects.filter(coursecode=course.id, category='Q1', rollno = student.rollno.id)
            # L5 = Marks.objects.filter(coursecode=course.id, category='Q2', rollno = student.rollno.id)
            # L6 = Marks.objects.filter(coursecode=course.id, category='Q3', rollno = student.rollno.id)
            if L1:
                ListofMarks1.append(L1[0].marks)
                ListofTotal1.append(L1[0].total)
            else:
                ListofMarks1.append([])
                ListofTotal1.append([])
            if L2:
                ListofMarks2.append(L2[0].marks)
                ListofTotal2.append(L2[0].total)
            else:
                ListofMarks2.append([])
                ListofTotal2.append([])
            if L3:
                ListofMarks3.append(L3[0].marks)
                ListofTotal3.append(L3[0].total)
            else:
                ListofMarks3.append([])
                ListofTotal3.append([])
            # if L4:
            #     ListofMarks4.append(L4[0].marks)
            #     ListofTotal4.append(L4[0].total)
            # else:
            #     ListofMarks4.append([])
            #     ListofTotal4.append([])
            # if L5:
            #     ListofMarks5.append(L5[0].marks)
            #     ListofTotal5.append(L5[0].total)
            # else:
            #     ListofMarks5.append([])
            #     ListofTotal5.append([])
            # if L6:
            #     ListofMarks6.append(L6[0].marks)
            #     ListofTotal6.append(L6[0].total)
            # else:
            #     ListofMarks6.append([])
            #     ListofTotal6.append([])
        ListofMarks = zip(StudentID,StudentName,ListofMarks1,ListofTotal1,ListofMarks2,ListofTotal2,ListofMarks3,ListofTotal3)#,ListofMarks4,ListofTotal4,ListofMarks5,ListofTotal5,ListofMarks6,ListofTotal6)
        form = DocumentForm()
        context = RequestContext(request, {'current': current, 'course': course, 'ListofMarks': ListofMarks,'form':form})
        return HttpResponse(template.render(context))
    return HttpResponseRedirect(redirect)