def test_validate_int(): number = 10 validator.validate_id(number) try: validator.validate_id(-10) assert False except ValueError: assert True
def search_by_id_course(self): id = raw_input("Course id: ") try: id = int(id) except ValueError: raise ValueError("Id must be an integer") validator.validate_id(id) course = self.course_controller.search_by_id(id) print(str(course))
def remove_course(self): print("Remove the course with the given id") id = raw_input("Course id: ") try: id = int(id) except ValueError: raise ValueError("Id must be an integer") validator.validate_id(id) self.grade_controller.remove_course(id)
def search_by_id_student(self): id = raw_input("Student registration number: ") try: id = int(id) except ValueError: raise ValueError("Registration number must be an integer") validator.validate_id(id) student = self.student_controller.search_by_id(id) print(str(student))
def remove_student(self): print("Remove the student with the given registration number") id = raw_input("Student registration number: ") try: id = int(id) except ValueError: raise ValueError("Registration number must be an integer") validator.validate_id(id) self.grade_controller.remove_student(id)
def remove_grade(self): student_id = raw_input("The registration number of the student: ") try: student_id = int(student_id) except ValueError: raise ValueError("Registration number must be an integer") validator.validate_id(student_id) course_id = raw_input("The course id: ") try: course_id = int(course_id) except ValueError: raise ValueError("Id must be an integer") validator.validate_id(course_id) self.grade_controller.remove_grade(student_id, course_id)
def student_grades(self): student_id = raw_input("The student id: ") try: student_id = int(student_id) except ValueError: raise ValueError("Id must be an integer") validator.validate_id(student_id) grades = self.grade_controller.search_student_grades(student_id) if grades == []: print("No grades found") else: for i in range(0, len(grades)): print("Registration number: " + str(grades[i].get_id_student()) + " Name: " + grades[i].get_student_name() + " Grade: " + str(grades[i].get_grade()))
def add_grade(self): student_id = raw_input("The registration number of the student: ") try: student_id = int(student_id) except ValueError: raise ValueError("Registration number must be an integer") validator.validate_id(student_id) course_id = raw_input("The course id: ") try: course_id = int(course_id) except ValueError: raise ValueError("Id must be an integer") validator.validate_id(course_id) grade = raw_input("Grade: ") try: grade = float(grade) except ValueError: raise ValueError("Grade must be a number") self.grade_controller.add(student_id, course_id, grade)