Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import uuid
|
|
| 4 |
from utils import (
|
| 5 |
load_idioms, generate_audio, init_db, add_favorite, get_favorite,
|
| 6 |
detect_idioms, translate_literal, build_examples_map, remove_favorite,
|
| 7 |
-
|
| 8 |
)
|
| 9 |
|
| 10 |
st.set_page_config(page_title="Idioms Learning App", layout="wide")
|
|
@@ -98,7 +98,12 @@ elif mode == "Idioms in sentences":
|
|
| 98 |
|
| 99 |
# Practice button
|
| 100 |
if st.button(f"Practice '{idiom}'"):
|
| 101 |
-
st.session_state.quiz =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
st.rerun()
|
| 103 |
|
| 104 |
# QUIZ
|
|
@@ -110,8 +115,8 @@ elif mode == "Quiz time!":
|
|
| 110 |
if "xp" not in st.session_state:
|
| 111 |
st.session_state.xp = 0
|
| 112 |
|
| 113 |
-
if "
|
| 114 |
-
st.session_state.
|
| 115 |
|
| 116 |
if "used_questions" not in st.session_state:
|
| 117 |
st.session_state.used_questions = set()
|
|
@@ -119,8 +124,7 @@ elif mode == "Quiz time!":
|
|
| 119 |
st.metric("XP", st.session_state.xp)
|
| 120 |
|
| 121 |
if "quiz" not in st.session_state:
|
| 122 |
-
st.session_state.quiz =
|
| 123 |
-
st.session_state.used_structures
|
| 124 |
|
| 125 |
if "question_id" not in st.session_state:
|
| 126 |
st.session_state.question_id = str(uuid.uuid4())
|
|
@@ -149,10 +153,12 @@ elif mode == "Quiz time!":
|
|
| 149 |
|
| 150 |
if st.button("New Question"):
|
| 151 |
|
| 152 |
-
new_quiz =
|
| 153 |
-
|
|
|
|
| 154 |
examples_map,
|
| 155 |
-
st.session_state.used_questions
|
|
|
|
| 156 |
)
|
| 157 |
st.session_state.used_structures
|
| 158 |
st.session_state.used_questions.add(new_quiz["answer"])
|
|
|
|
| 4 |
from utils import (
|
| 5 |
load_idioms, generate_audio, init_db, add_favorite, get_favorite,
|
| 6 |
detect_idioms, translate_literal, build_examples_map, remove_favorite,
|
| 7 |
+
generate_adaptive_quiz, update_analytics, get_learning_stats
|
| 8 |
)
|
| 9 |
|
| 10 |
st.set_page_config(page_title="Idioms Learning App", layout="wide")
|
|
|
|
| 98 |
|
| 99 |
# Practice button
|
| 100 |
if st.button(f"Practice '{idiom}'"):
|
| 101 |
+
st.session_state.quiz = generate_adaptive_quiz(
|
| 102 |
+
conn,
|
| 103 |
+
{idiom: idiom_map[idiom]},
|
| 104 |
+
examples_map,
|
| 105 |
+
st.session_state.used_questions,
|
| 106 |
+
st.session_state.used_structures)
|
| 107 |
st.rerun()
|
| 108 |
|
| 109 |
# QUIZ
|
|
|
|
| 115 |
if "xp" not in st.session_state:
|
| 116 |
st.session_state.xp = 0
|
| 117 |
|
| 118 |
+
if "used_structures" not in st.session_state:
|
| 119 |
+
st.session_state.used_structures = set()
|
| 120 |
|
| 121 |
if "used_questions" not in st.session_state:
|
| 122 |
st.session_state.used_questions = set()
|
|
|
|
| 124 |
st.metric("XP", st.session_state.xp)
|
| 125 |
|
| 126 |
if "quiz" not in st.session_state:
|
| 127 |
+
st.session_state.quiz = generate_adaptive_quiz(conn,idiom_map,examples_map,st.session_state.used_questions,st.session_state.used_structures)
|
|
|
|
| 128 |
|
| 129 |
if "question_id" not in st.session_state:
|
| 130 |
st.session_state.question_id = str(uuid.uuid4())
|
|
|
|
| 153 |
|
| 154 |
if st.button("New Question"):
|
| 155 |
|
| 156 |
+
new_quiz = generate_adaptive_quiz(
|
| 157 |
+
conn,
|
| 158 |
+
idiom_map,
|
| 159 |
examples_map,
|
| 160 |
+
st.session_state.used_questions,
|
| 161 |
+
st.session_state.used_structures
|
| 162 |
)
|
| 163 |
st.session_state.used_structures
|
| 164 |
st.session_state.used_questions.add(new_quiz["answer"])
|