Beispiel #1
0
def compute_grade(student_login):
    print(f'{student_login}:')
    st = all_students[student_login]

    env = j2.Environment(loader=j2.FileSystemLoader('templates/'))

    feedback_template = env.get_template('report.html')

    mandatoryD = [sk for sk in all_skills.values() if sk.mandatory == 'D']
    doneD = [(student_has_skill(st, sk), sk) for sk in mandatoryD]

    mandatoryC = [sk for sk in all_skills.values() if sk.mandatory == 'C']
    doneC = [(student_has_skill(st, sk), sk) for sk in mandatoryC]

    mandatoryB = [sk for sk in all_skills.values() if sk.mandatory == 'B']
    doneB = [(student_has_skill(st, sk), sk) for sk in mandatoryB]

    done_all = [
        ach for ach in st.all_achievements if ach.skill.mandatory == '-'
    ]
    done_all = sorted(done_all, key=lambda t: t.date)

    xp = st.compute_grade()
    conceito = 'I'

    if all([s[0] >= 0 for s in doneD]):
        conceito = 'D'

        if xp >= 60 and st.achievements.get(20, False) and\
           (st.achievements.get(30, False) or st.achievements.get(35, False)):
            conceito = 'C'

        if xp >= 100 and st.achievements.get(23, False):
            conceito = 'B'

    html = feedback_template.render(
        doneD=doneD,
        doneC=doneC,
        doneB=doneB,
        doneAll=done_all,
        xp_total=xp,
        st=st,
        conceito=conceito,
    )
    with open(f'students/{student_login}-report.html', 'w') as f:
        f.write(html)

    print('------------')
    print('Conceito final:', conceito)
    print(xp)
    print('Nota de grupo:', project_points[student_login])
Beispiel #2
0
def render_skill_type(sk_type):
    table = [(sk.id, sk.material_icon, sk.name, sk.descr, sk.xp)
             for sk in all_skills.values() if sk.type == sk_type.title()]
    with open(f'docs/_snippets/skills-{sk_type}.md', 'w') as f:
        f.write(
            tabulate.tabulate(table,
                              headers=('id', '', 'Nome', 'Descrição', 'XP'),
                              tablefmt='pipe'))
Beispiel #3
0
def load_skill_and_check_done(skill_name, st):
    skill_list = [copy.deepcopy(sk) for sk in all_skills.values() if sk.type == skill_name]
    for sk in skill_list:
        sk.done = False
        if sk.id in [3, 11, 12]:
            sk.done = True # nao eh obrigatoria
        for ach in st.achievements:
            if sk.id == ach.skill.id:
                sk.done = True
    return skill_list
Beispiel #4
0
def render_skill_type(template, sk_type):
    skills_type = [
        sk for sk in all_skills.values() if sk.type == sk_type.title()
    ]
    with open(f'docs/_snippets/skills-{sk_type}.md', 'w') as f:
        f.write(template.render(skills=skills_type))