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 })
def check_exam_enrollment_form(request, offer_year_id): a_student = mdl_base.student.find_by_user(request.user) off_year = offer_year.find_by_id(offer_year_id) if 'exam_enrollment' in settings.INSTALLED_APPS: if _exam_enrollment_up_to_date_in_db_with_document(a_student, off_year): return HttpResponse(status=200) else: return HttpResponse(status=404) return HttpResponse(status=405)
def exam_enrollment_form(request, offer_year_id): try: stud = student.find_by_user(request.user) except MultipleObjectsReturned: return dash_main_view.show_multiple_registration_id_error(request) off_year = offer_year.find_by_id(offer_year_id) if request.method == 'POST': return _process_exam_enrollment_form_submission(off_year, request, stud) else: return _get_exam_enrollment_form(off_year, request, stud)
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 })