class AssignmentRepo: def __init__(self): self.assignments = List_collector() self.file_n = None def append_function(self, element): self.assignments.append(element) def Get_list(self): return self.assignments def assignment_search(self, id): for i in range(len(self.assignments)): if self.assignments[i] != None and self.assignments[i].get_aid( ) == id: return self.assignments[i] return None def __str__(self): builder = "" for assignment in self.Get_list(): if assignment != None: builder += str(assignment) + "\n" return builder def repo_remove(self, id): for i in range(len(self.assignments)): if self.assignments[i] != None and self.assignments[i].get_aid( ) == id: self.assignments[i] = None
class StudentsRepo: def __init__(self): self.students = List_collector() self.file_n = None # it is none if it dose not uses files def append_function(self, element): self.students.append(element) def Get_list(self): return self.students def student_search(self, id): for i in range(len(self.students)): if self.students[i] != None and self.students[i].get_id() == id: return self.students[i] return None def __str__(self): builder = "" for student in self.Get_list(): if student != None: builder += str(student) + "\n" return builder def repo_remove(self, id): for i in range(len(self.students)): if self.students[i] != None and self.students[i].get_id() == id: self.students[i] = None
class GradeRepo: def __init__(self): self.grades = List_collector() self.file_n = None def append_function(self,element): self.grades.append(element) def Get_list(self): return self.grades def grade_search(self,aid,sid): for i in range(len(self.grades)): if self.grades[i] != None and (self.grades[i].get_assignment() == aid or self.grades[i].get_student() == aid): return self.grades[i].get_grade() return None def repo_remove(self,sid=None,aid=None):# WE MAKE BOTH NONE AT STARTBCS WE DON'T RECALL TH FUNCTION WITH BOTH PARAMS for i in range(len(self.grades)): if self.grades[i] != None and (self.grades[i].get_student() == sid or self.grades[i].get_assignment() == aid): self.grades[i] = None
def standings3(self): list_grades = [] avg = List_collector() sort = [] for i in range(len(self.grades.Get_list())): if self.grades.Get_list()[i] != None and self.grades.Get_list( )[i].get_grade != 0: list_grades.append(self.grades.Get_list()[i]) for i in range(len(self.students.Get_list())): if self.students.Get_list()[i] != None: Student = self.students.Get_list()[i] suma = 0 ct = 0 for j in range(len(list_grades)): if list_grades[j].get_student() == Student.get_id(): suma = suma + list_grades[j].get_grade() ct += 1 if ct != 0: suma = suma / ct avg.append([suma, Student]) avg.gnomeSort(self.compare) for avgElem in avg: sort.append(avgElem[1]) return sort
def __init__(self): self.grades = List_collector() self.file_n = None
def test_list_collector(self): new_list = List_collector() self.assertEqual(len(new_list),0) new_list.append(0) self.assertEqual(len(new_list),1) self.assertEqual(new_list[0],0) new_list[0]=10 self.assertEqual(new_list[0],10) del new_list[0] self.assertEqual(len(new_list),0) new_list.append(5) new_list.append(7) it=iter(new_list) v=next(it) self.assertEqual(v,5) v=next(it) self.assertEqual(v,7) self.assertRaises(StopIteration,next,it) new_list.append(8) new_list.append(3) new_list.gnomeSort(self.compare) self.assertEqual(new_list[0],3) self.assertEqual(new_list[1],5) self.assertEqual(new_list[2],7) self.assertEqual(new_list[3],8) self.assertEqual(new_list.filter(self.compare_filter),[7,8])
def __init__(self): self.assignments = List_collector() self.file_n = None
def __init__(self): self.students = List_collector() self.file_n = None # it is none if it dose not uses files