Dannyar608 commited on
Commit
1f35899
·
verified ·
1 Parent(s): 445f534

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +141 -33
app.py CHANGED
@@ -75,6 +75,114 @@ if HF_TOKEN:
75
  logger.error(f"Attempt {attempt + 1} failed to initialize Hugging Face API: {str(e)}")
76
  time.sleep(2 ** attempt) # Exponential backoff
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  # ========== ENHANCED MODEL LOADER ==========
79
  class ModelLoader:
80
  def __init__(self):
@@ -2577,12 +2685,9 @@ def create_enhanced_interface():
2577
  results.append("\n**Safety Schools:**")
2578
  results.extend([f"- {school}" for school in college_recs['safety'][:3]])
2579
 
2580
- # Store all analysis results
2581
- parsed_data['analysis'] = {
2582
- 'gpa_analysis': gpa_analysis,
2583
- 'grad_status': grad_status,
2584
- 'college_recs': college_recs
2585
- }
2586
 
2587
  # Update visualizations
2588
  viz_updates = [
@@ -2880,25 +2985,6 @@ def create_enhanced_interface():
2880
  outputs=goal_target_value
2881
  )
2882
 
2883
- # Add goal functionality
2884
- add_goal_btn.click(
2885
- fn=lambda gt, desc, date, val: (
2886
- goal_tracker.add_goal(name.value, gt, desc, date.isoformat(), val),
2887
- update_goals_display(name.value)
2888
- ),
2889
- inputs=[goal_type, goal_description, goal_target_date, goal_target_value],
2890
- outputs=[goals_output, goal_viz]
2891
- )
2892
-
2893
- # Generate calendar functionality
2894
- generate_calendar_btn.click(
2895
- fn=lambda date: (
2896
- update_calendar_display(name.value, date)
2897
- ),
2898
- inputs=calendar_start_date,
2899
- outputs=[calendar_output, calendar_viz]
2900
- )
2901
-
2902
  def update_goals_display(profile_name):
2903
  goals = goal_tracker.get_goals(profile_name)
2904
  if not goals:
@@ -2980,15 +3066,37 @@ def create_enhanced_interface():
2980
  "\n".join(calendar_html) if calendar_html else "<div class='alert-box'>No study sessions scheduled yet</div>",
2981
  gr.update(visible=study_calendar.create_calendar_visualization(calendar) is not None)
2982
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2983
 
2984
  # Navigation logic
2985
- def navigate_to_tab(tab_index: int, tab_completed_status):
2986
- current_tab = tabs.selected
2987
-
2988
- if tab_index <= current_tab:
2989
- return gr.Tabs(selected=tab_index), gr.update(visible=False)
2990
-
2991
- # Check all previous tabs are completed
2992
  for i in range(tab_index):
2993
  if not tab_completed_status.get(i, False):
2994
  messages = [
@@ -2999,7 +3107,7 @@ def create_enhanced_interface():
2999
  "Please complete the previous steps first"
3000
  ]
3001
  return (
3002
- gr.Tabs(selected=i),
3003
  gr.update(
3004
  value=f"<div class='error-message'>⛔ {messages[i]}</div>",
3005
  visible=True
 
75
  logger.error(f"Attempt {attempt + 1} failed to initialize Hugging Face API: {str(e)}")
76
  time.sleep(2 ** attempt) # Exponential backoff
77
 
78
+ # ========== LEARNING STYLE QUIZ ==========
79
+ class LearningStyleQuiz:
80
+ def __init__(self):
81
+ self.questions = [
82
+ "When learning something new, I prefer to:",
83
+ "I remember information best when I:",
84
+ "When giving directions, I:",
85
+ "When I'm bored, I tend to:",
86
+ "When learning a new skill, I prefer to:",
87
+ "When studying, I like to:",
88
+ "I prefer teachers who:",
89
+ "When solving problems, I:"
90
+ ]
91
+
92
+ self.options = [
93
+ ["See diagrams and charts", "Listen to explanations", "Read about it", "Try it out hands-on"],
94
+ ["See pictures or diagrams", "Hear someone explain it", "Read about it", "Do something physical with it"],
95
+ ["Draw a map", "Give verbal instructions", "Write down directions", "Demonstrate or guide physically"],
96
+ ["Doodle or look around", "Talk to myself or others", "Read or imagine things", "Fidget or move around"],
97
+ ["Watch demonstrations", "Listen to instructions", "Read instructions", "Jump in and try it"],
98
+ ["Use highlighters and diagrams", "Discuss with others", "Read and take notes", "Move around or use objects"],
99
+ ["Use visual aids", "Give interesting lectures", "Provide reading materials", "Include hands-on activities"],
100
+ ["Draw pictures or diagrams", "Talk through options", "Make lists", "Try different solutions physically"]
101
+ ]
102
+
103
+ self.learning_styles = {
104
+ 'visual': "**Visual** learners prefer seeing information in charts, diagrams, and pictures.",
105
+ 'auditory': "**Auditory** learners prefer hearing information spoken and learn best through lectures and discussions.",
106
+ 'reading/writing': "**Reading/Writing** learners prefer information displayed as words and learn best through reading and note-taking.",
107
+ 'kinesthetic': "**Kinesthetic** learners prefer physical experience and learn best through hands-on activities and movement."
108
+ }
109
+
110
+ def evaluate_quiz(self, *answers):
111
+ """Evaluate quiz answers and determine learning style"""
112
+ if not answers or any(a is None for a in answers):
113
+ raise gr.Error("Please answer all questions before submitting")
114
+
115
+ style_counts = {
116
+ 'visual': 0,
117
+ 'auditory': 0,
118
+ 'reading/writing': 0,
119
+ 'kinesthetic': 0
120
+ }
121
+
122
+ # Map each answer to a learning style
123
+ for answer in answers:
124
+ if answer.startswith("See") or answer.startswith("Draw") or answer.startswith("Watch") or "diagram" in answer.lower():
125
+ style_counts['visual'] += 1
126
+ elif answer.startswith("Listen") or answer.startswith("Hear") or answer.startswith("Talk") or "lecture" in answer.lower():
127
+ style_counts['auditory'] += 1
128
+ elif answer.startswith("Read") or "note" in answer.lower() or "write" in answer.lower():
129
+ style_counts['reading/writing'] += 1
130
+ elif answer.startswith("Try") or "physical" in answer.lower() or "hands-on" in answer.lower():
131
+ style_counts['kinesthetic'] += 1
132
+
133
+ primary_style = max(style_counts, key=style_counts.get)
134
+ secondary_styles = sorted(style_counts.items(), key=lambda x: x[1], reverse=True)[1:3]
135
+
136
+ # Generate results
137
+ result = [
138
+ "## 🎯 Your Learning Style Results",
139
+ f"Your primary learning style is **{primary_style.capitalize()}**",
140
+ self.learning_styles[primary_style],
141
+ "",
142
+ "### Tips for Your Learning Style:"
143
+ ]
144
+
145
+ if primary_style == 'visual':
146
+ result.extend([
147
+ "- Use color coding in your notes",
148
+ "- Create mind maps and diagrams",
149
+ "- Watch educational videos to visualize concepts",
150
+ "- Highlight or underline important information"
151
+ ])
152
+ elif primary_style == 'auditory':
153
+ result.extend([
154
+ "- Record lectures and listen to them",
155
+ "- Explain concepts out loud to yourself",
156
+ "- Participate in study groups",
157
+ "- Use rhymes or songs to remember information"
158
+ ])
159
+ elif primary_style == 'reading/writing':
160
+ result.extend([
161
+ "- Write detailed summaries in your own words",
162
+ "- Create question-answer sets for each topic",
163
+ "- Rewrite your notes to reinforce learning",
164
+ "- Read textbooks and articles on the subject"
165
+ ])
166
+ elif primary_style == 'kinesthetic':
167
+ result.extend([
168
+ "- Use hands-on activities when possible",
169
+ "- Study while moving or pacing",
170
+ "- Create physical models to represent concepts",
171
+ "- Take frequent short breaks to move around"
172
+ ])
173
+
174
+ result.extend([
175
+ "",
176
+ "### Secondary Learning Styles:",
177
+ f"1. {secondary_styles[0][0].capitalize()}",
178
+ f"2. {secondary_styles[1][0].capitalize()}"
179
+ ])
180
+
181
+ return "\n".join(result)
182
+
183
+ # Initialize learning style quiz
184
+ learning_style_quiz = LearningStyleQuiz()
185
+
186
  # ========== ENHANCED MODEL LOADER ==========
187
  class ModelLoader:
188
  def __init__(self):
 
2685
  results.append("\n**Safety Schools:**")
2686
  results.extend([f"- {school}" for school in college_recs['safety'][:3]])
2687
 
2688
+ if gpa_analysis.get('improvement_tips'):
2689
+ results.append("\n**Improvement Tips:**")
2690
+ results.extend([f"- {tip}" for tip in gpa_analysis['improvement_tips']])
 
 
 
2691
 
2692
  # Update visualizations
2693
  viz_updates = [
 
2985
  outputs=goal_target_value
2986
  )
2987
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2988
  def update_goals_display(profile_name):
2989
  goals = goal_tracker.get_goals(profile_name)
2990
  if not goals:
 
3066
  "\n".join(calendar_html) if calendar_html else "<div class='alert-box'>No study sessions scheduled yet</div>",
3067
  gr.update(visible=study_calendar.create_calendar_visualization(calendar) is not None)
3068
  )
3069
+
3070
+ # Add goal functionality
3071
+ add_goal_btn.click(
3072
+ fn=lambda gt, desc, date, val: (
3073
+ goal_tracker.add_goal(name.value, gt, desc, date.isoformat(), val),
3074
+ update_goals_display(name.value)
3075
+ ),
3076
+ inputs=[goal_type, goal_description, goal_target_date, goal_target_value],
3077
+ outputs=[goals_output, goal_viz]
3078
+ ).then(
3079
+ fn=lambda: name.value,
3080
+ inputs=None,
3081
+ outputs=None
3082
+ ).then(
3083
+ fn=update_goals_display,
3084
+ inputs=name,
3085
+ outputs=[goals_output, goal_viz]
3086
+ )
3087
+
3088
+ # Generate calendar functionality
3089
+ generate_calendar_btn.click(
3090
+ fn=lambda date: (
3091
+ update_calendar_display(name.value, date)
3092
+ ),
3093
+ inputs=calendar_start_date,
3094
+ outputs=[calendar_output, calendar_viz]
3095
+ )
3096
 
3097
  # Navigation logic
3098
+ def navigate_to_tab(tab_index: int, tab_completed_status: dict):
3099
+ # Check if all previous tabs are completed
 
 
 
 
 
3100
  for i in range(tab_index):
3101
  if not tab_completed_status.get(i, False):
3102
  messages = [
 
3107
  "Please complete the previous steps first"
3108
  ]
3109
  return (
3110
+ gr.Tabs(selected=i), # Go to first incomplete tab
3111
  gr.update(
3112
  value=f"<div class='error-message'>⛔ {messages[i]}</div>",
3113
  visible=True