Application Overview
Introduction
The Application is the aggreget model of OTAS
system, the main job of the system is to process a student application to an institution through it's diffrent phase along it's lifecycle.
Below is a digram explaing the application and it's relation with other entities of the system.
[Digram goes here]
As you can see an application has almost a relation with everything.
Create a new application
An application can be created from through the System, API and Third-party systems. here we will see how an application from the system.
You can create an application by visiting the route /dashboard/student/{student_id}/applications/add
under the hood this form hit the onSave
method on the add-application.htm
view, this method create an instance of SpotlayerTeam\InstitutionsPrograms\Models\Application
, validates the comming request and save the instance to the database
$application = new Application;$application->user_id = $this->param('studentId');$application->school_id = $data['school_id'];$application->level_id = $appProgram->level_id;$application->program_id = $data['program_id'];$application->description = $data['description'];$application->application_id = isset($data['application_id']) ? $data['application_id'] : null ;$application->online = isset($data['online']) ? $data['online'] : null ;$application->year_id = $data['year_id'];$application->semester_id = $data['semester_id'];$application->created_at = \Carbon\Carbon::now();$application->save()
After that any application application should be assigned to a CL1, this where we attach one of the important realtion
of the application cl1
. these process happane within a method of the application view like below
$nextInsertCL = $this->choseCl1($application); // the chose cl1 method body below function choseCl1($application){ $lastStudentApp = Application::where('user_id', $this->param('studentId')) ->where('deleted_at', null) ->orderBy('created_at', 'desc') ->first(); $nextInsertCL = Application::assignToCl1($this->param('studentId'), post('school_id'), $lastStudentApp->cl1 ?? null,$application->creator); if($application->creator->groupOf([10,12]) && $application->created_by == $nextInsertCL){ return $this->choseCl1($application); } return $nextInsertCL;}
within this method we check for the last inserted application for this student on the DB, if we find he has an application before we will assign his last cl1 to the application
otherwise will try to find another one who can match with the application's cls criteria
.
There are some other process which can take place when creating an application.
if (isset(\AuthManager::getUser()->id)) { $app->notify();} $shouldSendEmail = (!$app->auto && !$app->creator->hasGroup([5, 20]) && request('send_auto_email') == 1) || (!$app->auto && ApiClient::sourceIs($app->source, 'otas-plugin'));if ($shouldSendEmail) { Queue::push(EmailQueue::class, [ "template_name" => "otas::mail.application.created", "message_vars" => [ 'name' => $app->student->user->name, 'studentName' => $app->student->name, 'program' => $app->program->title_en, 'university' => $app->school->name, 'creatorName' => $app->creator->name, 'creatorTitle' => $app->creator->title, 'creatorOrganization' => $app->creator->organization, 'creatorPhone' => $app->creator->phone, 'creatorEmail' => $app->creator->email, ], "to_email" => $app->student->user->email, "to_name" => $app->student->name, "reply_to" => $app->creator->email, ], "emails");}
For every application got created within the system we will notify the assigned employee. and sometime we push a mail to the queue telling the student that he has an application got created.
See mailable on october cms.Mail Templates
CLs criteria
Choosing one of the Cls of the application can be a complex process. so for every application there are a set of criteria
that should be matched first to assigning the cl1/cl2
if these criteria were not matched the cl1/cl2
will be chosen randomly from the employees.
Cls criteria are:
- Creator of the application group,
cls can accept applications from a specific group of creators. these groups are saved in the filed
cl_creator_ids
on theUser
object of the employee - and can be edited from the system
Dashboard >> CL1/CL2 Permissions >> Edit CL
School the application is for, cls can accept application for specific schools, these schools are saved in the filedcl_school_ids
on theUser
object of the employee
and can be edited from the systemDashboard >> CL1/CL2 Permissions >> Edit CL
- Country the applicant is from, cls can accept application for specific countries, these countries are saved in the filed
cl_country_ids
on theUser
object of the employee
and can be edited from the systemDashboard >> CL1/CL2 Permissions >> Edit CL
.
With these criteria we will try to find appropriate Cl1 or Cl2 for the application as the code below
public static function getListOfApplicableCL($type, $schoolID){ $types = [1 => 12, 2 => 10]; $CLType = $types[$type]; $country = static::$country; return \KEERill\Users\Models\User::whereHas('groups', function ($query) use ($CLType) { $query->where('group_id', $CLType); })->where('is_activated', 1) ->where(function ($query) use ($schoolID, $country) { $query->whereInSet('cl_creator_ids', static::$creatorGroups) ->whereInSet('cl_school_ids', $schoolID) ->whereInSet('cl_country_ids', $country); })->pluck('id');}
The method above is on the SpotlayerTeam\InstitutionsPrograms\Models\Application
class and its chose a Cl based on the criteria.