Jintonic92 commited on
Commit
c00d243
·
verified ·
1 Parent(s): b205088

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +99 -35
app.py CHANGED
@@ -207,6 +207,51 @@ def display_math_content(content):
207
  st.markdown(f'<div class="math-container">{formatted_content}</div>', unsafe_allow_html=True)
208
 
209
  # 추가
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  def add_custom_css():
211
  st.markdown(
212
  """
@@ -217,54 +262,72 @@ def add_custom_css():
217
  font-weight: bold;
218
  margin-bottom: 20px;
219
  }
220
-
221
  .math-container {
222
- background-color: #f9f9f9;
223
- padding: 20px;
224
- border-radius: 10px;
225
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
226
- margin-bottom: 20px;
227
- }
228
-
229
- .options-container {
230
- display: grid;
231
- grid-template-columns: 1fr 1fr;
232
- gap: 20px;
233
- }
234
-
235
- .option {
236
- background-color: white;
237
- border: 1px solid #ddd;
238
- border-radius: 8px;
239
- padding: 15px;
240
- text-align: center;
241
- font-size: 18px;
242
- cursor: pointer;
243
- transition: background-color 0.3s;
244
  }
245
-
246
- .option:hover {
247
- background-color: #f8f9fa;
248
  }
249
  </style>
250
  """,
251
  unsafe_allow_html=True
252
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
  def display_question(question, answers):
255
  """Display question and options with LaTeX formatting"""
256
  st.markdown('<div class="problem-header">Problem:</div>', unsafe_allow_html=True)
257
  display_math_content(question)
258
 
259
- col1, col2 = st.columns(2)
260
- for i, (col, opt) in enumerate([(col1, 'A'), (col1, 'C'), (col2, 'B'), (col2, 'D')]):
261
- with col:
262
- st.markdown(f"### {opt})")
263
- display_option_content(answers[opt])
264
- if st.button("선택", key=f"btn_{opt}"):
265
- handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
266
- st.rerun()
267
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  def display_option_content(option_text):
269
  """Process and display option content with LaTeX formatting"""
270
  from pylatexenc.latex2text import LatexNodes2Text
@@ -292,6 +355,7 @@ def main():
292
 
293
  # Generator 초기화
294
  generator = load_question_generator()
 
295
 
296
  # 초기 화면
297
  if st.session_state.current_step == 'initial':
 
207
  st.markdown(f'<div class="math-container">{formatted_content}</div>', unsafe_allow_html=True)
208
 
209
  # 추가
210
+ # def add_custom_css():
211
+ # st.markdown(
212
+ # """
213
+ # <style>
214
+ # .problem-header {
215
+ # color: #FF6B6B;
216
+ # font-size: 24px;
217
+ # font-weight: bold;
218
+ # margin-bottom: 20px;
219
+ # }
220
+
221
+ # .math-container {
222
+ # background-color: #f9f9f9;
223
+ # padding: 20px;
224
+ # border-radius: 10px;
225
+ # box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
226
+ # margin-bottom: 20px;
227
+ # }
228
+
229
+ # .options-container {
230
+ # display: grid;
231
+ # grid-template-columns: 1fr 1fr;
232
+ # gap: 20px;
233
+ # }
234
+
235
+ # .option {
236
+ # background-color: white;
237
+ # border: 1px solid #ddd;
238
+ # border-radius: 8px;
239
+ # padding: 15px;
240
+ # text-align: center;
241
+ # font-size: 18px;
242
+ # cursor: pointer;
243
+ # transition: background-color 0.3s;
244
+ # }
245
+
246
+ # .option:hover {
247
+ # background-color: #f8f9fa;
248
+ # }
249
+ # </style>
250
+ # """,
251
+ # unsafe_allow_html=True
252
+ # )
253
+
254
+ # 2250
255
  def add_custom_css():
256
  st.markdown(
257
  """
 
262
  font-weight: bold;
263
  margin-bottom: 20px;
264
  }
 
265
  .math-container {
266
+ background-color: #f0f8ff;
267
+ padding: 15px 20px;
268
+ border-radius: 5px;
269
+ margin: 5px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  }
271
+ button {
272
+ color: #0066ff;
273
+ font-weight: 500;
274
  }
275
  </style>
276
  """,
277
  unsafe_allow_html=True
278
  )
279
+ # 2250
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
+ # col1, col2 = st.columns(2)
286
+ # for i, (col, opt) in enumerate([(col1, 'A'), (col1, 'C'), (col2, 'B'), (col2, 'D')]):
287
+ # with col:
288
+ # st.markdown(f"### {opt})")
289
+ # display_option_content(answers[opt])
290
+ # if st.button("선택", key=f"btn_{opt}"):
291
+ # handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
292
+ # st.rerun()
293
 
294
  def display_question(question, answers):
295
  """Display question and options with LaTeX formatting"""
296
  st.markdown('<div class="problem-header">Problem:</div>', unsafe_allow_html=True)
297
  display_math_content(question)
298
 
299
+ # Add custom CSS for options
300
+ st.markdown("""
301
+ <style>
302
+ .option-container {
303
+ background-color: #f0f8ff;
304
+ padding: 10px 20px;
305
+ margin: 5px 0;
306
+ border-radius: 5px;
307
+ cursor: pointer;
308
+ display: flex;
309
+ align-items: center;
310
+ gap: 20px;
311
+ }
312
+ .option-text {
313
+ color: #0066ff;
314
+ font-weight: 500;
315
+ width: 30px;
316
+ }
317
+ </style>
318
+ """, unsafe_allow_html=True)
319
+
320
+ # Display options
321
+ for opt in ['A', 'B', 'C', 'D']:
322
+ with st.container():
323
+ col1, col2 = st.columns([1, 11])
324
+ with col1:
325
+ if st.button(f"{opt}.", key=f"btn_{opt}", help="Click to select"):
326
+ handle_answer(opt, st.session_state.questions.iloc[st.session_state.current_question_index])
327
+ st.rerun()
328
+ with col2:
329
+ display_option_content(answers[opt])
330
+
331
  def display_option_content(option_text):
332
  """Process and display option content with LaTeX formatting"""
333
  from pylatexenc.latex2text import LatexNodes2Text
 
355
 
356
  # Generator 초기화
357
  generator = load_question_generator()
358
+ add_custom_css()
359
 
360
  # 초기 화면
361
  if st.session_state.current_step == 'initial':