ynh_extension_meeo/libs/controle/Controle.lib.php

41 lines
1.1 KiB
PHP
Raw Permalink Normal View History

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