Exemplo n.º 1
0
    def setUp(self):
        self.request_factory = RequestFactory()
        academic_year = _get_academic_year(year=2017)
        academic_calendar = AcademicCalendarFactory(
            title="Submission of score encoding - 1",
            start_date=academic_year.start_date,
            end_date=academic_year.end_date,
            academic_year=academic_year,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)

        SessionExamCalendarFactory(academic_calendar=academic_calendar,
                                   number_session=number_session.ONE)

        self.learning_unit_year = LearningUnitYearFactory(
            academic_year=academic_year)
        self.offer_year = test_offer_year.create_offer_year(
            'SINF1BA', 'Bachelor in informatica', academic_year)
        self.session_exam = test_session_exam.create_session_exam(
            number_session.ONE, self.learning_unit_year, self.offer_year)

        # Create enrollment related
        self.enrollments = []
        for index in range(0, 2):
            offer_year = OfferYearFactory(academic_year=academic_year)
            OfferYearCalendarFactory(academic_calendar=academic_calendar,
                                     offer_year=offer_year)
            offer_enrollment = test_offer_enrollment.create_offer_enrollment(
                StudentFactory(), offer_year)
            learning_unit_enrollment = test_learning_unit_enrollment.create_learning_unit_enrollment(
                offer_enrollment=offer_enrollment,
                learning_unit_year=self.learning_unit_year)
            exam_enrollment = test_exam_enrollment.create_exam_enrollment(
                self.session_exam, learning_unit_enrollment)
            self.enrollments.append(exam_enrollment)

        self.tutor = TutorFactory()
        test_attribution.create_attribution(
            tutor=self.tutor, learning_unit_year=self.learning_unit_year)
        add_permission(self.tutor.person.user, "can_access_scoreencoding")

        offer_year = self.enrollments[
            0].learning_unit_enrollment.offer_enrollment.offer_year
        self.program_manager_1 = ProgramManagerFactory(offer_year=offer_year)
        add_permission(self.program_manager_1.person.user,
                       "can_access_scoreencoding")

        offer_year = self.enrollments[
            1].learning_unit_enrollment.offer_enrollment.offer_year
        self.program_manager_2 = ProgramManagerFactory(offer_year=offer_year)
        add_permission(self.program_manager_2.person.user,
                       "can_access_scoreencoding")
    def test_order_find_related_tutors_somebody(self):
        # Create tutor - Dupont Tom
        tutor_five = TutorFactory(
            person=PersonFactory(last_name='Dupont', first_name='Tom'))
        test_attribution.create_attribution(
            tutor=tutor_five, learning_unit_year=self.learning_unit_year)
        # Create tutor - Dupont Albert
        tutor_third = TutorFactory(
            person=PersonFactory(last_name='Dupont', first_name='Albert'))
        test_attribution.create_attribution(
            tutor=tutor_third, learning_unit_year=self.learning_unit_year)
        # Create tutor - Armand Zoe
        tutor_second = TutorFactory(
            person=PersonFactory(last_name='Armand', first_name='Zoe'))
        test_attribution.create_attribution(
            tutor=tutor_second, learning_unit_year=self.learning_unit_year_2)
        # Create tutor - SOMEBODY_GID [Specific case: Must be at top of list - Global_id: 99999998]
        tutor_first = TutorFactory(
            person=PersonFactory(last_name='SOMEBODY_GID',
                                 first_name='SOMEBODY_GID',
                                 global_id='99999998'))
        test_attribution.create_attribution(
            tutor=tutor_first, learning_unit_year=self.learning_unit_year_2)

        tutors = list(
            score_encoding_progress.find_related_tutors(
                self.program_manager.person.user, self.academic_year,
                number_session.ONE))
        self.assertEqual(len(tutors), 5)
        self.assertEqual(tutors[0], tutor_first)  #SOMEBODY_GID
        self.assertEqual(tutors[1], tutor_second)  #Armand Zoe
        self.assertEqual(tutors[2], tutor_third)  #Dupont Albert
        self.assertEqual(tutors[3],
                         self.tutor)  #Dupont Thierry [ Set in setUp fct ]
        self.assertEqual(tutors[4], tutor_five)  #Dupont Tom
Exemplo n.º 3
0
    def setUp(self):
        group, created = Group.objects.get_or_create(name='entity_managers')
        content_type = ContentType.objects.get_for_model(EntityManager)
        perm, created = Permission.objects.get_or_create(codename='is_entity_manager', content_type=content_type)
        group.permissions.add(perm)
        self.person = PersonFactory()
        self.user = self.person.user
        self.tutor = TutorFactory(person=self.person)
        self.current_academic_year = create_current_academic_year()
        self.next_academic_year = AcademicYearFactory(
            year=self.current_academic_year.year + 1
        )

        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(
            person=self.person,
            structure=self.structure,
            entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.next_academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210"
        )
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.next_academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211"
        )

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            summary_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            summary_responsible=True)
Exemplo n.º 4
0
    def setUp(self):
        group, created = Group.objects.get_or_create(name='entity_managers')
        content_type = ContentType.objects.get_for_model(EntityManager)
        perm, created = Permission.objects.get_or_create(codename='is_entity_manager', content_type=content_type)
        group.permissions.add(perm)
        self.person = PersonFactory()
        self.user = self.person.user
        self.tutor = TutorFactory(person=self.person)
        self.current_academic_year = create_current_academic_year()
        self.next_academic_year = AcademicYearFactory(
            year=self.current_academic_year.year + 1
        )

        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(
            person=self.person,
            structure=self.structure,
            entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.next_academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210"
        )
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.next_academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211"
        )

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            summary_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            summary_responsible=True)
Exemplo n.º 5
0
    def test_get_scores_encoding_progress_with_tutors_and_score_responsible(self):
        # Create tutors
        test_attribution.create_attribution(tutor=TutorFactory(), learning_unit_year=self.learning_unit_year)
        test_attribution.create_attribution(tutor=TutorFactory(), learning_unit_year=self.learning_unit_year)

        progress_list = score_encoding_progress.get_scores_encoding_progress(
            user=self.program_manager.person.user,
            offer_year_id=self.offer_year_2,
            number_session=number_session.ONE,
            academic_year=self.academic_year
        )
        progress_list = score_encoding_progress.append_related_tutors_and_score_responsibles(progress_list)
        self.assertEqual(len(progress_list), 1)
        self.assertEqual(len(progress_list[0].tutors), 3)
        self.assertEqual(len(progress_list[0].score_responsibles), 1)
Exemplo n.º 6
0
    def create_learning_unit_year_annual_data(self, a_year):
        an_academic_yr = test_academic_year.create_academic_year_with_year(a_year)
        an_academic_yr.year = a_year
        a_learning_unit_year = test_learning_unit_year.create_learning_unit_year({
            'acronym': ACRONYM,
            'title': TITLE,
            'academic_year': an_academic_yr,
            'weight': WEIGHT,
            'vacant' : True,
            'in_charge': True})
        a_learning_unit_component_lecture = self.create_learning_unit_component(component_type.LECTURING,
                                                                                LEARNING_UNIT_LECTURING_DURATION,
                                                                                a_learning_unit_year)
        a_learning_unit_component_practice = \
            self.create_learning_unit_component(component_type.PRACTICAL_EXERCISES,
                                                LEARNING_UNIT_PRACTICAL_EXERCISES_DURATION,
                                                a_learning_unit_year)
        an_attribution = test_attribution.create_attribution({'function': function.CO_HOLDER,
                                                              'learning_unit_year': a_learning_unit_year,
                                                              'tutor': self.a_tutor})
        test_attribution_charge.create_attribution_charge(
            {'attribution': an_attribution,
             'learning_unit_component': a_learning_unit_component_lecture,
             'allocation_charge': ATTRIBUTION_CHARGE_LECTURING_DURATION})
        test_attribution_charge.create_attribution_charge(
            {'attribution': an_attribution,
             'learning_unit_component': a_learning_unit_component_practice,
             'allocation_charge': ATTRIBUTION_CHARGE_PRACTICAL_EXERCISES_DURATION})

        return {'academic_year':                   an_academic_yr,
                'learning_unit_year':               a_learning_unit_year,
                'learning_unit_component_lecture':  a_learning_unit_component_lecture,
                'learning_unit_component_practice': a_learning_unit_component_practice,
                'attribution':                      an_attribution}
Exemplo n.º 7
0
    def test_find_related_tutors(self):
        # Create tutors
        test_attribution.create_attribution(tutor=TutorFactory(), learning_unit_year=self.learning_unit_year)
        test_attribution.create_attribution(tutor=TutorFactory(), learning_unit_year=self.learning_unit_year)
        test_attribution.create_attribution(tutor=TutorFactory(), learning_unit_year=self.learning_unit_year_2)
        test_attribution.create_attribution(tutor=TutorFactory(), learning_unit_year=self.learning_unit_year_2)

        tutors = list(score_encoding_progress.find_related_tutors(self.program_manager.person.user, self.academic_year,
                                                                  number_session.ONE))
        self.assertEqual(len(tutors), 5)
Exemplo n.º 8
0
    def setUp(self):
        self.person = PersonFactory()
        self.user = self.person.user
        self.tutor = TutorFactory(person=self.person)
        self.current_academic_year = create_current_academic_year()
        self.next_academic_year = AcademicYearFactory(
            year=self.current_academic_year.year + 1)

        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(
            part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(person=self.person,
                                                   structure=self.structure,
                                                   entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.next_academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210")
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.next_academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211")

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            summary_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            summary_responsible=True)
    def setUp(self):
        self.academic_year = AcademicYearFactory(
            year=datetime.date.today().year)
        self.academic_calendar = AcademicCalendarFactory.build(
            title="Submission of score encoding - 1",
            start_date=self.academic_year.start_date,
            end_date=self.academic_year.end_date,
            academic_year=self.academic_year,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        self.academic_calendar.save(functions=[])
        SessionExamCalendarFactory(academic_calendar=self.academic_calendar,
                                   number_session=number_session.ONE)
        # Offer year CHIM1BA
        self.offer_year = OfferYearFactory(acronym="CHIM1BA",
                                           academic_year=self.academic_year)
        self.learning_unit_year = LearningUnitYearFactory(
            acronym="LBIR1210", academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year,
                                              self.offer_year, 10, 3)
        self.learning_unit_year_2 = LearningUnitYearFactory(
            acronym="LBIR1211", academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year_2,
                                              self.offer_year, 5)

        # Offer year DIR2BA
        self.offer_year_2 = OfferYearFactory(acronym="DIR2BA",
                                             academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year,
                                              self.offer_year_2, 8, 5)
        self.program_manager = ProgramManagerFactory(
            offer_year=self.offer_year)
        ProgramManagerFactory(offer_year=self.offer_year_2,
                              person=self.program_manager.person)
        # Tutor [Tom Dupont] have an attribution to LBIR1210
        person = PersonFactory(last_name="Dupont", first_name="Thierry")
        self.tutor = TutorFactory(person=person)
        test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
Exemplo n.º 10
0
 def setUpTestData(cls):
     cls.user = UserFactory()
     cls.person = PersonFactory(first_name="James",
                                last_name="Dupont",
                                user=cls.user)
     cls.tutor = TutorFactory(person=cls.person)
     TutorFactory()  # Create fake Tutor
     TutorFactory()  # Create fake Tutor
     cls.learning_unit_year = LearningUnitYearFactory()
     cls.attribution = test_attribution.create_attribution(
         tutor=cls.tutor,
         learning_unit_year=cls.learning_unit_year,
         score_responsible=False)
Exemplo n.º 11
0
 def setUp(self):
     self.user = UserFactory()
     self.person = PersonFactory(first_name="James",
                                 last_name="Dupont",
                                 user=self.user)
     self.tutor = TutorFactory(person=self.person)
     TutorFactory()  # Create fake Tutor
     TutorFactory()  # Create fake Tutor
     self.learning_unit_year = LearningUnitYearFactory()
     self.attribution = test_attribution.create_attribution(
         tutor=self.tutor,
         learning_unit_year=self.learning_unit_year,
         score_responsible=False,
         summary_responsible=True)
Exemplo n.º 12
0
 def create_learning_units(self):
     # Create two learning units
     learning_container_year = LearningContainerYearFactory(
         academic_year=self.academic_year, acronym="LBIR1210")
     self.learning_unit_year = LearningUnitYearFactory(
         structure=self.structure,
         acronym=learning_container_year.acronym,
         learning_container_year=learning_container_year,
         academic_year=self.academic_year)
     learning_container_year_children = LearningContainerYearFactory(
         academic_year=self.academic_year, acronym="LBIR1211")
     self.learning_unit_year_children = LearningUnitYearFactory(
         structure=self.structure_children,
         acronym=learning_container_year_children.acronym,
         learning_container_year=learning_container_year_children,
         academic_year=self.academic_year)
     # Create entity attribution
     EntityContainerYearFactory(
         type=entity_container_year_link_type.ALLOCATION_ENTITY,
         learning_container_year=self.learning_unit_year.
         learning_container_year,
         entity=self.child_one_entity)
     EntityContainerYearFactory(
         type=entity_container_year_link_type.ALLOCATION_ENTITY,
         learning_container_year=self.learning_unit_year_children.
         learning_container_year,
         entity=self.child_two_entity)
     # Create attributions
     self.attribution = test_attribution.create_attribution(
         tutor=self.tutor,
         learning_unit_year=self.learning_unit_year,
         score_responsible=True)
     self.attribution_children = test_attribution.create_attribution(
         tutor=self.tutor,
         learning_unit_year=self.learning_unit_year_children,
         score_responsible=True)