Sina Media Lab
commited on
Commit
·
45705e3
1
Parent(s):
31d5315
Updates
Browse files
app.py
CHANGED
@@ -111,12 +111,14 @@ def load_modules():
|
|
111 |
with open(config_path) as f:
|
112 |
exec(f.read(), config)
|
113 |
category_title = config.get("title", category.title().replace("_", " "))
|
|
|
114 |
order = config.get("order", 100) # Default order is 100 if not specified
|
115 |
else:
|
116 |
category_title = category.title().replace("_", " ")
|
|
|
117 |
order = 100
|
118 |
|
119 |
-
modules[category_title] = {"order": order, "modules": {}}
|
120 |
for filename in os.listdir(category_dir):
|
121 |
if filename.endswith(".py") and filename != "__init__.py" and filename != "config.py":
|
122 |
module_name = filename[:-3]
|
@@ -158,11 +160,19 @@ st.sidebar.markdown(
|
|
158 |
</div>
|
159 |
""", unsafe_allow_html=True)
|
160 |
|
|
|
|
|
|
|
161 |
st.sidebar.title("Quiz Categories")
|
162 |
-
selected_category = st.sidebar.selectbox("Choose a category:", list(modules.keys()))
|
163 |
|
164 |
if selected_category:
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
for module_name, module_data in modules[selected_category].items():
|
168 |
if module_data["title"] == selected_module:
|
@@ -174,7 +184,7 @@ if selected_category:
|
|
174 |
with col1:
|
175 |
st.markdown(
|
176 |
f"""
|
177 |
-
<div style="background-color: #333; padding: 10px; border-radius: 5px; margin-top: 20px;">
|
178 |
<span style='font-size: 18px; color: white;'>{selected_category} > {selected_module_data['title']}</span>
|
179 |
</div>
|
180 |
""",
|
|
|
111 |
with open(config_path) as f:
|
112 |
exec(f.read(), config)
|
113 |
category_title = config.get("title", category.title().replace("_", " "))
|
114 |
+
category_description = config.get("description", "No description available.")
|
115 |
order = config.get("order", 100) # Default order is 100 if not specified
|
116 |
else:
|
117 |
category_title = category.title().replace("_", " ")
|
118 |
+
category_description = "No description available."
|
119 |
order = 100
|
120 |
|
121 |
+
modules[category_title] = {"order": order, "description": category_description, "modules": {}}
|
122 |
for filename in os.listdir(category_dir):
|
123 |
if filename.endswith(".py") and filename != "__init__.py" and filename != "config.py":
|
124 |
module_name = filename[:-3]
|
|
|
160 |
</div>
|
161 |
""", unsafe_allow_html=True)
|
162 |
|
163 |
+
# Get category description for tooltip
|
164 |
+
category_description = modules[selected_category]["description"]
|
165 |
+
|
166 |
st.sidebar.title("Quiz Categories")
|
167 |
+
selected_category = st.sidebar.selectbox("Choose a category:", list(modules.keys()), help=category_description)
|
168 |
|
169 |
if selected_category:
|
170 |
+
module_options = [modules[selected_category][module]["title"] for module in modules[selected_category]]
|
171 |
+
selected_module = st.sidebar.radio(
|
172 |
+
"Choose a module:",
|
173 |
+
module_options,
|
174 |
+
help=modules[selected_category]["modules"][list(modules[selected_category]["modules"].keys())[module_options.index(selected_module)]]["description"]
|
175 |
+
)
|
176 |
|
177 |
for module_name, module_data in modules[selected_category].items():
|
178 |
if module_data["title"] == selected_module:
|
|
|
184 |
with col1:
|
185 |
st.markdown(
|
186 |
f"""
|
187 |
+
<div style="background-color: #333; padding: 10px; border-radius: 5px; margin-top: 20px;" title="{category_description} > {selected_module_data['description']}">
|
188 |
<span style='font-size: 18px; color: white;'>{selected_category} > {selected_module_data['title']}</span>
|
189 |
</div>
|
190 |
""",
|