Ejemplo n.º 1
0
def generate_exam_enrollments(year, with_different_offer=False):
    number_enrollments = 2
    academic_year = AcademicYearFactory(year=year)

    an_academic_calendar = AcademicCalendarFactory(
        academic_year=academic_year,
        start_date=(datetime.datetime.today() -
                    datetime.timedelta(days=20)).date(),
        end_date=(datetime.datetime.today() +
                  datetime.timedelta(days=20)).date(),
        reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
    session_exam_calendar = SessionExamCalendarFactory(
        number_session=number_session.ONE,
        academic_calendar=an_academic_calendar)

    learning_unit_year = LearningUnitYearFakerFactory(
        academic_year=academic_year,
        learning_container_year__academic_year=academic_year,
        acronym=LEARNING_UNIT_ACRONYM)
    attribution = AttributionFactory(learning_unit_year=learning_unit_year)

    if with_different_offer:
        session_exams = [
            SessionExamFactory(number_session=number_session.ONE,
                               learning_unit_year=learning_unit_year,
                               offer_year__academic_year=academic_year)
            for _ in range(0, number_enrollments)
        ]
    else:
        session_exams = [
            SessionExamFactory(number_session=number_session.ONE,
                               learning_unit_year=learning_unit_year,
                               offer_year__academic_year=academic_year)
        ] * number_enrollments
    offer_years = [session_exam.offer_year for session_exam in session_exams]

    exam_enrollments = list()
    for i in range(0, number_enrollments):
        student = StudentFactory()
        offer_enrollment = OfferEnrollmentFactory(offer_year=offer_years[i],
                                                  student=student)
        learning_unit_enrollment = LearningUnitEnrollmentFactory(
            learning_unit_year=learning_unit_year,
            offer_enrollment=offer_enrollment)
        exam_enrollments.append(
            ExamEnrollmentFactory(
                session_exam=session_exams[i],
                learning_unit_enrollment=learning_unit_enrollment,
                enrollment_state=exam_enrollment_state.ENROLLED,
                date_enrollment=an_academic_calendar.start_date))
    return locals()
    def _create_context_exam_enrollments(self,
                                         learning_unit_year,
                                         offer_year,
                                         nb_enrollment=10,
                                         nb_filled=None):
        counter_filled = nb_filled if (
            nb_filled and nb_filled <= nb_enrollment) else nb_enrollment
        session_exam = SessionExamFactory(
            number_session=number_session.ONE,
            learning_unit_year=learning_unit_year)
        OfferYearCalendarFactory(academic_calendar=self.academic_calendar,
                                 offer_year=offer_year)

        for index in range(0, nb_enrollment):
            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=learning_unit_year)
            exam_enrollment = test_exam_enrollment.create_exam_enrollment(
                session_exam, learning_unit_enrollment)
            if counter_filled:
                exam_enrollment.score_final = randint(0, 20)
                exam_enrollment.save()
                counter_filled -= 1
Ejemplo n.º 3
0
    def setUp(self):
        self.academic_year = AcademicYearFactory()
        self.offer_year = OfferYearFactory(academic_year=self.academic_year)
        self.learning_unit_year = LearningUnitYearFactory(academic_year=self.academic_year, acronym="LBIR1100",
                                                          decimal_scores=False)
        # Create tutor and score responsible
        _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Alibra', first_name='Paul'))
        _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Durant', first_name='Thomas'),
                            is_score_responsible=True)
        _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Lobradi', first_name='Pierre'))

        self.session_exam = SessionExamFactory(number_session=1, learning_unit_year=self.learning_unit_year)

        # Create three students and enrol them to learning unit year
        self.student_1 = StudentFactory(person=PersonFactory(last_name='Dupont', first_name='Jacques'))
        self.student_2 = StudentFactory(person=PersonFactory(last_name='Dupont', first_name='Axel'))
        self.student_3 = StudentFactory(person=PersonFactory(last_name='Armand', first_name='Zoe'))

        for student in (self.student_1, self.student_2, self.student_3):
            offer_enrollment = OfferEnrollmentFactory(offer_year=self.offer_year, student=student)
            lu_enrolmment = LearningUnitEnrollmentFactory(
                offer_enrollment=offer_enrollment,
                learning_unit_year=self.learning_unit_year
            )
            ExamEnrollmentFactory(learning_unit_enrollment=lu_enrolmment, session_exam=self.session_exam)
Ejemplo n.º 4
0
    def setUp(self):
        today = datetime.datetime.today()
        twenty_days = datetime.timedelta(days=20)

        #Take same academic year as the one in the associated xls file
        an_academic_year = AcademicYearFactory(year=2017)

        a_learning_unit_year = LearningUnitYearFakerFactory(
            academic_year=an_academic_year, acronym=LEARNING_UNIT_ACRONYM)

        tutor = TutorFactory()

        an_academic_calendar = AcademicCalendarFactory(
            academic_year=an_academic_year,
            start_date=today - twenty_days,
            end_date=today + twenty_days,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        SessionExamCalendarFactory(number_session=number_session.ONE,
                                   academic_calendar=an_academic_calendar)
        AttributionFactory(learning_unit_year=a_learning_unit_year,
                           tutor=tutor)
        a_session_exam = SessionExamFactory(
            number_session=number_session.ONE,
            learning_unit_year=a_learning_unit_year)

        self.person_student_1 = PersonFactory(email=EMAIL_1)
        person_student_2 = PersonFactory(email=EMAIL_2)

        student_1 = StudentFactory(registration_id=REGISTRATION_ID_1,
                                   person=self.person_student_1)
        student_2 = StudentFactory(registration_id=REGISTRATION_ID_2,
                                   person=person_student_2)

        an_offer_year = OfferYearFactory(academic_year=an_academic_year,
                                         acronym=OFFER_ACRONYM)
        offer_enrollment_1 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_1)
        offer_enrollment_2 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_2)

        learning_unit_enrollment_1 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_1)
        learning_unit_enrollment_2 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_2)

        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_1)
        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_2)

        user = tutor.person.user
        self.client = Client()
        self.client.force_login(user=user)
        self.url = reverse(
            'upload_encoding',
            kwargs={'learning_unit_year_id': a_learning_unit_year.id})
Ejemplo n.º 5
0
 def setUpTestData(cls):
     cls.academic_year = AcademicYearFactory(current=True)
     cls.session_exam_calendar = SessionExamCalendarFactory(
         academic_calendar__academic_year=cls.academic_year,
         number_session=number_session.ONE)
     cls.session_exam = SessionExamFactory(
         number_session=number_session.ONE,
         learning_unit_year__academic_year=cls.academic_year)
 def setUpTestData(cls):
     cls.academic_year = create_current_academic_year()
     cls.academic_calendar = AcademicCalendarFactory(title="Submission of score encoding - 1",
                                                     academic_year__current=True,
                                                     reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
     cls.session_exam_calendar = SessionExamCalendarFactory(academic_calendar=cls.academic_calendar,
                                                            number_session=number_session.ONE)
     learning_unit_yr = LearningUnitYearFactory(learning_container_year__academic_year__current=True)
     cls.session_exam = SessionExamFactory(number_session=number_session.ONE, learning_unit_year=learning_unit_yr)
Ejemplo n.º 7
0
 def setUp(self):
     self.academic_calendar = AcademicCalendarExamSubmissionFactory(
         title="Submission of score encoding - 1",
         academic_year__current=True)
     self.session_exam_calendar = SessionExamCalendarFactory(
         academic_calendar=self.academic_calendar,
         number_session=number_session.ONE)
     self.session_exam = SessionExamFactory(
         number_session=number_session.ONE,
         learning_unit_year__academic_year__current=True)
Ejemplo n.º 8
0
 def setUpTestData(cls):
     cls.academic_calendar = AcademicCalendarExamSubmissionFactory(
         title="Submission of score encoding - 1",
         academic_year__current=True)
     cls.session_exam_calendar = SessionExamCalendarFactory(
         academic_calendar=cls.academic_calendar,
         number_session=number_session.ONE)
     cls.session_exam = SessionExamFactory(
         number_session=number_session.ONE,
         learning_unit_year__academic_year__current=True)
Ejemplo n.º 9
0
    def setUp(self):
        self.academic_year = AcademicYearFactory()
        self.offer_year = OfferYearFactory(academic_year=self.academic_year)
        self.learning_unit_year = LearningUnitYearFactory(academic_year=self.academic_year, acronym="LBIR1100",
                                                          decimal_scores=False)
        # Create tutor and score responsible
        _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Alibra', first_name='Paul'))
        _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Durant', first_name='Thomas'),
                            is_score_responsible=True)
        _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Lobradi', first_name='Pierre'))

        self.session_exam = SessionExamFactory(number_session=1, learning_unit_year=self.learning_unit_year)

        # Create three students and enrol them to learning unit year
        self.student_1 = StudentFactory(person=PersonFactory(last_name='Dupont', first_name='Jacques'))
        self.student_2 = StudentFactory(person=PersonFactory(last_name='Dupont', first_name='Axel'))
        self.student_3 = StudentFactory(person=PersonFactory(last_name='Armand', first_name='Zoe'))
        self.deadline = datetime.datetime(2017, 3, 1)
        self._build_enrollment([self.student_1, self.student_2, self.student_3], enrollment_states.ENROLLED)

        self.student_not_enrolled = StudentFactory(person=PersonFactory(last_name='Armand', first_name='Zoe'))
        self._build_enrollment([self.student_not_enrolled], enrollment_states.NOT_ENROLLED)
Ejemplo n.º 10
0
 def setUp(self):
     self.academic_year = AcademicYearFactory(current=True)
     self.session_exam_calendar = SessionExamCalendarFactory(academic_calendar__academic_year=self.academic_year,
                                                             number_session=number_session.ONE)
     self.session_exam = SessionExamFactory(number_session=number_session.ONE,
                                            learning_unit_year__academic_year=self.academic_year)