Exemplo n.º 1
0
def get_scores_encoding_list(user, **kwargs):
    current_academic_year = academic_year.current_academic_year()
    current_number_session = session_exam_calendar.find_session_exam_number()
    is_program_manager = program_manager.is_program_manager(user)
    learning_unit_year_id = kwargs.get('learning_unit_year_id')
    offer_year_id = kwargs.get('offer_year_id')
    tutor_id = kwargs.get('tutor_id')
    enrollments_ids = kwargs.get('enrollments_ids')
    justification = kwargs.get('justification')
    only_enrolled = _need_to_filter_students_enrolled_to_exam(
        justification, kwargs)

    if is_program_manager:
        professor = tutor.find_by_id(tutor_id) if tutor_id else None
        offers_year = [offer_year.find_by_id(offer_year_id)] if offer_year_id else \
                       list(offer_year.find_by_user(user, academic_yr=current_academic_year))

        enrollments = exam_enrollment.find_for_score_encodings(
            academic_year=current_academic_year,
            session_exam_number=current_number_session,
            learning_unit_year_id=learning_unit_year_id,
            tutor=professor,
            offers_year=offers_year,
            registration_id=kwargs.get('registration_id'),
            student_last_name=kwargs.get('student_last_name'),
            student_first_name=kwargs.get('student_first_name'),
            justification=justification,
            only_enrolled=only_enrolled,
        )
    else:
        professor = tutor.find_by_user(user)
        enrollments = exam_enrollment.find_for_score_encodings(
            academic_year=current_academic_year,
            session_exam_number=current_number_session,
            learning_unit_year_id=learning_unit_year_id,
            tutor=professor,
            only_enrolled=only_enrolled)

    # Want a subset of exam enrollment list
    if enrollments_ids:
        enrollments = enrollments.filter(id__in=enrollments_ids)

    # Append deadline/deadline_tutor for each exam enrollments
    enrollments = _append_session_exam_deadline(list(enrollments))
    enrollments = sort_encodings(enrollments)

    return ScoresEncodingList(
        **{
            'academic_year':
            current_academic_year,
            'number_session':
            current_number_session,
            'learning_unit_year':
            learning_unit_year.get_by_id(learning_unit_year_id
                                         ) if learning_unit_year_id else None,
            'enrollments':
            enrollments
        })
Exemplo n.º 2
0
def get_scores_encoding_list(user, **kwargs):
    current_academic_year = academic_year.current_academic_year()
    current_number_session = session_exam_calendar.find_session_exam_number()
    is_program_manager = program_manager.is_program_manager(user)
    learning_unit_year_id = kwargs.get('learning_unit_year_id')
    offer_year_id = kwargs.get('offer_year_id')
    tutor_id = kwargs.get('tutor_id')
    enrollments_ids = kwargs.get('enrollments_ids')
    justification = kwargs.get('justification')
    only_enrolled = _need_to_filter_students_enrolled_to_exam(justification, kwargs)

    if is_program_manager:
        professor = tutor.find_by_id(tutor_id) if tutor_id else None
        offers_year = [offer_year.find_by_id(offer_year_id)] if offer_year_id else \
                       list(offer_year.find_by_user(user, academic_yr=current_academic_year))

        enrollments = exam_enrollment.find_for_score_encodings(
            academic_year=current_academic_year,
            session_exam_number=current_number_session,
            learning_unit_year_id=learning_unit_year_id,
            tutor=professor,
            offers_year=offers_year,
            registration_id=kwargs.get('registration_id'),
            student_last_name=kwargs.get('student_last_name'),
            student_first_name=kwargs.get('student_first_name'),
            justification=justification,
            only_enrolled=only_enrolled,
        )
    else:
        professor = tutor.find_by_user(user)
        enrollments = exam_enrollment.find_for_score_encodings(
            academic_year=current_academic_year,
            session_exam_number=current_number_session,
            learning_unit_year_id=learning_unit_year_id,
            tutor=professor,
            only_enrolled=only_enrolled
        )

    # Want a subset of exam enrollment list
    if enrollments_ids:
        enrollments = enrollments.filter(id__in=enrollments_ids)

    # Append deadline/deadline_tutor for each exam enrollments
    enrollments = _append_session_exam_deadline(list(enrollments))
    enrollments = sort_encodings(enrollments)

    return ScoresEncodingList(**{
        'academic_year': current_academic_year,
        'number_session': current_number_session,
        'learning_unit_year': learning_unit_year.get_by_id(learning_unit_year_id) if learning_unit_year_id else None,
        'enrollments': enrollments
    })
Exemplo n.º 3
0
 def test_find_by_id_wrong_id(self):
     self.assertIsNone(tutor.find_by_id(-1))
Exemplo n.º 4
0
 def test_find_by_id(self):
     self.assertEqual(self.tutor, tutor.find_by_id(self.tutor.id))