2024-07-20 08:13:50 +00:00
|
|
|
<?php
|
|
|
|
|
2024-07-20 18:58:35 +00:00
|
|
|
namespace YesWiki\MeeO\Controle;
|
2024-07-20 08:13:50 +00:00
|
|
|
|
2024-07-21 09:43:47 +00:00
|
|
|
use YesWiki\Meeo\Service\NoteManager;
|
|
|
|
|
2024-07-20 18:58:35 +00:00
|
|
|
class Controle {
|
|
|
|
public $intitule;
|
|
|
|
public $matiere;
|
|
|
|
public $coef;
|
|
|
|
public $eleves;
|
2024-07-20 08:13:50 +00:00
|
|
|
|
2024-07-20 18:58:35 +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;
|
2024-07-20 18:58:35 +00:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2024-07-21 09:43:47 +00:00
|
|
|
public function createNotes(NoteManager $noteManager) {
|
2024-07-20 18:58:35 +00:00
|
|
|
foreach ($this->eleves as $eleve => $note) {
|
2024-07-27 15:40:54 +00:00
|
|
|
if (!empty($note))
|
|
|
|
$noteManager->createNote($this->intitule, $eleve, $this->matiere, $note, $this->coef);
|
2024-07-20 18:58:35 +00:00
|
|
|
};
|
2024-07-20 08:13:50 +00:00
|
|
|
}
|
|
|
|
}
|