def test_enrollment_not_enrolled_deadline_unreached(self):
     enrollment = ExamEnrollmentFactory(
         enrollment_state=enrollment_states.ENROLLED)
     enrollment.deadline_reached = False
     context = {'is_program_manager': True, 'enrollment': enrollment}
     self.assertEqual(get_score_justification_disabled_status(context),
                      ENABLED)
Exemplo n.º 2
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})
Exemplo n.º 3
0
 def setUpTestData(cls):
     cls.academic_year = create_current_academic_year()
     cls.offer_year = test_offer_year.create_offer_year(
         'SINF1BA', 'Bachelor in informatica', cls.academic_year)
     cls.learn_unit_year = LearningUnitYearFactory(
         acronym='LSINF1010',
         specific_title='Introduction to algorithmic',
         academic_year=cls.academic_year)
     cls.session_exam = test_session_exam.create_session_exam(
         1, cls.learn_unit_year, cls.offer_year)
     cls.student = test_student.create_student('Pierre', 'Lacazette',
                                               '12345678')
     cls.offer_enrollment = test_offer_enrollment.create_offer_enrollment(
         cls.student, cls.offer_year)
     cls.learn_unit_enrol = test_learning_unit_enrollment.create_learning_unit_enrollment(
         cls.learn_unit_year, cls.offer_enrollment)
     cls.exam_enrollment = ExamEnrollmentFactory(
         session_exam=cls.session_exam,
         learning_unit_enrollment=cls.learn_unit_enrol,
         score_final=12.6,
         enrollment_state=enrollment_states.ENROLLED)
     student_unsuscribed = test_student.create_student(
         'Marco', 'Dubois', '12345679')
     offer_enrollment_2 = test_offer_enrollment.create_offer_enrollment(
         student_unsuscribed, cls.offer_year)
     learn_unit_enrol_2 = test_learning_unit_enrollment.create_learning_unit_enrollment(
         cls.learn_unit_year, offer_enrollment_2)
     cls.exam_enrollment_2 = ExamEnrollmentFactory(
         session_exam=cls.session_exam,
         learning_unit_enrollment=learn_unit_enrol_2,
         enrollment_state=enrollment_states.NOT_ENROLLED)
Exemplo n.º 4
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'))
        offer_enrollment = OfferEnrollmentFactory(offer_year=self.offer_year,
                                                  student=self.student_1)
        l_unit_enrollment = LearningUnitEnrollmentFactory(
            offer_enrollment=offer_enrollment,
            learning_unit_year=self.learning_unit_year)
        ExamEnrollmentFactory(learning_unit_enrollment=l_unit_enrollment,
                              session_exam=self.session_exam)

        self.student_2 = StudentFactory(
            person=PersonFactory(last_name='Dupont', first_name='Axel'))
        offer_enrollment = OfferEnrollmentFactory(offer_year=self.offer_year,
                                                  student=self.student_2)
        l_unit_enrollment = LearningUnitEnrollmentFactory(
            offer_enrollment=offer_enrollment,
            learning_unit_year=self.learning_unit_year)
        ExamEnrollmentFactory(learning_unit_enrollment=l_unit_enrollment,
                              session_exam=self.session_exam)

        self.student_3 = StudentFactory(
            person=PersonFactory(last_name='Armand', first_name='Zoe'))
        offer_enrollment = OfferEnrollmentFactory(offer_year=self.offer_year,
                                                  student=self.student_3)
        l_unit_enrollment = LearningUnitEnrollmentFactory(
            offer_enrollment=offer_enrollment,
            learning_unit_year=self.learning_unit_year)
        ExamEnrollmentFactory(learning_unit_enrollment=l_unit_enrollment,
                              session_exam=self.session_exam)
Exemplo n.º 5
0
 def test_get_line_color_enrolled(self):
     exam_enrollment = ExamEnrollmentFactory(
         session_exam=self.session_exam,
         enrollment_state=enrollment_states.ENROLLED,
         date_enrollment=self.academic_calendar.start_date -
         datetime.timedelta(days=1))
     self.assertIsNone(get_line_color(exam_enrollment))
Exemplo n.º 6
0
 def test_get_line_color_enrolled_late(self):
     exam_enrollment = ExamEnrollmentFactory(
         session_exam=self.session_exam,
         enrollment_state=enrollment_states.ENROLLED,
         date_enrollment=self.academic_calendar.start_date +
         datetime.timedelta(days=1))
     self.assertEqual(get_line_color(exam_enrollment), ENROLLED_LATE_COLOR)
    def test_coloring_normal_enrollment(self):
        exam_enrollment = ExamEnrollmentFactory(session_exam=self.session_exam,
                                                enrollment_state=enrollment_states.ENROLLED,
                                                date_enrollment=self.academic_calendar.start_date)
        _coloring_enrollment_state(self.worksheet, ROW_NUMBER, exam_enrollment)

        self.assertEqual(
            self.worksheet.cell(row=ROW_NUMBER, column=FIRST_COL_LEGEND_ENROLLMENT_STATUS).style.fill.fgColor,
            Color(rgb=WHITE_RGB))
 def test_enrollment_not_enrolled(self):
     enrollment_not_enrolled = ExamEnrollmentFactory(
         enrollment_state=enrollment_states.NOT_ENROLLED)
     context = {
         'is_program_manager': True,
         'enrollment': enrollment_not_enrolled
     }
     self.assertEqual(get_score_justification_disabled_status(context),
                      DISABLED)
    def test_coloring_not_enrolled(self):
        exam_enrollment = ExamEnrollmentFactory(session_exam=self.session_exam,
                                                enrollment_state=enrollment_states.NOT_ENROLLED)
        _coloring_enrollment_state(self.worksheet,
                                   ROW_NUMBER,
                                   exam_enrollment)

        self.assertEqual(
            self.worksheet.cell(row=ROW_NUMBER, column=FIRST_COL_LEGEND_ENROLLMENT_STATUS).style.fill.fgColor,
            Color(rgb=NOT_ENROLLED_COLOR.lstrip('#')))
Exemplo n.º 10
0
    def test_coloring_enrolled_late(self):
        exam_enrollment = ExamEnrollmentFactory(session_exam=self.session_exam,
                                                enrollment_state=enrollment_states.ENROLLED,
                                                date_enrollment=self.academic_calendar.start_date + datetime.timedelta(
                                                    days=1))
        _coloring_enrollment_state(self.worksheet,
                                   ROW_NUMBER,
                                   exam_enrollment)

        self.assertEqual(
            self.worksheet.cell(row=ROW_NUMBER, column=FIRST_COL_LEGEND_ENROLLMENT_STATUS).style.fill.fgColor,
            Color(rgb=ENROLLED_LATE_COLOR.lstrip('#')))
Exemplo n.º 11
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()
Exemplo n.º 12
0
    def _build_enrollment(self, students, enrollment_state):
        for student in students:
            offer_enrollment = OfferEnrollmentFactory(offer_year=self.offer_year, student=student)

            SessionExamDeadlineFactory(offer_enrollment=offer_enrollment,
                                       number_session=self.session_exam.number_session,
                                       deadline=self.deadline,
                                       deadline_tutor=0)
            lu_enrollment = LearningUnitEnrollmentFactory(
                offer_enrollment=offer_enrollment,
                learning_unit_year=self.learning_unit_year
            )
            ExamEnrollmentFactory(learning_unit_enrollment=lu_enrollment,
                                  session_exam=self.session_exam,
                                  enrollment_state=enrollment_state)
Exemplo n.º 13
0
 def test_get_line_color_not_enrolled(self):
     exam_enrollment = ExamEnrollmentFactory(
         session_exam=self.session_exam,
         enrollment_state=enrollment_states.NOT_ENROLLED)
     self.assertEqual(get_line_color(exam_enrollment), NOT_ENROLLED_COLOR)
Exemplo n.º 14
0
    def test_add_header_and_legend_to_file(self):
        exam_enrollment = ExamEnrollmentFactory(
            session_exam=self.session_exam,
            enrollment_state=enrollment_states.ENROLLED,
            date_enrollment=self.academic_calendar.start_date)
        ue = exam_enrollment.learning_unit_enrollment.learning_unit_year

        _add_header_and_legend_to_file([exam_enrollment], self.worksheet)
        self.assertEqual(
            self.worksheet.cell(row=1, column=1).value,
            str(ue) + " " +
            ue.complete_title if ue.complete_title else str(ue))
        self.assertEqual(
            self.worksheet.cell(row=2, column=1).value,
            str('Session: %s' % exam_enrollment.session_exam.number_session))
        self.assertEqual(
            self.worksheet.cell(row=4, column=1).value,
            str('%s' % (_(
                "The data presented on this document correspond to the state of the system dated %(printing_date)s "
                "and are likely to evolve") % {
                    'printing_date':
                    timezone.now().strftime(str(_('date_format')))
                })))
        self.assertEqual(
            self.worksheet.cell(row=5, column=1).value,
            str(_("Students deliberated are not shown")))
        self.assertEqual(
            self.worksheet.cell(row=7, column=1).value,
            str(_("Justification")))
        self.assertEqual(
            self.worksheet.cell(row=7, column=2).value,
            str(
                _("Accepted value: %(justification_label_authorized)s ") % {
                    "justification_label_authorized":
                    mdl.exam_enrollment.justification_label_authorized()
                }),
        )
        self.assertEqual(
            self.worksheet.cell(
                row=FIRST_ROW_LEGEND_ENROLLMENT_STATUS,
                column=FIRST_COL_LEGEND_ENROLLMENT_STATUS).value,
            str(_('Enrolled lately')))
        self.assertEqual(
            self.worksheet.cell(row=8, column=2).value,
            str(
                _("Other values reserved to administration: %(justification_other_values)s "
                  ) %
                {'justification_other_values': justification_other_values()}),
        )
        self.assertEqual(
            self.worksheet.cell(
                row=FIRST_ROW_LEGEND_ENROLLMENT_STATUS + 1,
                column=FIRST_COL_LEGEND_ENROLLMENT_STATUS).value,
            str(_('Unsubscribed lately')),
        )
        self.assertEqual(
            self.worksheet.cell(row=9, column=1).value,
            str(_('Numbered scores')),
        )
        self.assertEqual(
            self.worksheet.cell(row=9, column=2).value,
            str(
                _('Score legend: %(score_legend)s (0=Score of presence)') %
                {"score_legend": "0 - 20"}),
        )
        self.assertEqual(
            self.worksheet.cell(row=10, column=2).value,
            str(_('Decimals authorized for this learning unit'))
            if ue.decimal_scores else str(
                _('Unauthorized decimal for this learning unit')))
Exemplo n.º 15
0
    def test_enrolled_exam_exists(self):
        exam_enrollment = ExamEnrollmentFactory(session_exam=self.session_exam,
                                                enrollment_state=enrollment_states.ENROLLED)

        self.assertTrue(enrolled_exists([exam_enrollment]))
Exemplo n.º 16
0
class ExamEnrollmentTest(TestCase):
    def setUp(self):
        self.academic_year = create_current_academic_year()
        self.offer_year = test_offer_year.create_offer_year('SINF1BA', 'Bachelor in informatica', self.academic_year)
        self.learn_unit_year = LearningUnitYearFactory(acronym='LSINF1010',
                                                       specific_title='Introduction to algorithmic',
                                                       academic_year=self.academic_year)
        self.session_exam = test_session_exam.create_session_exam(1, self.learn_unit_year, self.offer_year)
        self.student = test_student.create_student('Pierre', 'Lacazette', '12345678')
        self.offer_enrollment = test_offer_enrollment.create_offer_enrollment(self.student, self.offer_year)
        self.learn_unit_enrol = test_learning_unit_enrollment.create_learning_unit_enrollment(self.learn_unit_year,
                                                                                              self.offer_enrollment)
        self.exam_enrollment = ExamEnrollmentFactory(session_exam=self.session_exam,
                                                     learning_unit_enrollment=self.learn_unit_enrol,
                                                     score_final=12.6,
                                                     enrollment_state=enrollment_states.ENROLLED)
        student_unsuscribed = test_student.create_student('Marco', 'Dubois', '12345679')
        offer_enrollment_2 = test_offer_enrollment.create_offer_enrollment(student_unsuscribed, self.offer_year)
        learn_unit_enrol_2 = test_learning_unit_enrollment.create_learning_unit_enrollment(self.learn_unit_year,
                                                                                           offer_enrollment_2)
        self.exam_enrollment_2 = ExamEnrollmentFactory(session_exam=self.session_exam,
                                                       learning_unit_enrollment=learn_unit_enrol_2,
                                                       enrollment_state=enrollment_states.NOT_ENROLLED)

    def test_save_with_invalid_justification_draft(self):
        ex_enrol = self.exam_enrollment
        ex_enrol.justification_draft = 'invalid_justification'
        self.assertRaises(exceptions.JustificationValueException, ex_enrol.save)

    def test_save_with_invalid_justification_final(self):
        ex_enrol = self.exam_enrollment
        ex_enrol.justification_final = 'invalid_justification'
        self.assertRaises(exceptions.JustificationValueException, ex_enrol.save)

    def test_save_with_invalid_justification_reencoded(self):
        ex_enrol = self.exam_enrollment
        ex_enrol.justification_reencoded = 'invalid_justification'
        self.assertRaises(exceptions.JustificationValueException, ex_enrol.save)

    def test_calculate_exam_enrollment_without_progress(self):
        self.assertEqual(exam_enrollment.calculate_exam_enrollment_progress(None), 0)

    def test_calculate_exam_enrollment_with_progress(self):
        ex_enrol = [self.exam_enrollment]
        progress = exam_enrollment.calculate_exam_enrollment_progress(ex_enrol)
        self.assertTrue(0 <= progress <= 100)

    def test_is_deadline_reached(self):
        self.exam_enrollment.save()
        SessionExamDeadlineFactory(deadline=datetime.date.today() - datetime.timedelta(days=1),
                                   number_session=self.session_exam.number_session,
                                   offer_enrollment=self.offer_enrollment)
        self.assertTrue(exam_enrollment.is_deadline_reached(self.exam_enrollment))

    def test_is_deadline_not_reached(self):
        self.exam_enrollment.save()
        SessionExamDeadlineFactory(deadline=datetime.date.today() + datetime.timedelta(days=2),
                                   number_session=self.session_exam.number_session,
                                   offer_enrollment=self.offer_enrollment)
        self.assertFalse(exam_enrollment.is_deadline_reached(self.exam_enrollment))

    def test_is_deadline_tutor_reached(self):
        self.exam_enrollment.save()
        SessionExamDeadlineFactory(deadline=datetime.date.today() + datetime.timedelta(days=3),
                                   deadline_tutor=5,
                                   number_session=self.session_exam.number_session,
                                   offer_enrollment=self.offer_enrollment)
        self.assertTrue(exam_enrollment.is_deadline_tutor_reached(self.exam_enrollment))

    def test_is_deadline_tutor_not_reached(self):
        self.exam_enrollment.save()
        SessionExamDeadlineFactory(deadline=datetime.date.today() + datetime.timedelta(days=3),
                                   deadline_tutor=2,
                                   number_session=self.session_exam.number_session,
                                   offer_enrollment=self.offer_enrollment)
        self.assertFalse(exam_enrollment.is_deadline_tutor_reached(self.exam_enrollment))

    def test_is_deadline_tutor_not_set_not_reached(self):
        self.exam_enrollment.save()
        SessionExamDeadlineFactory(deadline=datetime.date.today() + datetime.timedelta(days=3),
                                   deadline_tutor=None,
                                   number_session=self.session_exam.number_session,
                                   offer_enrollment=self.offer_enrollment)
        self.assertFalse(exam_enrollment.is_deadline_tutor_reached(self.exam_enrollment))

    def test_is_deadline_tutor_not_set_reached(self):
        self.exam_enrollment.save()
        SessionExamDeadlineFactory(deadline=datetime.date.today() - datetime.timedelta(days=1),
                                   deadline_tutor=None,
                                   number_session=self.session_exam.number_session,
                                   offer_enrollment=self.offer_enrollment)
        self.assertTrue(exam_enrollment.is_deadline_tutor_reached(self.exam_enrollment))

    def test_find_by_student(self):
        self.assertCountEqual(exam_enrollment.find_by_student(None), [])
        self.exam_enrollment.save()
        self.assertCountEqual(exam_enrollment.find_by_student(self.student), [self.exam_enrollment])

    def test_find_for_score_encodings_for_all_enrollement_state(self):
        self.assertCountEqual(exam_enrollment.find_for_score_encodings(
            session_exam_number=1,
        ), [self.exam_enrollment, self.exam_enrollment_2])

    def test_find_for_score_encodings_enrolled_state_only(self):
        self.assertCountEqual(exam_enrollment.find_for_score_encodings(
            session_exam_number=1,
            only_enrolled=True
        ), [self.exam_enrollment])
 def test_enrollment_not_enrolled(self):
     enrollment_not_enrolled = ExamEnrollmentFactory(
         enrollment_state=enrollment_states.NOT_ENROLLED)
     self.context.update({'enrollment': enrollment_not_enrolled})
     self.assertEqual(get_score_justification_disabled_status(self.context),
                      DISABLED)
 def setUp(self):
     self.context = {'is_program_manager': False}
     self.enrollment_enrolled = ExamEnrollmentFactory(
         enrollment_state=enrollment_states.ENROLLED)