From 21397272c90e064b9e752c5915bc033cceec6383 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Thu, 14 Jan 2021 20:09:25 +0100 Subject: [PATCH] Feat: move dashboard to its own directory --- recopytex/dashboard/__init__.py | 0 .../exam_dash.py => dashboard/exam.py} | 27 +++++++++++++------ recopytex/scripts/recopytex.py | 4 ++- 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 recopytex/dashboard/__init__.py rename recopytex/{scripts/exam_dash.py => dashboard/exam.py} (92%) diff --git a/recopytex/dashboard/__init__.py b/recopytex/dashboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/recopytex/scripts/exam_dash.py b/recopytex/dashboard/exam.py similarity index 92% rename from recopytex/scripts/exam_dash.py rename to recopytex/dashboard/exam.py index 58831c2..e0660ec 100644 --- a/recopytex/scripts/exam_dash.py +++ b/recopytex/dashboard/exam.py @@ -15,7 +15,7 @@ import numpy as np from .. import flat_df_students, pp_q_scores from ..config import NO_ST_COLUMNS -from .getconfig import config, CONFIGPATH +from ..scripts.getconfig import config, CONFIGPATH COLORS = { ".": "black", @@ -180,6 +180,7 @@ def update_final_scores_descr(data): ) def update_final_scores_hist(data): assessment_scores = pd.DataFrame.from_records(data) + ranges = np.linspace( 0, assessment_scores.Bareme.max(), int(assessment_scores.Bareme.max() * 2 + 1) ) @@ -200,8 +201,15 @@ def update_final_scores_hist(data): hovertemplate="", marker_color="#4E89DE", ) + # fig = go.Figure( + # data=go.Histogram( + # x=assessment_scores["Note"], + # xbins={"start": 0, "end": assessment_scores["Bareme"].max(), "size": 0.25}, + # ), + # ) return [fig] + @app.callback( [ dash.dependencies.Output("fig_competences", "figure"), @@ -232,20 +240,23 @@ def update_competence_fig(data): fig = go.Figure() bars = [ - {"score": -1, "name":"Pas de réponse", "color": COLORS["."]}, - {"score": 0, "name":"Faut", "color": COLORS[0]}, - {"score": 1, "name":"Peu juste", "color": COLORS[1]}, - {"score": 2, "name":"Presque juste", "color": COLORS[2]}, - {"score": 3, "name":"Juste", "color": COLORS[3]}, - ] + {"score": -1, "name": "Pas de réponse", "color": COLORS["."]}, + {"score": 0, "name": "Faut", "color": COLORS[0]}, + {"score": 1, "name": "Peu juste", "color": COLORS[1]}, + {"score": 2, "name": "Presque juste", "color": COLORS[2]}, + {"score": 3, "name": "Juste", "color": COLORS[3]}, + ] for b in bars: try: - fig.add_bar(x=index, y=pt[b["score"]], name=b["name"], marker_color=b["color"]) + fig.add_bar( + x=index, y=pt[b["score"]], name=b["name"], marker_color=b["color"] + ) except KeyError: pass fig.update_layout(barmode="relative") return [fig] + @app.callback( [dash.dependencies.Output("lastsave", "children")], [ diff --git a/recopytex/scripts/recopytex.py b/recopytex/scripts/recopytex.py index 27079bd..63f41e6 100644 --- a/recopytex/scripts/recopytex.py +++ b/recopytex/scripts/recopytex.py @@ -13,7 +13,7 @@ from .getconfig import config, CONFIGPATH from .prompts import prompt_exam, prompt_exercise, prompt_validate from ..config import NO_ST_COLUMNS from .exam import Exam -from .exam_dash import app as exam_app +from ..dashboard.exam import app as exam_app @click.group() @@ -85,10 +85,12 @@ def new_exam(): base_df.to_csv(exam.path(".csv"), index=False) print(f"Le fichier note a été enregistré à {exam.path('.csv')}") + @cli.command() def exam_analysis(): exam_app.run_server(debug=True) + @cli.command() @click.argument("csv_file") def report(csv_file):