2024-07-18 19:18:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace YesWiki\Meeo\Service;
|
|
|
|
|
2024-07-27 13:22:09 +00:00
|
|
|
include 'tools/meeo/libs/eleves/eleve.lib.php';
|
|
|
|
|
2024-07-18 19:18:59 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
|
|
use YesWiki\Bazar\Service\EntryManager;
|
|
|
|
use YesWiki\Bazar\Service\ListManager;
|
|
|
|
use YesWiki\Wiki;
|
2024-07-27 12:14:54 +00:00
|
|
|
use YesWiki\Meeo\Eleve\Eleve;
|
2024-07-18 19:18:59 +00:00
|
|
|
|
|
|
|
class EleveManager {
|
|
|
|
|
|
|
|
private $formId;
|
|
|
|
private $entryManager;
|
|
|
|
private $listManager;
|
|
|
|
private $wiki;
|
|
|
|
|
|
|
|
public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager)
|
|
|
|
{
|
|
|
|
$meeo_config = $params->get('meeo');
|
|
|
|
$this->wiki = $wiki;
|
|
|
|
$this->formId = $meeo_config['elevesFormId'];
|
|
|
|
$this->entryManager = $entryManager;
|
|
|
|
$this->listManager = $listManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function del($id) {
|
|
|
|
$this->entryManager->delete($id);
|
|
|
|
}
|
|
|
|
|
2024-07-27 13:22:09 +00:00
|
|
|
public function updateEleve(Eleve $eleve) {
|
|
|
|
$id = $eleve->getId();
|
|
|
|
$data = $eleve->getData();
|
|
|
|
$data['antispam'] = true;
|
2024-08-06 06:17:31 +00:00
|
|
|
// echo var_dump($data);
|
2024-07-27 13:22:09 +00:00
|
|
|
return $this->entryManager->update($id, $data);
|
2024-07-18 19:18:59 +00:00
|
|
|
}
|
|
|
|
|
2024-07-20 08:13:50 +00:00
|
|
|
public function getAll() {
|
2024-07-27 12:14:54 +00:00
|
|
|
$eleves = [];
|
|
|
|
foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data)
|
|
|
|
{
|
|
|
|
|
|
|
|
$eleve = new Eleve($this->entryManager, $data);
|
|
|
|
// echo "<p>".var_dump($eleve)."</p>";
|
|
|
|
$eleves[] = $eleve;
|
|
|
|
}
|
|
|
|
return $eleves;
|
|
|
|
}
|
|
|
|
|
2024-07-27 13:22:09 +00:00
|
|
|
public function getEleve(string $id) {
|
|
|
|
return new Eleve($this->entryManager, $this->entryManager->getOne($id));
|
|
|
|
}
|
|
|
|
|
2024-07-27 12:14:54 +00:00
|
|
|
public function getCurrentEleve(string $username) {
|
|
|
|
return $this->entryManager->getOne(str_replace(".","", $username));
|
2024-07-20 08:13:50 +00:00
|
|
|
}
|
|
|
|
|
2024-07-18 19:18:59 +00:00
|
|
|
public function view() {
|
2024-07-20 08:13:50 +00:00
|
|
|
$eleves = $this->getAll();
|
2024-07-18 19:18:59 +00:00
|
|
|
// echo '<p>'.var_dump($eleves).'</p>';
|
|
|
|
|
|
|
|
$classes = $this->listManager->getOne('ListeClasses');
|
2024-07-27 12:14:54 +00:00
|
|
|
// echo "<p>".var_dump($classes)."</p>";
|
|
|
|
return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['nodes']]);
|
2024-07-18 19:18:59 +00:00
|
|
|
}
|
2024-08-06 06:17:31 +00:00
|
|
|
}
|