def test_compute_gradebook__group__all_correct(group, students, student_group_assignments, student_assignments): for assignment in student_group_assignments: for assignment_ in assignment.studentassignment_set.all(): add_answers( student=assignment_.student, questions=assignment.questions, assignment=assignment.assignment, correct_first=True, correct_second=True, ) gradebook = compute_gradebook(group.pk) assert gradebook["group"] == group.title assert "assignment" not in gradebook for assignment in student_group_assignments: assert assignment.assignment.identifier in gradebook["assignments"] assert not gradebook["school_id_needed"] for student in gradebook["results"]: assert student["school_id"] is None assert student["email"] in [s.student.email for s in students] for assignment, assignment_ in zip(student["assignments"], gradebook["assignments"]): n = len( next(a for a in student_group_assignments if a.assignment.identifier == assignment_).questions) assert assignment["n_completed"] == n assert assignment["grade"] == n
def test_compute_gradebook__group__no_student_assignment( group, students, student_group_assignments): gradebook = compute_gradebook(group.pk) assert gradebook["group"] == group.title assert "assignment" not in gradebook for assignment in student_group_assignments: assert assignment.assignment.identifier in gradebook["assignments"] assert not gradebook["school_id_needed"] for student in gradebook["results"]: assert student["school_id"] is None assert student["email"] in [s.student.email for s in students] for assignment in student["assignments"]: assert assignment["n_completed"] is None assert assignment["grade"] is None
def test_compute_gradebook__assignment__no_student_assignment( group, students, student_group_assignments): assignment = student_group_assignments[0] gradebook = compute_gradebook(group.pk, assignment.pk) assert gradebook["group"] == group.title assert gradebook["assignment"] == assignment.assignment.title for question in gradebook["questions"]: assert question in [q.title for q in assignment.questions] assert not gradebook["school_id_needed"] for student in gradebook["results"]: assert student["school_id"] is None assert student["email"] in [s.student.email for s in students] for question in student["questions"]: assert question is None
def test_compute_gradebook__group__no_student_assignment__student_id( group, students, student_group_assignments): group.student_id_needed = True group.save() for i, student in enumerate(students): student.student_school_id = str(i) student.save() gradebook = compute_gradebook(group.pk) assert gradebook["group"] == group.title assert "assignment" not in gradebook for assignment in student_group_assignments: assert assignment.assignment.identifier in gradebook["assignments"] assert gradebook["school_id_needed"] for student in gradebook["results"]: assert student["email"] in [s.student.email for s in students] assert student["school_id"] == [s.student.email for s in students ].index(student["email"]) for assignment in student["assignments"]: assert assignment["n_completed"] is None assert assignment["grade"] is None
def test_compute_gradebook__assignment__no_student_assignment__student_id( group, students, student_group_assignments): assignment = student_group_assignments[0] group.student_id_needed = True group.save() for i, student in enumerate(students): student.student_school_id = str(i) student.save() gradebook = compute_gradebook(group.pk, assignment.pk) assert gradebook["group"] == group.title assert gradebook["assignment"] == assignment.assignment.title for question in gradebook["questions"]: assert question in [q.title for q in assignment.questions] assert gradebook["school_id_needed"] for student in gradebook["results"]: assert student["school_id"] is None assert student["email"] in [s.student.email for s in students] for question in student["questions"]: assert question is None assert student["school_id"] == [s.student.email for s in students ].index(student["email"])
def test_compute_gradebook__assignment__all_correct(group, students, student_group_assignments, student_assignments): assignment = student_group_assignments[0] for assignment_ in assignment.studentassignment_set.all(): add_answers( student=assignment_.student, questions=assignment.questions, assignment=assignment.assignment, correct_first=True, correct_second=True, ) gradebook = compute_gradebook(group.pk, assignment.pk) assert gradebook["group"] == group.title assert gradebook["assignment"] == assignment.assignment.title for question in gradebook["questions"]: assert question in [q.title for q in assignment.questions] assert not gradebook["school_id_needed"] for student in gradebook["results"]: assert student["school_id"] is None assert student["email"] in [s.student.email for s in students] for question in student["questions"]: assert question == 1