Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,13 @@ except Exception as e:
|
|
| 18 |
print(f"Error loading question generator: {e}")
|
| 19 |
question_generator = None
|
| 20 |
|
| 21 |
-
# Initialize user stats
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
if not os.path.exists("user_score.txt"):
|
| 23 |
with open("user_score.txt", "w") as f:
|
| 24 |
f.write("0")
|
|
@@ -139,6 +145,13 @@ def generate_quiz(context, theme="dark"):
|
|
| 139 |
except Exception as e:
|
| 140 |
return f"Error generating quiz: {str(e)}", None, None
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
with gr.Blocks(title="StudyBuddy: Accessible Study Aid for Neurodiverse Students") as app:
|
| 143 |
gr.Markdown(
|
| 144 |
"""
|
|
@@ -191,6 +204,6 @@ with gr.Blocks(title="StudyBuddy: Accessible Study Aid for Neurodiverse Students
|
|
| 191 |
)
|
| 192 |
|
| 193 |
with gr.Tab("View Logs"):
|
| 194 |
-
logs_output = gr.Textbox(label="Decision Logs", value=
|
| 195 |
|
| 196 |
app.launch()
|
|
|
|
| 18 |
print(f"Error loading question generator: {e}")
|
| 19 |
question_generator = None
|
| 20 |
|
| 21 |
+
# Initialize user stats and log files
|
| 22 |
+
if not os.path.exists("decision_log.txt"):
|
| 23 |
+
with open("decision_log.txt", "w") as f:
|
| 24 |
+
f.write("Decision Log Initialized\n")
|
| 25 |
+
if not os.path.exists("feedback.txt"):
|
| 26 |
+
with open("feedback.txt", "w") as f:
|
| 27 |
+
f.write("Feedback Log Initialized\n")
|
| 28 |
if not os.path.exists("user_score.txt"):
|
| 29 |
with open("user_score.txt", "w") as f:
|
| 30 |
f.write("0")
|
|
|
|
| 145 |
except Exception as e:
|
| 146 |
return f"Error generating quiz: {str(e)}", None, None
|
| 147 |
|
| 148 |
+
def read_logs():
|
| 149 |
+
try:
|
| 150 |
+
with open("decision_log.txt", "r") as f:
|
| 151 |
+
return f.read()
|
| 152 |
+
except FileNotFoundError:
|
| 153 |
+
return "Decision log not found. It will be created once you start using the app."
|
| 154 |
+
|
| 155 |
with gr.Blocks(title="StudyBuddy: Accessible Study Aid for Neurodiverse Students") as app:
|
| 156 |
gr.Markdown(
|
| 157 |
"""
|
|
|
|
| 204 |
)
|
| 205 |
|
| 206 |
with gr.Tab("View Logs"):
|
| 207 |
+
logs_output = gr.Textbox(label="Decision Logs", value=read_logs())
|
| 208 |
|
| 209 |
app.launch()
|