Renaming to Repytex
This commit is contained in:
7
Repytex/reports/__init__.py
Normal file
7
Repytex/reports/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
92
Repytex/reports/eval_reports.py
Executable file
92
Repytex/reports/eval_reports.py
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
Evaluation reports
|
||||
"""
|
||||
|
||||
from notes_tools.tools import (
|
||||
extract_flat_marks,
|
||||
get_class_ws,
|
||||
digest_flat_df,
|
||||
evaluation
|
||||
)
|
||||
import pandas as pd
|
||||
from path import Path
|
||||
from .produce_compile import produce_compile
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def eval_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["Nom"] = ds_df["Nom"].unique()[0]
|
||||
eval_info["Date"] = pd.to_datetime(ds_df["Date"].unique()[0]).strftime("%d-%m-%Y")
|
||||
eval_info["Trimestre"] = ds_df["Trimestre"].unique()[0]
|
||||
return eval_info
|
||||
|
||||
|
||||
def build_target_name(classe, evalname, path = Path("./")):
|
||||
""" Build the path where the .tex will be sored
|
||||
|
||||
>>> build_target_name("312", "DS1")
|
||||
Path('./312/report_DS1.tex')
|
||||
>>> build_target_name("312", "DS1", Path("plop/"))
|
||||
Path('plop/312/report_DS1.tex')
|
||||
"""
|
||||
return Path(path + "/" + classe + "/report_" + evalname + ".tex")
|
||||
|
||||
|
||||
def eval_report(classe, evalname, path = Path('./'),
|
||||
template="tpl_reports_eval.tex", force=1):
|
||||
""" Generate the report 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 report
|
||||
:param force: Override existing documents
|
||||
|
||||
"""
|
||||
ws = get_class_ws(classe, path)
|
||||
logger.info("Worksheets of {} imported".format(classe))
|
||||
|
||||
flat_df = extract_flat_marks(ws)
|
||||
logger.info("Worksheets parsed")
|
||||
|
||||
this_df = flat_df[flat_df['Nom'] == evalname]
|
||||
quest_df, exo_df, eval_df = digest_flat_df(this_df)
|
||||
|
||||
report_info = eval_info(classe, eval_df)
|
||||
|
||||
students = evaluation.students_pov(quest_df, exo_df, eval_df)
|
||||
class_pov = evaluation.class_pov(quest_df, exo_df, eval_df)
|
||||
|
||||
studs = {*this_df['Eleve']}
|
||||
present = {*eval_df['Eleve']}
|
||||
absents = studs - present
|
||||
|
||||
datas = {"report_info": report_info,
|
||||
"students":students,
|
||||
"classe": class_pov,
|
||||
"absents": absents
|
||||
}
|
||||
|
||||
target = build_target_name(classe, evalname, path)
|
||||
produce_compile(template, datas, target, force)
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
48
Repytex/reports/filters.py
Normal file
48
Repytex/reports/filters.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from uuid import uuid4
|
||||
from path import Path
|
||||
import logging
|
||||
import matplotlib.pyplot as plt
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def includegraphics(fig_ax, document_path="./", fig_path="fig/",
|
||||
prefix="", scale=1):
|
||||
""" Jinja2 filter which save the figure
|
||||
and return latex includegraphic to display it.
|
||||
|
||||
:param fig_ax: TODO
|
||||
:param path: TODO
|
||||
:param prefix: TODO
|
||||
:param scale: TODO
|
||||
:returns: TODO
|
||||
|
||||
"""
|
||||
try:
|
||||
fig, ax = fig_ax
|
||||
except (TypeError, ValueError):
|
||||
ax = fig_ax
|
||||
fig = ax.figure
|
||||
|
||||
if prefix:
|
||||
filename = "{}_{}.pdf".format(prefix, str(uuid4())[:8])
|
||||
else:
|
||||
filename = "{}.pdf".format(str(uuid4())[:8])
|
||||
|
||||
path_to_file = Path(document_path/fig_path)
|
||||
path_to_file.mkdir_p()
|
||||
|
||||
fig.tight_layout()
|
||||
fig.savefig(path_to_file/filename)
|
||||
logger.info(f"Graphique {filename} sauvé à {path_to_file}")
|
||||
plt.close(fig)
|
||||
return "\includegraphics[scale={sc}]{{{f}}}".format(sc = scale,
|
||||
f=Path(fig_path)/filename)
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
43
Repytex/reports/produce_compile.py
Normal file
43
Repytex/reports/produce_compile.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
Producing and compiling reports
|
||||
"""
|
||||
|
||||
from path import Path
|
||||
import pytex
|
||||
|
||||
import logging
|
||||
#logger = logging.getLogger(__name__)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
from .filters import includegraphics
|
||||
pytex.add_filter("includegraphics", includegraphics)
|
||||
# texenv.filters['includegraphics'] = includegraphics
|
||||
|
||||
pytex.add_pkg_loader("notes_tools.reports", "templates")
|
||||
|
||||
|
||||
def produce_compile(template, datas, target, force=1):
|
||||
""" Get the template and feed it to create reports
|
||||
|
||||
:param target: path where the report will be saved
|
||||
:param datas: dictonnary to feed the template
|
||||
:param template: the template
|
||||
"""
|
||||
directory = Path(target).dirname()
|
||||
datas.update({"directory": directory})
|
||||
pytex.feed(template, datas, target, force)
|
||||
logger.info(f"{target} has been created")
|
||||
pytex.pdflatex(target)
|
||||
logger.info(f"{target} has been compiled")
|
||||
# pytex.clean()
|
||||
# logger.info(f"Clean the directory")
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
50
Repytex/reports/reports_tools.py
Executable file
50
Repytex/reports/reports_tools.py
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from notes_tools.tools import extract_flat_marks, get_class_ws, list_classes
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import xlrd
|
||||
from path import Path
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def print_report_of(classe_ws):
|
||||
"""TODO: Docstring for list_report.
|
||||
|
||||
:param arg1: TODO
|
||||
:returns: TODO
|
||||
|
||||
"""
|
||||
try:
|
||||
df = extract_flat_marks(classe_ws)
|
||||
# TODO: il faudrait renommer l'exeption |lun. nov. 28 16:17:21 EAT 2016
|
||||
except ValueError:
|
||||
print("Erreur avec cette feuille de calcul")
|
||||
return None
|
||||
print("Évaluations")
|
||||
for e in df["Nom"].unique():
|
||||
print("\t-{}".format(e))
|
||||
print("Trimestre")
|
||||
for t in df['Trimestre'].unique():
|
||||
print("\t-Trimestre {}".format(t))
|
||||
|
||||
def print_reports(path):
|
||||
""" List all report which can be generate in the directory
|
||||
|
||||
:param path: the directory
|
||||
:returns: TODO
|
||||
|
||||
"""
|
||||
print("Liste des bilans disponibles")
|
||||
for c in list_classes(path):
|
||||
print("Classe de {}".format(c))
|
||||
ws = get_class_ws(c, path)
|
||||
print_report_of(ws)
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
31
Repytex/reports/templates/tpl_reports.tex
Normal file
31
Repytex/reports/templates/tpl_reports.tex
Normal file
@@ -0,0 +1,31 @@
|
||||
\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{\Var{report_info["Nom"]}}
|
||||
% \seconde \premiereS \PSTMG \TSTMG
|
||||
\classe{\Var{report_info["Classe"]}}
|
||||
\date{\Var{report_info["Date"]}}
|
||||
|
||||
|
||||
\begin{document}
|
||||
|
||||
\Block{block classPOV}\Block{endblock}
|
||||
|
||||
\pagebreak
|
||||
|
||||
\Block{block evalPOV}\Block{endblock}
|
||||
|
||||
\pagebreak
|
||||
|
||||
\Block{block students}\Block{endblock}
|
||||
|
||||
\end{document}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "master"
|
||||
%%% End:
|
||||
|
||||
83
Repytex/reports/templates/tpl_reports_eval.tex
Normal file
83
Repytex/reports/templates/tpl_reports_eval.tex
Normal file
@@ -0,0 +1,83 @@
|
||||
%- extends "tpl_reports.tex"
|
||||
|
||||
% FILENAME: "tpl_reports_eval.tex
|
||||
|
||||
%- block classPOV
|
||||
\maketitle
|
||||
|
||||
|
||||
%- if absents
|
||||
Liste des élèves absents
|
||||
\begin{itemize}
|
||||
%- for e in absents
|
||||
\item \Var{e}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
%- endif
|
||||
|
||||
\Var{classe.level_heatmap | includegraphics(document_path=directory, scale=0.6)}
|
||||
|
||||
\Var{classe.hist_boxplot | includegraphics(document_path=directory, scale=0.6)}
|
||||
|
||||
Compétences
|
||||
|
||||
\Var{classe.pies_eff_pts_on_competence | includegraphics(document_path=directory, scale=0.5)}
|
||||
|
||||
|
||||
Élements du programme
|
||||
|
||||
\Var{classe.pies_eff_pts_on_domaine | includegraphics(document_path=directory, scale=0.5)}
|
||||
|
||||
\vfill
|
||||
%- endblock
|
||||
|
||||
|
||||
%-block students
|
||||
%-for e in students
|
||||
\maketitle
|
||||
|
||||
\begin{minipage}{0.5\linewidth}
|
||||
\large
|
||||
\Var{e.name}
|
||||
\end{minipage}
|
||||
\begin{minipage}{0.3\linewidth}
|
||||
\begin{flushright}
|
||||
\Large \Var{e.eval["Mark_barem"]}
|
||||
\end{flushright}
|
||||
\end{minipage}
|
||||
|
||||
\vfill
|
||||
|
||||
\begin{minipage}{0.6\linewidth}
|
||||
\fbox{%
|
||||
\begin{minipage}{0.9\linewidth}
|
||||
\hfill
|
||||
\vspace{2cm}
|
||||
\end{minipage}
|
||||
}
|
||||
\end{minipage}
|
||||
|
||||
\vfill
|
||||
|
||||
\scriptsize
|
||||
\begin{multicols}{3}
|
||||
\noindent
|
||||
%- for exo_tab in e.latex_exo_tabulars
|
||||
\Var{exo_tab}
|
||||
%- endfor
|
||||
\end{multicols}
|
||||
\vfill
|
||||
|
||||
\begin{center}
|
||||
Pas de réponse \NoRep \hfill
|
||||
Tout faux \RepZ \hfill
|
||||
Beaucoup d'erreurs \RepU \hfill
|
||||
Quelques erreurs \RepD \hfill
|
||||
Juste \RepT \hfill
|
||||
\end{center}
|
||||
\normalsize
|
||||
\pagebreak
|
||||
%-endfor
|
||||
%-endblock
|
||||
|
||||
|
||||
73
Repytex/reports/templates/tpl_reports_term.tex
Normal file
73
Repytex/reports/templates/tpl_reports_term.tex
Normal file
@@ -0,0 +1,73 @@
|
||||
%- extends "tpl_reports.tex"
|
||||
% FILENAME: "tpl_reports_term.tex
|
||||
|
||||
%- block classPOV
|
||||
\maketitle
|
||||
{\Large Regard sur la classe}
|
||||
|
||||
\Var{classe.eval_tabular}
|
||||
|
||||
\vfill
|
||||
|
||||
\Var{classe.parallel_on_evals | includegraphics(document_path=directory, scale=0.6)}
|
||||
|
||||
Compétences
|
||||
|
||||
\Var{classe.pies_eff_pts_on_competence | includegraphics(document_path=directory, scale=0.3)}
|
||||
|
||||
|
||||
Élements du programme
|
||||
|
||||
\Var{classe.pies_eff_pts_on_domaine | includegraphics(document_path=directory, scale=0.6)}
|
||||
|
||||
|
||||
%- endblock
|
||||
|
||||
%-block evalPOV
|
||||
%#\maketitle
|
||||
%#{\Large Regard sur les évaluations}
|
||||
%#
|
||||
%#\Var{classe.evals_tabular}
|
||||
|
||||
|
||||
%-endblock
|
||||
|
||||
|
||||
|
||||
%-block students
|
||||
%- for e in students
|
||||
\maketitle
|
||||
|
||||
{\Large \Var{e.name}}
|
||||
|
||||
\vfill
|
||||
|
||||
\Var{e.marks_tabular}
|
||||
|
||||
\vfill
|
||||
\Var{e.radar_on_competence | includegraphics(document_path=directory, scale=0.8)}
|
||||
\Var{e.radar_on_domaine | includegraphics(document_path=directory, scale=0.8)}
|
||||
|
||||
|
||||
\vfill
|
||||
|
||||
\Var{e.heatmap_on_competence | includegraphics(document_path=directory, scale=0.6)}
|
||||
|
||||
\Var{e.heatmap_on_domain | includegraphics(document_path=directory, scale=0.6)}
|
||||
%# \Var{e.pies_on_competence | includegraphics(document_path=directory, scale=0.3)}
|
||||
%# \Var{e.pies_on_domaine | includegraphics(document_path=directory, scale=0.3)}
|
||||
|
||||
|
||||
%#\Var{conn_df}
|
||||
%# %- if not conn_df.empty
|
||||
%# \Var{e.parallel_on_evals(classe.eval_df) | includegraphics(document_path=directory, scale=0.5)}
|
||||
%# %- endif
|
||||
|
||||
\vfill
|
||||
\vfill
|
||||
|
||||
\normalsize
|
||||
\pagebreak
|
||||
%- endfor
|
||||
%- endblock
|
||||
|
||||
84
Repytex/reports/term_reports.py
Executable file
84
Repytex/reports/term_reports.py
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
""" Making term reports """
|
||||
|
||||
import logging
|
||||
from notes_tools.tools import (
|
||||
extract_flat_marks,
|
||||
get_class_ws,
|
||||
digest_flat_df,
|
||||
term
|
||||
)
|
||||
from .produce_compile import produce_compile
|
||||
from path import Path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
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_num, path=Path("./")):
|
||||
""" Build the path where the .tex will be sored
|
||||
|
||||
>>> build_target_name("312", "DS1")
|
||||
Path('./312/report_DS1.tex')
|
||||
>>> build_target_name("312", "DS1", Path("plop/"))
|
||||
Path('plop/312/report_DS1.tex')
|
||||
"""
|
||||
return Path(path + f"/{classe}/report_T{term_num}.tex")
|
||||
|
||||
|
||||
def term_report(classe, term_num, path=Path('./'),
|
||||
template="tpl_reports_term.tex", force=1):
|
||||
""" Generate the report 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 report
|
||||
:param force: Override existing documents
|
||||
|
||||
"""
|
||||
ws = get_class_ws(classe, path)
|
||||
logger.info(f"Worksheets of {classe} imported")
|
||||
|
||||
flat_df = extract_flat_marks(ws)
|
||||
logger.info("Worksheets parsed")
|
||||
|
||||
term_df = flat_df[flat_df['Trimestre'] == term_num]
|
||||
|
||||
quest_df, exo_df, eval_df = digest_flat_df(term_df)
|
||||
|
||||
report_info = term_info(classe, eval_df)
|
||||
|
||||
students_pov = term.students_pov(quest_df, exo_df, eval_df)
|
||||
class_pov = term.class_pov(quest_df, exo_df, eval_df)
|
||||
|
||||
datas = {
|
||||
"report_info": report_info,
|
||||
"classe": class_pov,
|
||||
"students": students_pov,
|
||||
}
|
||||
|
||||
target = build_target_name(classe, term_num, path)
|
||||
produce_compile(template, datas, target, force)
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
Reference in New Issue
Block a user