Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -204,51 +204,6 @@ def display_math_content(content):
|
|
| 204 |
# Clean and format the content
|
| 205 |
formatted_content = LatexNodes2Text().latex_to_text(content)
|
| 206 |
st.markdown(f'<div class="math-container">{formatted_content}</div>', unsafe_allow_html=True)
|
| 207 |
-
|
| 208 |
-
# 추가
|
| 209 |
-
# def add_custom_css():
|
| 210 |
-
# st.markdown(
|
| 211 |
-
# """
|
| 212 |
-
# <style>
|
| 213 |
-
# .problem-header {
|
| 214 |
-
# color: #FF6B6B;
|
| 215 |
-
# font-size: 24px;
|
| 216 |
-
# font-weight: bold;
|
| 217 |
-
# margin-bottom: 20px;
|
| 218 |
-
# }
|
| 219 |
-
|
| 220 |
-
# .math-container {
|
| 221 |
-
# background-color: #f9f9f9;
|
| 222 |
-
# padding: 20px;
|
| 223 |
-
# border-radius: 10px;
|
| 224 |
-
# box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 225 |
-
# margin-bottom: 20px;
|
| 226 |
-
# }
|
| 227 |
-
|
| 228 |
-
# .options-container {
|
| 229 |
-
# display: grid;
|
| 230 |
-
# grid-template-columns: 1fr 1fr;
|
| 231 |
-
# gap: 20px;
|
| 232 |
-
# }
|
| 233 |
-
|
| 234 |
-
# .option {
|
| 235 |
-
# background-color: white;
|
| 236 |
-
# border: 1px solid #ddd;
|
| 237 |
-
# border-radius: 8px;
|
| 238 |
-
# padding: 15px;
|
| 239 |
-
# text-align: center;
|
| 240 |
-
# font-size: 18px;
|
| 241 |
-
# cursor: pointer;
|
| 242 |
-
# transition: background-color 0.3s;
|
| 243 |
-
# }
|
| 244 |
-
|
| 245 |
-
# .option:hover {
|
| 246 |
-
# background-color: #f8f9fa;
|
| 247 |
-
# }
|
| 248 |
-
# </style>
|
| 249 |
-
# """,
|
| 250 |
-
# unsafe_allow_html=True
|
| 251 |
-
# )
|
| 252 |
|
| 253 |
# 2250
|
| 254 |
def add_custom_css():
|
|
@@ -276,44 +231,6 @@ def add_custom_css():
|
|
| 276 |
unsafe_allow_html=True
|
| 277 |
)
|
| 278 |
|
| 279 |
-
##
|
| 280 |
-
# def display_question(question, answers):
|
| 281 |
-
# """Display question and options with LaTeX formatting"""
|
| 282 |
-
# st.markdown('<div class="problem-header">Problem:</div>', unsafe_allow_html=True)
|
| 283 |
-
# display_math_content(question)
|
| 284 |
-
|
| 285 |
-
# # Add custom CSS for options
|
| 286 |
-
# st.markdown("""
|
| 287 |
-
# <style>
|
| 288 |
-
# .option-container {
|
| 289 |
-
# background-color: #f0f8ff;
|
| 290 |
-
# padding: 10px 20px;
|
| 291 |
-
# margin: 5px 0;
|
| 292 |
-
# border-radius: 5px;
|
| 293 |
-
# cursor: pointer;
|
| 294 |
-
# display: flex;
|
| 295 |
-
# align-items: center;
|
| 296 |
-
# gap: 20px;
|
| 297 |
-
# }
|
| 298 |
-
# .option-text {
|
| 299 |
-
# color: #0066ff;
|
| 300 |
-
# font-weight: 500;
|
| 301 |
-
# width: 30px;
|
| 302 |
-
# }
|
| 303 |
-
# </style>
|
| 304 |
-
# """, unsafe_allow_html=True)
|
| 305 |
-
|
| 306 |
-
# # Display options
|
| 307 |
-
# for opt in ['A', 'B', 'C', 'D']:
|
| 308 |
-
# with st.container():
|
| 309 |
-
# col1, col2 = st.columns([1, 11])
|
| 310 |
-
# with col1:
|
| 311 |
-
# if st.button(f"{opt}.", key=f"btn_{opt}", help="Click to select"):
|
| 312 |
-
# handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
|
| 313 |
-
# st.rerun()
|
| 314 |
-
# with col2:
|
| 315 |
-
# display_option_content(answers[opt])
|
| 316 |
-
|
| 317 |
def display_question(question, answers):
|
| 318 |
"""Display question and options with LaTeX formatting"""
|
| 319 |
st.markdown('<div class="problem-header">Problem:</div>', unsafe_allow_html=True)
|
|
@@ -322,31 +239,34 @@ def display_question(question, answers):
|
|
| 322 |
# Add custom CSS for options
|
| 323 |
st.markdown("""
|
| 324 |
<style>
|
| 325 |
-
.option-
|
| 326 |
-
width: 100%;
|
| 327 |
-
text-align: left;
|
| 328 |
-
margin: 5px 0;
|
| 329 |
-
padding: 10px;
|
| 330 |
background-color: #f0f8ff;
|
| 331 |
-
|
|
|
|
| 332 |
border-radius: 5px;
|
| 333 |
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
| 334 |
}
|
| 335 |
-
.option-
|
| 336 |
-
|
|
|
|
|
|
|
| 337 |
}
|
| 338 |
</style>
|
| 339 |
""", unsafe_allow_html=True)
|
| 340 |
|
| 341 |
-
# Display
|
| 342 |
for opt in ['A', 'B', 'C', 'D']:
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
|
|
|
| 350 |
|
| 351 |
def display_option_content(option_text):
|
| 352 |
"""Process and display option content with LaTeX formatting"""
|
|
@@ -355,41 +275,41 @@ def display_option_content(option_text):
|
|
| 355 |
st.markdown(f'<div class="math-container">{formatted_content}</div>', unsafe_allow_html=True)
|
| 356 |
|
| 357 |
# 추가
|
| 358 |
-
# def update_similar_question_display(new_question, i, answered=False):
|
| 359 |
-
# """Display similar question and its options"""
|
| 360 |
-
# display_math_content(new_question['question'])
|
| 361 |
-
|
| 362 |
-
# # Display options
|
| 363 |
-
# for opt in ['A', 'B', 'C', 'D']:
|
| 364 |
-
# with st.container():
|
| 365 |
-
# col1, col2 = st.columns([1, 11])
|
| 366 |
-
# with col1:
|
| 367 |
-
# if st.button(f"{opt}.", key=f"sim_btn_{opt}_{i}", help="Click to select"):
|
| 368 |
-
# if not answered:
|
| 369 |
-
# st.session_state[f"similar_question_answered_{i}"] = True
|
| 370 |
-
# st.session_state[f"selected_answer_{i}"] = opt
|
| 371 |
-
# correct_answer = st.session_state.get('current_similar_question_answer')
|
| 372 |
-
# st.session_state[f"is_correct_{i}"] = (opt == correct_answer)
|
| 373 |
-
# st.rerun()
|
| 374 |
-
# with col2:
|
| 375 |
-
# display_option_content(new_question['choices'][opt])
|
| 376 |
def update_similar_question_display(new_question, i, answered=False):
|
| 377 |
"""Display similar question and its options"""
|
| 378 |
display_math_content(new_question['question'])
|
| 379 |
-
st.write("**보기:**")
|
| 380 |
|
|
|
|
| 381 |
for opt in ['A', 'B', 'C', 'D']:
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
if st.button(opt, key=f"sim_btn_{opt}_{i}"):
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
def main():
|
| 394 |
"""메인 애플리케이션 로직"""
|
| 395 |
st.title("MisconcepTutor")
|
|
|
|
| 204 |
# Clean and format the content
|
| 205 |
formatted_content = LatexNodes2Text().latex_to_text(content)
|
| 206 |
st.markdown(f'<div class="math-container">{formatted_content}</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
# 2250
|
| 209 |
def add_custom_css():
|
|
|
|
| 231 |
unsafe_allow_html=True
|
| 232 |
)
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
def display_question(question, answers):
|
| 235 |
"""Display question and options with LaTeX formatting"""
|
| 236 |
st.markdown('<div class="problem-header">Problem:</div>', unsafe_allow_html=True)
|
|
|
|
| 239 |
# Add custom CSS for options
|
| 240 |
st.markdown("""
|
| 241 |
<style>
|
| 242 |
+
.option-container {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
background-color: #f0f8ff;
|
| 244 |
+
padding: 10px 20px;
|
| 245 |
+
margin: 5px 0;
|
| 246 |
border-radius: 5px;
|
| 247 |
cursor: pointer;
|
| 248 |
+
display: flex;
|
| 249 |
+
align-items: center;
|
| 250 |
+
gap: 20px;
|
| 251 |
}
|
| 252 |
+
.option-text {
|
| 253 |
+
color: #0066ff;
|
| 254 |
+
font-weight: 500;
|
| 255 |
+
width: 30px;
|
| 256 |
}
|
| 257 |
</style>
|
| 258 |
""", unsafe_allow_html=True)
|
| 259 |
|
| 260 |
+
# Display options
|
| 261 |
for opt in ['A', 'B', 'C', 'D']:
|
| 262 |
+
with st.container():
|
| 263 |
+
col1, col2 = st.columns([1, 11])
|
| 264 |
+
with col1:
|
| 265 |
+
if st.button(f"{opt}.", key=f"btn_{opt}", help="Click to select"):
|
| 266 |
+
handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
|
| 267 |
+
st.rerun()
|
| 268 |
+
with col2:
|
| 269 |
+
display_option_content(answers[opt])
|
| 270 |
|
| 271 |
def display_option_content(option_text):
|
| 272 |
"""Process and display option content with LaTeX formatting"""
|
|
|
|
| 275 |
st.markdown(f'<div class="math-container">{formatted_content}</div>', unsafe_allow_html=True)
|
| 276 |
|
| 277 |
# 추가
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
def update_similar_question_display(new_question, i, answered=False):
|
| 279 |
"""Display similar question and its options"""
|
| 280 |
display_math_content(new_question['question'])
|
|
|
|
| 281 |
|
| 282 |
+
# Display options
|
| 283 |
for opt in ['A', 'B', 'C', 'D']:
|
| 284 |
+
with st.container():
|
| 285 |
+
col1, col2 = st.columns([1, 11])
|
| 286 |
+
with col1:
|
| 287 |
+
if st.button(f"{opt}.", key=f"sim_btn_{opt}_{i}", help="Click to select"):
|
| 288 |
+
if not answered:
|
| 289 |
+
st.session_state[f"similar_question_answered_{i}"] = True
|
| 290 |
+
st.session_state[f"selected_answer_{i}"] = opt
|
| 291 |
+
correct_answer = st.session_state.get('current_similar_question_answer')
|
| 292 |
+
st.session_state[f"is_correct_{i}"] = (opt == correct_answer)
|
| 293 |
+
st.rerun()
|
| 294 |
+
with col2:
|
| 295 |
+
display_option_content(new_question['choices'][opt])
|
| 296 |
+
# def update_similar_question_display(new_question, i, answered=False):
|
| 297 |
+
# """Display similar question and its options"""
|
| 298 |
+
# display_math_content(new_question['question'])
|
| 299 |
+
# st.write("**보기:**")
|
| 300 |
+
|
| 301 |
+
# for opt in ['A', 'B', 'C', 'D']:
|
| 302 |
+
# col1, col2 = st.columns([1, 11])
|
| 303 |
+
# with col1:
|
| 304 |
+
# if not answered:
|
| 305 |
+
# if st.button(opt, key=f"sim_btn_{opt}_{i}"):
|
| 306 |
+
# st.session_state[f"similar_question_answered_{i}"] = True
|
| 307 |
+
# st.session_state[f"selected_answer_{i}"] = opt
|
| 308 |
+
# correct_answer = st.session_state.get('current_similar_question_answer')
|
| 309 |
+
# st.session_state[f"is_correct_{i}"] = (opt == correct_answer)
|
| 310 |
+
# st.rerun()
|
| 311 |
+
# with col2:
|
| 312 |
+
# display_option_content(new_question['choices'][opt])
|
| 313 |
def main():
|
| 314 |
"""메인 애플리케이션 로직"""
|
| 315 |
st.title("MisconcepTutor")
|