From 58d0a5ee14efcfca0c051cd5903dcba958c70448 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Tue, 27 Feb 2018 18:24:49 +0100 Subject: [PATCH] fix mising formations and groups --- build/api/module/Excel.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/build/api/module/Excel.php b/build/api/module/Excel.php index 7540023..488d164 100644 --- a/build/api/module/Excel.php +++ b/build/api/module/Excel.php @@ -72,7 +72,15 @@ class Excel * declaring the lambda tha twill extract the list of formation involved in the group */ $getFormations = function(?string $group) use (&$formation,&$allFormations) : array{ - if(!$group) return [$formation]; + if(!$group){ + if(!isset($allFormations[$formation])){ + $allFormations[$formation] = [ + "name" => $formation, + "internal" => 1 + ]; + } + return [$formation]; + } //replace the generic "INFO" keyword by the actual formation $group = str_replace("INFO",$formation,$group); @@ -280,9 +288,9 @@ class Excel foreach ($UE["groups"] as $type => $groups){ foreach ($groups as $group){ $formations = []; - foreach ($group["formations"] as $form){ - if(isset($allFormations[$form]["dbId"])){ - $formations[] = $allFormations[$form]["dbId"]; + foreach ($group["formations"] as $format){ + if(isset($allFormations[$format]["dbId"])){ + $formations[] = $allFormations[$format]["dbId"]; } } @@ -306,14 +314,12 @@ class Excel $formations); break; } + } } - } } - - return [ 'data' => ["professors" => $allProf, "formations" => $allFormations, "UEs" => $allUE ] ]; }catch (Exception $e){ return [ 'error' => new Error(Err::UnknownError) ];