def save_student_result(request): if request.method != 'POST': return HttpResponseRedirect('staff_add_result') student_admin_id = request.POST.get('student_list') assignment_marks = request.POST.get('assignment_marks') exam_marks = request.POST.get('exam_marks') subject_id = request.POST.get('subject') student_obj = Students.objects.get(admin=student_admin_id) subject_obj = Subjects.objects.get(id=subject_id) try: check_exist = StudentResult.objects.filter(subject_id=subject_obj, student_id=student_obj).exists() if check_exist: result = StudentResult.objects.get(subject_id=subject_obj, student_id=student_obj) result.subject_assignment_marks = assignment_marks result.subject_exam_marks = exam_marks result.save() messages.success(request, "Successfully Updated Result") return HttpResponseRedirect(reverse("staff_add_result")) else: result = StudentResult(student_id=student_obj, subject_id=subject_obj, subject_exam_marks=exam_marks, subject_assignment_marks=assignment_marks) result.save() messages.success(request, "Successfully Added Result") return HttpResponseRedirect(reverse("staff_add_result")) except: messages.error(request, "Failed to Added Result") return HttpResponseRedirect(reverse("staff_add_result"))
def save_student_result(request): if request.method != "POST": messages.error(request, "Invalid Method") return HttpResponseRedirect('staff_add_result') else: student_admin_id = request.POST.get('student_list') assignment_marks = request.POST.get('assignment_marks') exam_marks = request.POST.get('exam_marks') subject_id = request.POST.get('subject') student_obj = Students.objects.get(admin=student_admin_id) subject_obj = Subjects.objects.get(id=subject_id) try: # Check if Students Result Already Exists or not check_exist = StudentResult.objects.filter(subject_id=subject_obj, student_id=student_obj).exists() if check_exist: result = StudentResult.objects.get(subject_id=subject_obj, student_id=student_obj) result.subject_assignment_marks = assignment_marks result.subject_exam_marks = exam_marks result.save() messages.success(request, "Result Updated Successfully!") return HttpResponseRedirect('staff_add_result') else: result = StudentResult(student_id=student_obj, subject_id=subject_obj, subject_exam_marks=exam_marks, subject_assignment_marks=assignment_marks) result.save() messages.success(request, "Result Added Successfully!") return HttpResponseRedirect('staff_add_result') except: messages.error(request, "Failed to Add Result!") return HttpResponseRedirect('staff_add_result')
def save_students_result(request): if request.method != "POST": return HttpResponseRedirect(reverse("add_students_result")) else: roll_number = request.POST.get("roll_number") student_obj = CustomUser.objects.get(username=roll_number) student_id = student_obj.id student = Students.objects.get(admin_id=student_id) session_year = student.session_year_id_id branch = student.course_id_id dob = student.dob semester = request.POST.get("semester") subject_name = request.POST.get("subject_name") total_mark = request.POST.get("total_mark") secured_mark = request.POST.get("secured_mark") prac_total_mark = request.POST.get("prac_total_mark") prac_secured_mark = request.POST.get("prac_secured_mark") is_pass = request.POST.get("is_pass") print(student_id, session_year, branch) # try: student_result = StudentResult(roll_number=roll_number, session_year=session_year, branch=branch, semester=semester, subject_name=subject_name, total_mark=total_mark, secured_mark=secured_mark, prac_total_mark=prac_total_mark, prac_secured_mark=prac_secured_mark, is_pass=is_pass, dob=dob) student_result.save() messages.success(request, " Result Added Successfully") return HttpResponseRedirect(reverse("add_students_result")) # except Exception as e: messages.error(request, "Failed to Add Result {}") return HttpResponseRedirect(reverse("add_students_result"))
def staff_add_result_save(request): if request.method != "POST": messages.error(request, "Invalid Method") return redirect('staff_add_result') else: student_admin_id = request.POST.get('student_list') assignment_marks = request.POST.get('assignment_marks') exam_marks = request.POST.get('exam_marks') group_id = request.POST.get('group') student_obj = Students.objects.get(admin=student_admin_id) group_obj = Group.objects.get(id=group_id) try: # Check if Students Result Already Exists or not check_exist = StudentResult.objects.filter( group_id=group_id, student_id=student_obj).exists() if check_exist: result = StudentResult.objects.get(group_id=group_obj, student_id=student_obj) result.subject_assignment_marks = assignment_marks result.subject_exam_marks = exam_marks result.save() messages.success(request, "Nəticə yadda saxlanıldı!") return redirect('staff_add_result') else: result = StudentResult( student_id=student_obj, group_id=group_obj, subject_exam_marks=exam_marks, subject_assignment_marks=assignment_marks) result.save() messages.success(request, "Nəticə yadda saxlanıldı!") return redirect('staff_add_result') except: messages.error(request, "Nəticəni yadda saxlayarkən xəta baş verdi!") return redirect('staff_add_result')