diff --git a/notes_tools/generate_bilan/templates/tpl_bilan_term.tex b/notes_tools/generate_bilan/templates/tpl_bilan_term.tex new file mode 100644 index 0000000..d43ec6d --- /dev/null +++ b/notes_tools/generate_bilan/templates/tpl_bilan_term.tex @@ -0,0 +1,37 @@ +\documentclass{/media/documents/Cours/Prof/Enseignements/2016-2017/tools/style/classBilan} +\usepackage{/media/documents/Cours/Prof/Enseignements/2016-2017/theme} + +\usepackage{booktabs} + +% Title Page +\titre{Trimestre \Var{bilan_info["Trimestre"]}} +% \seconde \premiereS \PSTMG \TSTMG +\classe{\Var{bilan_info["Classe"]}} +\date{} + + +\begin{document} + +%- for e in students +\maketitle + +\Var{e["Nom"]} + +\Var{e["eval"].groupby("Nom").sum()[["Mark","Bareme"]].to_latex()} + +\Var{e["quest"] | radar_on("Competence") | includegraphics(document_path=directory, scale=0.7)} +\Var{e["quest"] | radar_on("Domaine") | includegraphics(document_path=directory, scale=0.7)} + +\vfill + +\normalsize +\pagebreak +%- endfor + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "master" +%%% End: + diff --git a/notes_tools/generate_bilan/term_bilan.py b/notes_tools/generate_bilan/term_bilan.py new file mode 100755 index 0000000..f47a591 --- /dev/null +++ b/notes_tools/generate_bilan/term_bilan.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# encoding: utf-8 + +from notes_tools.tools import extract_flat_marks, get_class_ws, digest_flat_df, term_tools, eval_tools +from .texenv import feed_template +import pandas as pd +import numpy as np +import xlrd +from path import Path + +import logging +logger = logging.getLogger("generate_bilan") + +def term_info(classe, ds_df): + """TODO: Docstring for build_ds_info. + + :param ds_df: TODO + :returns: TODO + + + # TODO: vérifier que toutes ces informations soient identiques sur les lignes |dim. nov. 6 16:06:58 EAT 2016 + """ + eval_info = {} + eval_info["Classe"] = classe + eval_info["Trimestre"] = ds_df["Trimestre"].unique()[0] + return eval_info + +def build_target_name(classe, term, path = Path("./")): + """ Build the path where the .tex will be sored + + >>> build_target_name("312", "DS1") + Path('./312/bilan_DS1.tex') + >>> build_target_name("312", "DS1", Path("plop/")) + Path('plop/312/bilan_DS1.tex') + """ + return Path(path + "/{cls}/bilan_T{term}.tex".format(cls=classe, term=term)) + +def term_bilan(classe, term, path = Path('./'), + template = "tpl_bilan_term.tex"): + """ Generate the bilan of a evaluation for a class + + :param classe: the classe name + :param evalname: name of the evaluation + :param path: path where xlsx are stored + :param template: template for the bilan + + """ + ws = get_class_ws(classe, path) + logger.info("Worksheets of {} imported".format(classe)) + + flat_df = extract_flat_marks(ws) + quest_df, exo_df, eval_df = digest_flat_df(flat_df) + logger.info("Worksheets parsed") + + quest_df, exo_df, eval_df = \ + term_tools.select(quest_df, exo_df, eval_df, term) + _, conn_df, _ = \ + eval_tools.select_contains(quest_df, exo_df, eval_df, "conn") + + bilan_info = term_info(classe, eval_df) + students = term_tools.students_pov(quest_df, exo_df, eval_df) + + datas = {"bilan_info": bilan_info, "students":students, + "quest_df":quest_df, "exo_df":exo_df, "eval_df":eval_df, + "conn_df": conn_df} + + target = build_target_name(classe, term, path) + feed_template(target, datas, template) + + +# ----------------------------- +# Reglages pour 'vim' +# vim:set autoindent expandtab tabstop=4 shiftwidth=4: +# cursor: 16 del diff --git a/notes_tools/tools/term_tools.py b/notes_tools/tools/term_tools.py new file mode 100644 index 0000000..5c75f81 --- /dev/null +++ b/notes_tools/tools/term_tools.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +# encoding: utf-8 + +import pandas as pd +import numpy as np + + +def select(quest_df, exo_df, eval_df, term): + """ Return quest, exo and eval rows which correspond to evalname + + :param quest_df: TODO + :param exo_df: TODO + :param eval_df: TODO + + """ + qu = quest_df[quest_df["Trimestre"] == term] + exo = exo_df[exo_df["Trimestre"] == term] + ev = eval_df[eval_df["Trimestre"] == term] + return qu, exo, ev + + +def students_pov(quest_df, exo_df, eval_df): + es = [] + for e in eval_df["Eleve"].unique(): + eleve = {"Nom":e} + e_quest = quest_df[quest_df["Eleve"] == e] + eleve["quest"] = e_quest + e_exo = exo_df[exo_df["Eleve"] == e] + eleve["exo"] = e_exo + e_eval = eval_df[eval_df["Eleve"] == e] + eleve["eval"] = e_eval + es.append(eleve) + return es + + +# ----------------------------- +# Reglages pour 'vim' +# vim:set autoindent expandtab tabstop=4 shiftwidth=4: +# cursor: 16 del