Sibucs commited on
Commit
7b19087
·
verified ·
1 Parent(s): 5e7c6ca

Pubblicato da GitHub: 67e7eb2

Browse files
Files changed (4) hide show
  1. .env.example +1 -1
  2. README.md +1 -1
  3. app.py +96 -0
  4. src/settings.py +1 -1
.env.example CHANGED
@@ -1,6 +1,6 @@
1
  # Variabili non sensibili
2
  APP_ENV=local
3
- APP_VERSION=0.5.2
4
  CONTENT_FILE_PATH=data/catalog.full.json
5
  CONTENT_REPO_ID=
6
  CONTENT_REVISION=main
 
1
  # Variabili non sensibili
2
  APP_ENV=local
3
+ APP_VERSION=0.5.3
4
  CONTENT_FILE_PATH=data/catalog.full.json
5
  CONTENT_REPO_ID=
6
  CONTENT_REVISION=main
README.md CHANGED
@@ -25,7 +25,7 @@ sono provvisori e i diritti di pubblicazione dei testi devono essere verificati
25
  prima dell’uso pubblico. Quando il Dataset degli eventi e i secret non sono
26
  configurati, l’interfaccia segnala che gli eventi non sono durevoli.
27
 
28
- La versione 0.5.2 separa la navigazione in passaggi successivi: prima
29
  l’identificazione, poi gli ambiti disponibili e infine le scale dell’ambito
30
  scelto. Percentuali, mappa e cronologia restano nella pagina personale separata
31
  `/percorso`; la panoramica del ricercatore resta nella pagina riservata
 
25
  prima dell’uso pubblico. Quando il Dataset degli eventi e i secret non sono
26
  configurati, l’interfaccia segnala che gli eventi non sono durevoli.
27
 
28
+ La versione 0.5.3 separa la navigazione in passaggi successivi: prima
29
  l’identificazione, poi gli ambiti disponibili e infine le scale dell’ambito
30
  scelto. Percentuali, mappa e cronologia restano nella pagina personale separata
31
  `/percorso`; la panoramica del ricercatore resta nella pagina riservata
app.py CHANGED
@@ -2020,6 +2020,61 @@ def back_to_practice(state: dict[str, Any]):
2020
  )
2021
 
2022
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2023
  def logout():
2024
  return (
2025
  _empty_ui_state(),
@@ -2541,6 +2596,22 @@ def build_demo() -> gr.Blocks:
2541
  visible=False,
2542
  variant="primary",
2543
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2544
 
2545
  with gr.Group(visible=False) as summary_group:
2546
  summary_stats = gr.HTML()
@@ -2781,6 +2852,31 @@ def build_demo() -> gr.Blocks:
2781
  user_message,
2782
  ],
2783
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2784
 
2785
  def bind_summary_filter(button, outcome):
2786
  button.click(
 
2020
  )
2021
 
2022
 
2023
+ def open_exercise_exit_confirmation():
2024
+ return gr.update(visible=True)
2025
+
2026
+
2027
+ def cancel_exercise_exit():
2028
+ return gr.update(visible=False)
2029
+
2030
+
2031
+ def pause_session_and_choose_scale(state: dict[str, Any]):
2032
+ """Leave the exercise UI without deleting its immutable session events."""
2033
+ session = state.get("session") or {}
2034
+ updated = dict(state)
2035
+ updated["session"] = None
2036
+ path = (
2037
+ str(session.get("schema", "")),
2038
+ str(session.get("modality", "")),
2039
+ str(session.get("activity", "")),
2040
+ str(session.get("scale", "")),
2041
+ )
2042
+ if all(path):
2043
+ navigation = _navigation_selection(path[0], path[1])
2044
+ scales = CATALOG.choices(
2045
+ "scale",
2046
+ schema=path[0],
2047
+ modality=path[1],
2048
+ activity=path[2],
2049
+ )
2050
+ navigation = (
2051
+ navigation[0],
2052
+ navigation[1],
2053
+ navigation[2],
2054
+ gr.Dropdown(
2055
+ choices=CATALOG.choices(
2056
+ "activity", schema=path[0], modality=path[1]
2057
+ ),
2058
+ value=path[2],
2059
+ ),
2060
+ gr.Dropdown(choices=scales, value=path[3]),
2061
+ (
2062
+ "Sessione messa in pausa. I tentativi già registrati restano "
2063
+ "salvati e puoi riprenderla dall’elenco delle sessioni."
2064
+ ),
2065
+ )
2066
+ else:
2067
+ navigation = _navigation_selection(*_first_path_values()[1:3])
2068
+ return (
2069
+ updated,
2070
+ gr.update(visible=True),
2071
+ gr.update(visible=False),
2072
+ gr.update(visible=False),
2073
+ *navigation,
2074
+ _resume_dropdown(str(updated.get("participant_id", ""))),
2075
+ )
2076
+
2077
+
2078
  def logout():
2079
  return (
2080
  _empty_ui_state(),
 
2596
  visible=False,
2597
  variant="primary",
2598
  )
2599
+ leave_exercise_button = gr.Button(
2600
+ "Torna alla scelta della scala"
2601
+ )
2602
+ with gr.Group(visible=False) as leave_exercise_confirmation:
2603
+ gr.Markdown(
2604
+ "### Mettere in pausa questa sessione?\n"
2605
+ "I tentativi già registrati non verranno cancellati. "
2606
+ "Potrai riprendere la sessione in seguito."
2607
+ )
2608
+ with gr.Row():
2609
+ confirm_leave_exercise_button = gr.Button(
2610
+ "Sì, torna alle scale", variant="primary"
2611
+ )
2612
+ cancel_leave_exercise_button = gr.Button(
2613
+ "No, continua l’esercizio"
2614
+ )
2615
 
2616
  with gr.Group(visible=False) as summary_group:
2617
  summary_stats = gr.HTML()
 
2852
  user_message,
2853
  ],
2854
  )
2855
+ leave_exercise_button.click(
2856
+ open_exercise_exit_confirmation,
2857
+ outputs=leave_exercise_confirmation,
2858
+ )
2859
+ cancel_leave_exercise_button.click(
2860
+ cancel_exercise_exit,
2861
+ outputs=leave_exercise_confirmation,
2862
+ )
2863
+ confirm_leave_exercise_button.click(
2864
+ pause_session_and_choose_scale,
2865
+ inputs=ui_state,
2866
+ outputs=[
2867
+ ui_state,
2868
+ scale_group,
2869
+ exercise_group,
2870
+ leave_exercise_confirmation,
2871
+ scale_selector,
2872
+ schema_choice,
2873
+ modality_choice,
2874
+ activity_choice,
2875
+ scale_choice,
2876
+ path_selection_message,
2877
+ resume_choice,
2878
+ ],
2879
+ )
2880
 
2881
  def bind_summary_filter(button, outcome):
2882
  button.click(
src/settings.py CHANGED
@@ -32,7 +32,7 @@ class Settings:
32
  return cls(
33
  base_dir=base_dir,
34
  app_env=app_env,
35
- app_version=os.getenv("APP_VERSION", "0.5.2").strip(),
36
  content_file_path=os.getenv(
37
  "CONTENT_FILE_PATH",
38
  (
 
32
  return cls(
33
  base_dir=base_dir,
34
  app_env=app_env,
35
+ app_version=os.getenv("APP_VERSION", "0.5.3").strip(),
36
  content_file_path=os.getenv(
37
  "CONTENT_FILE_PATH",
38
  (