Spaces:
Runtime error

D12004 commited on
Commit
f2e2bc6
·
verified ·
1 Parent(s): 0dd9186

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -32
app.py CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
2
  import pandas as pd
3
 
4
  # =====================================================
5
- # 1. إعداد الصفحة والتصميم المتقدم (ألوان واضحة جداً للأسئلة والاختيارات)
6
  # =====================================================
7
  st.set_page_config(
8
  page_title="Big Data Hero",
@@ -32,6 +32,17 @@ html, body, [class*="css"] {
32
  margin-bottom: 25px;
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
35
  /* رسالة الترحيب الثابتة التفاعلية */
36
  .welcome-box {
37
  background: #111827;
@@ -40,7 +51,7 @@ html, body, [class*="css"] {
40
  border-right: 8px solid #00f2ff;
41
  box-shadow: 0 0 20px rgba(0,242,255,0.2);
42
  color: white;
43
- font-size: 24px;
44
  font-weight: bold;
45
  text-align: center;
46
  margin-bottom: 30px;
@@ -75,9 +86,10 @@ html, body, [class*="css"] {
75
 
76
  /* تكبير وتوضيح النصوص العامة والمواضيع التعليمية */
77
  div[data-testid="stMarkdownContainer"] p, p, li {
78
- font-size: 22px !important;
79
  font-weight: bold !important;
80
- line-height: 1.8 !important;
 
81
  }
82
 
83
  /* تخصيص مستطيل الإدخال: خط كبير جداً، ولون أسود واضح */
@@ -101,35 +113,43 @@ div[data-testid="stTextInput"] input::placeholder {
101
  font-size: 18px !important;
102
  }
103
 
104
- /* إخفاء جملة Press Enter to apply تماماً لمنع حجب النص */
105
  div[data-testid="stTextInput"] [data-testid="InputInstructions"] {
106
  display: none !important;
107
  }
108
 
109
- /* صندوق نص السؤال ليكون بارزاً ومضيئاً باللون الأصفر الفاقع */
110
  div[data-testid="stNotification"] {
111
- background-color: #1e1b4b !important;
112
- border: 3px solid #ffaa00 !important;
113
- border-radius: 12px !important;
 
114
  }
115
 
116
  div[data-testid="stNotification"] div[data-testid="stMarkdownContainer"] p {
117
- color: #ffcc00 !important;
118
- font-size: 24px !important;
119
  font-weight: 900 !important;
120
  }
121
 
122
- /* تحويل نصوص الاختيارات إلى اللون الأبيض الناصع تماماً */
123
  div[data-testid="stRadio"] label p {
124
  color: #ffffff !important;
125
- font-size: 22px !important;
126
- font-weight: bold !important;
127
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
128
  }
129
 
130
  div[data-testid="stRadio"] > label {
131
- color: #00f2ff !important;
132
- font-size: 20px !important;
 
 
 
 
 
 
 
133
  font-weight: bold !important;
134
  }
135
 
@@ -229,7 +249,7 @@ QUIZ_DATA = [
229
  "answer": "أ) مواقع التواصل الاجتماعي"
230
  },
231
  {
232
- "question": "السؤال الثالث: ماذا تعني كلمة Velocity في البيانات الضخمة? ⚡",
233
  "options": ["أ) سرعة البيانات", "ب) لون البيانات", "ج) شكل البيانات"],
234
  "answer": "أ) سرعة البيانات"
235
  },
@@ -303,9 +323,7 @@ elif st.session_state.display_content in DATA:
303
  title_topic = st.session_state.display_content
304
  user_label = "ماذا سنتعلم في لعبة البيانات الضخمة؟" if title_topic == "ماذا سنتعلم" else f"أريد معرفة معلومات عن: {title_topic}"
305
 
306
- # تفريغ الـ history تماماً حتى تظهر فقط إجابة الزرار الجديد مضغوطاً
307
  st.session_state.chat_history = []
308
-
309
  st.session_state.chat_history.append({"role": "user", "text": user_label})
310
  st.session_state.chat_history.append({"role": "bot", "text": DATA[title_topic]})
311
  st.session_state.display_content = "chat"
@@ -313,21 +331,33 @@ elif st.session_state.display_content in DATA:
313
 
314
  # عرض التحدي والاختبار
315
  elif st.session_state.display_content == "quiz":
316
- st.markdown("## 🎯 التحدي والاختبار الذكي:")
317
  if st.session_state.quiz_index < len(QUIZ_DATA):
318
  q = QUIZ_DATA[st.session_state.quiz_index]
319
 
320
  st.info(q["question"])
321
- user_ans = st.radio("اختر إجابتك الصحيحة من الأسفل 👇:", q["options"], key=f"quiz_radio_{st.session_state.quiz_index}")
 
 
 
 
 
 
 
 
 
322
 
323
  if st.button("🚀 تأكيد الإجابة والتحقق"):
324
- if user_ans == q["answer"]:
325
- st.session_state.score += 1
326
- st.success("🎉 إجابة صحيحة وممتازة يا بطل الكنز! أحسنت 🔥")
327
  else:
328
- st.error("🦾 حاول بتركيز أكبر في السؤال القادم!")
329
- st.session_state.quiz_index += 1
330
- st.rerun()
 
 
 
 
331
  else:
332
  if st.session_state.score == len(QUIZ_DATA):
333
  st.balloons()
@@ -340,16 +370,28 @@ elif st.session_state.display_content == "quiz":
340
  st.session_state.score = 0
341
  st.rerun()
342
 
343
- # عرض الإحصائيات
344
  elif st.session_state.display_content == "stats":
345
- st.markdown("## 📊 لوحة الإحصائيات والنسب العالمية")
346
- st.write("نسبة اعتماد القطاعات الحيوية المختلفة على تقنيات البيانات الضخمة:")
347
 
348
  chart_values = [95, 88, 92, 90]
349
  chart_index = ["الطب", "التعليم", "البنوك", "التجارة"]
350
-
351
  chart_data = pd.DataFrame(chart_values, index=chart_index, columns=["النسبة"])
352
- st.bar_chart(chart_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
  # =====================================================
355
  # 5. عناصر القائمة الجانبية (Sidebar)
 
2
  import pandas as pd
3
 
4
  # =====================================================
5
+ # 1. إعداد الصفحة والتصميم المتقدم (ألوان واضحة جداً وتكبير شامل للخطوط)
6
  # =====================================================
7
  st.set_page_config(
8
  page_title="Big Data Hero",
 
32
  margin-bottom: 25px;
33
  }
34
 
35
+ /* عناوين الأقسام الرئيسية لتكون واضحة وفاقعة */
36
+ .section-heading {
37
+ color: #ffd700 !important;
38
+ font-size: 36px !important;
39
+ font-weight: 900 !important;
40
+ text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
41
+ margin-bottom: 20px;
42
+ border-right: 6px solid #ffd700;
43
+ padding-right: 12px;
44
+ }
45
+
46
  /* رسالة الترحيب الثابتة التفاعلية */
47
  .welcome-box {
48
  background: #111827;
 
51
  border-right: 8px solid #00f2ff;
52
  box-shadow: 0 0 20px rgba(0,242,255,0.2);
53
  color: white;
54
+ font-size: 26px;
55
  font-weight: bold;
56
  text-align: center;
57
  margin-bottom: 30px;
 
86
 
87
  /* تكبير وتوضيح النصوص العامة والمواضيع التعليمية */
88
  div[data-testid="stMarkdownContainer"] p, p, li {
89
+ font-size: 24px !important;
90
  font-weight: bold !important;
91
+ line-height: 1.9 !important;
92
+ color: #ffffff;
93
  }
94
 
95
  /* تخصيص مستطيل الإدخال: خط كبير جداً، ولون أسود واضح */
 
113
  font-size: 18px !important;
114
  }
115
 
116
+ /* إخفاء جملة Press Enter تماماً */
117
  div[data-testid="stTextInput"] [data-testid="InputInstructions"] {
118
  display: none !important;
119
  }
120
 
121
+ /* تعديل صندوق نص السؤال ليكون واضحاً جداً (خط أبيض وخلفية متباينة) */
122
  div[data-testid="stNotification"] {
123
+ background-color: #0f172a !important;
124
+ border: 3px solid #00f2ff !important;
125
+ border-radius: 14px !important;
126
+ box-shadow: 0 0 15px rgba(0, 242, 255, 0.3) !important;
127
  }
128
 
129
  div[data-testid="stNotification"] div[data-testid="stMarkdownContainer"] p {
130
+ color: #ffffff !important;
131
+ font-size: 26px !important;
132
  font-weight: 900 !important;
133
  }
134
 
135
+ /* تحويل نصوص الاختيارات الـ Radio إلى الأبيض الناصع والخط الكبير */
136
  div[data-testid="stRadio"] label p {
137
  color: #ffffff !important;
138
+ font-size: 24px !important;
139
+ font-weight: 900 !important;
140
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
141
  }
142
 
143
  div[data-testid="stRadio"] > label {
144
+ color: #ffd700 !important;
145
+ font-size: 22px !important;
146
+ font-weight: bold !important;
147
+ }
148
+
149
+ /* تكبير نصوص وتسميات المخططات البيانية والـ Tooltips الناشئة عند التمرير */
150
+ .vg-tooltip, .vega-bindings {
151
+ font-size: 18px !important;
152
+ font-family: 'Cairo', sans-serif !important;
153
  font-weight: bold !important;
154
  }
155
 
 
249
  "answer": "أ) مواقع التواصل الاجتماعي"
250
  },
251
  {
252
+ "question": "السؤال الثالث: ماذا تعني كلمة Velocity في البيانات الضخمة؟ ⚡",
253
  "options": ["أ) سرعة البيانات", "ب) لون البيانات", "ج) شكل البيانات"],
254
  "answer": "أ) سرعة البيانات"
255
  },
 
323
  title_topic = st.session_state.display_content
324
  user_label = "ماذا سنتعلم في لعبة البيانات الضخمة؟" if title_topic == "ماذا سنتعلم" else f"أريد معرفة معلومات عن: {title_topic}"
325
 
 
326
  st.session_state.chat_history = []
 
327
  st.session_state.chat_history.append({"role": "user", "text": user_label})
328
  st.session_state.chat_history.append({"role": "bot", "text": DATA[title_topic]})
329
  st.session_state.display_content = "chat"
 
331
 
332
  # عرض التحدي والاختبار
333
  elif st.session_state.display_content == "quiz":
334
+ st.markdown('<div class="section-heading">🎯 التحدي والاختبار الذكي:</div>', unsafe_allow_html=True)
335
  if st.session_state.quiz_index < len(QUIZ_DATA):
336
  q = QUIZ_DATA[st.session_state.quiz_index]
337
 
338
  st.info(q["question"])
339
+
340
+ # إضافة خيار وهمي بالبداية لمنع تفعيل الخيار الأول تلقائياً قبل ضغط الطالب
341
+ quiz_options = ["اضغط على الاختيار المناسب بالأسفل..."] + q["options"]
342
+
343
+ user_ans = st.radio(
344
+ "اختر إجابتك الصحيحة من الأسفل 👇:",
345
+ quiz_options,
346
+ index=0,
347
+ key=f"quiz_radio_{st.session_state.quiz_index}"
348
+ )
349
 
350
  if st.button("🚀 تأكيد الإجابة والتحقق"):
351
+ if user_ans == "اضغط على الاختيار المناسب بالأسفل...":
352
+ st.warning("⚠️ من فضلك اختر إجابة أولاً قبل التأكيد يا بطل!")
 
353
  else:
354
+ if user_ans == q["answer"]:
355
+ st.session_state.score += 1
356
+ st.success("🎉 إجابة صحيحة وممتازة يا بطل الكنز! أحسنت 🔥")
357
+ else:
358
+ st.error("🦾 حاول بتركيز أكبر في السؤال القادم!")
359
+ st.session_state.quiz_index += 1
360
+ st.rerun()
361
  else:
362
  if st.session_state.score == len(QUIZ_DATA):
363
  st.balloons()
 
370
  st.session_state.score = 0
371
  st.rerun()
372
 
373
+ # عرض الإحصائيات (معدلة ومكبرة بالكامل لتناسب جينالي)
374
  elif st.session_state.display_content == "stats":
375
+ st.markdown('<div class="section-heading">📊 لوحة الإحصائيات والنسب العالمية</div>', unsafe_allow_html=True)
376
+ st.markdown('<p style="font-size: 24px !important; font-weight: bold; margin-bottom: 20px;">نسبة اعتماد القطاعات الحيوية المختلفة على تقنيات البيانات الضخمة في العالم الرقمي:</p>', unsafe_allow_html=True)
377
 
378
  chart_values = [95, 88, 92, 90]
379
  chart_index = ["الطب", "التعليم", "البنوك", "التجارة"]
 
380
  chart_data = pd.DataFrame(chart_values, index=chart_index, columns=["النسبة"])
381
+
382
+ # تكبير خطوط المخطط والتلميحات الذكية Tooltips لتناسب جينالي وعيون الطلاب
383
+ st.bar_chart(chart_data, use_container_width=True)
384
+
385
+ st.markdown("""
386
+ <style>
387
+ /* كود مخصص لتكبير وتوضيح قراءات المخطط عند تحريك الماوس فوق الأعمدة */
388
+ div[data-testid="stVegaLiteChart"] text {
389
+ font-size: 16px !important;
390
+ font-weight: bold !important;
391
+ fill: #ffffff !important;
392
+ }
393
+ </style>
394
+ """, unsafe_allow_html=True)
395
 
396
  # =====================================================
397
  # 5. عناصر القائمة الجانبية (Sidebar)