Repository navigation
Expand file tree
/
Copy pathseed-db.ts
More file actions
1245 lines (1173 loc) · 50.8 KB
/
Copy pathseed-db.ts
File metadata and controls
1245 lines (1173 loc) · 50.8 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
/* eslint-disable comma-dangle */
import 'reflect-metadata';
import { createHash, randomBytes } from 'crypto';
import { getNotifications, importMessageTranslations, importNotifications } from './common/notification/notification';
import { _createFixedToken, createPassword, verifyEmail } from './common/secret';
import { userForStudent, userForPupil, refetchPupil, refetchStudent, userForScreener } from './common/user';
import { getLogger } from './common/logger/logger';
import { registerPupil, RegisterPupilData } from './common/pupil/registration';
import { isDev, isTest } from './common/util/environment';
import { prisma } from './common/prisma';
import { becomeInstructor, becomeTutor, BecomeTutorData, registerStudent, RegisterStudentData } from './common/student/registration';
import { addInstructorScreening, addTutorScreening, scheduleCoCReminders } from './common/student/screening';
import { addPupilScreening } from './common/pupil/screening';
import { createMatch } from './common/match/create';
import { TEST_POOL } from './common/match/pool';
import { createRemissionRequest } from './common/remission-request';
import { joinSubcourse, joinSubcourseWaitinglist } from './common/courses/participants';
import { addCourseInstructor, addSubcourseInstructor } from './common/courses/states';
import { createPupilMatchRequest, createStudentMatchRequest } from './common/match/request';
import { createCourseTag } from './common/courses/tags';
import { _setSilenceNotificationSystem } from './common/notification';
import {
course_category_enum as CourseCategory,
course_coursestate_enum as CourseState,
course_subject_enum as CourseSubject,
lecture_appointmenttype_enum as AppointmentType,
screener as Screener,
pupil as Pupil,
student as Student,
course_subject_enum,
learning_assignment_status,
pupil_email_owner_enum,
pupil_learninggermansince_enum as LearningGermanSince,
pupil_languages_enum as Language,
} from '@prisma/client';
import { importAchievements } from './seed-achievements';
import { CalendarPreferences, Day, WeeklyAvailability } from './graphql/types/calendarPreferences';
import { PupilUpdateInput } from './graphql/pupil/mutations';
import { Subject } from './common/util/subjectsutils';
import * as certificateOfConduct from './common/certificate-of-conduct/certificateOfConduct';
import { createLectureFeedback } from './common/lecture-feedback';
const logger = getLogger('DevSetup');
interface CreatePupilArgs extends Partial<RegisterPupilData> {
includePassword?: boolean;
calendarPreferences: CalendarPreferences;
subjects: Subject[];
languages: Language[];
learningGermanSince?: LearningGermanSince;
gradeAsInt: number;
}
const createSimpleCalendarPreferences = (weekdays: Day[], slots: { from: string; to: string }[]): CalendarPreferences => {
function toMinutes(time: string) {
const [hours, minutes] = time.split(':').map(Number);
return hours * 60 + minutes;
}
return {
weeklyAvailability: weekdays.reduce(
(acc, weekday) => {
acc[weekday] = slots.map(({ from, to }) => ({
from: toMinutes(from),
to: toMinutes(to),
}));
return acc;
},
{
monday: [],
tuesday: [],
wednesday: [],
thursday: [],
friday: [],
saturday: [],
sunday: [],
} as WeeklyAvailability
),
};
};
const createPupil = async ({ includePassword = true, calendarPreferences, ...data }: CreatePupilArgs) => {
const pupil = await registerPupil({
firstname: data.firstname,
lastname: data.lastname,
email: data.email,
aboutMe: data.aboutMe,
newsletter: data.newsletter ?? true,
registrationSource: 'normal',
school: data.school ?? {
name: 'Muster Schule',
schooltype: 'gymnasium',
state: 'be',
},
emailOwner: pupil_email_owner_enum.pupil,
});
await _createFixedToken(userForPupil(pupil), `authtokenP${pupil.id}`);
if (includePassword) {
await createPassword(userForPupil(pupil), `test`);
}
await verifyEmail(userForPupil(pupil));
const verifiedPupil = await refetchPupil(pupil);
await addPupilScreening(verifiedPupil, { comment: '', status: 'success', invalidated: false });
return await prisma.pupil.update({
where: { id: pupil.id },
data: {
languages: data.languages,
subjects: JSON.stringify(data.subjects),
learningGermanSince: data.learningGermanSince,
grade: `${data.gradeAsInt}. Klasse`,
calendarPreferences: calendarPreferences as Record<string, any>,
},
});
};
interface CreateStudentArgs extends Partial<RegisterStudentData>, BecomeTutorData {
isInstructor?: boolean;
isTutor?: boolean;
calendarPreferences: CalendarPreferences;
cooperationID?: number;
createCoC?: boolean;
}
const createStudent = async ({ isInstructor = true, isTutor = true, calendarPreferences, ...data }: CreateStudentArgs, screener: Screener) => {
const student = await registerStudent({
firstname: data.firstname,
lastname: data.lastname,
email: data.email,
aboutMe: data.aboutMe,
newsletter: data.newsletter ?? true,
registrationSource: data.registrationSource ?? 'normal',
isAdult: true,
});
await verifyEmail(userForStudent(student));
await _createFixedToken(userForStudent(student), `authtokenS${student.id}`);
await createPassword(userForStudent(student), `test`);
await createRemissionRequest(student);
await becomeTutor(student, {
languages: data.languages,
subjects: data.subjects,
});
const updatedStudent = await prisma.student.update({
where: { id: student.id },
data: { hasDoneEthicsOnboarding: true, calendarPreferences: calendarPreferences as Record<string, any>, cooperationID: data.cooperationID },
});
if (isTutor) {
await addTutorScreening(screener, updatedStudent, { status: 'success' });
}
if (isInstructor) {
await becomeInstructor(updatedStudent, {});
await addInstructorScreening(
screener,
updatedStudent,
{
status: 'success',
comment: 'Success',
},
false
);
}
if (data.createCoC) {
await certificateOfConduct.create(new Date(), new Date(), false, student.id);
}
return refetchStudent(student);
};
interface CreateTutoringMatchArgs {
pupil: Pupil;
student: Student;
topics?: {
name: string;
subject: course_subject_enum;
assignments: {
status: learning_assignment_status;
task: string;
}[];
}[];
lectures: Omit<CreateLecturesArgs, 'matchId'>;
}
const createTutoringMatch = async (data: CreateTutoringMatchArgs) => {
const { topics = [] } = data;
await createPupilMatchRequest(data.pupil, true);
await createStudentMatchRequest(data.student, true);
const match = await createMatch(await refetchPupil(data.pupil), await refetchStudent(data.student), TEST_POOL, { skipChatCreation: true });
await createLectures({
...data.lectures,
participantsIds: [`pupil/${data.pupil.id}`],
organizerIds: [`student/${data.student.id}`],
matchId: match.id,
});
if (topics.length) {
for (const topic of topics) {
const createdTopic = await prisma.learning_topic.create({
data: {
matchId: match.id,
name: topic.name,
subject: topic.subject,
pupilId: match.pupilId,
},
});
for (const assignment of topic.assignments) {
await prisma.learning_assignment.create({
data: {
status: assignment.status,
task: assignment.task,
topicId: createdTopic.id,
},
});
}
}
}
};
interface CreateCourseArgs {
name: string;
outline?: string;
description: string;
category: CourseCategory;
state: CourseState;
subject?: CourseSubject;
allowContact?: boolean;
joinAfterStart?: boolean;
minGrade?: number;
maxGrade?: number;
maxParticipants?: number;
published?: boolean;
course_tags_course_tag?: {
create: {
courseTagId: number;
};
};
instructors: Student[];
participants: Pupil[];
lectures: Omit<CreateLecturesArgs, 'subcourseId'>;
allowMentoring?: boolean;
}
interface CreateLecturesArgs {
amount: number;
intervalInDays: number;
startOffsetInDays: number;
participantsIds?: string[];
organizerIds?: string[];
subcourseId?: number;
matchId?: number;
}
const createLectures = async ({ amount, intervalInDays, startOffsetInDays, subcourseId, matchId, organizerIds, participantsIds }: CreateLecturesArgs) => {
let currentLecture = Date.now() + startOffsetInDays * 24 * 60 * 60 * 1000;
const interval = intervalInDays * 24 * 60 * 60 * 1000;
for (let i = 0; i < amount; i++) {
const start = new Date(currentLecture);
const lecture = await prisma.lecture.create({
data: {
subcourseId: subcourseId,
matchId: matchId,
duration: 60,
start,
organizerIds: organizerIds,
participantIds: participantsIds,
joinedBy: start <= new Date() ? participantsIds.concat(organizerIds ?? []) : [],
actualDuration: start <= new Date() ? 50 : undefined,
appointmentType: subcourseId ? 'group' : 'match',
},
});
if (!subcourseId && start > new Date()) {
await createLectureFeedback(lecture); // future feedback is always pending
} else if (!subcourseId && start <= new Date()) {
const shouldCreateFeedback = Math.random() < 0.3; // 30% chance to create feedback for past lectures
const rating = Math.floor(Math.random() * 5) + 1;
if (shouldCreateFeedback) {
await createLectureFeedback(lecture, {
status: 'submitted',
rating,
tags: ['Sonstiges: Lorem ipsum dolor sit amet, consetetur sadipscing elitr'],
});
} else {
await createLectureFeedback(lecture);
}
}
currentLecture += interval;
}
};
const createCourse = async (data: CreateCourseArgs) => {
const course = await prisma.course.create({
data: {
name: data.name,
outline: data.outline ?? '',
description: data.description,
category: data.category,
courseState: data.state,
subject: data.subject,
allowContact: data.allowContact ?? true,
course_tags_course_tag: data?.course_tags_course_tag,
},
});
const subcourse = await prisma.subcourse.create({
data: {
courseId: course.id,
joinAfterStart: data.joinAfterStart ?? true,
minGrade: data.minGrade ?? 1,
maxGrade: data.maxGrade ?? 14,
maxParticipants: data.maxParticipants ?? 10,
published: data.published ?? true,
allowMentoring: data.allowMentoring,
},
});
await createLectures({
subcourseId: subcourse.id,
...data.lectures,
participantsIds: data.participants.map((e) => `pupil/${e.id}`),
organizerIds: [...data.instructors.map((e) => `student/${e.id}`)],
});
// Add Instructors and Participants after adding Lectures, so that they are also added to the lectures:
await addCourseInstructor(null, course, data.instructors[0]);
for (const instructor of data.instructors) {
await addSubcourseInstructor(null, subcourse, instructor);
}
for (const participant of data.participants) {
await joinSubcourse(subcourse, participant, false);
}
return [course, subcourse] as const;
};
void (async function setupDevDB() {
if (!isDev && !isTest) {
throw new Error(`Are you sure you want to seed the DB in a non development / test environment?`);
}
if ((await prisma.pupil.count()) > 0) {
throw new Error(`Cannot seed a non empty database. Use npm run db:reset-hard to drop it`);
}
logger.info('Starting to Seed DB');
_setSilenceNotificationSystem(true);
await prisma.cooperation.createMany({
data: [
{
name: 'Lern-Fair e.V.',
tag: 'self',
type: 'company',
welcomeTitle: 'Wilkommen im Userbereich',
welcomeMessage: 'Als Lern-Fairer kennst du dich ja hier aus :)',
},
{
name: 'Uni Freiburg',
tag: 'uni-freiburg',
type: 'university',
welcomeTitle: 'Wilkommen im Userbereich',
welcomeMessage: 'Lorem ipsum dolor sit amet',
},
{
name: 'Uni CSS',
tag: 'uni-css',
type: 'university',
welcomeTitle: 'Wilkommen im Userbereich',
welcomeMessage: 'Lorem ipsum dolor sit amet',
},
{
name: 'Uni ABC',
tag: 'uni-abc',
type: 'university',
welcomeTitle: 'Wilkommen im Userbereich',
welcomeMessage: 'Lorem ipsum dolor sit amet',
},
{
name: 'Uni JS',
tag: 'uni-js',
type: 'university',
welcomeTitle: 'Wilkommen im Userbereich',
welcomeMessage: 'Lorem ipsum dolor sit amet',
},
],
});
const pupil1 = await createPupil({
firstname: 'Max',
lastname: 'Musterschüler',
email: 'test+dev+p1@lern-fair.de',
aboutMe: 'Hallo 👋! Ich heiße Max und ich interessiere mich für Englisch und Mathe',
languages: ['Deutsch', 'Italienisch'],
subjects: [{ name: 'Englisch' }, { name: 'Französisch' }, { name: 'Mathematik', mandatory: true }],
gradeAsInt: 6,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const pupil2 = await createPupil({
firstname: 'Tom',
lastname: 'Musterschüler',
email: 'test+dev+p2@lern-fair.de',
aboutMe: 'Hallo, ich bin Tom und ich lerne Deutsch!',
languages: ['Englisch'],
subjects: [{ name: 'Deutsch als Zweitsprache', mandatory: true }],
gradeAsInt: 6,
learningGermanSince: 'one_to_two',
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
[
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const pupil3 = await createPupil({
firstname: 'Lena',
lastname: 'Musterschüler',
email: 'test+dev+p3@lern-fair.de',
aboutMe: 'Hi, ich bin Lena und ich liebe Mathe und Biologie!',
languages: ['Deutsch', 'Franz_sisch'],
subjects: [{ name: 'Mathematik', mandatory: true }, { name: 'Biologie' }, { name: 'Französisch' }, { name: 'Englisch' }],
gradeAsInt: 6,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
]
),
});
const pupil4 = await createPupil({
firstname: 'Aisha',
lastname: 'Musterschüler',
email: 'test+dev+p4@lern-fair.de',
aboutMe: "I'm Aisha, and I want to improve my German",
languages: ['Englisch', 'Arabisch'],
subjects: [{ name: 'Deutsch als Zweitsprache', mandatory: true }],
learningGermanSince: 'one_to_two',
gradeAsInt: 7,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'friday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
]
),
});
const pupil5 = await createPupil({
firstname: 'Sofia',
lastname: 'Musterschüler',
email: 'test+dev+p5@lern-fair.de',
aboutMe: 'Ich bin Sofia und ich interessiere mich sehr für Deutsch und Englisch.',
languages: ['Italienisch'],
subjects: [
{ name: 'Deutsch als Zweitsprache', mandatory: true },
{ name: 'Englisch', mandatory: true },
],
learningGermanSince: 'two_to_four',
gradeAsInt: 5,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const pupil6 = await createPupil({
firstname: 'Yusuf',
lastname: 'Musterschüler',
email: 'test+dev+p6@lern-fair.de',
aboutMe: 'Moin, ich heiße Yusuf und ich liebe Mathe und Chemie',
languages: ['T_rkisch', 'Englisch', 'Deutsch'],
subjects: [{ name: 'Mathematik', mandatory: true }, { name: 'Chemie' }],
gradeAsInt: 10,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const pupil7 = await createPupil({
firstname: 'Emilia',
lastname: 'Musterschüler',
email: 'test+dev+p7@lern-fair.de',
aboutMe: 'Ich bin Emilia und ich lese gerne Bücher und liebe Englisch.',
languages: ['Deutsch'],
subjects: [{ name: 'Mathematik', mandatory: true }, { name: 'Englisch' }],
gradeAsInt: 4,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const pupil8 = await createPupil({
firstname: 'Diego',
lastname: 'Musterschüler',
email: 'test+dev+p8@lern-fair.de',
aboutMe: "I'm Diego, and I enjoy learning about math and science.",
languages: ['Spanisch', 'Englisch'],
subjects: [{ name: 'Deutsch als Zweitsprache', mandatory: true }, { name: 'Mathematik' }, { name: 'Englisch' }],
learningGermanSince: 'two_to_four',
gradeAsInt: 6,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const pupil9 = await createPupil({
firstname: 'Sarah',
lastname: 'Musterschüler',
email: 'test+dev+p9@lern-fair.de',
aboutMe: 'Hallo, ich bin Sarah und Mathe ist mein Lieblingsfach!',
languages: ['Deutsch', 'Englisch'],
subjects: [{ name: 'Mathematik', mandatory: true }, { name: 'Biologie' }, { name: 'Englisch' }],
gradeAsInt: 10,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const pupil10 = await createPupil({
firstname: 'Mateo',
lastname: 'Musterschüler',
email: 'test+dev+p10@lern-fair.de',
aboutMe: "I'm Mateo, and I'm working on improving my German skills",
languages: ['Spanisch', 'Englisch'],
subjects: [
{ name: 'Deutsch als Zweitsprache', mandatory: true },
{ name: 'Mathematik', mandatory: true },
],
learningGermanSince: 'two_to_four',
gradeAsInt: 4,
includePassword: false,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
});
const screener1 = await prisma.screener.create({
data: {
firstname: 'Alina',
lastname: 'Screenerfrau',
email: 'test+dev+sc1@lern-fair.de',
password: 'LEGACY',
verified: true,
active: true,
is_course_screener: true,
is_pupil_screener: true,
is_student_screener: true,
is_trusted: true,
},
});
await _createFixedToken(userForScreener(screener1), `authtokenSC1`);
await createPassword(userForScreener(screener1), `test`);
const screener2 = await prisma.screener.create({
data: {
firstname: 'Lina',
lastname: 'Screenerfrau',
email: 'test+dev+sc2@lern-fair.de',
password: 'LEGACY',
verified: true,
active: true,
is_course_screener: true,
is_pupil_screener: false,
is_student_screener: false,
is_trusted: false,
},
});
await _createFixedToken(userForScreener(screener2), `authtokenSC2`);
await createPassword(userForScreener(screener2), `test`);
const screener3 = await prisma.screener.create({
data: {
firstname: 'Leto',
lastname: 'Atreides',
email: 'test+dev+sc3@lern-fair.de',
password: 'LEGACY',
verified: true,
active: true,
is_course_screener: false,
is_pupil_screener: true,
is_student_screener: false,
is_trusted: false,
},
});
await _createFixedToken(userForScreener(screener3), `authtokenSC3`);
await createPassword(userForScreener(screener3), `test`);
const screener4 = await prisma.screener.create({
data: {
firstname: 'Paul',
lastname: 'Atreides',
email: 'test+dev+sc4@lern-fair.de',
password: 'LEGACY',
verified: true,
active: true,
is_course_screener: false,
is_pupil_screener: false,
is_student_screener: true,
is_trusted: false,
},
});
await _createFixedToken(userForScreener(screener4), `authtokenSC4`);
await createPassword(userForScreener(screener4), `test`);
const student1 = await createStudent(
{
firstname: 'Leon',
lastname: 'Jackson',
email: 'test+dev+s1@lern-fair.de',
aboutMe: `Im Student 1`,
languages: ['Deutsch', 'Englisch', 'Spanisch'],
newsletter: true,
createCoC: true,
subjects: [
{ name: 'Spanisch', grade: { min: 4, max: 10 } },
{ name: 'Deutsch als Zweitsprache', grade: { min: 4, max: 10 } },
{ name: 'Englisch', grade: { min: 4, max: 10 } },
{ name: 'Deutsch', grade: { min: 4, max: 10 } },
{ name: 'Mathematik', grade: { min: 4, max: 10 } },
],
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
},
screener1
);
const student2 = await createStudent(
{
firstname: 'Melanie',
lastname: 'Meiers',
aboutMe: `Im Student 2`,
email: 'test+dev+s2@lern-fair.de',
newsletter: false,
createCoC: true,
registrationSource: 'normal',
languages: ['Deutsch', 'Englisch', 'Franz_sisch'],
subjects: [
{ name: 'Deutsch als Zweitsprache', grade: { min: 1, max: 14 } },
{ name: 'Französisch', grade: { min: 1, max: 14 } },
{ name: 'Mathematik', grade: { min: 1, max: 14 } },
{ name: 'Englisch', grade: { min: 1, max: 14 } },
],
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
},
screener2
);
await prisma.student.update({
where: { id: student2.id },
data: { zoomUserId: 'kLKyaiAyTNC-MWjiWCFFFF' },
});
const student3 = await createStudent(
{
firstname: 'Jon',
lastname: 'Doe',
email: 'test+dev+s3@lern-fair.de',
aboutMe: `I'm Student 3`,
newsletter: true,
createCoC: true,
registrationSource: 'normal',
languages: ['Deutsch', 'Englisch', 'Franz_sisch'],
subjects: [
{ name: 'Französisch', grade: { min: 4, max: 10 } },
{ name: 'Englisch', grade: { min: 1, max: 14 } },
{ name: 'Rechnungswesen', grade: { min: 14, max: 14 } },
],
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
},
screener1
);
const student4 = await createStudent(
{
firstname: 'Jack',
lastname: 'Doe',
email: 'test+dev+s4@lern-fair.de',
aboutMe: `I'm Student 4`,
newsletter: false,
createCoC: true,
registrationSource: 'normal',
languages: ['Englisch', 'Franz_sisch', 'Deutsch'],
subjects: [
{ name: 'Französisch', grade: { min: 1, max: 14 } },
{ name: 'Mathematik', grade: { min: 1, max: 10 } },
],
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
},
screener1
);
const student5 = await createStudent(
{
firstname: 'Jane',
lastname: 'Doe',
email: 'test+dev+s5@lern-fair.de',
aboutMe: `I'm Student 5`,
newsletter: true,
createCoC: true,
registrationSource: 'cooperation',
cooperationID: 1,
languages: ['Englisch', 'Arabisch', 'Deutsch'],
subjects: [
{ name: 'Französisch', grade: { min: 1, max: 14 } },
{ name: 'Mathematik', grade: { min: 1, max: 10 } },
{ name: 'Biologie', grade: { min: 1, max: 10 } },
],
isInstructor: false,
calendarPreferences: createSimpleCalendarPreferences(
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
[
{ from: '10:00', to: '11:00' },
{ from: '11:00', to: '12:00' },
{ from: '12:00', to: '13:00' },
{ from: '13:00', to: '14:00' },
{ from: '14:00', to: '15:00' },
{ from: '15:00', to: '16:00' },
{ from: '16:00', to: '17:00' },
{ from: '17:00', to: '18:00' },
{ from: '18:00', to: '19:00' },
{ from: '19:00', to: '20:00' },
{ from: '20:00', to: '21:00' },
]
),
},
screener1
);
await createTutoringMatch({
pupil: pupil1,
student: student1,
topics: [
{
name: 'Nullstellenbestimmung',
subject: 'Mathematik',
assignments: [
{ status: 'pending', task: 'Bestimme die Nullstellen der Funktion f(x) = x ** 2 - 9' },
{ status: 'pending', task: 'Bestimme die Nullstellen der Funktion f(x) = x ** 2 - 6x + 9' },
],
},
{
name: 'Simple Past',
subject: 'Englisch',
assignments: [
{
status: 'pending',
task: "Übersetze 'Ich ging gestern zur Schule' ins Englische",
},
],
},
],
lectures: { amount: 20, intervalInDays: 1, startOffsetInDays: -8 },
});
await createTutoringMatch({ pupil: pupil1, student: student3, lectures: { amount: 5, intervalInDays: 1, startOffsetInDays: -2 } });
await createTutoringMatch({ pupil: pupil2, student: student1, lectures: { amount: 10, intervalInDays: 1, startOffsetInDays: 0 } });
await createTutoringMatch({ pupil: pupil3, student: student1, lectures: { amount: 8, intervalInDays: 1, startOffsetInDays: -1 } });
await createTutoringMatch({ pupil: pupil6, student: student1, lectures: { amount: 6, intervalInDays: 1, startOffsetInDays: -3 } });
await createTutoringMatch({ pupil: pupil3, student: student3, lectures: { amount: 7, intervalInDays: 1, startOffsetInDays: -2 } });
await createTutoringMatch({ pupil: pupil4, student: student2, lectures: { amount: 9, intervalInDays: 1, startOffsetInDays: -1 } });
await createTutoringMatch({ pupil: pupil5, student: student2, lectures: { amount: 5, intervalInDays: 1, startOffsetInDays: -2 } });
await createTutoringMatch({ pupil: pupil8, student: student2, lectures: { amount: 12, intervalInDays: 1, startOffsetInDays: -4 } });
const keepAtIt = await createCourseTag(null, 'Dranbleiben', CourseCategory.focus);
await createCourseTag(null, 'Denk an Dich', CourseCategory.focus);
const yourFuture = await createCourseTag(null, 'Deine Zukunft', CourseCategory.focus);
const digitalWorld = await createCourseTag(null, 'Digitale Welt', CourseCategory.focus);
await createCourseTag(null, 'Für Eltern', CourseCategory.focus);
const a1 = await createCourseTag(null, 'A1', CourseCategory.language);
const a2 = await createCourseTag(null, 'A2', CourseCategory.language);
await createCourseTag(null, 'B1', CourseCategory.language);
const emptyCourseData = {
name: 'Do not remove me',
outline: '',
description: "I'm here just to make sure course ids and subcourse ids are not equal This helps us to simulate a bit better how production works",
category: 'coaching',
courseState: 'created',
subject: 'Informatik',
allowContact: false,
} as const;
const emptyCourses = Array.from({ length: 10 }).fill(emptyCourseData) as Array<typeof emptyCourseData>;
await prisma.course.createMany({
data: emptyCourses,
});
const [course1, subcourse1] = await createCourse({
name: 'Deutsch Grammatik für Anfänger 📚',
outline: 'Grundlagen der deutschen Grammatik, Satzbau, Zeiten und Rechtschreibung.',
description:
'Lerne die Grundlagen der deutschen Sprache! 🧠 Mit einfachen Übungen und vielen Beispielen wirst du schnell die Regeln verstehen. Gemeinsam schauen wir uns Satzbau, Wortarten und Rechtschreibung an. Deutsch ist gar nicht so schwer, wenn man es spielerisch lernt! 😊',
category: CourseCategory.language,
state: CourseState.allowed,
subject: 'Deutsch_als_Zweitsprache',
course_tags_course_tag: { create: { courseTagId: a1.id } },
maxParticipants: 10,
instructors: [student1],
participants: [pupil4, pupil5, pupil8, pupil10],
lectures: { amount: 20, intervalInDays: 1, startOffsetInDays: -2 },
});
const [course2, subcourse2] = await createCourse({
name: 'Gesprächskurs Deutsch 💬',
outline: 'Sprechen, Zuhören und Alltagsgespräche üben.',
description:
'In diesem Kurs üben wir das freie Sprechen auf Deutsch. 🎙️ Du lernst, dich in alltäglichen Situationen sicher auszudrücken und verstehst, wie man höflich und freundlich Gespräche führt. Ideal, um Selbstbewusstsein beim Sprechen zu gewinnen und neue Freunde zu finden! 🤗',
category: CourseCategory.language,
subject: CourseSubject.Deutsch_als_Zweitsprache,
course_tags_course_tag: { create: { courseTagId: a2.id } },
state: CourseState.allowed,
maxParticipants: 5,
instructors: [student1, student2],
participants: [pupil2, pupil4, pupil5, pupil8, pupil10],
lectures: { amount: 6, intervalInDays: 7, startOffsetInDays: -1 },
});
const [course3, subcourse3] = await createCourse({
name: '🇩🇪 Deutsch Basics: Die ersten Schritte 🏃➡️',
outline: 'Grammatikgrundlagen, einfache Satzstrukturen, erste Texte.',
description:
'Wir machen gemeinsam die ersten Schritte in der deutschen Sprache! 📖 Von den wichtigsten Grammatikregeln bis hin zu ersten kurzen Texten lernst du hier alles, was du für den Anfang brauchst. Mit vielen praktischen Übungen wirst du schnell Fortschritte machen und deine ersten Sätze stolz vortragen können! 💪',
category: CourseCategory.language,
subject: 'Deutsch_als_Zweitsprache',
course_tags_course_tag: { create: { courseTagId: a1.id } },
state: CourseState.submitted,
allowContact: false,
published: false,
instructors: [student2],
participants: [],
lectures: { amount: 7, intervalInDays: 1, startOffsetInDays: 7 },
});
const [course4, subcourse4] = await createCourse({
name: 'Englisch für Anfänger 🇬🇧',
outline: 'Wortschatz, einfache Sätze, und grundlegende Grammatik.',
description:
"Let's speak English! 🗣️ In diesem Kurs lernst du die ersten Wörter und Sätze auf Englisch. Wir üben zusammen, sodass du bald erste Gespräche führen kannst. Mit Spielen und Liedern macht Englisch lernen besonders viel Spaß!",
category: CourseCategory.revision,
state: CourseState.allowed,