Jintonic92 commited on
Commit
03c3bbc
·
verified ·
1 Parent(s): af3db8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -42
app.py CHANGED
@@ -275,20 +275,44 @@ def add_custom_css():
275
  """,
276
  unsafe_allow_html=True
277
  )
278
- # 2250
 
279
  # def display_question(question, answers):
280
  # """Display question and options with LaTeX formatting"""
281
  # st.markdown('<div class="problem-header">Problem:</div>', unsafe_allow_html=True)
282
  # display_math_content(question)
283
 
284
- # col1, col2 = st.columns(2)
285
- # for i, (col, opt) in enumerate([(col1, 'A'), (col1, 'C'), (col2, 'B'), (col2, 'D')]):
286
- # with col:
287
- # st.markdown(f"### {opt})")
288
- # display_option_content(answers[opt])
289
- # if st.button("선택", key=f"btn_{opt}"):
290
- # handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
291
- # st.rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
  def display_question(question, answers):
294
  """Display question and options with LaTeX formatting"""
@@ -298,34 +322,31 @@ def display_question(question, answers):
298
  # Add custom CSS for options
299
  st.markdown("""
300
  <style>
301
- .option-container {
302
- background-color: #f0f8ff;
303
- padding: 10px 20px;
304
  margin: 5px 0;
 
 
 
305
  border-radius: 5px;
306
  cursor: pointer;
307
- display: flex;
308
- align-items: center;
309
- gap: 20px;
310
  }
311
- .option-text {
312
- color: #0066ff;
313
- font-weight: 500;
314
- width: 30px;
315
  }
316
  </style>
317
  """, unsafe_allow_html=True)
318
 
319
- # Display options
320
  for opt in ['A', 'B', 'C', 'D']:
321
- with st.container():
322
- col1, col2 = st.columns([1, 11])
323
- with col1:
324
- if st.button(f"{opt}.", key=f"btn_{opt}", help="Click to select"):
325
- handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
326
- st.rerun()
327
- with col2:
328
- display_option_content(answers[opt])
329
 
330
  def display_option_content(option_text):
331
  """Process and display option content with LaTeX formatting"""
@@ -334,25 +355,41 @@ def display_option_content(option_text):
334
  st.markdown(f'<div class="math-container">{formatted_content}</div>', unsafe_allow_html=True)
335
 
336
  # 추가
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  def update_similar_question_display(new_question, i, answered=False):
338
  """Display similar question and its options"""
339
  display_math_content(new_question['question'])
 
340
 
341
- # Display options
342
  for opt in ['A', 'B', 'C', 'D']:
343
- with st.container():
344
- col1, col2 = st.columns([1, 11])
345
- with col1:
346
- if st.button(f"{opt}.", key=f"sim_btn_{opt}_{i}", help="Click to select"):
347
- if not answered:
348
- st.session_state[f"similar_question_answered_{i}"] = True
349
- st.session_state[f"selected_answer_{i}"] = opt
350
- correct_answer = st.session_state.get('current_similar_question_answer')
351
- st.session_state[f"is_correct_{i}"] = (opt == correct_answer)
352
- st.rerun()
353
- with col2:
354
- display_option_content(new_question['choices'][opt])
355
-
356
  def main():
357
  """메인 애플리케이션 로직"""
358
  st.title("MisconcepTutor")
 
275
  """,
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"""
 
322
  # Add custom CSS for options
323
  st.markdown("""
324
  <style>
325
+ .option-button {
326
+ width: 100%;
327
+ text-align: left;
328
  margin: 5px 0;
329
+ padding: 10px;
330
+ background-color: #f0f8ff;
331
+ border: none;
332
  border-radius: 5px;
333
  cursor: pointer;
 
 
 
334
  }
335
+ .option-button:hover {
336
+ background-color: #e6f3ff;
 
 
337
  }
338
  </style>
339
  """, unsafe_allow_html=True)
340
 
341
+ # Display each option
342
  for opt in ['A', 'B', 'C', 'D']:
343
+ col1, col2 = st.columns([1, 11])
344
+ with col1:
345
+ if st.button(opt, key=f"btn_{opt}"):
346
+ handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
347
+ st.rerun()
348
+ with col2:
349
+ st.markdown(f'<div class="option-container">{answers[opt]}</div>', unsafe_allow_html=True)
 
350
 
351
  def display_option_content(option_text):
352
  """Process and display option content with LaTeX formatting"""
 
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
+ col1, col2 = st.columns([1, 11])
383
+ with col1:
384
+ if not answered:
385
+ if st.button(opt, key=f"sim_btn_{opt}_{i}"):
386
+ st.session_state[f"similar_question_answered_{i}"] = True
387
+ st.session_state[f"selected_answer_{i}"] = opt
388
+ correct_answer = st.session_state.get('current_similar_question_answer')
389
+ st.session_state[f"is_correct_{i}"] = (opt == correct_answer)
390
+ st.rerun()
391
+ with col2:
392
+ display_option_content(new_question['choices'][opt])
 
 
393
  def main():
394
  """메인 애플리케이션 로직"""
395
  st.title("MisconcepTutor")