-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug] Fix mistake in how status is computed for final assessment step (…
…#12539) * Refine computeAssessmentStatus so any disqualified step always disqualifies overallAssessmentStatus * Add regression test * Seed more comprehensive assessments, and skip random assessment seeder which wasn't helpful * Simplify and fix new test * Make SyncAssessmentStatus cmd dispatch CandidateStatusChanged just like ComputeCandidateAssessmentStatus listener (cherry picked from commit 95cdea5)
- Loading branch information
1 parent
c829173
commit 1548d53
Showing
5 changed files
with
193 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
use App\Enums\AssessmentDecisionLevel; | ||
use App\Enums\AssessmentResultJustification; | ||
use App\Enums\AssessmentResultType; | ||
use App\Enums\AssessmentStepType; | ||
use App\Enums\PoolSkillType; | ||
use App\Models\AssessmentResult; | ||
use App\Models\AssessmentStep; | ||
|
@@ -74,107 +75,116 @@ public function run() | |
]); | ||
|
||
$publishedPool = Pool::select('id')->where('name->en', 'Published – Complex')->sole(); | ||
$user1 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate1 = PoolCandidate::select('id')->where('user_id', $user1->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$assessmentStep = AssessmentStep::factory()->create([ | ||
'pool_id' => $publishedPool->id, | ||
]); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate1, | ||
$publishedPool->poolSkills()->pluck('id')->toArray(), | ||
$assessmentStep, | ||
AssessmentDecisionLevel::ABOVE_REQUIRED->name, | ||
[AssessmentResultJustification::EDUCATION_ACCEPTED_INFORMATION->name], | ||
AssessmentDecision::SUCCESSFUL->name, | ||
AssessmentResultType::EDUCATION); | ||
|
||
$user2 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate2 = PoolCandidate::select('id')->where('user_id', $user2->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate2, | ||
$publishedPool->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->pluck('id')->toArray(), | ||
$assessmentStep, | ||
AssessmentDecisionLevel::AT_REQUIRED->name, | ||
[AssessmentResultJustification::EDUCATION_ACCEPTED_WORK_EXPERIENCE_EQUIVALENCY->name], | ||
AssessmentDecision::SUCCESSFUL->name, | ||
AssessmentResultType::SKILL); | ||
|
||
$user3 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate3 = PoolCandidate::select('id')->where('user_id', $user3->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate3, | ||
$publishedPool->poolSkills()->pluck('id')->toArray(), | ||
$assessmentStep, | ||
AssessmentDecisionLevel::ABOVE_REQUIRED->name, | ||
[AssessmentResultJustification::EDUCATION_ACCEPTED_WORK_EXPERIENCE_EQUIVALENCY->name], | ||
AssessmentDecision::SUCCESSFUL->name, | ||
AssessmentResultType::SKILL); | ||
|
||
$user4 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate4 = PoolCandidate::select('id')->where('user_id', $user4->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate4, | ||
$publishedPool->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->pluck('id')->toArray(), | ||
$assessmentStep, AssessmentDecisionLevel::AT_REQUIRED->name, | ||
[AssessmentResultJustification::EDUCATION_ACCEPTED_WORK_EXPERIENCE_EQUIVALENCY->name], | ||
AssessmentDecision::HOLD->name, | ||
AssessmentResultType::SKILL); | ||
|
||
$user5 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate5 = PoolCandidate::select('id')->where('user_id', $user5->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate5, | ||
$publishedPool->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->pluck('id')->toArray(), | ||
$assessmentStep, | ||
AssessmentDecisionLevel::AT_REQUIRED->name, | ||
[AssessmentResultJustification::EDUCATION_FAILED_NOT_RELEVANT->name, | ||
AssessmentResultJustification::EDUCATION_FAILED_REQUIREMENT_NOT_MET->name], | ||
AssessmentDecision::UNSUCCESSFUL->name, | ||
AssessmentResultType::EDUCATION); | ||
|
||
$user6 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate6 = PoolCandidate::select('id')->where('user_id', $user6->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate6, | ||
$publishedPool->poolSkills()->pluck('id')->toArray(), $assessmentStep, | ||
null, | ||
[AssessmentResultJustification::EDUCATION_FAILED_REQUIREMENT_NOT_MET->name], | ||
AssessmentDecision::UNSUCCESSFUL->name, | ||
AssessmentResultType::EDUCATION); | ||
|
||
$user7 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate7 = PoolCandidate::select('id')->where('user_id', $user7->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate7, | ||
null, | ||
$assessmentStep, | ||
null, | ||
[AssessmentResultJustification::EDUCATION_ACCEPTED_WORK_EXPERIENCE_EQUIVALENCY->name], | ||
AssessmentDecision::HOLD->name, | ||
assessmentResultType::EDUCATION); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate7, | ||
$publishedPool->poolSkills()->pluck('id')->toArray(), | ||
$assessmentStep, | ||
null, | ||
[AssessmentResultJustification::SKILL_FAILED_INSUFFICIENTLY_DEMONSTRATED->name], | ||
AssessmentDecision::HOLD->name, | ||
assessmentResultType::SKILL); | ||
|
||
$user8 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate8 = PoolCandidate::select('id')->where('user_id', $user8->id)->where('pool_id', $publishedPool->id)->sole(); | ||
// select first essential skill from pool skills | ||
$firstEssentialSkill = $publishedPool->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->first(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate8, | ||
[$firstEssentialSkill->id], | ||
$assessmentStep, | ||
null, | ||
[AssessmentResultJustification::SKILL_FAILED_INSUFFICIENTLY_DEMONSTRATED->name, | ||
AssessmentResultJustification::FAILED_NOT_ENOUGH_INFORMATION->name, | ||
AssessmentResultJustification::FAILED_OTHER->name], | ||
AssessmentDecision::UNSUCCESSFUL->name, | ||
AssessmentResultType::SKILL); | ||
$publishedPool->load('assessmentSteps.poolSkills'); | ||
foreach ($publishedPool->assessmentSteps as $assessmentStep) { | ||
$user1 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate1 = PoolCandidate::select('id')->where('user_id', $user1->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate1, | ||
$assessmentStep->poolSkills, | ||
$assessmentStep, | ||
AssessmentDecisionLevel::ABOVE_REQUIRED->name, | ||
[AssessmentResultJustification::EDUCATION_ACCEPTED_INFORMATION->name], | ||
AssessmentDecision::SUCCESSFUL->name, | ||
AssessmentResultType::EDUCATION); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate1, | ||
$assessmentStep->poolSkills, | ||
$assessmentStep, | ||
AssessmentDecisionLevel::ABOVE_REQUIRED->name, | ||
null, | ||
AssessmentDecision::SUCCESSFUL->name, | ||
AssessmentResultType::SKILL); | ||
|
||
$user2 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate2 = PoolCandidate::select('id')->where('user_id', $user2->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate2, | ||
$assessmentStep->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->get(), | ||
$assessmentStep, | ||
AssessmentDecisionLevel::AT_REQUIRED->name, | ||
null, | ||
AssessmentDecision::SUCCESSFUL->name, | ||
AssessmentResultType::SKILL); | ||
|
||
$user3 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate3 = PoolCandidate::select('id')->where('user_id', $user3->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate3, | ||
$assessmentStep->poolSkills, | ||
$assessmentStep, | ||
AssessmentDecisionLevel::ABOVE_REQUIRED->name, | ||
null, | ||
AssessmentDecision::SUCCESSFUL->name, | ||
AssessmentResultType::SKILL); | ||
|
||
$user4 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate4 = PoolCandidate::select('id')->where('user_id', $user4->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate4, | ||
$assessmentStep->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->get(), | ||
$assessmentStep, AssessmentDecisionLevel::AT_REQUIRED->name, | ||
null, | ||
AssessmentDecision::HOLD->name, | ||
AssessmentResultType::SKILL); | ||
|
||
$user5 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate5 = PoolCandidate::select('id')->where('user_id', $user5->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate5, | ||
$assessmentStep->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->get(), | ||
$assessmentStep, | ||
AssessmentDecisionLevel::AT_REQUIRED->name, | ||
[AssessmentResultJustification::EDUCATION_FAILED_NOT_RELEVANT->name, | ||
AssessmentResultJustification::EDUCATION_FAILED_REQUIREMENT_NOT_MET->name], | ||
AssessmentDecision::UNSUCCESSFUL->name, | ||
AssessmentResultType::EDUCATION); | ||
|
||
$user6 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate6 = PoolCandidate::select('id')->where('user_id', $user6->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate6, | ||
$assessmentStep->poolSkills, | ||
$assessmentStep, | ||
null, | ||
[AssessmentResultJustification::EDUCATION_FAILED_REQUIREMENT_NOT_MET->name], | ||
AssessmentDecision::UNSUCCESSFUL->name, | ||
AssessmentResultType::EDUCATION); | ||
|
||
$user7 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate7 = PoolCandidate::select('id')->where('user_id', $user7->id)->where('pool_id', $publishedPool->id)->sole(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate7, | ||
null, | ||
$assessmentStep, | ||
null, | ||
[AssessmentResultJustification::EDUCATION_ACCEPTED_WORK_EXPERIENCE_EQUIVALENCY->name], | ||
AssessmentDecision::HOLD->name, | ||
assessmentResultType::EDUCATION); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate7, | ||
$assessmentStep->poolSkills, | ||
$assessmentStep, | ||
null, | ||
null, | ||
AssessmentDecision::HOLD->name, | ||
assessmentResultType::SKILL); | ||
|
||
$user8 = User::select('id')->where('email', '[email protected]')->sole(); | ||
$poolCandidate8 = PoolCandidate::select('id')->where('user_id', $user8->id)->where('pool_id', $publishedPool->id)->sole(); | ||
// select first essential skill from pool skills | ||
$firstEssentialSkill = $assessmentStep->poolSkills()->where('type', PoolSkillType::ESSENTIAL->name)->get()->first(); | ||
$this->assessSkillsWithLevelAndJustification( | ||
$poolCandidate8, | ||
[$firstEssentialSkill], | ||
$assessmentStep, | ||
null, | ||
[AssessmentResultJustification::SKILL_FAILED_INSUFFICIENTLY_DEMONSTRATED->name, | ||
AssessmentResultJustification::FAILED_NOT_ENOUGH_INFORMATION->name, | ||
AssessmentResultJustification::FAILED_OTHER->name], | ||
AssessmentDecision::UNSUCCESSFUL->name, | ||
AssessmentResultType::SKILL); | ||
} | ||
} | ||
|
||
private function assessSkillsWithLevelAndJustification($poolCandidate, | ||
|
@@ -185,6 +195,11 @@ private function assessSkillsWithLevelAndJustification($poolCandidate, | |
$assessmentDecision, | ||
$assessmentResultType) | ||
{ | ||
// Only save education assessment for the first assessment step | ||
if ($assessmentResultType == AssessmentResultType::EDUCATION && $assessmentStep->type != AssessmentStepType::APPLICATION_SCREENING->name) { | ||
return; | ||
} | ||
|
||
$nullJustifications = $assessmentDecision === AssessmentDecision::HOLD->name || is_null($assessmentDecision); | ||
|
||
if ($assessmentResultType == null) { | ||
|
@@ -201,7 +216,7 @@ private function assessSkillsWithLevelAndJustification($poolCandidate, | |
AssessmentResult::factory()->withResultType($assessmentResultType)->create([ | ||
'assessment_step_id' => $assessmentStep->id, | ||
'pool_candidate_id' => $poolCandidate->id, | ||
'pool_skill_id' => $poolSkill, | ||
'pool_skill_id' => $poolSkill->id, | ||
'assessment_decision_level' => $level, | ||
'justifications' => $nullJustifications ? null : $justifications, | ||
'assessment_decision' => $assessmentDecision, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters