Esempio n. 1
0
    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
Esempio n. 2
0
 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 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)
     self.sort_by_name(list_items_with_one_disciplineDTO)
     return list_items_with_one_disciplineDTO
 def students_and_grades_at_one_discipline_sorted_by_grade(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.grade,  reverse = True, algorithm = Algorithm.SHAKE_SORT)
     #self.sort_by_grade(list_items_with_one_disciplineDTO)
     return list_items_with_one_disciplineDTO