def test_remove_student_from_classroom(): """ Dependencies: - create_classroom() - add_student_to_classroom() """ student_Info = { "John Smith": markbook.create_student(first_name="John", last_name="Smith", gender="Male", image="jsmith.png", student_number=111, grade=9, email="*****@*****.**") } classroom_Info = { "ICS4U": markbook.create_classroom(course_code="ICS4U", course_name="Computer Science", period=2, teacher="Mr. Gallo") } markbook.add_student_to_classroom(student_Info["John Smith"], classroom_Info["ICS4U"]) assert len(classroom_Info["ICS4U"]["student_list"]) == 1 markbook.remove_student_from_classroom(student_Info["John Smith"], classroom_Info["ICS4U"]) assert type(classroom_Info["ICS4U"]["student_list"]) is list assert len(classroom_Info["ICS4U"]["student_list"]) == 0 assert len(student_Info["John Smith"]["classes"]) == 0
def test_remove_assignment(): assignment = markbook.create_assignment ("Math CPT", "October 21, 1999", 100) classroom = markbook.create_classroom("MHF4U", "Advanced Functions", 3, "Mr.Smith", ["Emma", "Ethan", "Nicholas"], []) markbook.add_assignment(assignment, classroom) assert len(classroom["assignment_list"]) == 1 markbook.remove_assignment(assignment, classroom) assert len(classroom["assignment_list"]) == 0 assert type(classroom["assignment_list"]) is list
def test_class_average(): classroom = markbook.create_classroom(course_code="ICS4U", course_name="Computer Science", period=2, teacher="Mr. Gallo") classroom["student_marks"]["John"] = 80.0 classroom["student_marks"]["Jane"] = 90.0 assert markbook.calculate_class_average(classroom) == 85.0
def test_class_average(): jayden = markbook.create_student("Jayden", "Smith", "Male", None, 5678910, 10, "*****@*****.**", [50, 60, 70, 80], None) samuel = markbook.create_student("Samuel", "Jiang", "Male", None, 8765432, 10, "*****@*****.**", [90, 30, 70, 50], None) emma = markbook.create_student("Emma", "Winnasdale". "female", None, 9567823, 10, "*****@*****.**", [60, 100, 70, 80], None) classroom = markbook.create_classroom("MHF4U", "Advanced Functions", 3, "Mr.Smith", [], []) markbook.add_student_to_classroom(jayden ,classroom) markbook.add_student_to_classroom(samuel ,classroom) markbook.add_student_to_classroom(emma ,classroom) assert classroom["student_list"] == 3 avg_of_class = markbook.class_average(classroom) assert avg_of_class == 67.5
def test_create_classroom(): classroom = markbook.create_classroom(course_code="ICS4U", course_name="Computer Science", period=2, teacher="Mr. Gallo") assert classroom["course_code"] == "ICS4U" assert classroom["course_name"] == "Computer Science" assert classroom["period"] == 2 assert classroom["teacher"] == "Mr. Gallo" # The classroom needs to be created with # empty lists for students and assignments assert classroom["student_list"] == [] assert classroom["assignment_list"] == []
def test_add_student_to_classroom(): """ Dependencies: - create_classroom() """ classroom = markbook.create_classroom(course_code="ICS4U", course_name="Computer Science", period=2, teacher="Mr. Gallo") first_name = "test" last_name = "test" markbook.add_student_to_classroom(first_name, last_name) assert type(classroom["Students"]) is list assert len(classroom["Students"]) == 1
def test_add_student_to_classroom(): """ Dependencies: - create_classroom() """ classroom = markbook.create_classroom(course_code="ICS4U", course_name="Computer Science", period=2, teacher="Mr. Gallo") student = {"first_name": "John", "last_name": "Smith"} assert len(classroom["student_list"]) == 0 markbook.add_student_to_classroom(student, classroom) assert type(classroom["student_list"]) is list assert len(classroom["student_list"]) == 1
def test_create_classroom(): classroom = markbook.create_classroom(course_code="ICS4U", course_name="Computer Science", period=2, teacher="Mr. Gallo") expected = { "course_code": "ICS4U", "course_name": "Computer Science", "period": 2, "teacher": "Mr. Gallo" } # The classroom needs to be a dictionary identical to the expected assert classroom == expected # The classroom needs to be created with # empty lists for students and assignments assert classroom["student_list"] == [] assert classroom["assignment_list"] == []
def create_classroom_interface(): while True: # Takes input from user try: course_code = input("\n* Course Code: ") course_name = input("\n* Course Name: ") period = int(input("\n* Period: ")) teacher = input("\n* Teacher Name: ") break except ValueError: print(" ---------------------------------------------------------- ") print("| Error, please enter a string. |") print(" ---------------------------------------------------------- ") # Gets data back from API function classroom = create_classroom(course_code, course_name, period, teacher) # Send the data to be added to the data file add_to_data("data.json", "classrooms", classroom)
while True: try: # collecting inputs course_code = input("Please Input the name of the classroom" + " or '0' to go back: ") if course_code == '0': break course_name = input('course_name: ') period = int(input('period: ')) teacher = input('teacher: ') break except ValueError: print('Please input an integer for the period') # make the classroom classroom = create_classroom(course_name, course_name, period, teacher) copy = copy() # append classroom to the classrooms list classrooms = copy["classrooms"] classrooms.append(classroom) overwrite(copy) print("Just created a classroom with the following details:") print(classrooms[-1]) break elif page == 3: # calculate student average clear_screen() print('---CALCULATE STUDENT AVERAGE---') copy = copy() classroom = class_search(copy)
def test_sort_students_alphabetically(): classroom = markbook.create_classroom("MHF4U", "Advanced Functions", 3, "Mr.Smith", ["Jayden","Samuel, ""Emma", "Ethan", "Nicholas"], []) markbook.sort_students_alphabetically(classroom) assert classroom["student_list"] == ["Emma", "Ethan", "Jayden", "Nicholas", "Samuel"] assert type(classroom["student_list"]) is list