def assign_grades_student(self, student_discipline_id, student_id, discipline_id, grade): st_di = Student_Discipline(student_discipline_id, student_id, discipline_id, grade) try: self.__student_discipline_repo.add_item(st_di) return st_di except ValidatorError as ve: raise StoreError(ex=ve)
def discipline_change(self, Id, name, prof): try: d = Discipline(Id, name, prof) self.__repository.update(d) return d except ValueError as ve: raise StoreError(ex=ve)
def students_and_grades_at_one_discipline_sorted(self, discipline_id): sd = self.__student_discipline_repo.get_all() list_items_with_one_discipline = [] list_items_with_one_disciplineDTO = [] for item in sd: if item.get_discipline_id() == discipline_id: list_items_with_one_discipline.append(item) for i in list_items_with_one_discipline: try: sdi = i.get_student_discipline_id() st = i.get_student_id() di = i.get_discipline_id() grade = i.get_grade() s = self.__student_repo.find_by_id(st) d = self.__discipline_repo.find_by_id(di) dto = StudentDisciplineAssembler.create_student_discipline_dto( sdi, s, d, grade) list_items_with_one_disciplineDTO.append(dto) except ValidatorError as ve: raise StoreError(ex=ve) Sorting.sort(list_items_with_one_disciplineDTO, key=lambda x: x.student_name, algorithm=Algorithm.SELECTION_SORT) #self.sort_by_name(list_items_with_one_disciplineDTO) return list_items_with_one_disciplineDTO
def get_first_20_percent(self,l): aux = [] x = len(l)//5 for s in range(0, x): try: aux.append(l[s]) except ValidatorError as ve: raise StoreError(ex=ve) return aux
def student_grade_change(self, Id, new_grade): student_discipline = self.__student_discipline_repo.find_by_id(Id) student_id = student_discipline.get_student_id() discipline_id = student_discipline.get_discipline_id() st_di = Student_Discipline(Id, student_id, discipline_id, new_grade) try: self.__student_discipline_repo.update(st_di) return st_di except ValidatorError as ve: raise StoreError(ex=ve)
def get_students_with_disciplines_and_grades(self): st_di = self.__student_discipline_repo.get_all() l=[] for i in st_di: try: sdi = i.get_student_discipline_id() st = i.get_student_id() di = i.get_discipline_id() grade = i.get_grade() s = self.__student_repo.find_by_id(st) d = self.__discipline_repo.find_by_id(di) dto = StudentDisciplineAssembler.create_student_discipline_dto(sdi, s, d, grade) l.append(dto) except ValidatorError as ve: raise StoreError(ex=ve) return l
def find(self, Id): try: return self.__student_discipline_repo.find_by_id(Id) except ValidatorError as ve: raise StoreError(ex=ve)
def delete_discipline(self, Id): try: self.__repository.delete(Id) except ValidatorError as ve: raise StoreError(ex=ve)
def add_discipline(self, Id, name, prof): try: s = Discipline(Id, name, prof) self.__repository.save(s) except ValidatorError as ve: raise StoreError(ex=ve)
def find_student(self, Id): try: return self.__repository.find_by_id(Id) except ValidatorError as ve: raise StoreError(ex=ve)
def delete_student(self, Id): try: self.__repository.delete(Id) except ValidatorError as ve: raise StoreError(ex=ve)
def add_student(self, Id, name): s = Student(Id, name) try: self.__repository.add_item(s) except ValidatorError as ve: raise StoreError(ex=ve)