Compare commits

..

No commits in common. "8cdeecfc5372a7d25b747bd090aa5e3a4a5fa242" and "235019102b48f509c26141ad21d17c0726db2333" have entirely different histories.

2 changed files with 3 additions and 91 deletions

View File

@ -55,23 +55,6 @@ layout = html.Div(
], ],
id="final_score_table_container", id="final_score_table_container",
), ),
html.Div(
children=[
dash_table.DataTable(
id="score_statistics_table",
columns=[],
)
],
id="score_statistics_table_container",
),
html.Div(
children=[
dcc.Graph(
id="fig_exam_histo",
)
],
id="fig_exam_histo_container",
),
], ],
id="analysis", id="analysis",
), ),
@ -83,14 +66,6 @@ layout = html.Div(
style_data_conditional=[], style_data_conditional=[],
fixed_columns={}, fixed_columns={},
editable=True, editable=True,
style_table={"minWidth": "100%"},
style_cell={
"minWidth": "100px",
"width": "100px",
"maxWidth": "100px",
"overflow": "hidden",
"textOverflow": "ellipsis",
},
) )
], ],
id="edit", id="edit",

View File

@ -2,12 +2,11 @@
# encoding: utf-8 # encoding: utf-8
from dash.dependencies import Input, Output, State from dash.dependencies import Input, Output, State
import dash
from dash.exceptions import PreventUpdate from dash.exceptions import PreventUpdate
import plotly.graph_objects as go
import dash_table import dash_table
import json import json
import pandas as pd import pandas as pd
import numpy as np
from recopytex.dashboard.app import app from recopytex.dashboard.app import app
from recopytex.dashboard.common.formating import highlight_scores from recopytex.dashboard.common.formating import highlight_scores
@ -53,6 +52,7 @@ def update_exams_choices(tribe):
], ],
) )
def update_scores_store(exam): def update_scores_store(exam):
ctx = dash.callback_context
if not exam: if not exam:
return [[], [], [], {}] return [[], [], [], {}]
exam = pd.DataFrame.from_dict([json.loads(exam)]) exam = pd.DataFrame.from_dict([json.loads(exam)])
@ -88,70 +88,7 @@ def update_scores_store(exam):
Input("scores_table", "data"), Input("scores_table", "data"),
], ],
) )
def update_finale_score_table(scores): def update_scores_store(scores):
scores_df = pd.DataFrame.from_records(scores) scores_df = pd.DataFrame.from_records(scores)
# print(scores_df) # print(scores_df)
return score_to_final_mark(scores_df) return score_to_final_mark(scores_df)
@app.callback(
[
Output("score_statistics_table", "columns"),
Output("score_statistics_table", "data"),
],
[
Input("final_score_table", "data"),
],
)
def update_statictics_table(finale_score):
df = pd.DataFrame.from_records(finale_score)
statistics = df["mark"].describe().to_frame().T
print(statistics)
return [
[{"id": c, "name": c} for c in statistics.columns],
statistics.to_dict("records"),
]
@app.callback(
[
Output("fig_exam_histo", "figure"),
],
[
Input("final_score_table", "data"),
],
)
def update_exam_histo(finale_scores):
scores = pd.DataFrame.from_records(finale_scores)
if scores.empty:
return [go.Figure(data=[go.Scatter(x=[], y=[])])]
ranges = np.linspace(
-0.5,
scores["score_rate"].max(),
int(scores["score_rate"].max() * 2 + 2),
)
bins = pd.cut(scores["mark"], ranges)
scores["Bin"] = bins
grouped = (
scores.reset_index()
.groupby("Bin")
.agg({"score_rate": "count", "student_name": lambda x: "\n".join(x)})
)
grouped.index = grouped.index.map(lambda i: i.right)
fig = go.Figure()
fig.add_bar(
x=grouped.index,
y=grouped["score_rate"],
text=grouped["student_name"],
textposition="auto",
hovertemplate="",
marker_color="#4E89DE",
)
fig.update_layout(
height=300,
margin=dict(l=5, r=5, b=5, t=5),
)
return [fig]