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
        )

[((665, 699), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (679, 699), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((722, 772), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (739, 772), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((781, 840), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (798, 840), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((858, 899), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (871, 899), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((922, 954), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (939, 954), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((1156, 1181), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (1170, 1181), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((1418, 1452), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (1432, 1452), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((1475, 1525), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (1492, 1525), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((1543, 1584), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (1556, 1584), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((1607, 1639), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (1624, 1639), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((1841, 1866), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (1855, 1866), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((2201, 2235), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (2215, 2235), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((2258, 2308), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (2275, 2308), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((2317, 2376), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (2334, 2376), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((2394, 2435), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (2407, 2435), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((2458, 2490), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (2475, 2490), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((2692, 2717), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (2706, 2717), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((3058, 3092), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (3072, 3092), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((3115, 3165), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (3132, 3165), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((3174, 3233), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (3191, 3233), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((3251, 3292), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (3264, 3292), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((3315, 3347), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (3332, 3347), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((3356, 3415), 'homeschool.students.tests.factories.CourseworkFactory', 'CourseworkFactory', ([], {'student': 'student', 'course_task': 'course_task'}), '(student=student, course_task=course_task)\n', (3373, 3415), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((3617, 3642), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (3631, 3642), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((3985, 4019), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (3999, 4019), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((4042, 4092), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (4059, 4092), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((4101, 4160), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (4118, 4160), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((4178, 4219), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (4191, 4219), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((4242, 4274), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (4259, 4274), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((4283, 4342), 'homeschool.students.tests.factories.CourseworkFactory', 'CourseworkFactory', ([], {'student': 'student', 'course_task': 'course_task'}), '(student=student, course_task=course_task)\n', (4300, 4342), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((4473, 4498), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (4487, 4498), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((4844, 4878), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (4858, 4878), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((4901, 4951), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (4918, 4951), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((4960, 5019), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (4977, 5019), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((5037, 5078), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (5050, 5078), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((5101, 5133), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (5118, 5133), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((5394, 5419), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (5408, 5419), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((5741, 5775), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (5755, 5775), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((5798, 5848), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (5815, 5848), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((5857, 5916), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (5874, 5916), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((5934, 5975), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (5947, 5975), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((5984, 6016), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (6001, 6016), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((6202, 6227), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (6216, 6227), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((6440, 6474), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (6454, 6474), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((6497, 6547), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (6514, 6547), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((6556, 6615), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (6573, 6615), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((6633, 6674), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (6646, 6674), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((6697, 6729), 'homeschool.courses.tests.factories.CourseTaskFactory', 'CourseTaskFactory', ([], {'course': 'course'}), '(course=course)\n', (6714, 6729), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((6898, 6923), 'homeschool.students.forms.CourseworkForm', 'CourseworkForm', ([], {'data': 'data'}), '(data=data)\n', (6912, 6923), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((7236, 7332), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student__school': 'user.school', 'grade_level__school_year__school': 'user.school'}), '(student__school=user.school,\n    grade_level__school_year__school=user.school)\n', (7253, 7332), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((7381, 7446), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year': 'enrollment.grade_level.school_year'}), '(school_year=enrollment.grade_level.school_year)\n', (7398, 7446), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((7618, 7654), 'homeschool.students.forms.EnrollmentForm', 'EnrollmentForm', ([], {'user': 'user', 'data': 'data'}), '(user=user, data=data)\n', (7632, 7654), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((8132, 8219), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student__school': 'school', 'grade_level__school_year__school': 'school'}), '(student__school=school, grade_level__school_year__school=\n    school)\n', (8149, 8219), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((8327, 8363), 'homeschool.students.forms.EnrollmentForm', 'EnrollmentForm', ([], {'user': 'user', 'data': 'data'}), '(user=user, data=data)\n', (8341, 8363), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((8658, 8692), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (8672, 8692), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((8715, 8765), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (8732, 8765), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((8774, 8833), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (8791, 8833), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((8851, 8892), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (8864, 8892), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((8915, 8960), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', ([], {'course_task__course': 'course'}), '(course_task__course=course)\n', (8932, 8960), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((9119, 9139), 'homeschool.students.forms.GradeForm', 'GradeForm', ([], {'data': 'data'}), '(data=data)\n', (9128, 9139), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((9342, 9376), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (9356, 9376), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((9399, 9449), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (9416, 9449), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((9458, 9517), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (9475, 9517), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((9535, 9576), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (9548, 9576), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((9585, 9630), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', ([], {'course_task__course': 'course'}), '(course_task__course=course)\n', (9602, 9630), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((9726, 9746), 'homeschool.students.forms.GradeForm', 'GradeForm', ([], {'data': 'data'}), '(data=data)\n', (9735, 9746), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((9932, 9966), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (9946, 9966), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((9989, 10039), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (10006, 10039), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((10048, 10107), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (10065, 10107), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((10125, 10166), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (10138, 10166), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((10189, 10234), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', ([], {'course_task__course': 'course'}), '(course_task__course=course)\n', (10206, 10234), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((10393, 10413), 'homeschool.students.forms.GradeForm', 'GradeForm', ([], {'data': 'data'}), '(data=data)\n', (10402, 10413), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((10751, 10785), 'homeschool.students.tests.factories.StudentFactory', 'StudentFactory', ([], {'school': 'user.school'}), '(school=user.school)\n', (10765, 10785), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((10808, 10858), 'homeschool.schools.tests.factories.GradeLevelFactory', 'GradeLevelFactory', ([], {'school_year__school': 'user.school'}), '(school_year__school=user.school)\n', (10825, 10858), False, 'from homeschool.schools.tests.factories import GradeLevelFactory\n'), ((10867, 10926), 'homeschool.students.tests.factories.EnrollmentFactory', 'EnrollmentFactory', ([], {'student': 'student', 'grade_level': 'grade_level'}), '(student=student, grade_level=grade_level)\n', (10884, 10926), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((10944, 10985), 'homeschool.courses.tests.factories.CourseFactory', 'CourseFactory', ([], {'grade_levels': '[grade_level]'}), '(grade_levels=[grade_level])\n', (10957, 10985), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((11008, 11053), 'homeschool.courses.tests.factories.GradedWorkFactory', 'GradedWorkFactory', ([], {'course_task__course': 'course'}), '(course_task__course=course)\n', (11025, 11053), False, 'from homeschool.courses.tests.factories import CourseFactory, CourseTaskFactory, GradedWorkFactory\n'), ((11062, 11116), 'homeschool.students.tests.factories.GradeFactory', 'GradeFactory', ([], {'student': 'student', 'graded_work': 'graded_work'}), '(student=student, graded_work=graded_work)\n', (11074, 11116), False, 'from homeschool.students.tests.factories import CourseworkFactory, EnrollmentFactory, GradeFactory, StudentFactory\n'), ((11275, 11295), 'homeschool.students.forms.GradeForm', 'GradeForm', ([], {'data': 'data'}), '(data=data)\n', (11284, 11295), False, 'from homeschool.students.forms import CourseworkForm, EnrollmentForm, GradeForm\n'), ((2793, 2860), 'homeschool.students.models.Coursework.objects.filter', 'Coursework.objects.filter', ([], {'student': 'student', 'course_task': 'course_task'}), '(student=student, course_task=course_task)\n', (2818, 2860), False, 'from homeschool.students.models import Coursework, Grade\n'), ((3718, 3785), 'homeschool.students.models.Coursework.objects.filter', 'Coursework.objects.filter', ([], {'student': 'student', 'course_task': 'course_task'}), '(student=student, course_task=course_task)\n', (3743, 3785), False, 'from homeschool.students.models import Coursework, Grade\n'), ((4574, 4641), 'homeschool.students.models.Coursework.objects.filter', 'Coursework.objects.filter', ([], {'student': 'student', 'course_task': 'course_task'}), '(student=student, course_task=course_task)\n', (4599, 4641), False, 'from homeschool.students.models import Coursework, Grade\n'), ((5327, 5353), 'datetime.timedelta', 'datetime.timedelta', ([], {'days': '(1)'}), '(days=1)\n', (5345, 5353), False, 'import datetime\n'), ((10489, 10562), 'homeschool.students.models.Grade.objects.filter', 'Grade.objects.filter', ([], {'student': 'student', 'graded_work': 'graded_work', 'score': '(100)'}), '(student=student, graded_work=graded_work, score=100)\n', (10509, 10562), False, 'from homeschool.students.models import Coursework, Grade\n'), ((11371, 11433), 'homeschool.students.models.Grade.objects.filter', 'Grade.objects.filter', ([], {'student': 'student', 'graded_work': 'graded_work'}), '(student=student, graded_work=graded_work)\n', (11391, 11433), False, 'from homeschool.students.models import Coursework, Grade\n')]