From d80e987f26340fee2ce078100a684feec82e938c Mon Sep 17 00:00:00 2001 From: sebastien <dupuy@datakode.fr> Date: Thu, 16 Feb 2023 16:17:48 +0100 Subject: [PATCH] =?UTF-8?q?issue=20#10=20Correction=20#1=20[=C3=89valuatio?= =?UTF-8?q?n]=20Niveau=20des=20mesures=20du=20plan=20d'action=20incorrect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/EvaluationsController.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Api/EvaluationsController.php b/app/Http/Controllers/Api/EvaluationsController.php index 151c3597..b1820dd4 100644 --- a/app/Http/Controllers/Api/EvaluationsController.php +++ b/app/Http/Controllers/Api/EvaluationsController.php @@ -194,17 +194,20 @@ public function save(EvaluationRepository $repository, EvaluationRequest $reques $evaluation->save(); - // Ajout du niveau supérieur pour les mesures preconisées - $preconizedMeasure = array_slice($this->repository->getBestMeasuresForEvaluation($evaluation), 0, 4); - foreach ($evaluation->measureLevels as $measureLevel) { - $measureLevelpreconized = MeasureLevel::whereId($measureLevel->id) - ->first(); - if ($measureLevelpreconized && in_array($measureLevelpreconized['measure_id'], $preconizedMeasure, true)) { - $measureLevelpreconized->expected_level = $measureLevelpreconized['actual_level'] < 3 ? $measureLevelpreconized['actual_level'] + 1 : null; + if ((Evaluation::STEP_ACTIONS === intval($evaluation->current_step))){ + // Ajout du niveau supérieur pour les mesures preconisées + $preconizedMeasure = array_slice($this->repository->getBestMeasuresForEvaluation($evaluation), 0, 4); + foreach ($evaluation->measureLevels as $measureLevel) { + $measureLevelpreconized = MeasureLevel::whereId($measureLevel->id) + ->first(); + if ($measureLevelpreconized && in_array($measureLevelpreconized['measure_id'], $preconizedMeasure, true)) { + $measureLevelpreconized->expected_level = $measureLevelpreconized['actual_level'] < 3 ? $measureLevelpreconized['actual_level'] + 1 : null; + } + $measureLevelpreconized->save(); } - $measureLevelpreconized->save(); } + // si mofification d'un step, reinitialisation des steps suivants if (isset($data['draft']) && $data['draft']) { if (1 === $evaluation->current_step) { -- GitLab