def post_leave_status_admin(self, leave_id: int, status: str): """ this function is used to update the status of the leave given by employee """ transaction_manager = TransactionalManager() db_conn = transaction_manager.GetDatabaseConnection("READWRITE") leave_dao = LeaveDao(db_conn) leave_dao.post_leave_status_admin(leave_id, status) transaction_manager.save()
def PostTeacherAttendance(self, form): transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") attendance_dao = AttendanceDao(db_conn) attendance_dao.PostTeacherAttendance(form) transaction_mgr.save()
def post_leave(self, user_id: int, start_date: str, end_date: str, type_of_leave: str, reason: str): """ this function is used to post a leave given the employee_id, start_date, end_date, type_of_leave reason""" transaction_manager = TransactionalManager() db_conn = transaction_manager.GetDatabaseConnection("READWRITE") leave_dao = LeaveDao(db_conn) leave_dao.post_leave(user_id, start_date, end_date, type_of_leave, reason) transaction_manager.save()
def upload_assignment(self, user_id, title, description, deadline, subject, class_, section, list_of_files, manual_marks): """ :return: """ return_val = None transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") section = re.findall('\w+', section) return_msg = "" # comma separate all files comma_files = str() for file_count in range(0, len(list_of_files)): comma_files = comma_files + list_of_files[file_count] if file_count <= len(list_of_files) - 2: comma_files += ", " assignment_dao = AssignmentDao(db_conn, class_=class_, section=section, subject=subject, \ comma_files=comma_files, title=title, description=description, \ deadline=deadline, user_id=user_id) for file in list_of_files: # Fetching assignment type, type = re.search('__[\w]+?__', file) type = file[type.start(0) + 2:type.end(0) - 2] file_ext = file.split('.')[1] # Fetching file number for manual marks, file_num = re.search('_file\d{1}?_', file) file_num = file[file_num.start(0) + 1:file_num.end(0) - 1] if type == "manual": mark = manual_marks.get(file_num, "") return_val = assignment_dao.upload_manual( file, comma_files, mark, type) elif type == "subjective" and file_ext.startswith("xls"): return_val = assignment_dao.upload_subjective( file, comma_files, type) elif type == "mcq" and file_ext.startswith("xls"): return_val = assignment_dao.upload_MCQ(file, comma_files, type) # Break if any one fails if return_val[1] == True: return_msg += " " + return_val[0] else: break if return_val[1] == True: transaction_mgr.save() return return_msg transaction_mgr.end() return return_msg
def PutStudentAttendance(self, student_id: int, start_date: str = None, end_date: str = None, status: str = None): """Put the student attendance based on start date and end date and student id""" if not start_date or not end_date: start_date = end_date = utils.GetTodaysDateAsStartAndEndDate() transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") attendance_dao = AttendanceDao(db_conn) attendance_dates_status_map = attendance_dao.PutAttendanceByStudentId( student_id, start_date, end_date, status) transaction_mgr.save()
def PostStudentsAttendance(self, class_id: int, updated_by: int, roll_no: int, start_date: str = None, end_date: str = None, status: str = None): """Post the student attendance based on start date and end date and student id""" if not start_date or not end_date: start_date = end_date = utils.GetTodaysDateAsStartAndEndDate() transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") attendance_dao = AttendanceDao(db_conn) attendance_dates_status_map = attendance_dao.PostAttendanceByClassId( class_id, updated_by, roll_no, start_date, end_date, status) transaction_mgr.save()
def assignment_submit(self, student_id: int, assignment_sol): transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") assignment_dao = AssignmentSubmitDao(db_conn) for solutions in assignment_sol: question_type = assignment_dao.check_question_type( solutions['question_pool_id']) if question_type[0]['question_type_id'] != 3: assignment_dao.submit_assignment(student_id, solutions['question_pool_id'], solutions['solution']) else: assignment_dao.submit_assignment_manual( student_id, solutions['question_pool_id'], solutions['solution']) assignment_dao.submit_assignment_student( student_id, assignment_sol[0]['question_pool_id']) transaction_mgr.save()
def active_assignments(self, user_id): """ :param user_id: :return: """ return_val = None transaction_manager = TransactionalManager() db_conn = transaction_manager.GetDatabaseConnection("READWRITE") assignment_view = AssignmentDao(db_conn) return_val = assignment_view.active_assignment_by_userid(user_id) if return_val[1] == True: transaction_manager.save() return return_val[0] transaction_manager.end() return return_val[0]
def assignment_student_detail_view(self, assignment_id, teacher_id): """ :param assignment_id: :return: """ return_val = None transaction_manager = TransactionalManager() db_conn = transaction_manager.GetDatabaseConnection("READ") assignment_view = AssignmentView(db_conn) return_val = assignment_view.student_submissions_view_by_assignment( assignment_id, teacher_id) if return_val[1] == True: transaction_manager.save() return return_val[0] transaction_manager.end() return return_val[0]
def teacher_assignment_view(self, user_id, teacher_id, class_, section, subject): """ :return: """ return_val = None transaction_manager = TransactionalManager() db_conn = transaction_manager.GetDatabaseConnection("READWRITE") assignment_view = AssignmentView(db_conn) return_val = assignment_view.assignment_by_class_subject_id( user_id, teacher_id, class_, section, subject) if return_val[1] == True: transaction_manager.save() return return_val[0] transaction_manager.end() return return_val[0]
def delete_assignment(self, user_id, assignment_id): """ :param employee_id: :param assignment_id: :return: """ transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") assignment_dao = AssignmentDao(db_conn) return_val = assignment_dao.delete_assignment_dao( user_id, assignment_id) if return_val[1]: transaction_mgr.save() return return_val transaction_mgr.end() return return_val
def UpdateStudentLeavesByParent(self, student_id: int = None, leave_date: str = None, remarks: str = None): transaction_manager = TransactionalManager() try: db_conn = transaction_manager.GetDatabaseConnection("READWRITE") leave_dao = LeaveDao(db_conn) status = None if student_id and leave_date and remarks: status = leave_dao.UpdateStudentLeaves(student_id, leave_date, remarks) transaction_manager.save() return status # Add specific exceptions. except Exception: # Log exception. print("Exception occurred while fetching leaves for a user.") transaction_manager.end() raise
def post_assignment_marks(self, teacher_id: int, student_marks): transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") assignment_dao = AssignmentSubmitDao(db_conn) total = 0 question_pool_id = student_marks[0]['question_pool_id'] for marks in student_marks: total = total + int(marks['marks']) question_type = assignment_dao.check_question_type( marks['question_pool_id']) if question_type[0]['question_type_id'] != 3: assignment_dao.submit_marks(marks['question_pool_id'], marks['student_id'], marks['marks']) else: assignment_dao.submit_marks_manual( marks['question_pool_id'], marks['student_id'], marks['marks'], marks['evaluated_sheet_link']) assignment_dao.submit_marks_in_map(total, teacher_id, question_pool_id, student_marks[0]['student_id']) transaction_mgr.save()
self.actual_answers.append(records[i].get("answer")) self.marks.append(records[i].get("marks")) # Compare question_pool answers with quiz_response answers, def process_marks_award(self): for record in range(0, len(self.quiz_responses)): current_id = self.quiz_responses[record].get("question_pool_id") if current_id in self.question_pool_ids: index = self.question_pool_ids.index(current_id) mark_awarded = float(0) if self.quiz_responses[record].get("answer") == self.actual_answers[index]: mark_awarded = float(self.marks[index]) query = "update quiz_response set marks_awarded=%s where " \ "question_pool_id=%s;" % (mark_awarded, self.question_pool_ids[index]) records = self.db_conn.processquery(query=query, fetch=False) transaction_mgr = TransactionalManager() db_conn = transaction_mgr.GetDatabaseConnection("READWRITE") marksAward = MarksAward(db_conn) if marksAward.check_records_if_any() and marksAward.check_marks_awarded(): marksAward.fetch_mcq_question() marksAward.process_marks_award() else: exit(1) transaction_mgr.save()