Sina Media Lab commited on
Commit
bacb566
·
1 Parent(s): eda0b5b
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -39,12 +39,10 @@ def generate_pdf_report():
39
 
40
  # Title of the report
41
  pdf.cell(0, 10, txt="Magic Math Quiz", ln=True, align="C")
42
- pdf.set_font("Arial", size=10)
43
- pdf.cell(0, 10, txt="by Ghassem Tofighi", ln=True, align="C", link="https://ghassem.com")
44
  pdf.ln(5)
45
 
46
- # Load the image from the local directory
47
- pdf.image("assets/gt.png", x=80, w=50, link="https://ghassem.com")
48
  pdf.ln(10)
49
 
50
  for i, entry in enumerate(st.session_state.questions):
@@ -112,20 +110,24 @@ def load_modules():
112
  with open(config_path) as f:
113
  exec(f.read(), config)
114
  category_title = config.get("title", category.title().replace("_", " "))
 
115
  else:
116
  category_title = category.title().replace("_", " ")
 
117
 
118
- modules[category_title] = {}
119
  for filename in os.listdir(category_dir):
120
  if filename.endswith(".py") and filename != "__init__.py" and filename != "config.py":
121
  module_name = filename[:-3]
122
  module = __import__(f"{category_dir.replace('/', '.')}.{module_name}", fromlist=[''])
123
- modules[category_title][module_name] = {
124
  "title": getattr(module, "title", module_name.replace("_", " ").title()),
125
  "description": getattr(module, "description", "No description available."),
126
  "generate_question": module.generate_question # Access the generate_question function
127
  }
128
- return modules
 
 
129
 
130
  def generate_new_question(category_name, module_name, module):
131
  question_data = module['generate_question']()
@@ -149,13 +151,11 @@ st.sidebar.markdown(
149
  """
150
  <div style='background-color: white; padding: 10px; border-radius: 10px; text-align: center; color: black;'>
151
  <h1 style='margin: 0;'>🪄 Magic Math Quiz!</h1>
152
- <a href="https://ghassem.com" target="_blank">
153
- <img src="assets/gt.png" alt="Logo" style="width:40%; border-radius: 5px;">
154
- </a>
155
- <h6 style='margin: 0; font-size: 10px;'><a href="https://ghassem.com" target="_blank" style="color: black; text-decoration: none;'>By Ghassem Tofighi</a></h6>
156
- </div>
157
  """, unsafe_allow_html=True)
158
 
 
 
 
159
  st.sidebar.title("Quiz Categories")
160
  selected_category = st.sidebar.selectbox("Choose a category:", list(modules.keys()))
161
 
 
39
 
40
  # Title of the report
41
  pdf.cell(0, 10, txt="Magic Math Quiz", ln=True, align="C")
 
 
42
  pdf.ln(5)
43
 
44
+ # Load the image from the local directory, scaled down
45
+ pdf.image("assets/gt.png", x=90, w=25, link="https://ghassem.com") # Adjust the size and position as needed
46
  pdf.ln(10)
47
 
48
  for i, entry in enumerate(st.session_state.questions):
 
110
  with open(config_path) as f:
111
  exec(f.read(), config)
112
  category_title = config.get("title", category.title().replace("_", " "))
113
+ order = config.get("order", 100) # Default order is 100 if not specified
114
  else:
115
  category_title = category.title().replace("_", " ")
116
+ order = 100
117
 
118
+ modules[category_title] = {"order": order, "modules": {}}
119
  for filename in os.listdir(category_dir):
120
  if filename.endswith(".py") and filename != "__init__.py" and filename != "config.py":
121
  module_name = filename[:-3]
122
  module = __import__(f"{category_dir.replace('/', '.')}.{module_name}", fromlist=[''])
123
+ modules[category_title]["modules"][module_name] = {
124
  "title": getattr(module, "title", module_name.replace("_", " ").title()),
125
  "description": getattr(module, "description", "No description available."),
126
  "generate_question": module.generate_question # Access the generate_question function
127
  }
128
+ # Sort categories by the order value
129
+ sorted_categories = sorted(modules.items(), key=lambda x: x[1]['order'])
130
+ return {category: data["modules"] for category, data in sorted_categories}
131
 
132
  def generate_new_question(category_name, module_name, module):
133
  question_data = module['generate_question']()
 
151
  """
152
  <div style='background-color: white; padding: 10px; border-radius: 10px; text-align: center; color: black;'>
153
  <h1 style='margin: 0;'>🪄 Magic Math Quiz!</h1>
 
 
 
 
 
154
  """, unsafe_allow_html=True)
155
 
156
+ # Display the local image using st.image
157
+ st.sidebar.image("assets/gt.png", use_column_width=True, caption="By Ghassem Tofighi")
158
+
159
  st.sidebar.title("Quiz Categories")
160
  selected_category = st.sidebar.selectbox("Choose a category:", list(modules.keys()))
161