BinghamtonUniversity / BComply

BComply is an Open Source Compliance Training application which allows administrators to upload, assign, and track the completion of custom-built training modules.
http://bcomplydev.binghamton.edu
MIT License
4 stars 0 forks source link

Handle Assignment Reminders with no due date #15

Open timcortesi opened 3 years ago

timcortesi commented 3 years ago

In app/Console/Kernel.php around like 47: We Need to confirm that $assignment->date_due is not null before continuing:

$differenceInDays = $assignment->date_due->diffInDays(Carbon::now());

We should also look at the situations which would cause a null date_due. Is this problematic in other situations? Should this be allowable?

If date_due is null, we get the following error:

[2020-12-26 02:00:19] prod.ERROR: Call to a member function diffInDays() on null {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function diffInDays() on null at /var/app/current/app/Console/Kernel.php:47)

We should probably also wrap all of the code inside the module_assignment loop with a try/catch so that it will continue in the event that ANYTHING fails within the loop (around line 43):

//Checks all of the assignment due dates to send emails to users
foreach($module_assignments as $assignment){
    // ADD A "try" block here!!
    $module = $modules->where('id',$assignment->module_id)->first();
    $user = $assignment->user()->where('id',$assignment->user_id)->first();
timcortesi commented 3 years ago

Tagging @phelpsa as an FYI on this issue.

alikemaltanriverdi commented 3 years ago

Fault prevention mechanism has been added to the Kernel.php and seems to be working fine. Once the all tests are done, I will commit my changes.

alikemaltanriverdi commented 3 years ago

The most up to date code is now in the BComply environment and it seems to be working fine so far. I will post another update once we think everything is working as expected and we are ready to go live. In order for me to complete the tests, I will need to wait for Bulk Assignment to run tomorrow (at 2am or 2:30am?) as scheduled.