diff --git a/recopytex/dashboard/create_exam/app.py b/recopytex/dashboard/create_exam/app.py index 61d8aec..513e1d9 100644 --- a/recopytex/dashboard/create_exam/app.py +++ b/recopytex/dashboard/create_exam/app.py @@ -109,7 +109,8 @@ layout = html.Div( ), ], ), - ] + ], + id="form", ), html.Section( children=[ @@ -124,8 +125,26 @@ layout = html.Div( ), html.Div( id="summary", - ) - ] + ), + ], + id="exercises", + ), + html.Section( + children=[ + html.Div( + id="score_rate", + ), + html.Div( + id="exercises-viz", + ), + html.Div( + id="competences-viz", + ), + html.Div( + id="domains-viz", + ), + ], + id="visualisation", ), ] ), @@ -287,6 +306,16 @@ def store_exam(tribe, exam_name, date, term, exercices, elements, elements_id): return exam.to_dict() +@app.callback( + dash.dependencies.Output("score_rate", "children"), + dash.dependencies.Input("exam_store", "data"), + prevent_initial_call=True, +) +def score_rate(data): + exam = Exam(**data) + return [html.P(f"Barème /{exam.score_rate}")] + + @app.callback( dash.dependencies.Output("is-saved", "children"), dash.dependencies.Input("save-csv", "n_clicks"), diff --git a/recopytex/scripts/exam.py b/recopytex/scripts/exam.py index 212683f..40296ef 100644 --- a/recopytex/scripts/exam.py +++ b/recopytex/scripts/exam.py @@ -157,3 +157,11 @@ class Exam: self.tribe_path.mkdir(exist_ok=True) base_df.to_csv(self.path(".csv"), index=False) + + @property + def score_rate(self): + total = 0 + for ex, questions in self._exercises.items(): + total += sum([q["score_rate"] for q in questions]) + + return total