fix mising formations and groups

This commit is contained in:
SeekDaSky 2018-02-27 18:24:49 +01:00
parent 3e1ab4796c
commit 58d0a5ee14
1 changed files with 13 additions and 7 deletions

View File

@ -72,7 +72,15 @@ class Excel
* declaring the lambda tha twill extract the list of formation involved in the group * declaring the lambda tha twill extract the list of formation involved in the group
*/ */
$getFormations = function(?string $group) use (&$formation,&$allFormations) : array{ $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 //replace the generic "INFO" keyword by the actual formation
$group = str_replace("INFO",$formation,$group); $group = str_replace("INFO",$formation,$group);
@ -280,9 +288,9 @@ class Excel
foreach ($UE["groups"] as $type => $groups){ foreach ($UE["groups"] as $type => $groups){
foreach ($groups as $group){ foreach ($groups as $group){
$formations = []; $formations = [];
foreach ($group["formations"] as $form){ foreach ($group["formations"] as $format){
if(isset($allFormations[$form]["dbId"])){ if(isset($allFormations[$format]["dbId"])){
$formations[] = $allFormations[$form]["dbId"]; $formations[] = $allFormations[$format]["dbId"];
} }
} }
@ -306,13 +314,11 @@ class Excel
$formations); $formations);
break; break;
} }
}
}
} }
} }
}
}
return [ 'data' => ["professors" => $allProf, "formations" => $allFormations, "UEs" => $allUE ] ]; return [ 'data' => ["professors" => $allProf, "formations" => $allFormations, "UEs" => $allUE ] ];
}catch (Exception $e){ }catch (Exception $e){