Ejemplo n.º 1
0
    def test_registered_school_unit_list_filter(self, filter_kwargs):
        self.client.login(username=self.admin_user.username, password='******')

        if list(filter_kwargs.keys())[0] == 'categories':
            rsu1 = RegisteredSchoolUnitFactory()
            category = SchoolUnitCategoryFactory()
            rsu1.categories.add(category)

            filter_kwargs = {'categories': category.id}
        elif list(filter_kwargs.keys())[0] == 'academic_profile':
            category = SchoolUnitCategoryFactory()
            academic_profile = SchoolUnitProfileFactory(category=category)
            rsu1 = RegisteredSchoolUnitFactory(
                academic_profile=academic_profile)

            filter_kwargs = {'academic_profile': academic_profile.id}
        else:
            rsu1 = RegisteredSchoolUnitFactory(**filter_kwargs)

        RegisteredSchoolUnitFactory()

        response = self.client.get(self.url, filter_kwargs)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data['results']), 1)
        self.assertEqual(response.data['results'][0]['id'], rsu1.id)
Ejemplo n.º 2
0
    def setUpTestData(cls):
        cls.principal = UserProfileFactory(user_role=UserProfile.UserRoles.PRINCIPAL)
        cls.school_unit = RegisteredSchoolUnitFactory(school_principal=cls.principal)

        cls.category1 = SchoolUnitCategoryFactory(category_level=SchoolUnitCategory.CategoryLevels.SECONDARY_SCHOOL)
        cls.category2 = SchoolUnitCategoryFactory(category_level=SchoolUnitCategory.CategoryLevels.HIGHSCHOOL)
        cls.school_unit.categories.add(cls.category1, cls.category2)

        cls.calendar = AcademicYearCalendarFactory()

        cls.subject1 = SubjectFactory()
        cls.subject2 = SubjectFactory()
        cls.coordination_subject = SubjectFactory(is_coordination=True)
        cls.academic_program = AcademicProgramFactory(school_unit=cls.school_unit)
        for class_grade, class_grade_arabic in zip(['VI', 'X'], [6, 10]):
            ProgramSubjectThroughFactory(academic_program=cls.academic_program, subject=cls.subject1,
                                         is_mandatory=False, class_grade=class_grade, class_grade_arabic=class_grade_arabic)
            ProgramSubjectThroughFactory(generic_academic_program=cls.academic_program.generic_academic_program,
                                         subject=cls.subject2, class_grade=class_grade, class_grade_arabic=class_grade_arabic)

        cls.teacher1 = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.teacher2 = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.teacher1.taught_subjects.add(cls.subject1, cls.subject2)
        cls.teacher2.taught_subjects.add(cls.subject1, cls.subject2)

        cls.study_class1 = StudyClassFactory(school_unit=cls.school_unit, class_master=cls.teacher1, academic_program=cls.academic_program,
                                             class_grade='X', class_grade_arabic=10, class_letter='A')
        TeacherClassThroughFactory(study_class=cls.study_class1, teacher=cls.teacher1, subject=cls.coordination_subject, is_class_master=True)
        cls.study_class2 = StudyClassFactory(school_unit=cls.school_unit, class_master=cls.teacher2, academic_program=cls.academic_program)
        TeacherClassThroughFactory(study_class=cls.study_class2, teacher=cls.teacher2, subject=cls.coordination_subject, is_class_master=True)

        TeacherClassThroughFactory(study_class=cls.study_class1, teacher=cls.teacher1, subject=cls.subject1, is_class_master=True)
        TeacherClassThroughFactory(study_class=cls.study_class1, teacher=cls.teacher2, subject=cls.subject2, is_class_master=False)
        TeacherClassThroughFactory(study_class=cls.study_class2, teacher=cls.teacher1, subject=cls.subject1, is_class_master=False)
        TeacherClassThroughFactory(study_class=cls.study_class2, teacher=cls.teacher2, subject=cls.subject2, is_class_master=True)

        cls.student1 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class1)
        StudentCatalogPerYearFactory(student=cls.student1, study_class=cls.study_class1)
        cls.student2 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class1)
        StudentCatalogPerYearFactory(student=cls.student2, study_class=cls.study_class1)
        cls.student3 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class2)
        StudentCatalogPerYearFactory(student=cls.student3, study_class=cls.study_class2)

        cls.academic_program2 = AcademicProgramFactory(school_unit=cls.school_unit)
        for class_grade, class_grade_arabic in zip(['VII', 'XI'], [7, 11]):
            ProgramSubjectThroughFactory(academic_program=cls.academic_program2, subject=cls.subject1,
                                         is_mandatory=False, class_grade=class_grade, class_grade_arabic=class_grade_arabic)
            ProgramSubjectThroughFactory(generic_academic_program=cls.academic_program2.generic_academic_program,
                                         subject=cls.subject2, class_grade=class_grade, class_grade_arabic=class_grade_arabic)

        cls.new_teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.new_student = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit)
Ejemplo n.º 3
0
    def test_registered_school_unit_update_validate_categories(self):
        self.client.login(username=self.admin_user.username, password='******')
        current_categories = self.school_unit.categories.all()

        # Invalid categories
        self.request_data['categories'] = [0]
        response = self.client.put(self.url, self.request_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(
            response.data,
            {'categories': ['Invalid pk "0" - object does not exist.']})

        # Multiple categories from the same level
        self.request_data['categories'] = [
            self.academic_profile1.category.id,
            self.academic_profile2.category.id,
            SchoolUnitCategoryFactory().id
        ]
        response = self.client.put(self.url, self.request_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(
            response.data, {
                'categories':
                ['Cannot have multiple categories for the same school level.']
            })

        self.school_unit.refresh_from_db()
        self.assertCountEqual(current_categories,
                              self.school_unit.categories.all())
Ejemplo n.º 4
0
    def setUpTestData(cls):
        cls.admin_user = UserProfileFactory(
            user_role=UserProfile.UserRoles.ADMINISTRATOR)
        cls.principal = UserProfileFactory(
            user_role=UserProfile.UserRoles.PRINCIPAL)
        cls.other_principal = UserProfileFactory(
            user_role=UserProfile.UserRoles.PRINCIPAL)
        cls.academic_profile1 = SchoolUnitProfileFactory()
        category = SchoolUnitCategoryFactory(
            category_level=SchoolUnitCategory.CategoryLevels.SECONDARY_SCHOOL)
        cls.academic_profile2 = SchoolUnitProfileFactory(category=category)

        cls.school_unit = RegisteredSchoolUnitFactory(
            address='original address',
            phone_number='+890882333',
            email='*****@*****.**',
            district='original district',
            city='original city',
            name='original name',
            school_principal=cls.principal,
            academic_profile=cls.academic_profile1)
        cls.school_unit.categories.add(cls.academic_profile1.category)

        cls.url = reverse('schools:school-unit-detail',
                          kwargs={'id': cls.school_unit.id})
    def test_my_school_unit_success(self):
        self.client.login(username=self.principal.username, password='******')

        category = SchoolUnitCategoryFactory()
        academic_profile = SchoolUnitProfileFactory(category=category)
        self.rsu.categories.add(category)
        self.rsu.academic_profile = academic_profile
        self.rsu.save()

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        expected_fields = ['categories', 'academic_profile', 'phone_number', 'email', 'district', 'city', 'name', 'id', 'is_active',
                           'school_principal', 'address', ]

        self.assertCountEqual(response.data.keys(), expected_fields)
        for field in expected_fields:
            if field == 'categories':
                category_data = response.data[field][0]
                self.assertEqual(category.id, category_data['id'])
                self.assertEqual(category.name, category_data['name'])
            elif field == 'academic_profile':
                academic_profile_data = response.data[field]
                self.assertEqual(academic_profile.id, academic_profile_data['id'])
                self.assertEqual(academic_profile.name, academic_profile_data['name'])
            elif field == 'school_principal':
                principal_data = response.data[field]
                self.assertEqual(self.principal.id, principal_data['id'])
                self.assertEqual(self.principal.full_name, principal_data['full_name'])
            else:
                self.assertEqual(getattr(self.rsu, field), response.data[field])
Ejemplo n.º 6
0
    def test_academic_program_list_filter_by_category(self):
        self.client.login(username=self.principal.username, password='******')
        highschool_category = SchoolUnitCategoryFactory()
        self.school_unit.categories.add(highschool_category)

        AcademicProgramFactory(
            academic_year=self.academic_year,
            name='program',
            school_unit=self.school_unit,
            generic_academic_program=GenericAcademicProgramFactory(
                category=highschool_category))
        AcademicProgramFactory(
            academic_year=self.academic_year,
            name='other',
            school_unit=self.school_unit,
            generic_academic_program=GenericAcademicProgramFactory(
                category=highschool_category))

        response = self.client.get(self.build_url(self.academic_year),
                                   {'class_grade': 'IX'})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 2)

        response = self.client.get(self.build_url(self.academic_year),
                                   {'class_grade': 'IV'})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 0)
    def test_academic_program_create_invalid_category(self, mocked_method):
        self.client.login(username=self.principal.username, password='******')
        self.generic_academic_program.category = SchoolUnitCategoryFactory()
        self.generic_academic_program.save()

        response = self.client.post(self.build_url(self.academic_year), self.data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data, {'generic_academic_program': ['Invalid generic academic program.']})
    def test_school_unit_category_list_success(self):
        self.client.login(username=self.admin_user.username, password='******')

        category1 = SchoolUnitCategoryFactory(name='c2')
        category2 = SchoolUnitCategoryFactory(name='c3')
        category3 = SchoolUnitCategoryFactory(name='c1')

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        results = response.data
        self.assertEqual(len(results), 3)
        self.assertEqual(category3.id, results[0]['id'])
        self.assertEqual(category1.id, results[1]['id'])
        self.assertEqual(category2.id, results[2]['id'])

        expected_fields = ['id', 'name', 'category_level']
        for result in results:
            self.assertCountEqual(result.keys(), expected_fields)
    def test_can_update_grades_or_absences_during_second_semester(
            self, event_type, class_grade, category_name, mocked_method):
        study_class = StudyClassFactory(class_grade_arabic=class_grade,
                                        class_letter='A',
                                        school_unit=self.school_unit)
        if category_name:
            self.school_unit.categories.add(
                SchoolUnitCategoryFactory(name='Liceu - Filieră Tehnologică'))

        second_semester = self.academic_year_calendar.second_semester
        second_semester.starts_at = datetime.date(2020, 6, 6)
        second_semester.ends_at = datetime.date(2020, 9, 9)
        SchoolEventFactory(
            semester=self.academic_year_calendar.second_semester,
            event_type=event_type,
            starts_at=datetime.date(2020, 9, 10),
            ends_at=datetime.date(2020, 9, 11))
        self.assertTrue(can_update_grades_or_absences(study_class))
    def test_academic_program_create_secondary_school_success(self, mocked_method):
        self.client.login(username=self.principal.username, password='******')
        category = SchoolUnitCategoryFactory(category_level=SchoolUnitCategory.CategoryLevels.SECONDARY_SCHOOL)
        generic_academic_program = GenericAcademicProgramFactory(
            category=category,
            optional_subjects_weekly_hours={
                "VI": 1,
                "VII": 1
            }
        )
        self.school_unit.categories.add(category)
        self.school_unit.academic_profile = None
        self.school_unit.save()

        self.data = {
            "generic_academic_program": generic_academic_program.id,
            "optional_subjects": [
                {
                    "class_grade": "VI",
                    "subject": self.subject.name,
                    "weekly_hours_count": 1
                },
                {
                    "class_grade": "VII",
                    "subject": self.subject.name,
                    "weekly_hours_count": 1
                }
            ]
        }

        response = self.client.post(self.build_url(self.academic_year), self.data)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        academic_program = AcademicProgram.objects.get(id=response.data['id'])
        self.assertEqual(academic_program.name, generic_academic_program.name)
        self.assertEqual(academic_program.school_unit, self.school_unit)
        self.assertEqual(academic_program.academic_year, self.academic_year)
        self.assertEqual(ProgramSubjectThrough.objects.filter(academic_program=academic_program).count(), 2)

        self.assertCountEqual(response.data['subjects'].keys(), ['VI', 'VII'])
        self.assertEqual(len(response.data['subjects']['VI']['mandatory_subjects']), 0)
        self.assertEqual(len(response.data['subjects']['VI']['optional_subjects']), 1)
        self.assertEqual(len(response.data['subjects']['VII']['mandatory_subjects']), 0)
        self.assertEqual(len(response.data['subjects']['VII']['optional_subjects']), 1)
Ejemplo n.º 11
0
    def test_registered_school_unit_list_success(self):
        self.client.login(username=self.admin_user.username, password='******')
        # Create two active registered school units and two inactive ones
        rsu1 = RegisteredSchoolUnitFactory(is_active=True, name='c')
        rsu2 = RegisteredSchoolUnitFactory(is_active=True, name='d')
        rsu3 = RegisteredSchoolUnitFactory(is_active=False, name='b')
        rsu4 = RegisteredSchoolUnitFactory(is_active=False, name='a')

        # Also add a category for one of the school units
        category = SchoolUnitCategoryFactory()
        academic_profile = SchoolUnitProfileFactory(category=category)
        rsu1.categories.add(category)
        rsu1.academic_profile = academic_profile
        rsu1.save()

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # The school units should be ordered by is_active, then name
        results = response.data['results']
        self.assertEqual(results[0]['id'], rsu1.id)
        self.assertEqual(results[1]['id'], rsu2.id)
        self.assertEqual(results[2]['id'], rsu4.id)
        self.assertEqual(results[3]['id'], rsu3.id)

        expected_fields = [
            'id', 'name', 'categories', 'academic_profile', 'is_active',
            'district', 'city'
        ]
        for result in results:
            self.assertCountEqual(result.keys(), expected_fields)
            if result['id'] == rsu1.id:
                self.assertCountEqual(
                    result['categories'],
                    [{
                        'name': category.name,
                        'id': category.id,
                        'category_level': category.category_level
                    }])
                self.assertCountEqual(result['academic_profile'], {
                    'name': academic_profile.name,
                    'id': academic_profile.id
                })
    def setUpTestData(cls):
        cls.calendar = AcademicYearCalendarFactory(
            first_semester__starts_at=datetime(2019, 9, 9),
            first_semester__ends_at=datetime(2020, 1, 12),
            second_semester__starts_at=datetime(2020, 1, 13),
            second_semester__ends_at=datetime(2020, 6, 12))
        cls.create_semester_end_events(cls.calendar)
        subject = SubjectFactory(name='Matematică')

        cls.school1 = RegisteredSchoolUnitFactory()

        cls.study_class1 = StudyClassFactory(school_unit=cls.school1)

        # No risk
        cls.student1 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class1)
        StudentCatalogPerYearFactory(student=cls.student1,
                                     study_class=cls.study_class1)
        # Absences risk 1
        cls.student2 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class1)
        StudentCatalogPerYearFactory(student=cls.student2,
                                     study_class=cls.study_class1,
                                     unfounded_abs_count_sem1=1,
                                     unfounded_abs_count_sem2=3)
        # Absences risk 2
        cls.student3 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class1)
        StudentCatalogPerYearFactory(student=cls.student3,
                                     study_class=cls.study_class1,
                                     unfounded_abs_count_sem1=4,
                                     unfounded_abs_count_sem2=5)

        cls.study_class2 = StudyClassFactory(school_unit=cls.school1,
                                             class_grade='X',
                                             class_grade_arabic=10)

        # Grades risk 1
        cls.student4 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class2)
        StudentCatalogPerYearFactory(student=cls.student4,
                                     study_class=cls.study_class2)
        cls.catalog4 = StudentCatalogPerSubjectFactory(
            student=cls.student4,
            study_class=cls.study_class2,
            subject=subject,
            avg_sem1=5,
            avg_sem2=6)
        # Grades risk 2 (sem II)
        cls.student5 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class2)
        StudentCatalogPerYearFactory(student=cls.student5,
                                     study_class=cls.study_class2)
        cls.catalog5 = StudentCatalogPerSubjectFactory(
            student=cls.student5,
            study_class=cls.study_class2,
            subject=subject,
            avg_sem1=7,
            avg_sem2=4)

        cls.study_class3 = StudyClassFactory(school_unit=cls.school1,
                                             class_grade='XII',
                                             class_grade_arabic=12)

        # Behavior grade risk 1 (sem II)
        cls.student6 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class3)
        StudentCatalogPerYearFactory(student=cls.student6,
                                     study_class=cls.study_class3,
                                     behavior_grade_sem1=10,
                                     behavior_grade_sem2=9)
        # Behavior grade risk 2
        cls.student7 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class3)
        StudentCatalogPerYearFactory(student=cls.student7,
                                     study_class=cls.study_class3,
                                     behavior_grade_sem1=7,
                                     behavior_grade_sem2=6)

        cls.school2 = RegisteredSchoolUnitFactory()
        cls.school2.categories.add(
            SchoolUnitCategoryFactory(name='Liceu - Filieră Tehnologică'))

        cls.study_class4 = StudyClassFactory(school_unit=cls.school2,
                                             class_grade='VIII',
                                             class_grade_arabic=8)

        # Absences risk 1 + Grades risk 2
        cls.student8 = UserProfileFactory(
            school_unit=cls.school2,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class4)
        StudentCatalogPerYearFactory(student=cls.student8,
                                     study_class=cls.study_class4,
                                     unfounded_abs_count_sem1=1,
                                     unfounded_abs_count_sem2=3)
        cls.catalog8 = StudentCatalogPerSubjectFactory(
            student=cls.student8,
            study_class=cls.study_class4,
            subject=subject,
            avg_sem1=4,
            avg_sem2=4)
        # Grades risk 1 + Behavior grade risk 2 (sem II)
        cls.student9 = UserProfileFactory(
            school_unit=cls.school2,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class4)
        StudentCatalogPerYearFactory(student=cls.student9,
                                     study_class=cls.study_class4,
                                     behavior_grade_sem1=10,
                                     behavior_grade_sem2=7)
        cls.catalog9 = StudentCatalogPerSubjectFactory(
            student=cls.student9,
            study_class=cls.study_class4,
            subject=subject,
            avg_sem1=7,
            avg_sem2=6)

        cls.study_class5 = StudyClassFactory(school_unit=cls.school2,
                                             class_grade='IX',
                                             class_grade_arabic=9)

        # Absences risk 2 (both sem) + Behavior grade risk 1 (sem II)
        cls.student10 = UserProfileFactory(
            school_unit=cls.school2,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class5)
        StudentCatalogPerYearFactory(student=cls.student10,
                                     study_class=cls.study_class5,
                                     behavior_grade_sem1=10,
                                     behavior_grade_sem2=9,
                                     unfounded_abs_count_sem1=4,
                                     unfounded_abs_count_sem2=5)

        # Absences risk 2 + Grades risk 2 + Behavior grade risk 2
        cls.student11 = UserProfileFactory(
            school_unit=cls.school2,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class5)
        StudentCatalogPerYearFactory(student=cls.student11,
                                     study_class=cls.study_class5,
                                     behavior_grade_sem1=7,
                                     behavior_grade_sem2=6,
                                     unfounded_abs_count_sem1=4,
                                     unfounded_abs_count_sem2=6)
        cls.catalog11 = StudentCatalogPerSubjectFactory(
            student=cls.student11,
            study_class=cls.study_class5,
            subject=subject,
            avg_sem1=4,
            avg_sem2=3)

        cls.create_risk_stats()
    def setUpTestData(cls):
        cls.principal = UserProfileFactory(
            user_role=UserProfile.UserRoles.PRINCIPAL)
        cls.school_unit = RegisteredSchoolUnitFactory(
            school_principal=cls.principal)

        cls.category1 = SchoolUnitCategoryFactory(
            category_level=SchoolUnitCategory.CategoryLevels.PRIMARY_SCHOOL)
        cls.category2 = SchoolUnitCategoryFactory(
            category_level=SchoolUnitCategory.CategoryLevels.SECONDARY_SCHOOL)
        cls.category3 = SchoolUnitCategoryFactory(
            category_level=SchoolUnitCategory.CategoryLevels.HIGHSCHOOL)
        cls.school_unit.categories.add(cls.category1, cls.category2,
                                       cls.category3)

        cls.calendar = AcademicYearCalendarFactory()

        cls.subject1 = SubjectFactory()
        cls.subject2 = SubjectFactory()
        cls.coordination_subject = SubjectFactory(is_coordination=True)
        cls.academic_program = AcademicProgramFactory(
            school_unit=cls.school_unit)
        for class_grade, class_grade_arabic in zip(['I', 'VI', 'IX'],
                                                   [1, 6, 9]):
            ProgramSubjectThroughFactory(academic_program=cls.academic_program,
                                         subject=cls.subject1,
                                         is_mandatory=False,
                                         class_grade=class_grade,
                                         class_grade_arabic=class_grade_arabic)
            ProgramSubjectThroughFactory(
                generic_academic_program=cls.academic_program.
                generic_academic_program,
                subject=cls.subject2,
                class_grade=class_grade,
                class_grade_arabic=class_grade_arabic)

        cls.teacher1 = UserProfileFactory(
            user_role=UserProfile.UserRoles.TEACHER,
            school_unit=cls.school_unit)
        cls.teacher2 = UserProfileFactory(
            user_role=UserProfile.UserRoles.TEACHER,
            school_unit=cls.school_unit)
        cls.teacher1.taught_subjects.add(cls.subject1)
        cls.teacher2.taught_subjects.add(cls.subject2)

        cls.student1 = UserProfileFactory(
            user_role=UserProfile.UserRoles.STUDENT,
            school_unit=cls.school_unit)
        cls.student2 = UserProfileFactory(
            user_role=UserProfile.UserRoles.STUDENT,
            school_unit=cls.school_unit)

        cls.url = reverse('study_classes:study-class-list',
                          kwargs={'academic_year': cls.calendar.academic_year})

        cls.class_master = UserProfileFactory(
            user_role=UserProfile.UserRoles.TEACHER,
            school_unit=cls.school_unit)
        cls.primary_school_request_data = {
            'class_grade':
            'I',
            'class_letter':
            'A',
            'academic_program':
            cls.academic_program.id,
            "class_master":
            cls.class_master.id,
            "teachers_class_through": [{
                "teacher": cls.teacher1.id,
                "subject": cls.subject1.id
            }, {
                "teacher": cls.teacher2.id,
                "subject": cls.subject2.id
            }],
            "students": [cls.student1.id, cls.student2.id]
        }
        cls.secondary_school_request_data = {
            'class_grade':
            'VI',
            'class_letter':
            'A1',
            'academic_program':
            cls.academic_program.id,
            "class_master":
            cls.class_master.id,
            "teachers_class_through": [{
                "teacher": cls.teacher1.id,
                "subject": cls.subject1.id
            }, {
                "teacher": cls.teacher2.id,
                "subject": cls.subject2.id
            }],
            "students": [cls.student1.id, cls.student2.id]
        }
Ejemplo n.º 14
0
    def setUpTestData(cls):
        cls.calendar = AcademicYearCalendarFactory(
            first_semester__starts_at=datetime(2019, 9, 9),
            first_semester__ends_at=datetime(2020, 1, 12),
            second_semester__starts_at=datetime(2020, 1, 13),
            second_semester__ends_at=datetime(2020, 6, 12))
        cls.create_semester_end_events(cls.calendar)
        cls.subject = SubjectFactory(name='Matematică')
        cls.subject2 = SubjectFactory(name='Limba Romana')
        coordination_subject = SubjectFactory(is_coordination=True)

        cls.school1 = RegisteredSchoolUnitFactory()

        cls.study_class1 = StudyClassFactory(school_unit=cls.school1)

        # behavior grade for the 1st semester lower than 8 and subject average grade for the 1st semester lower than 5
        cls.student1 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class1)
        cls.parent1 = UserProfileFactory(
            school_unit=cls.school1, user_role=UserProfile.UserRoles.PARENT)
        cls.student1.parents.add(cls.parent1)
        StudentCatalogPerYearFactory(student=cls.student1,
                                     study_class=cls.study_class1)
        StudentCatalogPerSubjectFactory(student=cls.student1,
                                        study_class=cls.study_class1,
                                        subject=cls.subject,
                                        avg_sem1=4,
                                        avg_final=6)
        StudentCatalogPerSubjectFactory(student=cls.student1,
                                        study_class=cls.study_class1,
                                        subject=coordination_subject,
                                        avg_sem1=7,
                                        avg_final=9)

        cls.study_class2 = StudyClassFactory(school_unit=cls.school1,
                                             class_grade='XII',
                                             class_grade_arabic=12)

        # Average below limit (both sem) - 12th grade
        cls.student2 = UserProfileFactory(
            school_unit=cls.school1,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class2)
        StudentCatalogPerYearFactory(student=cls.student2,
                                     study_class=cls.study_class2)
        StudentCatalogPerSubjectFactory(student=cls.student2,
                                        study_class=cls.study_class2,
                                        subject=cls.subject)
        StudentCatalogPerSubjectFactory(student=cls.student2,
                                        study_class=cls.study_class2,
                                        subject=cls.subject,
                                        avg_sem1=4,
                                        avg_sem2=1)

        cls.school2 = RegisteredSchoolUnitFactory()
        cls.school2.categories.add(
            SchoolUnitCategoryFactory(name='Liceu - Filieră Tehnologică'))

        cls.study_class3 = StudyClassFactory(school_unit=cls.school2,
                                             class_grade='VIII',
                                             class_grade_arabic=8)

        # Average below limit (both sem) - 8th grade
        cls.student3 = UserProfileFactory(
            school_unit=cls.school2,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class3)
        StudentCatalogPerYearFactory(student=cls.student3,
                                     study_class=cls.study_class3)
        StudentCatalogPerSubjectFactory(student=cls.student3,
                                        study_class=cls.study_class3,
                                        subject=cls.subject,
                                        avg_sem1=4,
                                        avg_sem2=3)

        cls.study_class4 = StudyClassFactory(school_unit=cls.school2,
                                             class_grade='IX',
                                             class_grade_arabic=9)

        # Averages below limit (both sem) - 9th grade, technological
        cls.student4 = UserProfileFactory(
            school_unit=cls.school2,
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class4)
        StudentCatalogPerYearFactory(student=cls.student4,
                                     study_class=cls.study_class4)
        StudentCatalogPerSubjectFactory(student=cls.student4,
                                        study_class=cls.study_class4,
                                        subject=cls.subject,
                                        avg_sem1=4,
                                        avg_sem2=2)
        StudentCatalogPerSubjectFactory(student=cls.student4,
                                        study_class=cls.study_class4,
                                        subject=cls.subject2,
                                        avg_sem1=3,
                                        avg_sem2=4)