import datetime

from homeschool.courses.tests.factories import (
    CourseFactory,
    CourseTaskFactory,
    GradedWorkFactory,
)
from homeschool.schools.tests.factories import GradeLevelFactory
from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm
from homeschool.students.models import Coursework, Grade
from homeschool.students.tests.factories import (
    CourseworkFactory,
    EnrollmentFactory,
    GradeFactory,
    StudentFactory,
)
from homeschool.test import TestCase


class TestCourseworkForm(TestCase):
    def test_is_valid(self):
        """The coursework validates."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        course_task = CourseTaskFactory(course=course)
        data = {
            "student": str(student.id),
            "course_task": str(course_task.id),
            "completed_date": str(grade_level.school_year.start_date),
        }
        form = CourseworkForm(data=data)

        is_valid = form.is_valid()

        assert is_valid

    def test_student_can_create_coursework(self):
        """The student is enrolled in a course that contains the task."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        course = CourseFactory(grade_levels=[grade_level])
        course_task = CourseTaskFactory(course=course)
        data = {
            "student": str(student.id),
            "course_task": str(course_task.id),
            "completed_date": str(grade_level.school_year.start_date),
        }
        form = CourseworkForm(data=data)

        is_valid = form.is_valid()

        assert not is_valid
        assert form.non_field_errors() == [
            "The student is not enrolled in this course."
        ]

    def test_save_new_coursework(self):
        """A new coursework is created for a student and task."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        course_task = CourseTaskFactory(course=course)
        data = {
            "student": str(student.id),
            "course_task": str(course_task.id),
            "completed_date": str(grade_level.school_year.start_date),
        }
        form = CourseworkForm(data=data)
        form.is_valid()

        form.save()

        assert (
            Coursework.objects.filter(student=student, course_task=course_task).count()
            == 1
        )

    def test_save_existing_coursework(self):
        """A new coursework is created for a student and task."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        course_task = CourseTaskFactory(course=course)
        CourseworkFactory(student=student, course_task=course_task)
        data = {
            "student": str(student.id),
            "course_task": str(course_task.id),
            "completed_date": str(grade_level.school_year.start_date),
        }
        form = CourseworkForm(data=data)
        form.is_valid()

        form.save()

        assert (
            Coursework.objects.filter(student=student, course_task=course_task).count()
            == 1
        )

    def test_save_deletes_coursework(self):
        """A blank completed date deletes an existing coursework."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        course_task = CourseTaskFactory(course=course)
        CourseworkFactory(student=student, course_task=course_task)
        data = {
            "student": str(student.id),
            "course_task": str(course_task.id),
        }
        form = CourseworkForm(data=data)
        form.is_valid()

        form.save()

        assert (
            Coursework.objects.filter(student=student, course_task=course_task).count()
            == 0
        )

    def test_completed_date_outside_school_year(self):
        """The completed data must be in the school year."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        course_task = CourseTaskFactory(course=course)
        data = {
            "student": str(student.id),
            "course_task": str(course_task.id),
            "completed_date": str(
                grade_level.school_year.start_date - datetime.timedelta(days=1)
            ),
        }
        form = CourseworkForm(data=data)

        is_valid = form.is_valid()

        assert not is_valid
        assert form.non_field_errors() == [
            "The completed date must be in the school year."
        ]

    def test_invalid_course_task(self):
        """An invalid course task is an error."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        CourseTaskFactory(course=course)
        data = {
            "student": str(student.id),
            "course_task": "0",
            "completed_date": str(grade_level.school_year.start_date),
        }
        form = CourseworkForm(data=data)

        is_valid = form.is_valid()

        assert not is_valid

    def test_invalid_completed_date(self):
        """An invalid completed date is an error."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        course_task = CourseTaskFactory(course=course)
        data = {
            "student": str(student.id),
            "course_task": str(course_task.id),
            "completed_date": "boom",
        }
        form = CourseworkForm(data=data)

        is_valid = form.is_valid()

        assert not is_valid


class TestEnrollmentForm(TestCase):
    def test_students_only_enroll_in_one_grade_level_per_year(self):
        """A student can only be enrolled in a single grade level in a school year."""
        user = self.make_user()
        enrollment = EnrollmentFactory(
            student__school=user.school, grade_level__school_year__school=user.school
        )
        another_grade_level = GradeLevelFactory(
            school_year=enrollment.grade_level.school_year
        )
        data = {
            "student": str(enrollment.student.id),
            "grade_level": str(another_grade_level.id),
        }
        form = EnrollmentForm(user=user, data=data)

        is_valid = form.is_valid()

        assert not is_valid
        assert (
            "A student may not be enrolled in multiple grade levels in a school year. "
            f"{enrollment.student} is enrolled in {enrollment.grade_level}."
            in form.non_field_errors()
        )

    def test_no_grade_level(self):
        """A missing grade level raises a validation error."""
        user = self.make_user()
        school = user.school
        enrollment = EnrollmentFactory(
            student__school=school, grade_level__school_year__school=school
        )
        data = {"student": str(enrollment.student.id), "grade_level": "0"}
        form = EnrollmentForm(user=user, data=data)

        is_valid = form.is_valid()

        assert not is_valid
        assert "You need to select a grade level." in form.non_field_errors()


class TestGradeForm(TestCase):
    def test_is_valid(self):
        """The new grade validates."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        graded_work = GradedWorkFactory(course_task__course=course)
        data = {
            "student": str(student.id),
            "graded_work": str(graded_work.id),
            "score": "100",
        }
        form = GradeForm(data=data)

        is_valid = form.is_valid()

        assert is_valid

    def test_invalid_graded_work(self):
        """An invalid graded work is an error."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        GradedWorkFactory(course_task__course=course)
        data = {"student": str(student.id), "graded_work": "0", "score": "100"}
        form = GradeForm(data=data)

        is_valid = form.is_valid()

        assert not is_valid

    def test_save(self):
        """The form creates a new grade."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        graded_work = GradedWorkFactory(course_task__course=course)
        data = {
            "student": str(student.id),
            "graded_work": str(graded_work.id),
            "score": "100",
        }
        form = GradeForm(data=data)
        form.is_valid()

        form.save()

        assert (
            Grade.objects.filter(
                student=student, graded_work=graded_work, score=100
            ).count()
            == 1
        )

    def test_save_update(self):
        """The form updates a grade."""
        user = self.make_user()
        student = StudentFactory(school=user.school)
        grade_level = GradeLevelFactory(school_year__school=user.school)
        EnrollmentFactory(student=student, grade_level=grade_level)
        course = CourseFactory(grade_levels=[grade_level])
        graded_work = GradedWorkFactory(course_task__course=course)
        GradeFactory(student=student, graded_work=graded_work)
        data = {
            "student": str(student.id),
            "graded_work": str(graded_work.id),
            "score": "100",
        }
        form = GradeForm(data=data)
        form.is_valid()

        form.save()

        assert (
            Grade.objects.filter(student=student, graded_work=graded_work).count() == 1
        )

[((24, 18, 24, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((25, 22, 25, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((26, 8, 26, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((27, 17, 27, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((28, 22, 28, 54), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((34, 15, 34, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((43, 18, 43, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((44, 22, 44, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((45, 17, 45, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((46, 22, 46, 54), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((52, 15, 52, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((64, 18, 64, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((65, 22, 65, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((66, 8, 66, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((67, 17, 67, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((68, 22, 68, 54), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((74, 15, 74, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((87, 18, 87, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((88, 22, 88, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((89, 8, 89, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((90, 17, 90, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((91, 22, 91, 54), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((92, 8, 92, 67), 'homeschool.students.tests.factories.CourseworkFactory', 'CourseworkFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((98, 15, 98, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((111, 18, 111, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((112, 22, 112, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((113, 8, 113, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((114, 17, 114, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((115, 22, 115, 54), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((116, 8, 116, 67), 'homeschool.students.tests.factories.CourseworkFactory', 'CourseworkFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((121, 15, 121, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((134, 18, 134, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((135, 22, 135, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((136, 8, 136, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((137, 17, 137, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((138, 22, 138, 54), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((146, 15, 146, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((158, 18, 158, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((159, 22, 159, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((160, 8, 160, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((161, 17, 161, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((162, 8, 162, 40), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((168, 15, 168, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((177, 18, 177, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((178, 22, 178, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((179, 8, 179, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((180, 17, 180, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((181, 22, 181, 54), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((187, 15, 187, 40), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((198, 21, 200, 9), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((201, 30, 203, 9), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((208, 15, 208, 51), 'homeschool.students.forms.EnrollmentForm', 'EnrollmentForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((223, 21, 225, 9), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((227, 15, 227, 51), 'homeschool.students.forms.EnrollmentForm', 'EnrollmentForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((239, 18, 239, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((240, 22, 240, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((241, 8, 241, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((242, 17, 242, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((243, 22, 243, 67), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((249, 15, 249, 35), 'homeschool.students.forms.GradeForm', 'GradeForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((258, 18, 258, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((259, 22, 259, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((260, 8, 260, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((261, 17, 261, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((262, 8, 262, 53), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((264, 15, 264, 35), 'homeschool.students.forms.GradeForm', 'GradeForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((273, 18, 273, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((274, 22, 274, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((275, 8, 275, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((276, 17, 276, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((277, 22, 277, 67), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((283, 15, 283, 35), 'homeschool.students.forms.GradeForm', 'GradeForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((298, 18, 298, 52), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((299, 22, 299, 72), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', (), '', False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((300, 8, 300, 67), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((301, 17, 301, 58), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((302, 22, 302, 67), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', (), '', False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((303, 8, 303, 62), 'homeschool.students.tests.factories.GradeFactory', 'GradeFactory', (), '', False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((309, 15, 309, 35), 'homeschool.students.forms.GradeForm', 'GradeForm', (), '', False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((80, 12, 80, 79), 'homeschool.students.models.Coursework.objects.filter', 'Coursework.objects.filter', (), '', False, 'from homeschool.students.models import Coursework, Grade\n'), ((104, 12, 104, 79), 'homeschool.students.models.Coursework.objects.filter', 'Coursework.objects.filter', (), '', False, 'from homeschool.students.models import Coursework, Grade\n'), ((127, 12, 127, 79), 'homeschool.students.models.Coursework.objects.filter', 'Coursework.objects.filter', (), '', False, 'from homeschool.students.models import Coursework, Grade\n'), ((143, 53, 143, 79), 'datetime.timedelta', 'datetime.timedelta', (), '', False, 'import datetime\n'), ((289, 12, 291, 13), 'homeschool.students.models.Grade.objects.filter', 'Grade.objects.filter', (), '', False, 'from homeschool.students.models import Coursework, Grade\n'), ((315, 12, 315, 74), 'homeschool.students.models.Grade.objects.filter', 'Grade.objects.filter', (), '', False, 'from homeschool.students.models import Coursework, Grade\n')]