vendredi 6 décembre 2019

About designing a course system. When should I inspect assignments due or not? Where should I put this logic?

I am working on designing a system for students, teachers, etc. to use, and I'm using Laravel Framework to develop. Teachers can create course and assign homework to the courses' students, and they can set the due date for them separately.

My question is:

  1. When should I check the date is expired or not?
  2. Where should I put this logic?

In my opinion:

  1. For example, we have course Mathematics for student Aaron, and the teacher is Josh. When Aaron or Josh log into the system, check their course Mathematics is expired or not. Otherwise, only check when they click on the assignment or course page.
  2. Create a middleware for checking, and apply it to Route.

    Route::group(['middleware' => 'check'], function(){
        Route::get('/dashboard'); 
        Route::get('/courses');
        Route::get('/assignments');
    }
    

    Otherwise, create a service(use service and repository design pattern) for controller to call.

    //controller 
    public function getDashboard(){
        $user = Auth::user();
        ...
        $this->assignmentService->check(); //check for assignment
        $this->courseService->check(); // check for course
        ...
    }
    

Aucun commentaire:

Enregistrer un commentaire