@@ -26,6 +26,6 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | public function store_student_comment(User $user, Student $student) |
| 28 | 28 | { |
| 29 | - return ($student->enrollments()->whereHas('course', fn ($q) => $q->where('teacher_id', $user->id))->count() > 0) || $user->can('comments.edit'); |
|
| 29 | + return ($student->enrollments()->whereHas('course', fn($q) => $q->where('teacher_id', $user->id))->count() > 0) || $user->can('comments.edit'); |
|
| 30 | 30 | } |
| 31 | 31 | } |
@@ -30,69 +30,69 @@ |
||
| 30 | 30 | * a user is allowed to edit the course grades if they are the teacher for this course, |
| 31 | 31 | * or if they have explicit permission to do so |
| 32 | 32 | */ |
| 33 | - Gate::define('edit-course-grades', fn ($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('evaluation.edit')); |
|
| 33 | + Gate::define('edit-course-grades', fn($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('evaluation.edit')); |
|
| 34 | 34 | |
| 35 | 35 | /* |
| 36 | 36 | * a user is allowed to view the course attendance sheet if they are the teacher for this course, |
| 37 | 37 | * or if they have explicit permission to view all course attendance sheets |
| 38 | 38 | */ |
| 39 | - Gate::define('view-course-attendance', fn ($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('attendance.view')); |
|
| 39 | + Gate::define('view-course-attendance', fn($user, $course) => $user->isTeacher() && $user->id == $course->teacher_id || $user->can('attendance.view')); |
|
| 40 | 40 | |
| 41 | 41 | /* |
| 42 | 42 | * a user is allowed to view the event attendance sheet if they are the teacher for this event, |
| 43 | 43 | * if they are the teacher for this course, |
| 44 | 44 | * or if they have explicit permission to view all event attendance sheets |
| 45 | 45 | */ |
| 46 | - Gate::define('view-event-attendance', fn ($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.view')); |
|
| 46 | + Gate::define('view-event-attendance', fn($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.view')); |
|
| 47 | 47 | |
| 48 | 48 | /* |
| 49 | 49 | * a user is allowed to edit an attendance sheet if they are the teacher for the event, |
| 50 | 50 | * if they are the teacher for the course, |
| 51 | 51 | * or if they have explicit permission to edit any attendance sheets |
| 52 | 52 | */ |
| 53 | - Gate::define('edit-attendance', fn ($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.edit')); |
|
| 53 | + Gate::define('edit-attendance', fn($user, $event) => ($event->teacher_id == $user->id) || ($event->course->teacher_id == $user->id) || $user->can('attendance.edit')); |
|
| 54 | 54 | |
| 55 | 55 | /* |
| 56 | 56 | * teachers are allowed to view their own calendar, |
| 57 | 57 | * and users with explicit permission can view all calendars |
| 58 | 58 | */ |
| 59 | - Gate::define('view-teacher-calendar', fn ($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('calendars.view')); |
|
| 59 | + Gate::define('view-teacher-calendar', fn($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('calendars.view')); |
|
| 60 | 60 | |
| 61 | 61 | /* |
| 62 | 62 | * teachers are allowed to view their own courses, |
| 63 | 63 | * and users with explicit permission can view all courses |
| 64 | 64 | */ |
| 65 | - Gate::define('view-course', fn ($user, Course $course) => ($user->isTeacher() && $user->id == $course->teacher_id) || $user->can('courses.view')); |
|
| 65 | + Gate::define('view-course', fn($user, Course $course) => ($user->isTeacher() && $user->id == $course->teacher_id) || $user->can('courses.view')); |
|
| 66 | 66 | |
| 67 | 67 | /* |
| 68 | 68 | * the user is allowed to view the result if they are the student, |
| 69 | 69 | * if they are a teacher |
| 70 | 70 | * of if they have explicit permission to view any result |
| 71 | 71 | */ |
| 72 | - Gate::define('view-enrollment', fn ($user, $enrollment) => ($user->isStudent() && $user->id == $enrollment->student_id) || $user->isTeacher() || $user->can('evaluation.view')); |
|
| 72 | + Gate::define('view-enrollment', fn($user, $enrollment) => ($user->isStudent() && $user->id == $enrollment->student_id) || $user->isTeacher() || $user->can('evaluation.view')); |
|
| 73 | 73 | |
| 74 | 74 | /* |
| 75 | 75 | * if the user is the teacher of the course |
| 76 | 76 | * of if they have explicit permission to enroll students |
| 77 | 77 | */ |
| 78 | - Gate::define('enroll-in-course', fn ($user, $course) => $course->teacher_id == $user->id || $user->can('enrollments.edit')); |
|
| 78 | + Gate::define('enroll-in-course', fn($user, $course) => $course->teacher_id == $user->id || $user->can('enrollments.edit')); |
|
| 79 | 79 | |
| 80 | 80 | /* |
| 81 | 81 | * if the user is a teacher |
| 82 | 82 | * of if they have explicit permission to enroll students |
| 83 | 83 | */ |
| 84 | - Gate::define('enroll-students', fn ($user) => $user->isTeacher() || $user->can('enrollments.edit')); |
|
| 84 | + Gate::define('enroll-students', fn($user) => $user->isTeacher() || $user->can('enrollments.edit')); |
|
| 85 | 85 | |
| 86 | 86 | /* |
| 87 | 87 | * teachers are allowed to view their own hours, |
| 88 | 88 | * and users with explicit permission can view all hours |
| 89 | 89 | */ |
| 90 | - Gate::define('view-teacher-hours', fn ($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('hr.view')); |
|
| 90 | + Gate::define('view-teacher-hours', fn($user, $teacher) => ($user->isTeacher() && $user->id == $teacher->id) || $user->can('hr.view')); |
|
| 91 | 91 | |
| 92 | 92 | /* |
| 93 | 93 | * teachers are allowed to edit results for their own students |
| 94 | 94 | * as well as users with explicit permission to edit any result |
| 95 | 95 | */ |
| 96 | - Gate::define('edit-result', fn ($user, $enrollment) => ($user->isTeacher() && $user->id == $enrollment->course->teacher_id) || $user->can('evaluation.edit')); |
|
| 96 | + Gate::define('edit-result', fn($user, $enrollment) => ($user->isTeacher() && $user->id == $enrollment->course->teacher_id) || $user->can('evaluation.edit')); |
|
| 97 | 97 | } |
| 98 | 98 | } |
@@ -172,7 +172,7 @@ |
||
| 172 | 172 | 'price_b' => $enrollment->course->price_b, |
| 173 | 173 | 'price_c' => $enrollment->course->price_c, |
| 174 | 174 | ]), |
| 175 | - 'studentPriceCategory' => $enrollment->student?->price_category, |
|
| 175 | + 'studentPriceCategory' => $enrollment->student ? ->price_category, |
|
| 176 | 176 | ] |
| 177 | 177 | ); |
| 178 | 178 | } |
@@ -172,7 +172,7 @@ |
||
| 172 | 172 | 'price_b' => $enrollment->course->price_b, |
| 173 | 173 | 'price_c' => $enrollment->course->price_c, |
| 174 | 174 | ]), |
| 175 | - 'studentPriceCategory' => $enrollment->student?->price_category, |
|
| 175 | + 'studentPriceCategory' => $enrollment->student ? ->price_category, |
|
| 176 | 176 | ] |
| 177 | 177 | ); |
| 178 | 178 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | protected $description = 'Guess gender for existing students, based on their firstname'; |
| 14 | 14 | |
| 15 | 15 | // wordpress implementation, from https://github.com/WordPress/WordPress/blob/a2693fd8602e3263b5925b9d799ddd577202167d/wp-includes/formatting.php#L1528 |
| 16 | - private function remove_accents( $string ) { |
|
| 16 | + private function remove_accents($string) { |
|
| 17 | 17 | |
| 18 | 18 | $chars = array( |
| 19 | 19 | // Decompositions for Latin-1 Supplement |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | 'À' => 'A', 'Á' => 'A', |
| 22 | 22 | 'Â' => 'A', 'Ã' => 'A', |
| 23 | 23 | 'Ä' => 'A', 'Å' => 'A', |
| 24 | - 'Æ' => 'AE','Ç' => 'C', |
|
| 24 | + 'Æ' => 'AE', 'Ç' => 'C', |
|
| 25 | 25 | 'È' => 'E', 'É' => 'E', |
| 26 | 26 | 'Ê' => 'E', 'Ë' => 'E', |
| 27 | 27 | 'Ì' => 'I', 'Í' => 'I', |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | 'Ö' => 'O', 'Ù' => 'U', |
| 33 | 33 | 'Ú' => 'U', 'Û' => 'U', |
| 34 | 34 | 'Ü' => 'U', 'Ý' => 'Y', |
| 35 | - 'Þ' => 'TH','ß' => 's', |
|
| 35 | + 'Þ' => 'TH', 'ß' => 's', |
|
| 36 | 36 | 'à' => 'a', 'á' => 'a', |
| 37 | 37 | 'â' => 'a', 'ã' => 'a', |
| 38 | 38 | 'ä' => 'a', 'å' => 'a', |
| 39 | - 'æ' => 'ae','ç' => 'c', |
|
| 39 | + 'æ' => 'ae', 'ç' => 'c', |
|
| 40 | 40 | 'è' => 'e', 'é' => 'e', |
| 41 | 41 | 'ê' => 'e', 'ë' => 'e', |
| 42 | 42 | 'ì' => 'i', 'í' => 'i', |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'Ĭ' => 'I', 'ĭ' => 'i', |
| 76 | 76 | 'Į' => 'I', 'į' => 'i', |
| 77 | 77 | 'İ' => 'I', 'ı' => 'i', |
| 78 | - 'IJ' => 'IJ','ij' => 'ij', |
|
| 78 | + 'IJ' => 'IJ', 'ij' => 'ij', |
|
| 79 | 79 | 'Ĵ' => 'J', 'ĵ' => 'j', |
| 80 | 80 | 'Ķ' => 'K', 'ķ' => 'k', |
| 81 | 81 | 'ĸ' => 'k', 'Ĺ' => 'L', |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | 'Ō' => 'O', 'ō' => 'o', |
| 92 | 92 | 'Ŏ' => 'O', 'ŏ' => 'o', |
| 93 | 93 | 'Ő' => 'O', 'ő' => 'o', |
| 94 | - 'Œ' => 'OE','œ' => 'oe', |
|
| 95 | - 'Ŕ' => 'R','ŕ' => 'r', |
|
| 96 | - 'Ŗ' => 'R','ŗ' => 'r', |
|
| 97 | - 'Ř' => 'R','ř' => 'r', |
|
| 98 | - 'Ś' => 'S','ś' => 's', |
|
| 99 | - 'Ŝ' => 'S','ŝ' => 's', |
|
| 100 | - 'Ş' => 'S','ş' => 's', |
|
| 94 | + 'Œ' => 'OE', 'œ' => 'oe', |
|
| 95 | + 'Ŕ' => 'R', 'ŕ' => 'r', |
|
| 96 | + 'Ŗ' => 'R', 'ŗ' => 'r', |
|
| 97 | + 'Ř' => 'R', 'ř' => 'r', |
|
| 98 | + 'Ś' => 'S', 'ś' => 's', |
|
| 99 | + 'Ŝ' => 'S', 'ŝ' => 's', |
|
| 100 | + 'Ş' => 'S', 'ş' => 's', |
|
| 101 | 101 | 'Š' => 'S', 'š' => 's', |
| 102 | 102 | 'Ţ' => 'T', 'ţ' => 't', |
| 103 | 103 | 'Ť' => 'T', 'ť' => 't', |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | public function handle() |
| 199 | 199 | { |
| 200 | - Student::whereNull('gender_id')->chunkById(10, function ($students) { |
|
| 200 | + Student::whereNull('gender_id')->chunkById(10, function($students) { |
|
| 201 | 201 | $query = $students->map(fn($student) => ['id' => $student->id, 'name' => $this->remove_accents(strtok($student->firstname, " "))]); |
| 202 | 202 | |
| 203 | - $response = Http::get('https://api.genderize.io/?name[]=' . $query->pluck('name')->implode('&name[]=')); |
|
| 203 | + $response = Http::get('https://api.genderize.io/?name[]='.$query->pluck('name')->implode('&name[]=')); |
|
| 204 | 204 | foreach ($students as $student) { |
| 205 | 205 | $firstname = $query->firstWhere('id', $student->id)['name']; |
| 206 | 206 | |