Skip to content

Commit

Permalink
Fix Student Completion Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaMicallefYBSU committed Aug 15, 2024
1 parent 124a65e commit 39bd75c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/Http/Controllers/Training/InstructingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ public function certifyStudent($cid)
{
$student = Student::where('user_id', $cid)->firstOrFail();

//Make as not current
$student->current = false;
$student->save();

// Remove Student Status & Set Controller as Active
$student->user->removeRole('Student');
$student->user->assignRole('Certified Controller');
Expand All @@ -472,21 +476,25 @@ public function certifyStudent($cid)
]);
$link->save();

// Unassign Instructor from Student
$instructor_id = InstructorStudentAssignment::where('student_id', $student->id)->firstOrFail();
$instructor_id->delete();

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

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

// Update Roster with Certification Status
$rosterMember = RosterMember::where('cid', $cid)->firstOrFail();

//Assign values
$rosterMember->certification = 'Certified';
$rosterMember->active = 1;
$rosterMember->remarks = 'Certified on NAT_FSS (Automatic Message)';
$rosterMember->remarks = 'Certified on NAT_FSS (Web Message)';
$rosterMember->date_certified = Carbon::now();

//User
Expand All @@ -512,6 +520,8 @@ public function certifyStudent($cid)
$discord->assignRole($rosterMember->user->discord_user_id, $roles['student']);
$discord->removeRole($rosterMember->user->discord_user_id, $roles['certified']);
}


} else {
Session::flash('info', 'Unable to add Discord permissions automatically.');
}
Expand Down
14 changes: 14 additions & 0 deletions app/Models/Users/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ public function isBot()
return false;
}

// // Assign role to user Model
// public function assignRole($role)
// {
// return $role;
// }

// // Remove role from user Model
// public function removeRole($role)
// {

// }

/**
* Return articles that the user has written.
*
Expand Down Expand Up @@ -245,6 +257,8 @@ public function highestRole()
return $this->roles[0];
}



/**
* Get the user's name in requested format.
* FLC - First, Last, CID
Expand Down

0 comments on commit 39bd75c

Please sign in to comment.