Skip to content

Commit

Permalink
Merge pull request #296 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Some Updates
  • Loading branch information
JoshuaMicallefYBSU authored Aug 18, 2024
2 parents c4a3b38 + df225f3 commit f86795e
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 47 deletions.
3 changes: 1 addition & 2 deletions app/Http/Controllers/Training/ApplicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function apply(Request $request)
}

//Check hours of controller

//Download via CURL
$url = 'https://api.vatsim.net/v2/members/'.auth()->id().'/stats';
// $url = 'https://api.vatsim.net/v2/members/1342084/stats';
Expand Down Expand Up @@ -438,7 +437,7 @@ public function adminAcceptApplication($reference_id, Request $request)
$discord->assignRole($student->user->discord_user_id, 482824058141016075);

//Create Instructor Thread
$discord->createTrainingThread($student->user->fullName('FLC'), '<@'.$student->user->discord_user_id.'>');
$discord->createTrainingThread($student->user->id, '<@'.$student->user->discord_user_id.'>');

// Notify Senior Team that the application was accepted.
$discord->sendMessageWithEmbed(config('app.env') == 'local' ? intval(config('services.discord.web_logs')) : intval(config('services.discord.applications')), 'Accepted Applicant', $student->user->fullName('FLC').' has just been accepted.', 'error');
Expand Down
36 changes: 24 additions & 12 deletions app/Http/Controllers/Training/InstructingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public function instructors()
public function students()
{
//Get all students
$students = Student::whereCurrent(true)->get();
$pastStudents = Student::whereCurrent(false)->get();
$students = Student::whereCurrent(true)->orderBy('created_at', 'desc')->get();
$pastStudents = Student::whereCurrent(false)->orderBy('updated_at', 'desc')->get();

//Return view
return view('admin.training.instructing.students.index', compact('students', 'pastStudents'));
Expand Down Expand Up @@ -409,10 +409,10 @@ public function removeStudent($cid)
//remove student discord role
$discord->removeRole($student->user->discord_user_id, 482824058141016075);

$discord->EditThreadTag('Inactive', $student->user->fullName('FLC'));
$discord->EditThreadTag('Inactive', $student->user->id);

//close Instructor Thread
$discord->closeTrainingThread($student->user->fullName('FLC'), 'cancel');
$discord->closeTrainingThread($student->user->id, $student->user->discord_user_id, 'cancel');

// Notify Senior Team that new training has been terminated.
$discord->sendMessageWithEmbed(config('app.env') == 'local' ? intval(config('services.discord.web_logs')) : intval(config('services.discord.instructors')), 'Training Terminated', $student->user->fullName('FLC').' has had their training terminated.', 'error');
Expand All @@ -433,6 +433,7 @@ public function removeStudent($cid)
$label->delete();
}
}

if ($student->instructor()) {
$student->instructor()->delete();
}
Expand All @@ -446,7 +447,7 @@ public function removeStudent($cid)
//Save
$student->save();

//Remove assignments
//Remove Instructor from Student
$links = InstructorStudentAssignment::where('student_id', $student->id);
foreach ($links as $l) {
$l->delete();
Expand Down Expand Up @@ -479,6 +480,13 @@ public function certifyStudent($cid)
]);
$link->save();

//Remove labels and instructor links and availability
foreach ($student->labels as $label) {
if (!in_array($label->label()->name, ['Completed'])) {
$label->delete();
}
}

// Unassign Instructor from Student
$instructor_link = InstructorStudentAssignment::where('student_id', $cid);
$instructor_link->delete();
Expand All @@ -491,13 +499,17 @@ public function certifyStudent($cid)
]);
$controller_cert->save();

// Update Thread Tag to match site
$discord = new DiscordClient();
$discord->EditThreadTag('Completed', $student->user->fullName('FLC'));
if ($student->user->hasDiscord() && $student->user->member_of_czqo) {
// Update Thread Tag to match site
$discord = new DiscordClient();
$discord->EditThreadTag('Completed', $student->user->id);

// Close Training Thread Out & Send Completion Message
$discord = new DiscordClient();
$discord->closeTrainingThread($student->user->fullName('FLC'), 'certify');
// Close Training Thread Out & Send Completion Message
$discord = new DiscordClient();
$discord->closeTrainingThread($student->user->fullName('FLC'), $student->user->discord_user_id, 'certify');
} else {

}

// Update Roster with Certification Status
$rosterMember = RosterMember::where('cid', $cid)->firstOrFail();
Expand Down Expand Up @@ -694,7 +706,7 @@ public function assignStatusLabelToStudent(Request $request, $student_id)

// Update Thread Tag to match site
$discord = new DiscordClient();
$discord->EditThreadTag($label->name, $student->user->fullName('FLC'));
$discord->EditThreadTag($label->name, $student->user->id);

//Create the link
$link = new StudentStatusLabelLink([
Expand Down
Loading

0 comments on commit f86795e

Please sign in to comment.