Feat: add total score_rate

This commit is contained in:
Bertrand Benjamin 2021-02-08 15:45:50 +01:00
parent 7dba11996a
commit e1d3940e9d
2 changed files with 40 additions and 3 deletions

View File

@ -109,7 +109,8 @@ layout = html.Div(
), ),
], ],
), ),
] ],
id="form",
), ),
html.Section( html.Section(
children=[ children=[
@ -124,8 +125,26 @@ layout = html.Div(
), ),
html.Div( html.Div(
id="summary", 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() 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( @app.callback(
dash.dependencies.Output("is-saved", "children"), dash.dependencies.Output("is-saved", "children"),
dash.dependencies.Input("save-csv", "n_clicks"), dash.dependencies.Input("save-csv", "n_clicks"),

View File

@ -157,3 +157,11 @@ class Exam:
self.tribe_path.mkdir(exist_ok=True) self.tribe_path.mkdir(exist_ok=True)
base_df.to_csv(self.path(".csv"), index=False) 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