Feat: default values for elements

This commit is contained in:
Bertrand Benjamin 2021-01-24 06:53:06 +01:00
parent 1255bf4b9e
commit 429fed6a1e
1 changed files with 27 additions and 3 deletions

View File

@ -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")