-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
3686 lines (3329 loc) · 144 KB
/
app.py
File metadata and controls
3686 lines (3329 loc) · 144 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import json
import datetime
import random
from flask import Flask, render_template, request, redirect, url_for, jsonify, session, abort, Blueprint
from ai_routes import ai_bp
from firebase_routes import firebase_routes, send_email
import firebase_admin
from firebase_admin import credentials, firestore
import uuid
# Add email functionality imports
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Try to import from our initialization module
try:
from db_init import db, is_firebase_available
except ImportError:
# Fall back to a local initialization if import fails
is_firebase_available = lambda: False
db = None
app = Flask(__name__)
# Register the AI Blueprint
app.register_blueprint(ai_bp, url_prefix='/ai')
app.register_blueprint(firebase_routes, url_prefix='/api')
# Set a secret key for session management
app.secret_key = 'your_secret_key_here' # This should be a secure random key in production
# Temporary storage for verification codes (in production, use Redis or database)
verification_codes = {}
# Function to send email with verification code
def send_verification_email(email, verification_code):
"""Send verification code via email"""
try:
# Create email message
msg = MIMEMultipart()
msg['From'] = "sciwebbot@gmail.com"
msg['To'] = email
msg['Subject'] = "SciWeb 3.0 - Email Verification Code"
# Email body
body = f"""
Hello!
Thank you for signing up for SciWeb 3.0! To complete your registration, please enter the following verification code:
Verification Code: {verification_code}
This code will expire in 10 minutes.
If you didn't sign up for SciWeb 3.0, please ignore this email.
Best regards,
The SciWeb Team
"""
msg.attach(MIMEText(body, 'plain'))
# Use the existing send_email function from firebase_routes
return send_email(email, msg)
except Exception as e:
print(f"Error creating verification email: {e}")
return False
# Function to initialize sample class data
def init_sample_class_data():
print("Initializing sample class data...")
"""Initialize sample class data in the database if it doesn't already exist."""
if not is_firebase_available():
print("Firebase not available. Sample class data not initialized.")
return
try:
# Check if the sample class already exists
sample_class_ref = db.collection('Classes').document('sample-ap-biology')
sample_class = sample_class_ref.get()
if sample_class.exists:
print("Sample class already exists. Skipping initialization.")
return
print("Initializing sample class data...")
# Create teacher first
teacher_data = {
'id': 'teacher123',
'first_name': 'Alex',
'last_name': 'Rodriguez',
'email': 'arodriguez@school.edu',
'username': 'arod_teacher',
'password': 'teacher123', # In production, this would be hashed
'profilePicUrl': 'https://randomuser.me/api/portraits/men/44.jpg',
'grade': 'Faculty',
'userType': 'teacher',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=365),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=1),
'bio': 'PhD in Biology with 10+ years of teaching experience in AP Biology and molecular biology research.',
'settings': {
'privacy': {
'profileVisibility': 'everyone',
'webVisibility': 'everyone',
'classesVisibility': 'everyone'
},
'appearance': {
'theme': 'light',
'colorAccent': 'blue'
}
}
}
# Add teacher to Members collection
db.collection('Members').document('teacher123').set(teacher_data)
# Create sample students first
students = [
{
'id': 'student1',
'first_name': 'Emma',
'last_name': 'Thompson',
'email': 'ethompson@student.edu',
'username': 'ethompson',
'password': 'password123', # In production, this would be hashed
'profilePicUrl': 'https://randomuser.me/api/portraits/women/22.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(hours=2),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=5),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Passionate about biology and planning to study pre-med in college.',
'settings': {
'privacy': {
'profileVisibility': 'friends',
'webVisibility': 'friends',
'classesVisibility': 'friends'
},
'appearance': {
'theme': 'light',
'colorAccent': 'pink'
}
}
},
{
'id': 'student2',
'first_name': 'James',
'last_name': 'Wilson',
'email': 'jwilson@student.edu',
'username': 'jwilson',
'password': 'password123', # In production, this would be hashed
'profilePicUrl': 'https://randomuser.me/api/portraits/men/32.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(days=1),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=10),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Interested in biochemistry and molecular research.',
'settings': {
'privacy': {
'profileVisibility': 'everyone',
'webVisibility': 'friends',
'classesVisibility': 'friends'
},
'appearance': {
'theme': 'dark',
'colorAccent': 'blue'
}
}
},
{
'id': 'student3',
'first_name': 'Sophia',
'last_name': 'Lee',
'email': 'slee@student.edu',
'username': 'slee',
'password': 'password123', # In production, this would be hashed
'profilePicUrl': 'https://randomuser.me/api/portraits/women/33.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(hours=3),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=2),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Future veterinarian with a love for animal biology.',
'settings': {
'privacy': {
'profileVisibility': 'friends',
'webVisibility': 'private',
'classesVisibility': 'friends'
},
'appearance': {
'theme': 'light',
'colorAccent': 'green'
}
}
},
{
'id': 'student4',
'first_name': 'Michael',
'last_name': 'Brown',
'email': 'mbrown@student.edu',
'username': 'mbrown',
'password': 'password123', # In production, this would be hashed
'profilePicUrl': 'https://randomuser.me/api/portraits/men/55.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(hours=5),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=7),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Aspiring to study genetics and genomics.',
'settings': {
'privacy': {
'profileVisibility': 'friends',
'webVisibility': 'friends',
'classesVisibility': 'friends'
},
'appearance': {
'theme': 'dark',
'colorAccent': 'purple'
}
}
},
{
'id': 'student5',
'first_name': 'Olivia',
'last_name': 'Garcia',
'email': 'ogarcia@student.edu',
'username': 'ogarcia',
'profilePicUrl': 'https://randomuser.me/api/portraits/women/66.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(minutes=15),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(hours=1),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Interested in marine biology and environmental science.',
'settings': {
'privacy': {
'profileVisibility': 'everyone',
'webVisibility': 'everyone',
'classesVisibility': 'friends'
},
'appearance': {
'theme': 'light',
'colorAccent': 'orange'
}
}
},
{
'id': 'student6',
'first_name': 'William',
'last_name': 'Chen',
'email': 'wchen@student.edu',
'username': 'wchen',
'profilePicUrl': 'https://randomuser.me/api/portraits/men/77.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(days=2),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=15),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Planning to pursue biotechnology and bioengineering.',
'settings': {
'privacy': {
'profileVisibility': 'friends',
'webVisibility': 'friends',
'classesVisibility': 'private'
},
'appearance': {
'theme': 'dark',
'colorAccent': 'blue'
}
}
},
{
'id': 'student7',
'first_name': 'Ava',
'last_name': 'Patel',
'email': 'apatel@student.edu',
'username': 'apatel',
'profilePicUrl': 'https://randomuser.me/api/portraits/women/45.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(hours=4),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=3),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Fascinated by microbiology and infectious diseases.',
'settings': {
'privacy': {
'profileVisibility': 'friends',
'webVisibility': 'friends',
'classesVisibility': 'friends'
},
'appearance': {
'theme': 'light',
'colorAccent': 'pink'
}
}
},
{
'id': 'student8',
'first_name': 'Noah',
'last_name': 'Johnson',
'email': 'njohnson@student.edu',
'username': 'njohnson',
'profilePicUrl': 'https://randomuser.me/api/portraits/men/15.jpg',
'grade': '11th Grade',
'lastActive': datetime.datetime.now() - datetime.timedelta(hours=1),
'createdAt': datetime.datetime.now() - datetime.timedelta(days=120),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=1),
'role': 'student',
'status': 'active',
'userType': 'student',
'bio': 'Exploring the intersection of biology and computer science.',
'settings': {
'privacy': {
'profileVisibility': 'everyone',
'webVisibility': 'friends',
'classesVisibility': 'everyone'
},
'appearance': {
'theme': 'dark',
'colorAccent': 'green'
}
}
}
]
# Add students to Members collection
for student in students:
student_id = student['id']
db.collection('Members').document(student_id).set(student)
# Create a sample class
class_data = {
'id': 'sample-ap-biology',
'name': 'AP Biology',
'description': 'Advanced Placement Biology - An in-depth study of the fundamental concepts in biology, with emphasis on cellular processes, genetics, evolution, and ecology.',
'teacherId': 'teacher123',
'teacherName': 'Dr. Alex Rodriguez',
'teacherEmail': 'arodriguez@school.edu',
'teacherProfilePic': 'https://randomuser.me/api/portraits/men/44.jpg',
'teacherOfficeHours': [
'Monday: 3:00 PM - 4:30 PM',
'Wednesday: 2:00 PM - 3:30 PM',
'Friday: By appointment'
],
'period': '2nd Period (10:15 AM - 11:45 AM)',
'yearGroup': '11-12',
'subject': 'Science',
'studentCount': 28,
'createdAt': datetime.datetime.now(),
'updatedAt': datetime.datetime.now(),
'syllabus': 'This course covers fundamental concepts in molecular biology and genetics, with an emphasis on recent discoveries and research methods. Students will learn about DNA structure and replication, gene expression, protein synthesis, and the regulation of cellular processes. Laboratory sessions will provide hands-on experience with techniques such as PCR, gel electrophoresis, and microscopy. The course also explores ethical implications of genetic research and biotechnology applications.',
'syllabusFileUrl': '',
'members': [
{
'userId': 'teacher123',
'role': 'teacher',
'joinedAt': datetime.datetime.now(),
'status': 'active'
},
{
'userId': 'student1',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=80),
'status': 'active'
},
{
'userId': 'student2',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=80),
'status': 'active'
},
{
'userId': 'student3',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=79),
'status': 'active'
},
{
'userId': 'student4',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=79),
'status': 'active'
},
{
'userId': 'student5',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=78),
'status': 'active'
},
{
'userId': 'student6',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=78),
'status': 'active'
},
{
'userId': 'student7',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=77),
'status': 'active'
},
{
'userId': 'student8',
'role': 'student',
'joinedAt': datetime.datetime.now() - datetime.timedelta(days=77),
'status': 'active'
}
],
'channels': [
{
'id': 'general',
'name': 'general',
'description': 'General class discussion',
'type': 'general',
'createdAt': datetime.datetime.now(),
'createdBy': 'teacher123',
'isPrivate': False,
'allowedMembers': []
},
{
'id': 'questions',
'name': 'questions',
'description': 'Ask questions about class material',
'type': 'help',
'createdAt': datetime.datetime.now(),
'createdBy': 'teacher123',
'isPrivate': False,
'allowedMembers': []
},
{
'id': 'resources',
'name': 'resources',
'description': 'Share helpful resources',
'type': 'resources',
'createdAt': datetime.datetime.now(),
'createdBy': 'teacher123',
'isPrivate': False,
'allowedMembers': []
},
{
'id': 'lab_partners',
'name': 'lab_partners',
'description': 'Coordinate with your lab partners',
'type': 'team',
'createdAt': datetime.datetime.now(),
'createdBy': 'teacher123',
'isPrivate': False,
'allowedMembers': []
},
{
'id': 'announcements',
'name': 'announcements',
'description': 'Important class announcements',
'type': 'announcement',
'createdAt': datetime.datetime.now(),
'createdBy': 'teacher123',
'isPrivate': False,
'allowedMembers': []
}
],
'units': [
{
'id': 'unit1',
'title': 'Molecular Biology Fundamentals',
'description': 'An exploration of DNA structure, replication, and protein synthesis',
'position': 1,
'status': 'active',
'startDate': datetime.datetime.now(),
'endDate': datetime.datetime.now() + datetime.timedelta(days=30),
'progress': 65,
'topics': [
'DNA Structure and Organization',
'Replication Mechanisms',
'Transcription and RNA Processing',
'Translation and Protein Synthesis',
'Gene Regulation'
],
'current_topic': 'Translation and Protein Synthesis',
'associatedFiles': [],
'associatedProblems': []
},
{
'id': 'unit2',
'title': 'Cell Structure and Function',
'description': 'Understanding cellular components and their roles in maintaining life',
'position': 2,
'status': 'upcoming',
'startDate': datetime.datetime.now() + datetime.timedelta(days=31),
'endDate': datetime.datetime.now() + datetime.timedelta(days=60),
'progress': 0,
'topics': [
'Cell Membrane Structure',
'Organelles and Their Functions',
'Cellular Transport',
'Cell Communication',
'Cell Cycle and Division'
],
'current_topic': '',
'associatedFiles': [],
'associatedProblems': []
}
],
'settings': {
'joinCode': 'BIO2025',
'visibility': 'school',
'gradingSystem': {
'A': 90,
'B': 80,
'C': 70,
'D': 60,
'F': 0
}
},
'recentActivities': [
{
'id': 'a1',
'text': 'Lab Report: DNA Extraction graded (92%)',
'time': '2 hours ago',
'timestamp': datetime.datetime.now() - datetime.timedelta(hours=2),
'icon': 'fas fa-flask',
'type': 'grade',
'userId': 'teacher123'
},
{
'id': 'a2',
'text': 'Dr. Rodriguez posted new lecture slides',
'time': 'Yesterday',
'timestamp': datetime.datetime.now() - datetime.timedelta(days=1),
'icon': 'fas fa-file-powerpoint',
'type': 'resource',
'userId': 'teacher123'
},
{
'id': 'a3',
'text': 'New assignment posted: Protein Synthesis Diagram',
'time': '2 days ago',
'timestamp': datetime.datetime.now() - datetime.timedelta(days=2),
'icon': 'fas fa-tasks',
'type': 'assignment',
'userId': 'teacher123'
}
],
'stats': {
'assignments': 14,
'resources': 26,
'discussions': 72,
'average_grade': '89%'
}
}
# Note: Students are already added to class members array above
# Add the class to Firestore
sample_class_ref.set(class_data)
# Create sample assignments
assignments = [
{
'id': 'as1',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Protein Synthesis Diagram',
'description': 'Create a detailed diagram showing the process of protein synthesis, including transcription and translation steps.',
'type': 'project',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=5),
'due_date': 'Oct 15, 2025',
'time_left': '5 days left',
'points': 50,
'weight': 0.1,
'status': 'not_started',
'visibleToStudents': True,
'allowed_formats': 'PDF, JPG, PNG',
'resources': ['Lecture 4 Slides', 'Chapter 7 in textbook'],
'submissions': {
'count': 0,
'graded': 0,
'average': 0
}
},
{
'id': 'as2',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Gene Expression Problem Set',
'description': 'Complete the problem set on gene expression regulation and feedback mechanisms.',
'type': 'homework',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=8),
'due_date': 'Oct 18, 2025',
'time_left': '8 days left',
'points': 25,
'weight': 0.05,
'status': 'in_progress',
'visibleToStudents': True,
'allowed_formats': 'PDF',
'resources': ['Problem Set PDF', 'Chapter 8 in textbook'],
'submissions': {
'count': 0,
'graded': 0,
'average': 0
}
},
{
'id': 'as3',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'DNA Replication Quiz',
'description': 'Online quiz covering DNA replication, enzymes involved, and proofreading mechanisms.',
'type': 'quiz',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=12),
'due_date': 'Oct 22, 2025',
'time_left': '12 days left',
'points': 30,
'weight': 0.05,
'status': 'not_started',
'visibleToStudents': True,
'time_limit': '30 minutes',
'resources': ['Lecture 3 Slides', 'Study Guide'],
'submissions': {
'count': 0,
'graded': 0,
'average': 0
}
},
{
'id': 'as4',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Genetic Disorders Research Paper',
'description': 'Write a 5-page research paper on a genetic disorder of your choice, covering causes, symptoms, treatments, and current research.',
'type': 'paper',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=26),
'due_date': 'Nov 5, 2025',
'time_left': '26 days left',
'points': 100,
'weight': 0.15,
'status': 'not_started',
'visibleToStudents': True,
'allowed_formats': 'DOCX, PDF',
'resources': ['Research Paper Guidelines', 'Example Papers'],
'submissions': {
'count': 0,
'graded': 0,
'average': 0
}
},
{
'id': 'as5',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Cell Division Video Analysis',
'description': 'Watch the provided video on cell division and answer the analysis questions.',
'type': 'analysis',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=15),
'due_date': 'Oct 25, 2025',
'time_left': '15 days left',
'points': 20,
'weight': 0.05,
'status': 'not_started',
'visibleToStudents': True,
'allowed_formats': 'PDF, DOCX',
'resources': ['Video Link', 'Analysis Questions'],
'submissions': {
'count': 0,
'graded': 0,
'average': 0
}
},
{
'id': 'as6',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Midterm Exam',
'description': 'Comprehensive exam covering all topics from the first half of the semester.',
'type': 'exam',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=31),
'due_date': 'Nov 10, 2025',
'time_left': '31 days left',
'points': 200,
'weight': 0.25,
'status': 'not_started',
'visibleToStudents': True,
'time_limit': '2 hours',
'resources': ['Study Guide', 'Review Session Schedule'],
'submissions': {
'count': 0,
'graded': 0,
'average': 0
}
},
{
'id': 'as7',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Lab Report: Microscopy Techniques',
'description': 'Write a detailed lab report on the microscopy techniques used in last week\'s lab session.',
'type': 'lab',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=14),
'dueDate': datetime.datetime.now() - datetime.timedelta(days=7),
'due_date': 'Oct 3, 2025',
'time_left': 'Completed',
'points': 40,
'weight': 0.08,
'status': 'graded',
'visibleToStudents': True,
'allowed_formats': 'PDF, DOCX',
'resources': ['Lab Manual', 'Microscopy Guidelines'],
'submissions': {
'count': 28,
'graded': 28,
'average': 87.5
}
},
{
'id': 'as8',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Cellular Respiration Worksheet',
'description': 'Complete the worksheet on cellular respiration pathways and energy production.',
'type': 'homework',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=21),
'dueDate': datetime.datetime.now() - datetime.timedelta(days=14),
'due_date': 'Sep 26, 2025',
'time_left': 'Completed',
'points': 15,
'weight': 0.03,
'status': 'graded',
'visibleToStudents': True,
'allowed_formats': 'PDF',
'resources': ['Chapter 9 Notes', 'Cellular Respiration Diagram'],
'submissions': {
'count': 27,
'graded': 27,
'average': 91.2
}
},
{
'id': 'as9',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Enzyme Activity Lab Analysis',
'description': 'Analyze the data from the enzyme activity lab and create graphs showing the relationship between temperature and enzyme activity.',
'type': 'analysis',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() + datetime.timedelta(days=3),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=10),
'due_date': 'Oct 20, 2025',
'time_left': '10 days left',
'points': 35,
'weight': 0.07,
'status': 'not_started',
'visibleToStudents': True,
'allowed_formats': 'PDF, Excel',
'resources': ['Lab Data Sheet', 'Graphing Instructions'],
'submissions': {
'count': 0,
'graded': 0,
'average': 0
}
},
{
'id': 'as10',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Photosynthesis vs Respiration Comparison',
'description': 'Create a detailed comparison chart showing the similarities and differences between photosynthesis and cellular respiration.',
'type': 'project',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=3),
'dueDate': datetime.datetime.now() + datetime.timedelta(days=2),
'due_date': 'Oct 12, 2025',
'time_left': '2 days left',
'points': 60,
'weight': 0.12,
'status': 'in_progress',
'visibleToStudents': True,
'allowed_formats': 'PDF, PowerPoint, Google Slides',
'resources': ['Photosynthesis Notes', 'Respiration Notes', 'Comparison Template'],
'submissions': {
'count': 8,
'graded': 0,
'average': 0
}
}
]
# Add assignments to Firestore
for assignment in assignments:
db.collection('Assignments').document(assignment['id']).set(assignment)
# Create sample events
events = [
{
'id': 'e1',
'classId': 'sample-ap-biology',
'title': 'Lab Session: DNA Extraction',
'description': 'Hands-on lab to extract DNA from various cell types.',
'type': 'lab',
'location': 'Lab 203',
'date': 'Tomorrow',
'time': '2:30 PM - 4:00 PM',
'startDate': datetime.datetime.now() + datetime.timedelta(days=1),
'endDate': datetime.datetime.now() + datetime.timedelta(days=1, hours=1.5),
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'hostId': 'teacher123',
'recurring': False
},
{
'id': 'e2',
'classId': 'sample-ap-biology',
'title': 'Quiz: Cell Structure',
'description': 'Short quiz covering basic cell structure topics.',
'type': 'quiz',
'location': 'Classroom',
'date': 'Friday',
'time': 'During class',
'startDate': datetime.datetime.now() + datetime.timedelta(days=3),
'endDate': datetime.datetime.now() + datetime.timedelta(days=3, minutes=30),
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'hostId': 'teacher123',
'recurring': False
},
{
'id': 'e3',
'classId': 'sample-ap-biology',
'title': 'Study Group Session',
'description': 'Student-led study group to review molecular biology concepts.',
'type': 'study_group',
'location': 'Library Study Room 4',
'date': 'Saturday',
'time': '11:00 AM - 1:00 PM',
'startDate': datetime.datetime.now() + datetime.timedelta(days=4),
'endDate': datetime.datetime.now() + datetime.timedelta(days=4, hours=2),
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'hostId': 'teacher123',
'recurring': False
},
{
'id': 'e4',
'classId': 'sample-ap-biology',
'title': 'Guest Lecture: Genomic Research',
'description': 'Special guest lecture by Dr. Janice Wong from the University Research Center.',
'type': 'lecture',
'location': 'Auditorium',
'date': 'Next Tuesday',
'time': '1:00 PM - 2:30 PM',
'startDate': datetime.datetime.now() + datetime.timedelta(days=6),
'endDate': datetime.datetime.now() + datetime.timedelta(days=6, hours=1.5),
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'hostId': 'teacher123',
'recurring': False
},
{
'id': 'e5',
'classId': 'sample-ap-biology',
'title': 'Review Session: DNA and RNA',
'description': 'Comprehensive review session for the upcoming quiz.',
'type': 'review',
'location': 'Classroom',
'date': 'Next Wednesday',
'time': '3:00 PM - 4:30 PM',
'startDate': datetime.datetime.now() + datetime.timedelta(days=7),
'endDate': datetime.datetime.now() + datetime.timedelta(days=7, hours=1.5),
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now(),
'hostId': 'teacher123',
'recurring': False
}
]
# Add events to Firestore
for event in events:
db.collection('Events').document(event['id']).set(event)
# Create sample resources
resources = [
{
'id': 'r1',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Lecture 1: Introduction to Molecular Biology',
'description': 'Overview of course, key concepts, and research methodologies',
'type': 'slides',
'date_added': 'Sep 5, 2025',
'file_type': 'PDF',
'file_size': '2.4 MB',
'thumbnail': 'https://via.placeholder.com/300x200/4361ee/ffffff?text=Lecture+1',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=30),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=30),
'visibility': 'class',
'views': 26,
'downloads': 18
},
{
'id': 'r2',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'DNA Structure and Replication',
'description': 'Video lecture explaining DNA structure and the replication process',
'type': 'videos',
'date_added': 'Sep 8, 2025',
'duration': '28:45',
'thumbnail': 'https://via.placeholder.com/300x200/3a0ca3/ffffff?text=DNA+Video',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=27),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=27),
'visibility': 'class',
'views': 22,
'downloads': 0
},
{
'id': 'r3',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Lab 1: Microscopy Techniques',
'description': 'Handout for first lab session on microscopy techniques',
'type': 'handouts',
'date_added': 'Sep 10, 2025',
'file_type': 'PDF',
'file_size': '1.8 MB',
'thumbnail': 'https://via.placeholder.com/300x200/f72585/ffffff?text=Lab+1',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=25),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=25),
'visibility': 'class',
'views': 28,
'downloads': 24
},
{
'id': 'r4',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'The Cell Cycle and Division',
'description': 'Interactive simulation of cell division processes',
'type': 'practice',
'date_added': 'Sep 15, 2025',
'duration': 'Interactive',
'thumbnail': 'https://via.placeholder.com/300x200/4cc9f0/000000?text=Cell+Cycle',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=20),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=20),
'visibility': 'class',
'views': 19,
'downloads': 0
},
{
'id': 'r5',
'classId': 'sample-ap-biology',
'unitId': 'unit1',
'title': 'Current Research in Gene Therapy',
'description': 'Recent journal articles on advances in gene therapy applications',
'type': 'readings',
'date_added': 'Sep 18, 2025',
'file_type': 'PDF',
'file_size': '4.2 MB',
'thumbnail': 'https://via.placeholder.com/300x200/7209b7/ffffff?text=Research',
'createdBy': 'teacher123',
'createdAt': datetime.datetime.now() - datetime.timedelta(days=17),
'updatedAt': datetime.datetime.now() - datetime.timedelta(days=17),
'visibility': 'class',
'views': 12,
'downloads': 8
},
{
'id': 'r6',