From 429fed6a1e361d7d10f7a22a019c2ff66e606432 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Sun, 24 Jan 2021 06:53:06 +0100 Subject: [PATCH] Feat: default values for elements --- recopytex/dashboard/create_exam/app.py | 30 +++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/recopytex/dashboard/create_exam/app.py b/recopytex/dashboard/create_exam/app.py index 1e2d146..8bbdb8e 100644 --- a/recopytex/dashboard/create_exam/app.py +++ b/recopytex/dashboard/create_exam/app.py @@ -135,7 +135,19 @@ def add_exercise(n_clicks, children): if n_clicks is None: return children element_table = pd.DataFrame(columns=[c["id"] for c in QUESTION_COLUMNS]) - element_table = element_table.append(pd.Series(name=0)) + element_table = element_table.append( + pd.Series( + data={ + "id": 1, + "competence": "Rechercher", + "theme": "", + "comment": "", + "score_rate": 1, + "is_leveled": 1, + }, + name=0, + ) + ) new_exercise = html.Div( children=[ html.Div( @@ -162,7 +174,7 @@ def add_exercise(n_clicks, children): editable=True, row_deletable=True, dropdown={ - "Competence": { + "competence": { "options": [ {"label": i, "value": i} for i in config["competences"] ] @@ -205,7 +217,19 @@ def add_element(n_clicks, elements): return elements df = pd.DataFrame.from_records(elements) - df = df.append(pd.Series(name=n_clicks)) + df = df.append( + pd.Series( + data={ + "id": len(df) + 1, + "competence": "", + "theme": "", + "comment": "", + "score_rate": 1, + "is_leveled": 1, + }, + name=n_clicks, + ) + ) return df.to_dict("records")