Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -238,14 +238,22 @@ def main():
|
|
238 |
st.info(f"Misconception ID: {int(misconception_id)}\n\n{misconception_text}")
|
239 |
else:
|
240 |
st.info("Misconception ์ ๋ณด๊ฐ ์์ต๋๋ค.")
|
241 |
-
|
242 |
-
#
|
243 |
-
#
|
244 |
-
#
|
245 |
-
#
|
246 |
-
#
|
247 |
-
#
|
248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
# ์ ์ฌ ๋ฌธ์ ์์ฑ ๋ฒํผ
|
250 |
if st.button(f"๐ ์ ์ฌ ๋ฌธ์ ํ๊ธฐ #{i + 1}", key=f"retry_{i}"):
|
251 |
with st.spinner("์ ์ฌ ๋ฌธ์ ๋ฅผ ์์ฑํ๊ณ ์์ต๋๋ค..."):
|
@@ -254,13 +262,63 @@ def main():
|
|
254 |
if new_question:
|
255 |
st.write("### ๐ฏ ์ ์ฌ ๋ฌธ์ ")
|
256 |
st.write(new_question['question'])
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
else:
|
263 |
st.error("์ ์ฌ ๋ฌธ์ ๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.")
|
|
|
|
|
264 |
if __name__ == "__main__":
|
265 |
main()
|
266 |
|
|
|
238 |
st.info(f"Misconception ID: {int(misconception_id)}\n\n{misconception_text}")
|
239 |
else:
|
240 |
st.info("Misconception ์ ๋ณด๊ฐ ์์ต๋๋ค.")
|
241 |
+
|
242 |
+
# # ์ ์ฌ ๋ฌธ์ ์์ฑ ๋ฒํผ
|
243 |
+
# if st.button(f"๐ ์ ์ฌ ๋ฌธ์ ํ๊ธฐ #{i + 1}", key=f"retry_{i}"):
|
244 |
+
# with st.spinner("์ ์ฌ ๋ฌธ์ ๋ฅผ ์์ฑํ๊ณ ์์ต๋๋ค..."):
|
245 |
+
# logger.info(f"Generating similar question for misconception_id: {misconception_id}")
|
246 |
+
# new_question = generate_similar_question(wrong_q, misconception_id, generator)
|
247 |
+
# if new_question:
|
248 |
+
# st.write("### ๐ฏ ์ ์ฌ ๋ฌธ์ ")
|
249 |
+
# st.write(new_question['question'])
|
250 |
+
# st.write("**๋ณด๊ธฐ:**")
|
251 |
+
# for choice, text in new_question['choices'].items():
|
252 |
+
# st.write(f"{choice}) {text}")
|
253 |
+
# st.write("**โ
์ ๋ต:**", new_question['correct'])
|
254 |
+
# st.write("**๐ ํด์ค:**", new_question['explanation'])
|
255 |
+
# else:
|
256 |
+
# st.error("์ ์ฌ ๋ฌธ์ ๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.")
|
257 |
# ์ ์ฌ ๋ฌธ์ ์์ฑ ๋ฒํผ
|
258 |
if st.button(f"๐ ์ ์ฌ ๋ฌธ์ ํ๊ธฐ #{i + 1}", key=f"retry_{i}"):
|
259 |
with st.spinner("์ ์ฌ ๋ฌธ์ ๋ฅผ ์์ฑํ๊ณ ์์ต๋๋ค..."):
|
|
|
262 |
if new_question:
|
263 |
st.write("### ๐ฏ ์ ์ฌ ๋ฌธ์ ")
|
264 |
st.write(new_question['question'])
|
265 |
+
|
266 |
+
# ์ ๋ต์ ์ธ์
์คํ
์ดํธ์ ์ ์ฅ
|
267 |
+
if f"similar_question_answered_{i}" not in st.session_state:
|
268 |
+
st.session_state[f"similar_question_answered_{i}"] = False
|
269 |
+
if f"similar_question_correct_{i}" not in st.session_state:
|
270 |
+
st.session_state[f"similar_question_correct_{i}"] = new_question['correct']
|
271 |
+
|
272 |
+
# ์์ง ๋ต๋ณํ์ง ์์ ๊ฒฝ์ฐ์๋ง ๋ณด๊ธฐ ๋ฒํผ ํ์
|
273 |
+
if not st.session_state[f"similar_question_answered_{i}"]:
|
274 |
+
st.write("**๋ณด๊ธฐ:**")
|
275 |
+
col1, col2 = st.columns(2)
|
276 |
+
with col1:
|
277 |
+
if st.button(f"A) {new_question['choices']['A']}", key=f"similar_A_{i}"):
|
278 |
+
st.session_state[f"similar_question_answered_{i}"] = True
|
279 |
+
if 'A' == new_question['correct']:
|
280 |
+
st.success("โ
์ ๋ต์
๋๋ค!")
|
281 |
+
else:
|
282 |
+
st.error("โ ํ๋ ธ์ต๋๋ค.")
|
283 |
+
st.rerun()
|
284 |
+
|
285 |
+
if st.button(f"C) {new_question['choices']['C']}", key=f"similar_C_{i}"):
|
286 |
+
st.session_state[f"similar_question_answered_{i}"] = True
|
287 |
+
if 'C' == new_question['correct']:
|
288 |
+
st.success("โ
์ ๋ต์
๋๋ค!")
|
289 |
+
else:
|
290 |
+
st.error("โ ํ๋ ธ์ต๋๋ค.")
|
291 |
+
st.rerun()
|
292 |
+
|
293 |
+
with col2:
|
294 |
+
if st.button(f"B) {new_question['choices']['B']}", key=f"similar_B_{i}"):
|
295 |
+
st.session_state[f"similar_question_answered_{i}"] = True
|
296 |
+
if 'B' == new_question['correct']:
|
297 |
+
st.success("โ
์ ๋ต์
๋๋ค!")
|
298 |
+
else:
|
299 |
+
st.error("โ ํ๋ ธ์ต๋๋ค.")
|
300 |
+
st.rerun()
|
301 |
+
|
302 |
+
if st.button(f"D) {new_question['choices']['D']}", key=f"similar_D_{i}"):
|
303 |
+
st.session_state[f"similar_question_answered_{i}"] = True
|
304 |
+
if 'D' == new_question['correct']:
|
305 |
+
st.success("โ
์ ๋ต์
๋๋ค!")
|
306 |
+
else:
|
307 |
+
st.error("โ ํ๋ ธ์ต๋๋ค.")
|
308 |
+
st.rerun()
|
309 |
+
|
310 |
+
# ๋ต๋ณํ ๊ฒฝ์ฐ ๊ฒฐ๊ณผ ๋ฐ ํด์ค ํ์
|
311 |
+
if st.session_state[f"similar_question_answered_{i}"]:
|
312 |
+
st.write("---")
|
313 |
+
st.write("**๐ ํด์ค:**", new_question['explanation'])
|
314 |
+
# ๋ค์ ํ๊ธฐ ๋ฒํผ
|
315 |
+
if st.button("๐ ๋ค์ ํ๊ธฐ", key=f"reset_{i}"):
|
316 |
+
st.session_state[f"similar_question_answered_{i}"] = False
|
317 |
+
st.rerun()
|
318 |
else:
|
319 |
st.error("์ ์ฌ ๋ฌธ์ ๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.")
|
320 |
+
|
321 |
+
|
322 |
if __name__ == "__main__":
|
323 |
main()
|
324 |
|