Пример #1
0
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
Пример #2
0
def test_student_activity__some_questions_done_correct_first_wrong_second(
    client,
    teacher,
    group,
    students,
    student_group_assignments,
    student_assignments,
):
    assert login_teacher(client, teacher)
    group.teacher.add(teacher)
    teacher.current_groups.add(group)
    for assignment in student_group_assignments:
        for question in assignment.questions:
            question.grading_scheme = GradingScheme.ADVANCED
            question.save()
        for assignment_ in assignment.studentassignment_set.all()[::2]:
            add_answers(
                student=assignment_.student,
                questions=assignment.questions,
                assignment=assignment.assignment,
                correct_first=True,
                correct_second=False,
            )

    resp = client.post(
        reverse("teacher-dashboard--student-activity"),
        json.dumps({}),
        content_type="application/json",
    )
    data = json.loads(resp.content)["groups"][0]
    assert data["title"] == group.title
    assert data["n_students"] == len(students)
    assert data["new"] is True
    assert len(data["assignments"]) == len(student_group_assignments)
    for assignment, assignment_ in zip(data["assignments"],
                                       student_group_assignments):
        assert assignment["title"] == assignment_.assignment.title
        assert assignment["n_completed"] == float(len(students[::2]))
        assert (
            assignment["mean_grade"] == float(len(assignment_.questions)) // 2)
        assert (assignment["min_grade"] == float(len(assignment_.questions)) //
                2)
        assert (assignment["max_grade"] == float(len(assignment_.questions)) //
                2)
        assert assignment["new"] is True
        assert assignment["expired"] is False
        assert assignment["link"].endswith(assignment_.hash + "/")
Пример #3
0
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