Exemple #1
0
def schedule():
    """List schedule."""
    schedules = get_declaration_schedule()
    if len(schedules) == 0:
        print("No schedule available for this run")
    final_list = []
    header = ("start", "end")
    for schedule in schedules:
        schedule_list = []
        schedule_list.append(schedule['start'])
        schedule_list.append(schedule['end'])
        final_list.append(schedule_list)
    print_table(final_list, header)
Exemple #2
0
def list():
    """List projects."""
    wrapper = config.setup_api()
    projects = wrapper.get_projects()
    final_list = []
    header = ('Name', 'UV', 'starts at', 'ends on', 'Time', 'Validated')
    for project in projects:
        project_list = []
        project_list.append(project['long_name'])
        project_list.append(project['uv_name'])
        project_list.append(project['date_start'])
        project_list.append(project['date_end'])
        project_list.append(f"{int(project['duration']) / 3600} hours")
        project_list.append(is_validated(project['validation']))
        final_list.append(project_list)
    print_table(final_list, header)
Exemple #3
0
def promo(student: str = None):
    """Get student's promotions."""
    wrapper = config.setup_api()
    promo_data = wrapper.get_user_promotion(student)
    header = ('ID', 'promotion', 'name', 'start', 'end', 'spe')
    final_list = []
    for i, _ in enumerate(promo_data):
        promo_list = []
        promo_list.append(promo_data[i]['id'])
        promo_list.append(promo_data[i]['promo'])
        promo_list.append(promo_data[i]['wall_name'])
        promo_list.append(promo_data[i]['learning_start'])
        promo_list.append(promo_data[i]['learning_end'])
        promo_list.append(promo_data[i]['spe'])
        final_list.append(promo_list)

    print_table(final_list, header)
Exemple #4
0
def list(student: str = None, time: str = None):
    """List events."""
    wrapper = config.setup_api()
    events_data = get_events(wrapper, student, time)
    header = ('name', 'UV name', 'activity', 'location', 'start', 'ends')
    final_list = []
    for event in events_data:
        event_list = []
        event_list.append(event['name'])
        event_list.append(event['uv_name'])
        event_list.append(event['activity_name'])
        event_list.append(event['location'])
        event_list.append(event['start'])
        event_list.append(event['end'])
        final_list.append(event_list)

    print_table(final_list, header)
Exemple #5
0
def grades(student: str = None, promo: int = None, activity: str = None):
    """Get student's grades."""
    wrapper = config.setup_api()
    if promo is None:
        promo = wrapper.get_user_promotion(student)[0]['id']
    grades_data = wrapper.get_grades(login=student, promotion_id=promo)
    header = ('activity', 'type', "UV name", 'mark', 'average', 'max', 'min')
    final_list = []

    for mark in grades_data:
        mark_list = []
        mark_list.append(mark['activity_name'])
        mark_list.append(mark['activity_type'])
        mark_list.append(mark['uv_name'])
        mark_list.append(mark['student_mark'])
        mark_list.append(roundify(mark['average']))
        mark_list.append(mark['maximal'])
        mark_list.append(mark['minimal'])
        final_list.append(mark_list)

    print_table(final_list, header)
Exemple #6
0
def print_available_modules():
    """List available modules to declare for."""
    wrapper = config.setup_api()
    start_run = get_begining_of_run()
    if start_run is None:
        start_run = date.today()
    projects = wrapper.get_projects(date=start_run)
    final_list = []
    header = ("ID", "name", "UV", "start", "end", "duration")
    for project in projects:
        project_list = []
        if project['duration'] != 0:
            project_list.append(project['id'])
            project_list.append(project['long_name'])
            project_list.append(project['uv_name'])
            project_list.append(project['date_start'])
            project_list.append(project['date_end'])
            project_list.append(f"{int(project['duration']) / 3600} hours")
            final_list.append(project_list)
        else:
            pass
    print_table(final_list, header)
Exemple #7
0
def list_declarations(number: int):
    """List declarations."""
    wrapper = config.setup_api()
    declarations = wrapper.get_declarations()
    cnt = 0
    final_list = []
    header = ('UV', 'start', 'end', 'description', "declared at")
    for declaration in declarations['hits']:
        declare_list = []
        start = declaration['start'].replace('T', ' ').split('+')[0]
        end = declaration['end'].replace('T', ' ').split('+')[0]
        declare_list.append(declaration['uv_name'])
        declare_list.append(start)
        declare_list.append(end)
        declare_list.append(declaration['metas']['description'])
        declare_list.append(declaration['metas']['declared_at'])
        final_list.append(declare_list)
        cnt += 1
        if number is not None and cnt == number:
            break

    print_table(final_list, header, fmt='fancy_grid', prettify=False)
Exemple #8
0
def get_student_rank(student: str = None,
                     promo: str = None,
                     activity: str = None):
    """Get student rank."""
    wrapper = config.setup_api()

    if promo is None and student is None:
        student_info = wrapper.get_user_info()
        login = student_info['login']
        promo = wrapper.get_user_promotion(login)[0]['id']
    elif student is not None and promo is None:
        promo = wrapper.get_user_promotion(student)[0]['id']
    elif student is None and promo is not None:
        student_info = wrapper.get_user_info()
        login = student_info['login']
    else:
        return

    promo_list = get_students_by_promo(wrapper, int(promo))
    if promo_list is None:
        return

    student_marks = {}

    for student in promo_list:
        print(f"grabing grades for {student}", end='\r')
        student_grades = wrapper.get_grades(login=student, promotion_id=promo)

        student_marks[student] = 0
        cnt = 0

        for student_grade in student_grades:
            if activity is not None:
                if activity == student_grade['activity_name']:
                    student_marks[student] = student_grade['student_mark']
                    cnt = 1
                    break
            else:
                # Some users have 'Null' instead of a real mark
                if student_grade['student_mark'] is not None:
                    student_marks[student] += int(
                        student_grade['student_mark'])
                    cnt += 1
                else:
                    pass
    sorted_students = sorted(student_marks.items(),
                             key=operator.itemgetter(1),
                             reverse=True)

    header = ('rank', 'student', 'average')
    final_list = []
    for i in range(0, len(sorted_students)):
        student_list = []
        try:
            average = sorted_students[i][1] / cnt
        except ZeroDivisionError:
            average = 0
        student_list.append(i + 1)
        student_list.append(sorted_students[i][0])
        student_list.append(round(average, 2))
        final_list.append(student_list)
    print_table(final_list, header)