ynh_extension_meeo/libs/controle/Controle.lib.php

45 lines
1.2 KiB
PHP
Raw Normal View History

2024-07-20 08:13:50 +00:00
<?php
namespace YesWiki\MeeO\Controle;
2024-07-20 08:13:50 +00:00
class Controle {
public $intitule;
public $matiere;
public $coef;
public $eleves;
2024-07-20 08:13:50 +00:00
public function __construct($intitule, $matiere, $coef, $eleves) {
2024-07-20 08:13:50 +00:00
$this->intitule = $intitule;
$this->matiere = $matiere;
$this->coef = $coef;
$this->eleves = $this->removePrefixFromKeys($eleves, "eleve_");
}
function removePrefixFromKeys($inputArray, $prefix) {
$outputArray = array();
foreach ($inputArray as $key => $value) {
if (strpos($key, $prefix) === 0) {
$newKey = substr($key, strlen($prefix)); // Remove the prefix
$outputArray[$newKey] = $value;
} else {
$outputArray[$key] = $value;
}
}
return $outputArray;
}
public function getNotes() {
$notes = [];
foreach ($this->eleves as $eleve => $note) {
$notes[] = [
'bf_titre' => "Note : ".$this->intitule." - ".$eleve." - ".$this->matiere,
'bf_intitule' => $this->intitule,
'listeListeMatierebf_matiere' => $this->matiere,
'listefiche6bf_eleve' => $eleve,
'bf_note' => $note,
'bf_coef' => $this->coef,
];
};
return $notes;
2024-07-20 08:13:50 +00:00
}
}