Example #1
0
    for test_row in tests_read:
        graphs.add_tests(test_row[0], test_row[1], test_row[2])

    for course_row in courses_read:
        graphs.add_courses(course_row[0], course_row[1], course_row[2])

#This is where we grab the Id of each student found in the array idOrder in graphs. The array is sorted ensuring we are looking at the students in order of their id.We pass in the ID and the name of the student into the student class. We then use the calculate method to receive back all the relevant information for that specific student and add this information to the student class. Afterwards we calculate the average  and append the student to the array of overall students we defined at the top of this file. (The methods are expanded on in their respective files)
for ID in graphs.idOrder:
    student = Student(graphs.studentsId[f"{ID}"], ID)
    calculations = graphs.calculate_grade(ID)
    for i in calculations[0]:
        if calculations[2][i] != 100:
            calculations[0][i] = "Weight does not equal 100. Error!!"

    student.add_array_Class_Info(calculations[0], calculations[1])
    student.calculate_average()
    all_Students.append(student)

# We are opening up the reportCard text file and filling out the information accordingly. We for loop through the arrray of students then fill in the information of each student. This information is stored in the students attributes.
with open("reportCard.txt", "w") as reportCard:
    for stud in all_Students:
        reportCard.write(
            f"Student Id: { stud.student_id}, name: {stud.name}\n")
        reportCard.write(f"Total Average:   {stud.total_average}%\n\n")
        for Class in stud.class_Teacher:
            reportCard.write(
                f"\t\tCourse: {Class}, Teacher: {stud.class_Teacher[Class]}\n")
            reportCard.write(
                f"\t\tFinal Grade:   {stud.class_Info[Class]}0%\n\n\n")
    reportCard.close()