banao-tech commited on
Commit
282fafd
Β·
verified Β·
1 Parent(s): a9bc18a

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +101 -20
  2. main.py +373 -0
  3. requirements.txt +2 -3
README.md CHANGED
@@ -1,20 +1,101 @@
1
- ---
2
- title: Base Course Personalization
3
- emoji: πŸš€
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: Base Course Personalization
12
- license: apache-2.0
13
- ---
14
-
15
- # Welcome to Streamlit!
16
-
17
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
18
-
19
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Base Course Personalization
2
+
3
+ ![Banner](https://img.shields.io/badge/Streamlit-App-FF4B4B?style=for-the-badge&logo=streamlit&logoColor=white)
4
+ ![Python](https://img.shields.io/badge/Python-3.7+-blue?style=for-the-badge&logo=python&logoColor=white)
5
+
6
+ ## πŸ“š Overview
7
+
8
+ Base Course Personalization is an interactive web application that tailors educational content to match individual learning preferences. By collecting user profile information and preferences, the system generates personalized course materials optimized for each learner's unique needs.
9
+
10
+ ## ✨ Features
11
+
12
+ - **Personalized User Profiles**: Customize learning experiences based on user demographics and preferences
13
+ - **Adaptive Learning Styles**: Support for visual, auditory, and kinesthetic learning approaches
14
+ - **Language Customization**: Set your preferred language and voice settings
15
+ - **Technical Preferences**: Specify programming language preferences
16
+ - **Dark Mode Interface**: Easy-on-the-eyes interface for extended learning sessions
17
+
18
+ ## πŸš€ Quick Start
19
+
20
+ The application is hosted on Hugging Face Spaces. You can access it here:
21
+
22
+ [Launch Base Course Personalization App](https://huggingface.co/spaces/YOUR_USERNAME/base-course-personalization)
23
+
24
+ ## πŸ› οΈ Local Development
25
+
26
+ ### Prerequisites
27
+ - Python 3.7+
28
+ - Streamlit
29
+
30
+ ### Installation
31
+
32
+ 1. Clone this repository
33
+ ```bash
34
+ git clone https://github.com/yourusername/base-course-personalization.git
35
+ cd base-course-personalization
36
+ ```
37
+
38
+ 2. Install dependencies
39
+ ```bash
40
+ pip install -r requirements.txt
41
+ ```
42
+
43
+ 3. Run the application
44
+ ```bash
45
+ streamlit run main.py
46
+ ```
47
+
48
+ ## πŸ“‹ How It Works
49
+
50
+ 1. **Fill Your Profile**: Enter personal details and preferences
51
+ 2. **Specify Learning Style**: Choose your preferred learning style (visual, auditory, kinesthetic)
52
+ 3. **Set Language Preferences**: Select language settings and voice preferences
53
+ 4. **Submit**: Generate your personalized course structure
54
+ 5. **View Results**: See your personalized course outline and settings
55
+
56
+ ## πŸ”§ Technical Details
57
+
58
+ The application generates a JSON payload that can be processed by the backend learning management system to create personalized course content. Key components include:
59
+
60
+ - **User Profile**: Demographic and preference information
61
+ - **Topics**: Course structure and content links
62
+ - **Settings**: Language, voice, and technical preferences
63
+
64
+ ### API Integration
65
+
66
+ The application integrates with a personalization API that processes the user preferences and returns customized course content. The API endpoint accepts POST requests with a JSON payload containing all collected user information.
67
+
68
+ ```python
69
+ # Example API call
70
+ import requests
71
+
72
+ response = requests.post(
73
+ "https://api.example.com/personalize-course",
74
+ json=payload
75
+ )
76
+ ```
77
+
78
+ Response format:
79
+ ```json
80
+ {
81
+ "success": true,
82
+ "course_id": "personalized-123",
83
+ "topics": [...]
84
+ }
85
+ ```
86
+
87
+ ## πŸ”’ Privacy
88
+
89
+ All data is processed in the browser and is not stored unless explicitly submitted to the API. Your preferences are used solely to tailor the learning experience.
90
+
91
+ ## πŸ“ License
92
+
93
+ This project is licensed under the MIT License - see the LICENSE file for details.
94
+
95
+ ## πŸ‘₯ Contact
96
+
97
+ For questions, feedback, or support, please [open an issue](https://github.com/yourusername/base-course-personalization/issues).
98
+
99
+ ---
100
+
101
+ Β© 2025 Base Course Personalization | All Rights Reserved
main.py ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import json
3
+ from datetime import datetime
4
+ import time
5
+ import requests
6
+
7
+ # API endpoint (replace with your actual endpoint)
8
+ API_ENDPOINT = "https://api.example.com/personalize-course"
9
+
10
+ # Set page configuration
11
+ st.set_page_config(
12
+ page_title="Base Course Personalization",
13
+ layout="wide",
14
+ initial_sidebar_state="collapsed",
15
+ page_icon="πŸ“š",
16
+ menu_items={
17
+ 'Get Help': None,
18
+ 'Report a bug': None,
19
+ 'About': None
20
+ }
21
+ )
22
+
23
+ # Custom CSS for dark theme styling
24
+ st.markdown("""
25
+ <style>
26
+ /* Dark theme colors */
27
+ :root {
28
+ --background-color: #1E1E1E;
29
+ --card-background: #2D2D2D;
30
+ --text-color: #E0E0E0;
31
+ --accent-color: #4F97FF;
32
+ --border-color: #444444;
33
+ --header-color: #4F97FF;
34
+ --subheader-color: #BBBBBB;
35
+ }
36
+
37
+ /* Main container styling */
38
+ .stApp {
39
+ background-color: var(--background-color);
40
+ color: var(--text-color);
41
+ }
42
+
43
+ /* Headers */
44
+ .main-header {
45
+ font-size: 2.5rem;
46
+ font-weight: 600;
47
+ color: var(--header-color);
48
+ margin-bottom: 1rem;
49
+ }
50
+
51
+ .section-header {
52
+ font-size: 1.5rem;
53
+ font-weight: 500;
54
+ color: var(--subheader-color);
55
+ margin-top: 2rem;
56
+ margin-bottom: 1rem;
57
+ padding-bottom: 0.5rem;
58
+ border-bottom: 1px solid var(--border-color);
59
+ }
60
+
61
+ /* Form container */
62
+ div[data-testid="stForm"] {
63
+ background-color: var(--card-background);
64
+ padding: 1.5rem;
65
+ border-radius: 8px;
66
+ box-shadow: 0 4px 6px rgba(0,0,0,0.3);
67
+ }
68
+
69
+ /* Button styling */
70
+ .stButton>button {
71
+ background-color: var(--accent-color);
72
+ color: white;
73
+ border-radius: 4px;
74
+ padding: 0.5rem 2rem;
75
+ font-weight: 500;
76
+ border: none;
77
+ }
78
+
79
+ /* Input fields */
80
+ div[data-baseweb="select"] > div {
81
+ background-color: var(--background-color);
82
+ border-color: var(--border-color);
83
+ }
84
+
85
+ .stTextInput > div > div > input {
86
+ background-color: var(--background-color);
87
+ color: var(--text-color);
88
+ border-color: var(--border-color);
89
+ }
90
+
91
+ .stNumberInput > div > div > input {
92
+ background-color: var(--background-color);
93
+ color: var(--text-color);
94
+ }
95
+
96
+ .stTextArea > div > div > textarea {
97
+ background-color: var(--background-color);
98
+ color: var(--text-color);
99
+ border-color: var(--border-color);
100
+ }
101
+
102
+ /* Radio buttons */
103
+ .stRadio > div {
104
+ background-color: transparent;
105
+ }
106
+
107
+ /* Spacing */
108
+ div.block-container {
109
+ padding-top: 2rem;
110
+ }
111
+
112
+ hr {
113
+ margin-top: 1rem;
114
+ margin-bottom: 1rem;
115
+ border-color: var(--border-color);
116
+ }
117
+
118
+ /* Footer */
119
+ footer {
120
+ color: #888888;
121
+ }
122
+
123
+ /* API Response Container */
124
+ .api-response {
125
+ background-color: #1A1A1A;
126
+ border-radius: 8px;
127
+ padding: 1rem;
128
+ border-left: 4px solid var(--accent-color);
129
+ }
130
+ </style>
131
+ """, unsafe_allow_html=True)
132
+
133
+ # App Header
134
+ col1, col2, col3 = st.columns([1, 3, 1])
135
+ with col2:
136
+ st.markdown('<h1 class="main-header">πŸ“š Base Course Personalization</h1>', unsafe_allow_html=True)
137
+ st.markdown("""
138
+ Complete this form to tailor your learning experience to your preferences.
139
+ Your personalized course will be generated based on the information you provide below.
140
+ """)
141
+
142
+ # Main Form
143
+ with st.form("personalization_form", clear_on_submit=False):
144
+ # Personal Information Section
145
+ st.markdown('<div class="section-header">πŸ‘€ Personal Details</div>', unsafe_allow_html=True)
146
+
147
+ col1, col2 = st.columns(2)
148
+ with col1:
149
+ user_name = st.text_input("Full Name", placeholder="Enter your full name")
150
+ user_age = st.number_input("Age", min_value=10, max_value=100, value=22)
151
+
152
+ with col2:
153
+ user_gender = st.selectbox(
154
+ "Gender",
155
+ ["male", "female", "other"],
156
+ index=0,
157
+ format_func=lambda x: x.capitalize()
158
+ )
159
+ tech_knowledge = st.select_slider(
160
+ "Technical Knowledge",
161
+ options=["beginner", "intermediate", "advanced"],
162
+ value="beginner"
163
+ )
164
+
165
+ st.markdown('<div class="section-header">🎯 Preferences</div>', unsafe_allow_html=True)
166
+ col1, col2 = st.columns(2)
167
+
168
+ with col1:
169
+ preferred_activity = st.text_area(
170
+ "Preferred Activities",
171
+ placeholder="e.g., movies, painting, shopping",
172
+ help="Enter activities separated by commas"
173
+ )
174
+ physical_activities = st.text_area(
175
+ "Physical Activities",
176
+ placeholder="e.g., badminton, cricket, yoga",
177
+ help="Enter activities separated by commas"
178
+ )
179
+
180
+ with col2:
181
+ food = st.text_area(
182
+ "Food Preferences",
183
+ placeholder="e.g., vegetarian, paneer, pizza",
184
+ help="Enter food items separated by commas"
185
+ )
186
+
187
+ # Learning Style Section
188
+ st.markdown('<div class="section-header">πŸŽ“ Learning Preferences</div>', unsafe_allow_html=True)
189
+
190
+ learning_style = st.radio(
191
+ "Learning Style",
192
+ ["visual", "auditory", "kinesthetic"],
193
+ index=0,
194
+ help="Visual: learn by seeing, Auditory: learn by hearing, Kinesthetic: learn by doing",
195
+ horizontal=True,
196
+ format_func=lambda x: x.capitalize()
197
+ )
198
+
199
+ with st.expander("Learn more about learning styles"):
200
+ st.info("""
201
+ - **Visual learners** prefer images, diagrams, and spatial understanding
202
+ - **Auditory learners** learn best through listening and verbal instructions
203
+ - **Kinesthetic learners** prefer hands-on activities and learning by doing
204
+ """)
205
+
206
+ # Language Settings Section
207
+ st.markdown('<div class="section-header">πŸ—£οΈ Language & Voice Settings</div>', unsafe_allow_html=True)
208
+
209
+ col1, col2, col3 = st.columns(3)
210
+ with col1:
211
+ target_language = st.selectbox(
212
+ "Target Language",
213
+ ["english", "hindi", "telugu", "tamil", "other"],
214
+ index=0,
215
+ format_func=lambda x: x.capitalize()
216
+ )
217
+
218
+ with col2:
219
+ tts_gender = st.selectbox(
220
+ "Voice Gender",
221
+ ["male", "female"],
222
+ index=0,
223
+ format_func=lambda x: x.capitalize()
224
+ )
225
+
226
+ with col3:
227
+ tts_voice = st.selectbox(
228
+ "Voice Style",
229
+ ["echo", "soprano", "alto", "robotic"],
230
+ index=0,
231
+ format_func=lambda x: x.capitalize()
232
+ )
233
+
234
+ toggle_hinglish = st.toggle("Enable Hinglish", value=True, help="Mix of Hindi and English")
235
+
236
+ # Course Settings Section
237
+ st.markdown('<div class="section-header">πŸ’» Technical Preferences</div>', unsafe_allow_html=True)
238
+
239
+ programming_language = st.selectbox(
240
+ "Programming Language",
241
+ ["python", "java", "javascript", "c++", "go"],
242
+ index=0,
243
+ format_func=lambda x: x.capitalize()
244
+ )
245
+
246
+ # Show sample lesson structure
247
+ with st.expander("πŸ“‹ Sample Course Structure"):
248
+ st.markdown("""
249
+ ### Introduction to Flask
250
+ 1. What is Flask
251
+ 2. Setting Up Flask Environment
252
+ 3. Understanding Flask Project Structure
253
+ """)
254
+
255
+ # Submit button
256
+ st.markdown("<br>", unsafe_allow_html=True)
257
+ col1, col2, col3 = st.columns([1, 2, 1])
258
+ with col2:
259
+ submitted = st.form_submit_button("Generate Personalized Course", use_container_width=True)
260
+
261
+ # Handle submission
262
+ if submitted:
263
+ # Validate inputs
264
+ if not user_name:
265
+ st.error("Please enter your name")
266
+ elif not preferred_activity:
267
+ st.warning("Adding preferred activities will help us personalize your content better")
268
+ else:
269
+ # Show loading state
270
+ with st.spinner("Generating your personalized course..."):
271
+ time.sleep(1.5) # Simulating API call delay
272
+
273
+ # Create payload
274
+ payload = {
275
+ "personalization_id": 100,
276
+ "user_id": 30,
277
+ "course_id": 47,
278
+ "total_videos": 3,
279
+ "created_at": datetime.utcnow().isoformat(),
280
+ "user_profile": {
281
+ "personalized": True,
282
+ "user_name": user_name,
283
+ "user_age": user_age,
284
+ "user_gender": user_gender,
285
+ "user_tech_knowledge": tech_knowledge,
286
+ "user_preferred_activity": preferred_activity,
287
+ "user_food": food,
288
+ "user_physical_activities": physical_activities,
289
+ "learning_style": learning_style,
290
+ "target_language": target_language,
291
+ "tts_gender": tts_gender,
292
+ "tts_voice": tts_voice,
293
+ "toggle_hinglish": toggle_hinglish,
294
+ "run_visualization": False,
295
+ "subtitle": "",
296
+ "age_group": "18-25",
297
+ },
298
+ "topics": [
299
+ {
300
+ "topic_id": 10834,
301
+ "topic_title": "Setting Up Flask Environment",
302
+ "chapter_id": 647,
303
+ "chapter_title": "Introduction to Flask",
304
+ "course_id": 47,
305
+ "video_url": "https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/1729064365.mp4",
306
+ "video_duration": 462,
307
+ "sequence_number": 2
308
+ },
309
+ {
310
+ "topic_id": 10835,
311
+ "topic_title": "Understanding Flask Project Structure",
312
+ "chapter_id": 647,
313
+ "chapter_title": "Introduction to Flask",
314
+ "course_id": 47,
315
+ "video_url": "https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/1729064412.mp4",
316
+ "video_duration": 429,
317
+ "sequence_number": 3
318
+ },
319
+ {
320
+ "topic_id": 10833,
321
+ "topic_title": "What is Flask",
322
+ "chapter_id": 647,
323
+ "chapter_title": "Introduction to Flask",
324
+ "course_id": 47,
325
+ "video_url": "https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/1729064322.mp4",
326
+ "video_duration": 410,
327
+ "sequence_number": 1
328
+ }
329
+ ],
330
+ "settings": {
331
+ "target_language": target_language,
332
+ "tts_gender": tts_gender,
333
+ "tts_voice": tts_voice,
334
+ "toggle_hinglish": toggle_hinglish,
335
+ "run_visualization": False,
336
+ "subtitle": "",
337
+ "programming_language": programming_language,
338
+ }
339
+ }
340
+
341
+ # Make API call
342
+ try:
343
+ response = requests.post(API_ENDPOINT, json=payload)
344
+
345
+ if response.status_code == 200:
346
+ st.success(f"Course personalized successfully for {user_name}!")
347
+
348
+ # Display results in a clean format
349
+ st.markdown("### πŸŽ‰ Your personalized course is ready!")
350
+ st.markdown(f"""
351
+ **Course**: Introduction to Flask
352
+ **Programming Language**: {programming_language.capitalize()}
353
+ **Learning Style**: {learning_style.capitalize()}
354
+ **Voice**: {tts_voice.capitalize()} ({tts_gender.capitalize()})
355
+ """)
356
+
357
+ # Display API response
358
+ st.markdown('<div class="section-header">🌍 API Response</div>', unsafe_allow_html=True)
359
+ st.markdown('<div class="api-response">', unsafe_allow_html=True)
360
+ st.json(response.json())
361
+ st.markdown('</div>', unsafe_allow_html=True)
362
+ else:
363
+ st.error(f"API Error: {response.status_code} - {response.text}")
364
+ except Exception as e:
365
+ st.error(f"API call failed: {e}")
366
+
367
+ # Show local payload as fallback
368
+ st.warning("Using local data as fallback:")
369
+ st.json(payload)
370
+
371
+ # Footer
372
+ st.markdown("---")
373
+ st.caption("Β© 2025 Base Course Personalization | All Rights Reserved")
requirements.txt CHANGED
@@ -1,3 +1,2 @@
1
- altair
2
- pandas
3
- streamlit
 
1
+ streamlit
2
+ requests