diff --git a/recopytex/dashboard/pages/exams_scores/app.py b/recopytex/dashboard/pages/exams_scores/app.py index ee6a64d..1144de7 100644 --- a/recopytex/dashboard/pages/exams_scores/app.py +++ b/recopytex/dashboard/pages/exams_scores/app.py @@ -55,6 +55,15 @@ layout = html.Div( ], id="final_score_table_container", ), + html.Div( + children=[ + dash_table.DataTable( + id="score_statistics_table", + columns=[], + ) + ], + id="score_statistics_table_container", + ), ], id="analysis", ), diff --git a/recopytex/dashboard/pages/exams_scores/callbacks.py b/recopytex/dashboard/pages/exams_scores/callbacks.py index ea0da49..7fe07a5 100644 --- a/recopytex/dashboard/pages/exams_scores/callbacks.py +++ b/recopytex/dashboard/pages/exams_scores/callbacks.py @@ -2,7 +2,6 @@ # encoding: utf-8 from dash.dependencies import Input, Output, State -import dash from dash.exceptions import PreventUpdate import dash_table import json @@ -52,7 +51,6 @@ def update_exams_choices(tribe): ], ) def update_scores_store(exam): - ctx = dash.callback_context if not exam: return [[], [], [], {}] exam = pd.DataFrame.from_dict([json.loads(exam)]) @@ -88,7 +86,26 @@ def update_scores_store(exam): Input("scores_table", "data"), ], ) -def update_scores_store(scores): +def update_finale_score_table(scores): scores_df = pd.DataFrame.from_records(scores) # print(scores_df) return score_to_final_mark(scores_df) + + +@app.callback( + [ + Output("score_statistics_table", "columns"), + Output("score_statistics_table", "data"), + ], + [ + Input("final_score_table", "data"), + ], +) +def update_statictics_table(finale_score): + df = pd.DataFrame.from_records(finale_score) + statistics = df["mark"].describe().to_frame().T + print(statistics) + return [ + [{"id": c, "name": c} for c in statistics.columns], + statistics.to_dict("records"), + ]