Update app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,6 @@ from dash.dependencies import Input, Output, State
|
|
| 31 |
from dash import Dash, html, dcc, callback, callback_context, ctx, Output, Input, dash_table, State, no_update, _dash_renderer, clientside_callback
|
| 32 |
from dash import html
|
| 33 |
|
| 34 |
-
import dash_bootstrap_components as dbc
|
| 35 |
import dash_bootstrap_components as dbc
|
| 36 |
from dash.exceptions import PreventUpdate
|
| 37 |
import dash_mantine_components as dmc
|
|
@@ -1048,7 +1047,7 @@ app_page = dmc.MantineProvider(
|
|
| 1048 |
fluid=False,
|
| 1049 |
children=[
|
| 1050 |
html.Div(id="BCC-status", className="mb-3"),
|
| 1051 |
-
|
| 1052 |
html.Div(id="BCC-output", className="p-3", style={"font-size":"0.75rem"}),
|
| 1053 |
),
|
| 1054 |
],
|
|
@@ -1108,7 +1107,7 @@ app_page = dmc.MantineProvider(
|
|
| 1108 |
className="g-0"
|
| 1109 |
),
|
| 1110 |
html.H4(id="text-enseignement-dropdown", className="mb-3 text-success", style={"font-size": "0.7rem"}),
|
| 1111 |
-
dbc.Textarea(id="enseignement-dropdown", className="mb-3", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),
|
| 1112 |
], md=6),
|
| 1113 |
dbc.Col([
|
| 1114 |
dbc.Row(
|
|
@@ -1122,7 +1121,7 @@ app_page = dmc.MantineProvider(
|
|
| 1122 |
className="g-0"
|
| 1123 |
),
|
| 1124 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
| 1125 |
-
dbc.Textarea(id="classification-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),
|
| 1126 |
], md=6)
|
| 1127 |
]),
|
| 1128 |
dbc.Row([
|
|
@@ -1138,7 +1137,7 @@ app_page = dmc.MantineProvider(
|
|
| 1138 |
className="g-0"
|
| 1139 |
),
|
| 1140 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
| 1141 |
-
dbc.Textarea(id="situation-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),
|
| 1142 |
], md=6),
|
| 1143 |
dbc.Col([
|
| 1144 |
dbc.Row(
|
|
@@ -1196,7 +1195,7 @@ app_page = dmc.MantineProvider(
|
|
| 1196 |
className="g-0"
|
| 1197 |
),
|
| 1198 |
html.Div(id="generation-status", className="mb-3"),
|
| 1199 |
-
|
| 1200 |
html.Div(id="competence-output", className="p-3 border rounded", style={"color":"rgb(90, 242, 156)","border-color":"rgb(90, 242, 156)!important","background-color":"rgba(90, 242, 156, 0.2)"}),
|
| 1201 |
),
|
| 1202 |
], md=12),
|
|
@@ -1266,7 +1265,7 @@ app_page = dmc.MantineProvider(
|
|
| 1266 |
align="left",
|
| 1267 |
className="g-0"
|
| 1268 |
),
|
| 1269 |
-
html.Div(id='output-response', style={"color":"rgb(90, 242, 156)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(90, 242, 156, 0.2)","padding":"5px"}),
|
| 1270 |
html.Div(id="notification_wrapper", style={"margin-top":"1rem"}),
|
| 1271 |
], width=12)
|
| 1272 |
])
|
|
@@ -1438,7 +1437,7 @@ app_avid_page = dmc.MantineProvider(
|
|
| 1438 |
fluid=False,
|
| 1439 |
children=[
|
| 1440 |
html.Div(id="BCC-status", className="mb-3"),
|
| 1441 |
-
|
| 1442 |
html.Div(id="BCC-output", className="p-3", style={"font-size":"0.75rem"}),
|
| 1443 |
),
|
| 1444 |
],
|
|
@@ -1578,7 +1577,7 @@ app_avid_page = dmc.MantineProvider(
|
|
| 1578 |
className="g-0"
|
| 1579 |
),
|
| 1580 |
html.Div(id="generation-status", className="mb-3"),
|
| 1581 |
-
|
| 1582 |
html.Div(id="competence-output", className="p-3 border rounded", style={"color":"rgb(90, 242, 156)","border-color":"rgb(90, 242, 156)!important","background-color":"rgba(90, 242, 156, 0.2)"}),
|
| 1583 |
),
|
| 1584 |
], md=12),
|
|
@@ -1648,7 +1647,7 @@ app_avid_page = dmc.MantineProvider(
|
|
| 1648 |
align="left",
|
| 1649 |
className="g-0"
|
| 1650 |
),
|
| 1651 |
-
html.Div(id='output-response-avid', style={"color":"rgb(156, 242, 242)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(156, 242, 242, 0.2)","padding":"5px"}),
|
| 1652 |
html.Div(id="notification_wrapper-avid", style={"margin-top":"1rem"}),
|
| 1653 |
], width=12)
|
| 1654 |
])
|
|
@@ -1777,28 +1776,31 @@ def update_skills_dropdown(categorie_selected, pathname):
|
|
| 1777 |
)
|
| 1778 |
def update_enseignements_dropdown(categorie_selected, pathname):
|
| 1779 |
"""Mettre à jour les options du dropdown d'enseignements en fonction de la catégorie sélectionnée."""
|
| 1780 |
-
|
| 1781 |
-
|
| 1782 |
-
|
| 1783 |
-
|
| 1784 |
-
|
| 1785 |
-
|
| 1786 |
-
|
| 1787 |
-
|
|
|
|
| 1788 |
|
| 1789 |
-
|
| 1790 |
-
|
| 1791 |
-
|
| 1792 |
-
|
| 1793 |
-
|
| 1794 |
-
|
| 1795 |
-
|
| 1796 |
-
|
| 1797 |
-
|
| 1798 |
sort_keys = True, ensure_ascii=False), "Choisir d'abord une maquette de formation avec propositions BCC : " + default_text + jsonData.get("niveau", ""), modal_text
|
| 1799 |
-
|
| 1800 |
-
|
| 1801 |
sort_keys = True, ensure_ascii=False), "Choisir d'abord une maquette de formation avec propositions BCC : " + default_text + jsonData.get("niveau_etude", ""), modal_text
|
|
|
|
|
|
|
| 1802 |
|
| 1803 |
@app.callback(
|
| 1804 |
Output("classification-dropdown", "placeholder"),
|
|
@@ -1809,41 +1811,44 @@ def update_enseignements_dropdown(categorie_selected, pathname):
|
|
| 1809 |
)
|
| 1810 |
def update_classification_dropdown(categorie_selected, pathname):
|
| 1811 |
"""Mettre à jour les options du dropdown d'enseignements en fonction de la catégorie sélectionnée."""
|
| 1812 |
-
|
| 1813 |
-
|
| 1814 |
-
|
| 1815 |
-
|
| 1816 |
-
|
| 1817 |
-
|
| 1818 |
-
|
| 1819 |
-
|
|
|
|
| 1820 |
|
| 1821 |
-
|
| 1822 |
-
|
| 1823 |
-
|
| 1824 |
-
|
| 1825 |
-
|
| 1826 |
-
|
| 1827 |
-
|
| 1828 |
-
|
| 1829 |
-
|
| 1830 |
-
|
| 1831 |
-
|
| 1832 |
-
|
| 1833 |
-
|
| 1834 |
-
|
| 1835 |
-
|
| 1836 |
-
|
| 1837 |
-
|
| 1838 |
-
|
| 1839 |
-
|
| 1840 |
|
| 1841 |
-
|
| 1842 |
-
|
| 1843 |
sort_keys = True, ensure_ascii=False),modal_text
|
| 1844 |
-
|
| 1845 |
-
|
| 1846 |
sort_keys = True, ensure_ascii=False),modal_text
|
|
|
|
|
|
|
| 1847 |
|
| 1848 |
@app.callback(
|
| 1849 |
Output("situation-dropdown", "placeholder"),
|
|
@@ -1854,18 +1859,19 @@ def update_classification_dropdown(categorie_selected, pathname):
|
|
| 1854 |
)
|
| 1855 |
def update_situations_dropdown(categorie_selected, pathname):
|
| 1856 |
"""Mettre à jour les options du dropdown d'enseignements en fonction de la catégorie sélectionnée."""
|
| 1857 |
-
if not categorie_selected:
|
| 1858 |
-
default_text = "par défaut : "
|
| 1859 |
-
if pathname == "/bcc":
|
| 1860 |
-
categorie_selected = 'JSON/L1-Anglais.json'
|
| 1861 |
-
elif pathname == "/bcc-avid":
|
| 1862 |
-
categorie_selected = 'VD/JSON/L1-Lettres-Modernes.json'
|
| 1863 |
-
else:
|
| 1864 |
-
default_text = ""
|
| 1865 |
-
|
| 1866 |
-
url = f"https://api.github.com/repos/{OWNER}/{REPO}/contents/{categorie_selected}"
|
| 1867 |
-
res = requests.get(url, headers=headers, params=params)
|
| 1868 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1869 |
if res.status_code == 200:
|
| 1870 |
jsonData = json.loads(base64.b64decode(res.json()['content']))
|
| 1871 |
modal_text = "**Description des situations d'apprentissage :**"
|
|
|
|
| 31 |
from dash import Dash, html, dcc, callback, callback_context, ctx, Output, Input, dash_table, State, no_update, _dash_renderer, clientside_callback
|
| 32 |
from dash import html
|
| 33 |
|
|
|
|
| 34 |
import dash_bootstrap_components as dbc
|
| 35 |
from dash.exceptions import PreventUpdate
|
| 36 |
import dash_mantine_components as dmc
|
|
|
|
| 1047 |
fluid=False,
|
| 1048 |
children=[
|
| 1049 |
html.Div(id="BCC-status", className="mb-3"),
|
| 1050 |
+
dcc.Loading(
|
| 1051 |
html.Div(id="BCC-output", className="p-3", style={"font-size":"0.75rem"}),
|
| 1052 |
),
|
| 1053 |
],
|
|
|
|
| 1107 |
className="g-0"
|
| 1108 |
),
|
| 1109 |
html.H4(id="text-enseignement-dropdown", className="mb-3 text-success", style={"font-size": "0.7rem"}),
|
| 1110 |
+
dcc.Loading(dbc.Textarea(id="enseignement-dropdown", className="mb-3", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),),
|
| 1111 |
], md=6),
|
| 1112 |
dbc.Col([
|
| 1113 |
dbc.Row(
|
|
|
|
| 1121 |
className="g-0"
|
| 1122 |
),
|
| 1123 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
| 1124 |
+
dcc.Loading(dbc.Textarea(id="classification-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),),
|
| 1125 |
], md=6)
|
| 1126 |
]),
|
| 1127 |
dbc.Row([
|
|
|
|
| 1137 |
className="g-0"
|
| 1138 |
),
|
| 1139 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
| 1140 |
+
dcc.Loading(dbc.Textarea(id="situation-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),),
|
| 1141 |
], md=6),
|
| 1142 |
dbc.Col([
|
| 1143 |
dbc.Row(
|
|
|
|
| 1195 |
className="g-0"
|
| 1196 |
),
|
| 1197 |
html.Div(id="generation-status", className="mb-3"),
|
| 1198 |
+
dcc.Loading(
|
| 1199 |
html.Div(id="competence-output", className="p-3 border rounded", style={"color":"rgb(90, 242, 156)","border-color":"rgb(90, 242, 156)!important","background-color":"rgba(90, 242, 156, 0.2)"}),
|
| 1200 |
),
|
| 1201 |
], md=12),
|
|
|
|
| 1265 |
align="left",
|
| 1266 |
className="g-0"
|
| 1267 |
),
|
| 1268 |
+
dcc.Loading(html.Div(id='output-response', style={"color":"rgb(90, 242, 156)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(90, 242, 156, 0.2)","padding":"5px"}),),
|
| 1269 |
html.Div(id="notification_wrapper", style={"margin-top":"1rem"}),
|
| 1270 |
], width=12)
|
| 1271 |
])
|
|
|
|
| 1437 |
fluid=False,
|
| 1438 |
children=[
|
| 1439 |
html.Div(id="BCC-status", className="mb-3"),
|
| 1440 |
+
dcc.Loading(
|
| 1441 |
html.Div(id="BCC-output", className="p-3", style={"font-size":"0.75rem"}),
|
| 1442 |
),
|
| 1443 |
],
|
|
|
|
| 1577 |
className="g-0"
|
| 1578 |
),
|
| 1579 |
html.Div(id="generation-status", className="mb-3"),
|
| 1580 |
+
dcc.Loading(
|
| 1581 |
html.Div(id="competence-output", className="p-3 border rounded", style={"color":"rgb(90, 242, 156)","border-color":"rgb(90, 242, 156)!important","background-color":"rgba(90, 242, 156, 0.2)"}),
|
| 1582 |
),
|
| 1583 |
], md=12),
|
|
|
|
| 1647 |
align="left",
|
| 1648 |
className="g-0"
|
| 1649 |
),
|
| 1650 |
+
dcc.Loading(html.Div(id='output-response-avid', style={"color":"rgb(156, 242, 242)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(156, 242, 242, 0.2)","padding":"5px"}),),
|
| 1651 |
html.Div(id="notification_wrapper-avid", style={"margin-top":"1rem"}),
|
| 1652 |
], width=12)
|
| 1653 |
])
|
|
|
|
| 1776 |
)
|
| 1777 |
def update_enseignements_dropdown(categorie_selected, pathname):
|
| 1778 |
"""Mettre à jour les options du dropdown d'enseignements en fonction de la catégorie sélectionnée."""
|
| 1779 |
+
try:
|
| 1780 |
+
if not categorie_selected:
|
| 1781 |
+
default_text = "par défaut : "
|
| 1782 |
+
if pathname == "/bcc":
|
| 1783 |
+
categorie_selected = 'JSON/L1-Anglais.json'
|
| 1784 |
+
elif pathname == "/bcc-avid":
|
| 1785 |
+
categorie_selected = 'VD/JSON/L1-Lettres-Modernes.json'
|
| 1786 |
+
else:
|
| 1787 |
+
default_text = "formation sélectionnée : "
|
| 1788 |
|
| 1789 |
+
url = f"https://api.github.com/repos/{OWNER}/{REPO}/contents/{categorie_selected}"
|
| 1790 |
+
res = requests.get(url, headers=headers, params=params)
|
| 1791 |
+
if res.status_code == 200:
|
| 1792 |
+
jsonData = json.loads(base64.b64decode(res.json()['content']))
|
| 1793 |
+
modal_text = "**Description des catégories d'enseignements : **\n\n"
|
| 1794 |
+
for item in jsonData.get("categories", []):
|
| 1795 |
+
modal_text += f"- **{item['nom']}**:\n\n{item['description']}\n\n"
|
| 1796 |
+
if pathname == "/bcc":
|
| 1797 |
+
return "Choisir d'abord une maquette de formation avec proposition BCC", json.dumps(jsonData.get("categories", []), indent = 6, separators =(",", ":"),
|
| 1798 |
sort_keys = True, ensure_ascii=False), "Choisir d'abord une maquette de formation avec propositions BCC : " + default_text + jsonData.get("niveau", ""), modal_text
|
| 1799 |
+
elif pathname == "/bcc-avid":
|
| 1800 |
+
return "Choisir d'abord une maquette de formation avec proposition BCC", json.dumps(jsonData.get("categories", []), indent = 6, separators =(",", ":"),
|
| 1801 |
sort_keys = True, ensure_ascii=False), "Choisir d'abord une maquette de formation avec propositions BCC : " + default_text + jsonData.get("niveau_etude", ""), modal_text
|
| 1802 |
+
except:
|
| 1803 |
+
print("Aucun fichier chargé!")
|
| 1804 |
|
| 1805 |
@app.callback(
|
| 1806 |
Output("classification-dropdown", "placeholder"),
|
|
|
|
| 1811 |
)
|
| 1812 |
def update_classification_dropdown(categorie_selected, pathname):
|
| 1813 |
"""Mettre à jour les options du dropdown d'enseignements en fonction de la catégorie sélectionnée."""
|
| 1814 |
+
try:
|
| 1815 |
+
if not categorie_selected:
|
| 1816 |
+
default_text = "par défaut : "
|
| 1817 |
+
if pathname == "/bcc":
|
| 1818 |
+
categorie_selected = 'JSON/L1-Anglais.json'
|
| 1819 |
+
elif pathname == "/bcc-avid":
|
| 1820 |
+
categorie_selected = 'VD/JSON/L1-Lettres-Modernes.json'
|
| 1821 |
+
else:
|
| 1822 |
+
default_text = ""
|
| 1823 |
|
| 1824 |
+
url = f"https://api.github.com/repos/{OWNER}/{REPO}/contents/{categorie_selected}"
|
| 1825 |
+
res = requests.get(url, headers=headers, params=params)
|
| 1826 |
+
if res.status_code == 200:
|
| 1827 |
+
jsonData = json.loads(base64.b64decode(res.json()['content']))
|
| 1828 |
+
modal_text = "**Classification des enseignements :**"
|
| 1829 |
+
if pathname == "/bcc":
|
| 1830 |
+
textarea_value = jsonData.get("classified_teachings", [])
|
| 1831 |
+
for key, value in textarea_value.items():
|
| 1832 |
+
modal_text += f"\n\n- **{key}**: "
|
| 1833 |
+
for i in range(0,len(value)):
|
| 1834 |
+
modal_text += f"{value[i]}\t"
|
| 1835 |
+
elif pathname == "/bcc-avid":
|
| 1836 |
+
textarea_value = jsonData.get("dataframe", [])
|
| 1837 |
+
test = " "
|
| 1838 |
+
for item in sorted(textarea_value, key=lambda x: x['categorie'] if x['categorie'] else ""):
|
| 1839 |
+
if test != item['categorie']:
|
| 1840 |
+
modal_text += f"\n\n- **{item['categorie']}**: "
|
| 1841 |
+
modal_text += f"{item['enseignements']}\t"
|
| 1842 |
+
test = item['categorie']
|
| 1843 |
|
| 1844 |
+
if pathname == "/bcc":
|
| 1845 |
+
return "Choisir d'abord une maquette de formation avec proposition BCC", json.dumps(textarea_value, indent = 6, separators =(",", ":"),
|
| 1846 |
sort_keys = True, ensure_ascii=False),modal_text
|
| 1847 |
+
elif pathname == "/bcc-avid":
|
| 1848 |
+
return "Choisir d'abord une maquette de formation avec proposition BCC", json.dumps(textarea_value, indent = 6, separators =(",", ":"),
|
| 1849 |
sort_keys = True, ensure_ascii=False),modal_text
|
| 1850 |
+
except:
|
| 1851 |
+
print("Aucun fichier chargé!")
|
| 1852 |
|
| 1853 |
@app.callback(
|
| 1854 |
Output("situation-dropdown", "placeholder"),
|
|
|
|
| 1859 |
)
|
| 1860 |
def update_situations_dropdown(categorie_selected, pathname):
|
| 1861 |
"""Mettre à jour les options du dropdown d'enseignements en fonction de la catégorie sélectionnée."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1862 |
try:
|
| 1863 |
+
if not categorie_selected:
|
| 1864 |
+
default_text = "par défaut : "
|
| 1865 |
+
if pathname == "/bcc":
|
| 1866 |
+
categorie_selected = 'JSON/L1-Anglais.json'
|
| 1867 |
+
elif pathname == "/bcc-avid":
|
| 1868 |
+
categorie_selected = 'VD/JSON/L1-Lettres-Modernes.json'
|
| 1869 |
+
else:
|
| 1870 |
+
default_text = ""
|
| 1871 |
+
|
| 1872 |
+
url = f"https://api.github.com/repos/{OWNER}/{REPO}/contents/{categorie_selected}"
|
| 1873 |
+
res = requests.get(url, headers=headers, params=params)
|
| 1874 |
+
|
| 1875 |
if res.status_code == 200:
|
| 1876 |
jsonData = json.loads(base64.b64decode(res.json()['content']))
|
| 1877 |
modal_text = "**Description des situations d'apprentissage :**"
|