Feat: filter dans store scores
This commit is contained in:
parent
b5bf1ac137
commit
3dbfc85447
@ -10,8 +10,10 @@ from datetime import date, datetime
|
|||||||
import uuid
|
import uuid
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import yaml
|
import yaml
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from ...scripts.getconfig import config
|
from ...scripts.getconfig import config
|
||||||
|
from ... import flat_df_students, pp_q_scores
|
||||||
from ...config import NO_ST_COLUMNS
|
from ...config import NO_ST_COLUMNS
|
||||||
from ..app import app
|
from ..app import app
|
||||||
from ...scripts.exam import Exam
|
from ...scripts.exam import Exam
|
||||||
@ -117,9 +119,11 @@ layout = html.Div(
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
dcc.Store(id="student-scores"),
|
dcc.Store(id="student-scores"),
|
||||||
|
html.P(id="test"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
[
|
[
|
||||||
dash.dependencies.Output("student", "options"),
|
dash.dependencies.Output("student", "options"),
|
||||||
@ -131,22 +135,61 @@ layout = html.Div(
|
|||||||
def update_students_list(tribe):
|
def update_students_list(tribe):
|
||||||
tribe_config = [t for t in config["tribes"] if t["name"] == tribe][0]
|
tribe_config = [t for t in config["tribes"] if t["name"] == tribe][0]
|
||||||
students = get_students(tribe_config["students"])
|
students = get_students(tribe_config["students"])
|
||||||
options=[
|
options = [
|
||||||
{"label": t["Nom"], "value": t["Nom"]}
|
{"label": t["Nom"], "value": t["Nom"]}
|
||||||
for t in students
|
for t in students
|
||||||
]
|
]
|
||||||
value=students[0]["Nom"]
|
value = students[0]["Nom"]
|
||||||
return options, value
|
return options, value
|
||||||
|
|
||||||
# @app.callback(
|
|
||||||
# [
|
@app.callback(
|
||||||
# dash.dependencies.Output("student-scores", "data"),
|
[
|
||||||
# ],
|
dash.dependencies.Output("student-scores", "data"),
|
||||||
# [
|
],
|
||||||
# dash.dependencies.Input("tribe", "value"),
|
[
|
||||||
# dash.dependencies.Input("student", "value"),
|
dash.dependencies.Input("tribe", "value"),
|
||||||
# dash.dependencies.Input("term", "value"),
|
dash.dependencies.Input("student", "value"),
|
||||||
# ],
|
dash.dependencies.Input("term", "value"),
|
||||||
# )
|
],
|
||||||
# def update_student_scores(tribe, student, term):
|
)
|
||||||
# return []
|
def update_student_scores(tribe, student, term):
|
||||||
|
tribe_config = [t for t in config["tribes"] if t["name"] == tribe][0]
|
||||||
|
|
||||||
|
p = Path(tribe_config["name"])
|
||||||
|
csvs = list(p.glob("*.csv"))
|
||||||
|
|
||||||
|
dfs = []
|
||||||
|
for csv in csvs:
|
||||||
|
try:
|
||||||
|
scores = pd.read_csv(csv)
|
||||||
|
except pd.errors.ParserError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
if scores.iloc[0]["Commentaire"] == "commentaire":
|
||||||
|
scores.drop([0], inplace=True)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
scores = flat_df_students(scores).dropna(subset=["Score"])
|
||||||
|
scores = scores[scores["Eleve"] == student]
|
||||||
|
scores = scores[scores["Trimestre"] == term]
|
||||||
|
dfs.append(scores)
|
||||||
|
|
||||||
|
df = pd.concat(dfs)
|
||||||
|
|
||||||
|
return [df.to_dict("records")]
|
||||||
|
|
||||||
|
|
||||||
|
@app.callback(
|
||||||
|
[
|
||||||
|
dash.dependencies.Output("test", "children"),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
dash.dependencies.Input("student-scores", "data"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def update_test(data):
|
||||||
|
return [str(data)]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user