|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Command; |
|
4
|
|
|
|
|
5
|
|
|
use App\Entity\Appointment; |
|
6
|
|
|
use App\Entity\AppointmentCategory; |
|
7
|
|
|
use App\Entity\Exam; |
|
8
|
|
|
use App\Entity\Grade; |
|
9
|
|
|
use App\Entity\GradeMembership; |
|
10
|
|
|
use App\Entity\GradeTeacher; |
|
11
|
|
|
use App\Entity\PrivacyCategory; |
|
12
|
|
|
use App\Entity\Room; |
|
13
|
|
|
use App\Entity\Section; |
|
14
|
|
|
use App\Entity\Student; |
|
15
|
|
|
use App\Entity\StudyGroup; |
|
16
|
|
|
use App\Entity\StudyGroupMembership; |
|
17
|
|
|
use App\Entity\Subject; |
|
18
|
|
|
use App\Entity\Teacher; |
|
19
|
|
|
use App\Entity\TimetableLesson; |
|
20
|
|
|
use App\Entity\TimetableSupervision; |
|
21
|
|
|
use App\Entity\Tuition; |
|
22
|
|
|
use App\Entity\UserTypeEntity; |
|
23
|
|
|
use App\Request\Data\AppointmentCategoriesData; |
|
24
|
|
|
use App\Request\Data\AppointmentCategoryData; |
|
25
|
|
|
use App\Request\Data\AppointmentData; |
|
26
|
|
|
use App\Request\Data\AppointmentsData; |
|
27
|
|
|
use App\Request\Data\ExamData; |
|
28
|
|
|
use App\Request\Data\ExamsData; |
|
29
|
|
|
use App\Request\Data\ExamTuition; |
|
30
|
|
|
use App\Request\Data\GradeData; |
|
31
|
|
|
use App\Request\Data\GradeMembershipData; |
|
32
|
|
|
use App\Request\Data\GradeMembershipsData; |
|
33
|
|
|
use App\Request\Data\GradesData; |
|
34
|
|
|
use App\Request\Data\GradeTeacherData; |
|
35
|
|
|
use App\Request\Data\GradeTeachersData; |
|
36
|
|
|
use App\Request\Data\PrivacyCategoriesData; |
|
37
|
|
|
use App\Request\Data\PrivacyCategoryData; |
|
38
|
|
|
use App\Request\Data\RoomData; |
|
39
|
|
|
use App\Request\Data\RoomsData; |
|
40
|
|
|
use App\Request\Data\StudentData; |
|
41
|
|
|
use App\Request\Data\StudentsData; |
|
42
|
|
|
use App\Request\Data\StudyGroupData; |
|
43
|
|
|
use App\Request\Data\StudyGroupMembershipData; |
|
44
|
|
|
use App\Request\Data\StudyGroupMembershipsData; |
|
45
|
|
|
use App\Request\Data\StudyGroupsData; |
|
46
|
|
|
use App\Request\Data\SubjectData; |
|
47
|
|
|
use App\Request\Data\SubjectsData; |
|
48
|
|
|
use App\Request\Data\TeacherData; |
|
49
|
|
|
use App\Request\Data\TeachersData; |
|
50
|
|
|
use App\Request\Data\TimetableLessonData; |
|
51
|
|
|
use App\Request\Data\TimetableLessonsData; |
|
52
|
|
|
use App\Request\Data\TimetableSupervisionData; |
|
53
|
|
|
use App\Request\Data\TimetableSupervisionsData; |
|
54
|
|
|
use App\Request\Data\TuitionData; |
|
55
|
|
|
use App\Request\Data\TuitionsData; |
|
56
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
57
|
|
|
use JMS\Serializer\SerializerInterface; |
|
58
|
|
|
use Symfony\Component\Console\Attribute\AsCommand; |
|
59
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
|
|
60
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
61
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
62
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
63
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
|
64
|
|
|
|
|
65
|
|
|
#[AsCommand('app:export', description: 'Exportiert alle importierten Daten, sodass diese (z.B. auf einem anderen Server importiert werden können).')] |
|
66
|
|
|
class ExportDataCommand extends Command { |
|
67
|
|
|
|
|
68
|
|
|
public function __construct(private readonly KernelInterface $kernel, private readonly EntityManagerInterface $em, private readonly SerializerInterface $serializer, string $name = null) { |
|
69
|
|
|
parent::__construct($name); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function execute(InputInterface $input, OutputInterface $output): int { |
|
73
|
|
|
$io = new SymfonyStyle($input, $output); |
|
74
|
|
|
|
|
75
|
|
|
$this->exportStudents($io); |
|
76
|
|
|
$this->exportTeachers($io); |
|
77
|
|
|
$this->exportSubjects($io); |
|
78
|
|
|
$this->exportRooms($io); |
|
79
|
|
|
$this->exportPrivacyCategories($io); |
|
80
|
|
|
$this->exportGrades($io); |
|
81
|
|
|
$this->exportGradeMemberships($io); |
|
82
|
|
|
$this->exportGradeTeachers($io); |
|
83
|
|
|
$this->exportStudyGroups($io); |
|
84
|
|
|
$this->exportStudyGroupMemberships($io); |
|
85
|
|
|
$this->exportTuitions($io); |
|
86
|
|
|
$this->exportExams($io); |
|
87
|
|
|
$this->exportAppointmentCategories($io); |
|
88
|
|
|
$this->exportAppointments($io); |
|
89
|
|
|
$this->exportTimetable($io); |
|
90
|
|
|
$this->exportSupervisions($io); |
|
91
|
|
|
|
|
92
|
|
|
$io->success('Export erfolgreich - bitte das Verzeichnis export/ prüfen'); |
|
93
|
|
|
|
|
94
|
|
|
return Command::SUCCESS; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
private function writeFile(string $filename, $object): void { |
|
98
|
|
|
$json = $this->serializer->serialize($object, 'json'); |
|
99
|
|
|
$target = sprintf('%s/%s', $this->kernel->getProjectDir(), 'export'); |
|
100
|
|
|
if(!is_dir($target)) { |
|
101
|
|
|
mkdir($target); |
|
102
|
|
|
$handle = fopen(sprintf('%s/.gitignore', $target), 'w'); |
|
103
|
|
|
fwrite($handle, '*'); |
|
104
|
|
|
fclose($handle); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$handle = fopen(sprintf('%s/%s', $target, $filename), 'w'); |
|
108
|
|
|
fwrite($handle, $json); |
|
109
|
|
|
fclose($handle); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
private function getSectionKey(Section $section): string { |
|
113
|
|
|
return sprintf('%d_%d', $section->getYear(), $section->getNumber()); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
private function exportStudents(SymfonyStyle $io): void { |
|
117
|
|
|
$io->section('Exportiere Lernende'); |
|
118
|
|
|
|
|
119
|
|
|
$students = [ ]; |
|
120
|
|
|
|
|
121
|
|
|
/** @var Section[] $sections */ |
|
122
|
|
|
$sections = $this->em->getRepository(Section::class)->findAll(); |
|
123
|
|
|
|
|
124
|
|
|
/** @var Student $student */ |
|
125
|
|
|
foreach($this->em->getRepository(Student::class)->findAll() as $student) { |
|
126
|
|
|
foreach($student->getSections() as $section) { |
|
127
|
|
|
$key = $this->getSectionKey($section); |
|
128
|
|
|
|
|
129
|
|
|
if(!isset($students[$key])) { |
|
130
|
|
|
$students[$key] = [ ]; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
$students[$key][] = (new StudentData()) |
|
134
|
|
|
->setId($student->getExternalId()) |
|
135
|
|
|
->setFirstname($student->getFirstname()) |
|
136
|
|
|
->setLastname($student->getLastname()) |
|
137
|
|
|
->setEmail($student->getEmail()) |
|
138
|
|
|
->setBirthday($student->getBirthday()) |
|
139
|
|
|
->setGender($student->getGender()->value) |
|
140
|
|
|
->setStatus($student->getStatus()); |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
foreach($sections as $section) { |
|
145
|
|
|
$data = $students[$this->getSectionKey($section)] ?? [ ]; |
|
146
|
|
|
|
|
147
|
|
|
$this->writeFile( |
|
148
|
|
|
sprintf('students_%s.json', $this->getSectionKey($section)), |
|
149
|
|
|
(new StudentsData())->setSection($section->getNumber())->setYear($section->getYear())->setStudents($data) |
|
150
|
|
|
); |
|
151
|
|
|
|
|
152
|
|
|
$io->success(sprintf('%d Lernende exportiert (%s)', count($data), $section->getDisplayName())); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
private function exportPrivacyCategories(SymfonyStyle $io): void { |
|
157
|
|
|
$io->section('Exportiere Datenschutzkategorien'); |
|
158
|
|
|
|
|
159
|
|
|
$categories = [ ]; |
|
160
|
|
|
/** @var PrivacyCategory $category */ |
|
161
|
|
|
foreach($this->em->getRepository(PrivacyCategory::class)->findAll() as $category) { |
|
162
|
|
|
$categories[] = (new PrivacyCategoryData()) |
|
163
|
|
|
->setId($category->getExternalId()) |
|
164
|
|
|
->setLabel($category->getLabel()) |
|
165
|
|
|
->setDescription($category->getDescription()); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
$data = new PrivacyCategoriesData(); |
|
169
|
|
|
$data->setCategories($categories); |
|
170
|
|
|
|
|
171
|
|
|
$this->writeFile('privacy.json', $data); |
|
172
|
|
|
$io->success(sprintf('%d Datenschutzkategorie(n) exportiert', count($categories))); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
private function exportTeachers(SymfonyStyle $io): void { |
|
176
|
|
|
$io->section('Exportiere Lehrkräfte'); |
|
177
|
|
|
|
|
178
|
|
|
$teachers = [ ]; |
|
179
|
|
|
|
|
180
|
|
|
/** @var Section[] $sections */ |
|
181
|
|
|
$sections = $this->em->getRepository(Section::class)->findAll(); |
|
182
|
|
|
|
|
183
|
|
|
/** @var Teacher $teacher */ |
|
184
|
|
|
foreach($this->em->getRepository(Teacher::class)->findAll() as $teacher) { |
|
185
|
|
|
foreach($teacher->getSections() as $section) { |
|
186
|
|
|
$key = $this->getSectionKey($section); |
|
187
|
|
|
|
|
188
|
|
|
if (!isset($teachers[$key])) { |
|
189
|
|
|
$teachers[$key] = []; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
$teachers[$key][] = (new TeacherData()) |
|
193
|
|
|
->setId($teacher->getExternalId()) |
|
194
|
|
|
->setAcronym($teacher->getAcronym()) |
|
195
|
|
|
->setFirstname($teacher->getFirstname()) |
|
196
|
|
|
->setLastname($teacher->getLastname()) |
|
197
|
|
|
->setEmail($teacher->getEmail()) |
|
198
|
|
|
->setGender($teacher->getGender()->value) |
|
199
|
|
|
->setTitle($teacher->getTitle()) |
|
200
|
|
|
->setSubjects($teacher->getSubjects()->map(fn(Subject $subject) => $subject->getExternalId())->toArray()); |
|
201
|
|
|
} |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
foreach($sections as $section) { |
|
205
|
|
|
$data = $teachers[$this->getSectionKey($section)] ?? [ ]; |
|
206
|
|
|
|
|
207
|
|
|
$this->writeFile( |
|
208
|
|
|
sprintf('teachers_%s.json', $this->getSectionKey($section)), |
|
209
|
|
|
(new TeachersData())->setSection($section->getNumber())->setYear($section->getYear())->setTeachers($data) |
|
210
|
|
|
); |
|
211
|
|
|
|
|
212
|
|
|
$io->success(sprintf('%d Lehrkräfte exportiert (%s)', count($data), $section->getDisplayName())); |
|
213
|
|
|
} |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
private function exportSubjects(SymfonyStyle $io): void { |
|
217
|
|
|
$io->section('Exportiere Fächer'); |
|
218
|
|
|
$subjects = [ ]; |
|
219
|
|
|
|
|
220
|
|
|
/** @var Subject $subject */ |
|
221
|
|
|
foreach($this->em->getRepository(Subject::class)->findAll() as $subject) { |
|
222
|
|
|
if($subject->getExternalId() === null) { |
|
223
|
|
|
continue; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
$subjects[] = (new SubjectData()) |
|
227
|
|
|
->setId($subject->getExternalId()) |
|
228
|
|
|
->setAbbreviation($subject->getAbbreviation()) |
|
229
|
|
|
->setName($subject->getName()); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
$data = (new SubjectsData())->setSubjects($subjects); |
|
233
|
|
|
$this->writeFile('subjects.json', $data); |
|
234
|
|
|
|
|
235
|
|
|
$io->success(sprintf('%d Fächer exportiert', count($subjects))); |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
private function exportRooms(SymfonyStyle $io): void { |
|
239
|
|
|
$io->section('Exportiere Räume'); |
|
240
|
|
|
$rooms = [ ]; |
|
241
|
|
|
|
|
242
|
|
|
/** @var Room $room */ |
|
243
|
|
|
foreach($this->em->getRepository(Room::class)->findAll() as $room) { |
|
244
|
|
|
$rooms[] = (new RoomData()) |
|
245
|
|
|
->setId($room->getExternalId()) |
|
246
|
|
|
->setName($room->getName()) |
|
247
|
|
|
->setCapacity($room->getCapacity()) |
|
248
|
|
|
->setDescription($room->getDescription()); |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
$data = (new RoomsData())->setRooms($rooms); |
|
252
|
|
|
$this->writeFile('rooms.json', $data); |
|
253
|
|
|
|
|
254
|
|
|
$io->success(sprintf('%d Räume exportiert', count($rooms))); |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
private function exportGrades(SymfonyStyle $io): void { |
|
258
|
|
|
$io->section('Exportiere Klassen'); |
|
259
|
|
|
|
|
260
|
|
|
$grades = [ ]; |
|
261
|
|
|
|
|
262
|
|
|
/** @var Grade $grade */ |
|
263
|
|
|
foreach($this->em->getRepository(Grade::class)->findAll() as $grade) { |
|
264
|
|
|
$grades[] = (new GradeData()) |
|
265
|
|
|
->setId($grade->getExternalId()) |
|
266
|
|
|
->setName($grade->getName()); |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
$data = (new GradesData())->setGrades($grades); |
|
270
|
|
|
$this->writeFile('grades.json', $data); |
|
271
|
|
|
|
|
272
|
|
|
$io->success(sprintf('%d Klassen exportiert', count($grades))); |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
private function exportGradeMemberships(SymfonyStyle $io): void { |
|
276
|
|
|
$io->section('Exportiere Klassenmitgliedschaften'); |
|
277
|
|
|
|
|
278
|
|
|
$memberships = [ ]; |
|
279
|
|
|
|
|
280
|
|
|
/** @var Section[] $sections */ |
|
281
|
|
|
$sections = $this->em->getRepository(Section::class)->findAll(); |
|
282
|
|
|
|
|
283
|
|
|
/** @var GradeMembership $membership */ |
|
284
|
|
|
foreach($this->em->getRepository(GradeMembership::class)->findAll() as $membership) { |
|
285
|
|
|
$key = $this->getSectionKey($membership->getSection()); |
|
286
|
|
|
|
|
287
|
|
|
if(!isset($memberships[$key])) { |
|
288
|
|
|
$memberships[$key] = [ ]; |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
$memberships[$key][] = (new GradeMembershipData()) |
|
292
|
|
|
->setGrade($membership->getGrade()->getExternalId()) |
|
293
|
|
|
->setStudent($membership->getStudent()->getExternalId()); |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
foreach($sections as $section) { |
|
297
|
|
|
$data = $memberships[$this->getSectionKey($section)] ?? [ ]; |
|
298
|
|
|
|
|
299
|
|
|
$this->writeFile( |
|
300
|
|
|
sprintf('grade_memberships_%s.json', $this->getSectionKey($section)), |
|
301
|
|
|
(new GradeMembershipsData())->setSection($section->getNumber())->setYear($section->getYear())->setMemberships($data) |
|
302
|
|
|
); |
|
303
|
|
|
|
|
304
|
|
|
$io->success(sprintf('%d Klassenmitgliedschaften exportiert (%s)', count($data), $section->getDisplayName())); |
|
305
|
|
|
} |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
private function exportGradeTeachers(SymfonyStyle $io): void { |
|
309
|
|
|
$io->section('Exportiere Klassenleitungen'); |
|
310
|
|
|
|
|
311
|
|
|
$gradeTeachers = [ ]; |
|
312
|
|
|
|
|
313
|
|
|
/** @var Section[] $sections */ |
|
314
|
|
|
$sections = $this->em->getRepository(Section::class)->findAll(); |
|
315
|
|
|
|
|
316
|
|
|
/** @var GradeTeacher $gradeTeacher */ |
|
317
|
|
|
foreach($this->em->getRepository(GradeTeacher::class)->findAll() as $gradeTeacher) { |
|
318
|
|
|
$key = $this->getSectionKey($gradeTeacher->getSection()); |
|
319
|
|
|
|
|
320
|
|
|
if(!isset($gradeTeachers[$key])) { |
|
321
|
|
|
$gradeTeachers[$key] = [ ]; |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
$gradeTeachers[$key][] = (new GradeTeacherData()) |
|
325
|
|
|
->setGrade($gradeTeacher->getGrade()->getExternalId()) |
|
326
|
|
|
->setTeacher($gradeTeacher->getTeacher()->getExternalId()) |
|
327
|
|
|
->setType($gradeTeacher->getType()->value); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
foreach($sections as $section) { |
|
331
|
|
|
$data = $gradeTeachers[$this->getSectionKey($section)] ?? [ ]; |
|
332
|
|
|
|
|
333
|
|
|
$this->writeFile( |
|
334
|
|
|
sprintf('grade_teachers%s.json', $this->getSectionKey($section)), |
|
335
|
|
|
(new GradeTeachersData())->setSection($section->getNumber())->setYear($section->getYear())->setGradeTeachers($data) |
|
336
|
|
|
); |
|
337
|
|
|
|
|
338
|
|
|
$io->success(sprintf('%d Klassenleitungen exportiert (%s)', count($data), $section->getDisplayName())); |
|
339
|
|
|
} |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
private function exportStudyGroups(SymfonyStyle $io): void { |
|
343
|
|
|
$io->section('Exportiere Lerngruppen'); |
|
344
|
|
|
|
|
345
|
|
|
$studyGroups = [ ]; |
|
346
|
|
|
|
|
347
|
|
|
/** @var Section[] $sections */ |
|
348
|
|
|
$sections = $this->em->getRepository(Section::class)->findAll(); |
|
349
|
|
|
|
|
350
|
|
|
/** @var StudyGroup $studyGroup */ |
|
351
|
|
|
foreach($this->em->getRepository(StudyGroup::class)->findAll() as $studyGroup) { |
|
352
|
|
|
$key = $this->getSectionKey($studyGroup->getSection()); |
|
353
|
|
|
|
|
354
|
|
|
if(!isset($studyGroups[$key])) { |
|
355
|
|
|
$studyGroups[$key] = [ ]; |
|
356
|
|
|
} |
|
357
|
|
|
|
|
358
|
|
|
$studyGroups[$key][] = (new StudyGroupData()) |
|
359
|
|
|
->setId($studyGroup->getExternalId()) |
|
360
|
|
|
->setName($studyGroup->getName()) |
|
361
|
|
|
->setType($studyGroup->getType()->value) |
|
362
|
|
|
->setGrades($studyGroup->getGrades()->map(fn(Grade $grade) => $grade->getExternalId())->toArray()); |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
foreach($sections as $section) { |
|
366
|
|
|
$data = $studyGroups[$this->getSectionKey($section)] ?? [ ]; |
|
367
|
|
|
|
|
368
|
|
|
$this->writeFile( |
|
369
|
|
|
sprintf('studygroups_%s.json', $this->getSectionKey($section)), |
|
370
|
|
|
(new StudyGroupsData())->setSection($section->getNumber())->setYear($section->getYear())->setStudyGroups($data) |
|
371
|
|
|
); |
|
372
|
|
|
|
|
373
|
|
|
$io->success(sprintf('%d Lerngruppen exportiert (%s)', count($data), $section->getDisplayName())); |
|
374
|
|
|
} |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
private function exportStudyGroupMemberships(SymfonyStyle $io): void { |
|
378
|
|
|
$io->section('Exportiere Lerngruppenmitgliedschaften'); |
|
379
|
|
|
|
|
380
|
|
|
$memberships = [ ]; |
|
381
|
|
|
|
|
382
|
|
|
/** @var Section[] $sections */ |
|
383
|
|
|
$sections = $this->em->getRepository(Section::class)->findAll(); |
|
384
|
|
|
|
|
385
|
|
|
/** @var StudyGroupMembership $membership */ |
|
386
|
|
|
foreach($this->em->getRepository(StudyGroupMembership::class)->findAll() as $membership) { |
|
387
|
|
|
$key = $this->getSectionKey($membership->getStudyGroup()->getSection()); |
|
388
|
|
|
|
|
389
|
|
|
if(!isset($memberships[$key])) { |
|
390
|
|
|
$memberships[$key] = [ ]; |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
$memberships[$key][] = (new StudyGroupMembershipData()) |
|
394
|
|
|
->setStudent($membership->getStudent()->getExternalId()) |
|
395
|
|
|
->setStudyGroup($membership->getStudyGroup()->getExternalId()) |
|
396
|
|
|
->setType($membership->getType()); |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
foreach($sections as $section) { |
|
400
|
|
|
$data = $memberships[$this->getSectionKey($section)] ?? [ ]; |
|
401
|
|
|
|
|
402
|
|
|
$this->writeFile( |
|
403
|
|
|
sprintf('studygroup_memberships_%s.json', $this->getSectionKey($section)), |
|
404
|
|
|
(new StudyGroupMembershipsData())->setSection($section->getNumber())->setYear($section->getYear())->setMemberships($data) |
|
405
|
|
|
); |
|
406
|
|
|
|
|
407
|
|
|
$io->success(sprintf('%d Lerngruppenmitgliedschaften exportiert (%s)', count($data), $section->getDisplayName())); |
|
408
|
|
|
} |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
private function exportTuitions(SymfonyStyle $io): void { |
|
412
|
|
|
$io->section('Exportiere Unterrichte'); |
|
413
|
|
|
|
|
414
|
|
|
$tuitions = [ ]; |
|
415
|
|
|
|
|
416
|
|
|
/** @var Section[] $sections */ |
|
417
|
|
|
$sections = $this->em->getRepository(Section::class)->findAll(); |
|
418
|
|
|
|
|
419
|
|
|
/** @var Tuition $tuition */ |
|
420
|
|
|
foreach($this->em->getRepository(Tuition::class)->findAll() as $tuition) { |
|
421
|
|
|
$key = $this->getSectionKey($tuition->getSection()); |
|
422
|
|
|
|
|
423
|
|
|
if(!isset($tuitions[$key])) { |
|
424
|
|
|
$tuitions[$key] = [ ]; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
$tuitions[$key][] = (new TuitionData()) |
|
428
|
|
|
->setId($tuition->getExternalId()) |
|
429
|
|
|
->setName($tuition->getName()) |
|
430
|
|
|
->setDisplayName($tuition->getDisplayName()) |
|
431
|
|
|
->setSubject($tuition->getSubject()->getExternalId()) |
|
432
|
|
|
->setStudyGroup($tuition->getStudyGroup()->getExternalId()) |
|
433
|
|
|
->setTeachers($tuition->getTeachers()->map(fn(Teacher $teacher) => $teacher->getExternalId())->toArray()); |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
foreach($sections as $section) { |
|
437
|
|
|
$data = $tuitions[$this->getSectionKey($section)] ?? [ ]; |
|
438
|
|
|
|
|
439
|
|
|
$this->writeFile( |
|
440
|
|
|
sprintf('tuitions_%s.json', $this->getSectionKey($section)), |
|
441
|
|
|
(new TuitionsData())->setSection($section->getNumber())->setYear($section->getYear())->setTuitions($data) |
|
442
|
|
|
); |
|
443
|
|
|
|
|
444
|
|
|
$io->success(sprintf('%d Unterrichte exportiert (%s)', count($data), $section->getDisplayName())); |
|
445
|
|
|
} |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
private function exportExams(SymfonyStyle $io): void { |
|
449
|
|
|
$io->section('Exportiere Klausurplan'); |
|
450
|
|
|
$exams = [ ]; |
|
451
|
|
|
|
|
452
|
|
|
$startDate = null; |
|
453
|
|
|
$endDate = null; |
|
454
|
|
|
|
|
455
|
|
|
/** @var Exam $exam */ |
|
456
|
|
|
foreach($this->em->getRepository(Exam::class)->findAll() as $exam) { |
|
457
|
|
|
if($exam->getExternalId() === null) { |
|
458
|
|
|
continue; |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
if($startDate === null || $startDate > $exam->getDate()) { |
|
462
|
|
|
$startDate = clone $exam->getDate(); |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
if($endDate === null || $endDate < $exam->getDate()) { |
|
466
|
|
|
$endDate = clone $exam->getDate(); |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
$supervisions = [ ]; |
|
470
|
|
|
foreach($exam->getSupervisions() as $supervision) { |
|
471
|
|
|
$supervisions[$supervision->getLesson()] = $supervision->getTeacher()->getExternalId(); |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
$exams[] = (new ExamData()) |
|
475
|
|
|
->setId($exam->getExternalId()) |
|
476
|
|
|
->setDate($exam->getDate()) |
|
477
|
|
|
->setLessonStart($exam->getLessonStart()) |
|
478
|
|
|
->setLessonEnd($exam->getLessonEnd()) |
|
479
|
|
|
->setRooms(array_values(array_fill($exam->getLessonStart(), $exam->getLessonEnd(), $exam->getRoom()))) |
|
480
|
|
|
->setStudents($exam->getStudents()->map(fn(Student $student) => $student->getExternalId())->toArray()) |
|
481
|
|
|
->setTuitions($exam->getTuitions()->map(function(Tuition $tuition) { |
|
482
|
|
|
return (new ExamTuition()) |
|
483
|
|
|
->setTeachers($tuition->getTeachers()->map(fn(Teacher $teacher) => $teacher->getExternalId())->toArray()) |
|
484
|
|
|
->setGrades($tuition->getStudyGroup()->getGrades()->map(fn(Grade $grade) => $grade->getExternalId())->toArray()) |
|
485
|
|
|
->setSubjectOrCourse($tuition->getName()); |
|
486
|
|
|
})->toArray()) |
|
487
|
|
|
->setSupervisions(array_values($supervisions)); |
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
|
$data = (new ExamsData())->setStartDate($startDate)->setEndDate($endDate)->setExams($exams); |
|
491
|
|
|
$this->writeFile('exams.json', $data); |
|
492
|
|
|
|
|
493
|
|
|
$io->success(sprintf('%d Klausur(en) exportiert', count($exams))); |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
private function exportAppointmentCategories(SymfonyStyle $io): void { |
|
497
|
|
|
$io->section('Exportiere Terminkategorien'); |
|
498
|
|
|
|
|
499
|
|
|
$categories = [ ]; |
|
500
|
|
|
|
|
501
|
|
|
/** @var AppointmentCategory $category */ |
|
502
|
|
|
foreach($this->em->getRepository(AppointmentCategory::class)->findAll() as $category) { |
|
503
|
|
|
$categories[] = (new AppointmentCategoryData()) |
|
504
|
|
|
->setId($category->getExternalId()) |
|
505
|
|
|
->setColor($category->getColor()) |
|
506
|
|
|
->setName($category->getName()); |
|
507
|
|
|
} |
|
508
|
|
|
|
|
509
|
|
|
$data = (new AppointmentCategoriesData())->setCategories($categories); |
|
510
|
|
|
$this->writeFile('appointment_categories.json', $data); |
|
511
|
|
|
|
|
512
|
|
|
$io->success(sprintf('%d Terminkategorien exportiert', count($categories))); |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
private function exportAppointments(SymfonyStyle $io): void { |
|
516
|
|
|
$io->section('Exportiere Termine'); |
|
517
|
|
|
$appointments = [ ]; |
|
518
|
|
|
|
|
519
|
|
|
/** @var Appointment $appointment */ |
|
520
|
|
|
foreach($this->em->getRepository(Appointment::class)->findAll() as $appointment) { |
|
521
|
|
|
if($appointment->getExternalId() === null) { |
|
522
|
|
|
continue; |
|
523
|
|
|
} |
|
524
|
|
|
|
|
525
|
|
|
$appointments[] = (new AppointmentData()) |
|
526
|
|
|
->setId($appointment->getExternalId()) |
|
527
|
|
|
->setStart($appointment->getStart()) |
|
528
|
|
|
->setEnd($appointment->getEnd()) |
|
529
|
|
|
->setContent($appointment->getContent()) |
|
530
|
|
|
->setIsAllDay($appointment->isAllDay()) |
|
531
|
|
|
->setLocation($appointment->getLocation()) |
|
532
|
|
|
->setSubject($appointment->getTitle()) |
|
533
|
|
|
->setCategory($appointment->getCategory()->getExternalId()) |
|
534
|
|
|
->setExternalOrganizers($appointment->getExternalOrganizers()) |
|
535
|
|
|
->setOrganizers($appointment->getOrganizers()->map(fn(Teacher $teacher) => $teacher->getExternalId())->toArray()) |
|
536
|
|
|
->setStudyGroups($appointment->getStudyGroups()->map(fn(StudyGroup $studyGroup) => $studyGroup->getExternalId())->toArray()) |
|
537
|
|
|
->setVisibilities($appointment->getVisibilities()->map(fn(UserTypeEntity $type) => $type->getUserType()->value)->toArray()); |
|
538
|
|
|
} |
|
539
|
|
|
|
|
540
|
|
|
$data = (new AppointmentsData())->setAppointments($appointments); |
|
541
|
|
|
$this->writeFile('appointment.json', $data); |
|
542
|
|
|
|
|
543
|
|
|
$io->success(sprintf('%d Termine exportiert', count($appointments))); |
|
544
|
|
|
} |
|
545
|
|
|
|
|
546
|
|
|
private function exportTimetable(SymfonyStyle $io): void { |
|
547
|
|
|
$io->section('Exportiere Stundenplan'); |
|
548
|
|
|
|
|
549
|
|
|
$timetable = [ ]; |
|
550
|
|
|
|
|
551
|
|
|
/** @var TimetableLesson $lesson */ |
|
552
|
|
|
foreach($this->em->getRepository(TimetableLesson::class)->findAll() as $lesson) { |
|
553
|
|
|
$timetable[] = (new TimetableLessonData()) |
|
554
|
|
|
->setId($lesson->getExternalId()) |
|
555
|
|
|
->setDate($lesson->getDate()) |
|
556
|
|
|
->setLessonStart($lesson->getLessonStart()) |
|
557
|
|
|
->setLessonEnd($lesson->getLessonEnd()) |
|
558
|
|
|
->setRoom($lesson->getRoom() !== null ? $lesson->getRoom()->getExternalId() : $lesson->getLocation()) |
|
559
|
|
|
->setSubject($lesson->getSubjectName()) |
|
560
|
|
|
->setTeachers($lesson->getTeachers()->map(fn(Teacher $teacher) => $teacher->getExternalId())->toArray()); |
|
561
|
|
|
} |
|
562
|
|
|
|
|
563
|
|
|
/** @var Section $section */ |
|
564
|
|
|
foreach($this->em->getRepository(Section::class)->findAll() as $section) { |
|
565
|
|
|
$data = array_filter($timetable, fn(TimetableLessonData $lesson) => $lesson->getDate() >= $section->getStart() && $lesson->getDate() <= $section->getEnd()); |
|
566
|
|
|
|
|
567
|
|
|
$this->writeFile( |
|
568
|
|
|
sprintf('timetable_lessons_%s.json', $this->getSectionKey($section)), |
|
569
|
|
|
(new TimetableLessonsData())->setStartDate($section->getStart())->setEndDate($section->getEnd())->setLessons($data) |
|
570
|
|
|
); |
|
571
|
|
|
|
|
572
|
|
|
$io->success(sprintf('%d Stundenplanstunden exportiert (%s)', count($data), $section->getDisplayName())); |
|
573
|
|
|
} |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
private function exportSupervisions(SymfonyStyle $io): void { |
|
577
|
|
|
$io->section('Exportiere Aufsichten'); |
|
578
|
|
|
|
|
579
|
|
|
$supervisions = [ ]; |
|
580
|
|
|
|
|
581
|
|
|
/** @var TimetableSupervision $supervision */ |
|
582
|
|
|
foreach($this->em->getRepository(TimetableSupervision::class)->findAll() as $supervision) { |
|
583
|
|
|
$supervisions[] = (new TimetableSupervisionData()) |
|
584
|
|
|
->setId($supervision->getExternalId()) |
|
585
|
|
|
->setIsBefore($supervision->isBefore()) |
|
586
|
|
|
->setDate($supervision->getDate()) |
|
587
|
|
|
->setLesson($supervision->getLesson()) |
|
588
|
|
|
->setLocation($supervision->getLocation()) |
|
589
|
|
|
->setTeacher($supervision->getTeacher()->getExternalId()); |
|
590
|
|
|
} |
|
591
|
|
|
|
|
592
|
|
|
/** @var Section $section */ |
|
593
|
|
|
foreach($this->em->getRepository(Section::class)->findAll() as $section) { |
|
594
|
|
|
$data = array_filter($supervisions, fn(TimetableSupervisionData $supervision) => $supervision->getDate() >= $section->getStart() && $supervision->getDate() <= $section->getEnd()); |
|
595
|
|
|
|
|
596
|
|
|
$this->writeFile( |
|
597
|
|
|
sprintf('timetable_supervisions_%s.json', $this->getSectionKey($section)), |
|
598
|
|
|
(new TimetableSupervisionsData())->setStartDate($section->getStart())->setEndDate($section->getEnd())->setSupervisions($supervisions) |
|
599
|
|
|
); |
|
600
|
|
|
|
|
601
|
|
|
$io->success(sprintf('%d Aufsichten exportiert (%s)', count($data), $section->getDisplayName())); |
|
602
|
|
|
} |
|
603
|
|
|
} |
|
604
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths