Compare commits
5 Commits
ff94470fb4
...
581b0f4f2f
Author | SHA1 | Date | |
---|---|---|---|
581b0f4f2f | |||
3dbfc85447 | |||
b5bf1ac137 | |||
74d751a586 | |||
1855d4016d |
@ -5,6 +5,7 @@ from dash.dependencies import Input, Output
|
|||||||
from .app import app
|
from .app import app
|
||||||
from .exam_analysis import app as exam_analysis
|
from .exam_analysis import app as exam_analysis
|
||||||
from .create_exam import app as create_exam
|
from .create_exam import app as create_exam
|
||||||
|
from .student_analysis import app as student_analysis
|
||||||
|
|
||||||
|
|
||||||
app.layout = html.Div(
|
app.layout = html.Div(
|
||||||
@ -18,6 +19,8 @@ def display_page(pathname):
|
|||||||
return exam_analysis.layout
|
return exam_analysis.layout
|
||||||
elif pathname == "/create-exam":
|
elif pathname == "/create-exam":
|
||||||
return create_exam.layout
|
return create_exam.layout
|
||||||
|
elif pathname == "/students":
|
||||||
|
return student_analysis.layout
|
||||||
else:
|
else:
|
||||||
return "404"
|
return "404"
|
||||||
|
|
||||||
|
0
recopytex/dashboard/student_analysis/__init__.py
Normal file
0
recopytex/dashboard/student_analysis/__init__.py
Normal file
217
recopytex/dashboard/student_analysis/app.py
Normal file
217
recopytex/dashboard/student_analysis/app.py
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
import dash
|
||||||
|
import dash_html_components as html
|
||||||
|
import dash_core_components as dcc
|
||||||
|
import dash_table
|
||||||
|
import plotly.graph_objects as go
|
||||||
|
from datetime import date, datetime
|
||||||
|
import uuid
|
||||||
|
import pandas as pd
|
||||||
|
import yaml
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from ...scripts.getconfig import config
|
||||||
|
from ... import flat_df_students, pp_q_scores
|
||||||
|
from ...config import NO_ST_COLUMNS
|
||||||
|
from ..app import app
|
||||||
|
from ...scripts.exam import Exam
|
||||||
|
|
||||||
|
def get_students(csv):
|
||||||
|
return list(pd.read_csv(csv).T.to_dict().values())
|
||||||
|
|
||||||
|
|
||||||
|
QUESTION_COLUMNS = [
|
||||||
|
{"id": "id", "name": "Question"},
|
||||||
|
{
|
||||||
|
"id": "competence",
|
||||||
|
"name": "Competence",
|
||||||
|
"presentation": "dropdown",
|
||||||
|
},
|
||||||
|
{"id": "theme", "name": "Domaine"},
|
||||||
|
{"id": "comment", "name": "Commentaire"},
|
||||||
|
{"id": "score_rate", "name": "Bareme"},
|
||||||
|
{"id": "is_leveled", "name": "Est_nivele"},
|
||||||
|
]
|
||||||
|
|
||||||
|
layout = html.Div(
|
||||||
|
[
|
||||||
|
html.Header(
|
||||||
|
children=[
|
||||||
|
html.H1("Bilan des élèves"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
html.Main(
|
||||||
|
children=[
|
||||||
|
html.Section(
|
||||||
|
children=[
|
||||||
|
html.Form(
|
||||||
|
id="select-student",
|
||||||
|
children=[
|
||||||
|
html.Label(
|
||||||
|
children=[
|
||||||
|
"Classe",
|
||||||
|
dcc.Dropdown(
|
||||||
|
id="tribe",
|
||||||
|
options=[
|
||||||
|
{"label": t["name"], "value": t["name"]}
|
||||||
|
for t in config["tribes"]
|
||||||
|
],
|
||||||
|
value=config["tribes"][0]["name"],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
html.Label(
|
||||||
|
children=[
|
||||||
|
"Élève",
|
||||||
|
dcc.Dropdown(
|
||||||
|
id="student",
|
||||||
|
options=[
|
||||||
|
{"label": t["Nom"], "value": t["Nom"]}
|
||||||
|
for t in get_students(config["tribes"][0]["students"])
|
||||||
|
],
|
||||||
|
value=get_students(config["tribes"][0]["students"])[0]["Nom"],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
html.Label(
|
||||||
|
children=[
|
||||||
|
"Trimestre",
|
||||||
|
dcc.Dropdown(
|
||||||
|
id="term",
|
||||||
|
options=[
|
||||||
|
{"label": i + 1, "value": i + 1}
|
||||||
|
for i in range(3)
|
||||||
|
],
|
||||||
|
value=1,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
id="form",
|
||||||
|
),
|
||||||
|
html.Section(
|
||||||
|
children=[
|
||||||
|
html.H2("Évaluations"),
|
||||||
|
html.Div(
|
||||||
|
dash_table.DataTable(
|
||||||
|
id="exam_scores",
|
||||||
|
columns=[
|
||||||
|
{"id": "Nom", "name": "Évaluations"},
|
||||||
|
{"id": "Note", "name": "Note"},
|
||||||
|
{"id": "Bareme", "name": "Barème"},
|
||||||
|
],
|
||||||
|
data=[],
|
||||||
|
style_data_conditional=[
|
||||||
|
{
|
||||||
|
"if": {"row_index": "odd"},
|
||||||
|
"backgroundColor": "rgb(248, 248, 248)",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
style_data={
|
||||||
|
"width": "100px",
|
||||||
|
"maxWidth": "100px",
|
||||||
|
"minWidth": "100px",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
id="eval-table",
|
||||||
|
),
|
||||||
|
html.Div(
|
||||||
|
id="describe",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
id="Évaluations",
|
||||||
|
),
|
||||||
|
html.Section(
|
||||||
|
children=[
|
||||||
|
html.Div(
|
||||||
|
id="competences-viz",
|
||||||
|
),
|
||||||
|
html.Div(
|
||||||
|
id="themes-viz",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
id="visualisation",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
dcc.Store(id="student-scores"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.callback(
|
||||||
|
[
|
||||||
|
dash.dependencies.Output("student", "options"),
|
||||||
|
dash.dependencies.Output("student", "value"),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
dash.dependencies.Input("tribe", "value")
|
||||||
|
],)
|
||||||
|
def update_students_list(tribe):
|
||||||
|
tribe_config = [t for t in config["tribes"] if t["name"] == tribe][0]
|
||||||
|
students = get_students(tribe_config["students"])
|
||||||
|
options = [
|
||||||
|
{"label": t["Nom"], "value": t["Nom"]}
|
||||||
|
for t in students
|
||||||
|
]
|
||||||
|
value = students[0]["Nom"]
|
||||||
|
return options, value
|
||||||
|
|
||||||
|
|
||||||
|
@app.callback(
|
||||||
|
[
|
||||||
|
dash.dependencies.Output("student-scores", "data"),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
dash.dependencies.Input("tribe", "value"),
|
||||||
|
dash.dependencies.Input("student", "value"),
|
||||||
|
dash.dependencies.Input("term", "value"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
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("exam_scores", "data"),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
dash.dependencies.Input("student-scores", "data"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def update_exam_scores(data):
|
||||||
|
scores = pd.DataFrame.from_records(data)
|
||||||
|
scores = pp_q_scores(scores)
|
||||||
|
assessment_scores = scores.groupby(["Nom"]).agg({"Note": "sum", "Bareme": "sum"})
|
||||||
|
return [assessment_scores.reset_index().to_dict("records")]
|
||||||
|
return [{}]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user