예제 #1
0
def final_grade(lec_grades: dict, lab_grades: dict) -> float:
    """
        lec_exams -> list of lecture exam grades
        final_lec_exam -> float of final lecture exam grade
        lec_quizzes -> list of lecture quiz grades
        lab_exams -> list of lab exam grades
        final_lab_exam -> float of final lab exam grade
        participation -> float of lab participation grade

        Overall grade is determined by both lecture and lab
            lecture = 75%
            lab = 25%

        Calculating Grade -
            (((Test1% + Test2% + Test3% + Test4%) / 4) * 0.7 + ((Quiz Total / Total Possible) * 100) * 0.1 + (Exam%) * 0.2) * 0.75
            +
            (((Practical1 + Practical2 + Practical3) / 3) * 0.6) + (Final Practical% * 0.3) + ((Participation) * 0.1)) * 0.25
    """

    lec_wtd_grade = lecture.weighted_grade(lec_grades["exams"], lec_grades["final_exam"], lec_grades["quizzes"])
    lab_wtd_grade = lab.weighted_grade(
        lab_grades["exams"], lab_grades["final_exam"], lab_grades["participation"], lab_grades["days_missed"]
    )

    return lec_wtd_grade + lab_wtd_grade
예제 #2
0
def final_grade(lec_grades: dict, lab_grades: dict) -> float:
    """
        lec_exams -> list of lecture exam grades
        final_lec_exam -> float of final lecture exam grade
        lec_quizzes -> list of lecture quiz grades
        lab_exams -> list of lab exam grades
        final_lab_exam -> float of final lab exam grade
        participation -> float of lab participation grade

        Overall grade is determined by both lecture and lab
            lecture = 75%
            lab = 25%

        Calculating Grade -
            (((Test1% + Test2% + Test3% + Test4%) / 4) * 0.7 + ((Quiz Total / Total Possible) * 100) * 0.1 + (Exam%) * 0.2) * 0.75
            +
            (((Practical1 + Practical2 + Practical3) / 3) * 0.6) + (Final Practical% * 0.3) + ((Participation) * 0.1)) * 0.25
    """

    lec_wtd_grade = lecture.weighted_grade(lec_grades['exams'],
                                           lec_grades['final_exam'],
                                           lec_grades['quizzes'])
    lab_wtd_grade = lab.weighted_grade(lab_grades['exams'],
                                       lab_grades['final_exam'],
                                       lab_grades['participation'],
                                       lab_grades['days_missed'])

    return lec_wtd_grade + lab_wtd_grade
예제 #3
0
def write_grade_to_file(lec_info: dict, lab_info: dict) -> bool:
    """
    Writes all the grades and totals out to a formatted text file

    @param lec_info:
    @param lab_info:
    @return: True on success
    """
    with open("grades.txt", "w") as f:
        # Computed Grades
        f.write("===== COMPUTED GRADES =====\n")

        # Lecture Grades
        f.write("\n--- Lecture Grades ---\n")

        # Raw Lecture Grades
        raw_lec_grade = lecture.raw_grade(lec_info["exams"], lec_info["final_exam"], lec_info["quizzes"])
        f.write("Raw grades are calculated by simply inputting the numbers and averaging them.\n\n")
        f.write("Your calculated RAW grade for Lecture is: ")
        f.write("{0}\n".format(raw_lec_grade))
        f.write("Your calculated RAW letter grade for Lecture is: ")
        f.write(find_letter_grade(raw_lec_grade) + "\n")
        f.write("{0}\n\n".format(get_letter_grade_definitions(find_letter_grade(raw_lec_grade))))

        # Weighted Lecture Grade
        weighted_lec_grade = lecture.weighted_grade(lec_info["exams"], lec_info["final_exam"], lec_info["quizzes"])
        f.write("Weighted grades are calculated using the formula provided by the professor.\n")
        f.write(
            "The first grade is 75% of the whole grade and the second grade is what it would correlate to as a whole grade.\n\n"
        )
        f.write("Your calculated WEIGHTED grade for Lecture is: ")
        f.write("{0}\n".format(weighted_lec_grade))
        f.write("The WEIGHTED equivalent is: ")
        f.write("{0}\n".format(weighted_lec_grade / 0.75))
        f.write("The WEIGHTED letter equivalent is: ")
        f.write("{0}\n".format(find_letter_grade(weighted_lec_grade / 0.75)))
        f.write("{0}\n\n".format(get_letter_grade_definitions(find_letter_grade(weighted_lec_grade / 0.75))))

        # Lab Grades
        f.write("\n--- Lab Grades ---\n")

        # Raw Lab Grades
        raw_lab_grade = lab.raw_grade(lab_info["exams"], lab_info["final_exam"], lab_info["participation"])
        f.write("Raw grades are calculated by simply inputting the numbers and averaging them.\n\n")
        f.write("Your calculated RAW grade for Lab is: ")
        f.write("{0}\n".format(raw_lab_grade))
        f.write("Your calculated RAW letter grade for Lab is: ")
        f.write("{0}\n".format(find_letter_grade(raw_lab_grade)))
        f.write("{0}\n\n".format(get_letter_grade_definitions(find_letter_grade(raw_lab_grade))))

        # Weighted Lab Grades Output
        weighted_lab_grade = lab.weighted_grade(
            lab_info["exams"], lab_info["final_exam"], lab_info["participation"], lab_info["days_missed"]
        )
        f.write("Weighted grades are calculated using the formula provided by the professor.\n")
        f.write(
            "The first grade is 25% of the whole grade and the second grade is what it would correlate to as a whole grade.\n\n"
        )

        if lab_info["days_missed"] == 1:
            day_str = "day"
        elif lab_info["days_missed"] > 1 or lab_info["days_missed"] == 0:
            day_str = "days"

        f.write(
            "You missed {0} {1} of lab resulting in a {2}% ({3}pts) decrease in the final overall lab grade.".format(
                lab_info["days_missed"],
                day_str,
                lab_info["days_missed"] * 0.02,
                weighted_lab_grade * (lab_info["days_missed"] * 0.02),
            )
        )
        f.write("\nYour calculated WEIGHTED grade for Lab is: ")
        f.write("{0}\n".format(weighted_lab_grade))
        f.write("The WEIGHTED equivalent is: ")
        f.write("{0}\n".format(str(weighted_lab_grade / 0.25)))
        f.write("The WEIGHTED letter equivalent is: ")
        f.write("{0}\n".format(find_letter_grade(weighted_lab_grade / 0.25)))
        f.write(get_letter_grade_definitions(find_letter_grade(weighted_lab_grade / 0.25)) + "\n\n")

        # Final Grades Output
        f_grade = final_grade(lec_info, lab_info)

        f.write("|" + "=" * 50 + "\n")
        f.write("| Your Final Weighted Grade Is: {0}\n".format(f_grade))
        f.write("| Your Final Letter Grade Is: {0}\n".format(find_letter_grade(f_grade)))
        f.write("| {0}\n".format(get_letter_grade_definitions(find_letter_grade(f_grade))))
        f.write("|" + "=" * 50 + "\n\n")

        # Grades output...
        f.write("===== Actual and Estimated Grades =====\n\n")

        # Lecture Header
        f.write("*" * 15)
        f.write("\n*** LECTURE ***\n")
        f.write("*" * 15)

        # Lecture quizzes
        i = 1
        f.write("\n--- Quizzes ---\n")
        for lec_qz in lec_info["quizzes"]:
            f.write("Quiz {0} - {1}\n".format(i, lec_qz))
            i += 1

        # Lecture Exams
        f.write("\n\n--- Exams ---\n")
        i = 1
        for lec_exam in lec_info["exams"]:
            f.write("Exam {0}: {1}\n".format(i, lec_exam))
            i += 1

        # Lecture Final Exam
        f.write("\n\n--- Final Exam ---\n")
        f.write("Final Exam: {0}\n".format(lec_info["final_exam"]))

        # Lecture Days Missed
        f.write("\n--- Days Missed ---\n")
        f.write("Days Missed: {0}\n\n".format(lec_info["days_missed"]))

        # Lab Header
        f.write("*" * 15)
        f.write("\n***** LAB *****\n")
        f.write("*" * 15)

        # Lab Exams
        f.write("\n--- Exams ---\n")
        i = 1
        for lab_exam in lab_info["exams"]:
            f.write("Exam {0}: {1}\n".format(i, lab_exam))
            i += 1

        # Lab Final Exam
        f.write("\n--- Final Exam ---\n")
        f.write("Final Exam: {0}\n".format(lab_info["final_exam"]))

        # Lab Participation
        f.write("\n--- Participation ---\n")
        f.write("Participation: {0}\n".format(lab_info["participation"]))

        # Lab Days Missed
        f.write("\n--- Days Missed ---\n")
        f.write("Days Missed: {0}\n\n".format(lab_info["days_missed"]))

    return f.closed
예제 #4
0
def write_grade_to_file(lec_info: dict, lab_info: dict) -> bool:
    """
    Writes all the grades and totals out to a formatted text file

    @param lec_info:
    @param lab_info:
    @return: True on success
    """
    with open("grades.txt", "w") as f:
        # Computed Grades
        f.write("===== COMPUTED GRADES =====\n")

        # Lecture Grades
        f.write("\n--- Lecture Grades ---\n")

        # Raw Lecture Grades
        raw_lec_grade = lecture.raw_grade(lec_info['exams'],
                                          lec_info['final_exam'],
                                          lec_info['quizzes'])
        f.write(
            "Raw grades are calculated by simply inputting the numbers and averaging them.\n\n"
        )
        f.write("Your calculated RAW grade for Lecture is: ")
        f.write("{0}\n".format(raw_lec_grade))
        f.write("Your calculated RAW letter grade for Lecture is: ")
        f.write(find_letter_grade(raw_lec_grade) + "\n")
        f.write("{0}\n\n".format(
            get_letter_grade_definitions(find_letter_grade(raw_lec_grade))))

        # Weighted Lecture Grade
        weighted_lec_grade = lecture.weighted_grade(lec_info['exams'],
                                                    lec_info['final_exam'],
                                                    lec_info['quizzes'])
        f.write(
            "Weighted grades are calculated using the formula provided by the professor.\n"
        )
        f.write(
            "The first grade is 75% of the whole grade and the second grade is what it would correlate to as a whole grade.\n\n"
        )
        f.write("Your calculated WEIGHTED grade for Lecture is: ")
        f.write("{0}\n".format(weighted_lec_grade))
        f.write("The WEIGHTED equivalent is: ")
        f.write("{0}\n".format(weighted_lec_grade / 0.75))
        f.write("The WEIGHTED letter equivalent is: ")
        f.write("{0}\n".format(find_letter_grade(weighted_lec_grade / 0.75)))
        f.write("{0}\n\n".format(
            get_letter_grade_definitions(
                find_letter_grade(weighted_lec_grade / 0.75))))

        # Lab Grades
        f.write("\n--- Lab Grades ---\n")

        # Raw Lab Grades
        raw_lab_grade = lab.raw_grade(lab_info['exams'],
                                      lab_info['final_exam'],
                                      lab_info['participation'])
        f.write(
            "Raw grades are calculated by simply inputting the numbers and averaging them.\n\n"
        )
        f.write("Your calculated RAW grade for Lab is: ")
        f.write("{0}\n".format(raw_lab_grade))
        f.write("Your calculated RAW letter grade for Lab is: ")
        f.write("{0}\n".format(find_letter_grade(raw_lab_grade)))
        f.write("{0}\n\n".format(
            get_letter_grade_definitions(find_letter_grade(raw_lab_grade))))

        # Weighted Lab Grades Output
        weighted_lab_grade = lab.weighted_grade(lab_info['exams'],
                                                lab_info['final_exam'],
                                                lab_info['participation'],
                                                lab_info['days_missed'])
        f.write(
            "Weighted grades are calculated using the formula provided by the professor.\n"
        )
        f.write(
            "The first grade is 25% of the whole grade and the second grade is what it would correlate to as a whole grade.\n\n"
        )

        if lab_info['days_missed'] == 1:
            day_str = "day"
        elif lab_info["days_missed"] > 1 or lab_info["days_missed"] == 0:
            day_str = "days"

        f.write(
            "You missed {0} {1} of lab resulting in a {2}% ({3}pts) decrease in the final overall lab grade."
            .format(lab_info['days_missed'], day_str,
                    lab_info['days_missed'] * 0.02,
                    weighted_lab_grade * (lab_info['days_missed'] * 0.02)))
        f.write("\nYour calculated WEIGHTED grade for Lab is: ")
        f.write("{0}\n".format(weighted_lab_grade))
        f.write("The WEIGHTED equivalent is: ")
        f.write("{0}\n".format(str(weighted_lab_grade / 0.25)))
        f.write("The WEIGHTED letter equivalent is: ")
        f.write("{0}\n".format(find_letter_grade(weighted_lab_grade / 0.25)))
        f.write(
            get_letter_grade_definitions(
                find_letter_grade(weighted_lab_grade / 0.25)) + "\n\n")

        # Final Grades Output
        f_grade = final_grade(lec_info, lab_info)

        f.write("|" + "=" * 50 + "\n")
        f.write("| Your Final Weighted Grade Is: {0}\n".format(f_grade))
        f.write("| Your Final Letter Grade Is: {0}\n".format(
            find_letter_grade(f_grade)))
        f.write("| {0}\n".format(
            get_letter_grade_definitions(find_letter_grade(f_grade))))
        f.write("|" + "=" * 50 + "\n\n")

        # Grades output...
        f.write("===== Actual and Estimated Grades =====\n\n")

        # Lecture Header
        f.write("*" * 15)
        f.write("\n*** LECTURE ***\n")
        f.write("*" * 15)

        # Lecture quizzes
        i = 1
        f.write("\n--- Quizzes ---\n")
        for lec_qz in lec_info["quizzes"]:
            f.write("Quiz {0} - {1}\n".format(i, lec_qz))
            i += 1

        # Lecture Exams
        f.write("\n\n--- Exams ---\n")
        i = 1
        for lec_exam in lec_info["exams"]:
            f.write("Exam {0}: {1}\n".format(i, lec_exam))
            i += 1

        # Lecture Final Exam
        f.write("\n\n--- Final Exam ---\n")
        f.write("Final Exam: {0}\n".format(lec_info["final_exam"]))

        # Lecture Days Missed
        f.write("\n--- Days Missed ---\n")
        f.write("Days Missed: {0}\n\n".format(lec_info["days_missed"]))

        # Lab Header
        f.write("*" * 15)
        f.write("\n***** LAB *****\n")
        f.write("*" * 15)

        # Lab Exams
        f.write("\n--- Exams ---\n")
        i = 1
        for lab_exam in lab_info["exams"]:
            f.write("Exam {0}: {1}\n".format(i, lab_exam))
            i += 1

        # Lab Final Exam
        f.write("\n--- Final Exam ---\n")
        f.write("Final Exam: {0}\n".format(lab_info["final_exam"]))

        # Lab Participation
        f.write("\n--- Participation ---\n")
        f.write("Participation: {0}\n".format(lab_info["participation"]))

        # Lab Days Missed
        f.write("\n--- Days Missed ---\n")
        f.write("Days Missed: {0}\n\n".format(lab_info["days_missed"]))

    return f.closed