Group bulletin par classe
This commit is contained in:
parent
fe9affb53c
commit
2b2be5166e
3 changed files with 77 additions and 14 deletions
40
libs/classes/Classe.lib.php
Normal file
40
libs/classes/Classe.lib.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace YesWiki\Meeo\Classes;
|
||||
|
||||
use YesWiki\Bazar\Service\EntryManager;
|
||||
use YesWiki\Meeo\Service\NoteManager;
|
||||
|
||||
class Classe {
|
||||
private $id;
|
||||
private $name;
|
||||
private $bulletins = [];
|
||||
|
||||
public function __construct($wiki, $id, $name) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
|
||||
$noteManager = $wiki->services->get(NoteManager::class);
|
||||
foreach ($noteManager->allBulletins() as $bulletin) {
|
||||
if ($bulletin->getClasse() == $this->id) {
|
||||
array_push($this->bulletins, $bulletin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getBulletins() {
|
||||
return $this->bulletins;
|
||||
}
|
||||
|
||||
public function haveBulletins(){
|
||||
return sizeof($this->bulletins) > 0;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ use YesWiki\Core\Service\UserManager;
|
|||
use YesWiki\Wiki;
|
||||
use YesWiki\Meeo\Bulletin\Bulletin;
|
||||
use YesWiki\Meeo\Service\EleveManager;
|
||||
use YesWiki\Meeo\Classes\Classe;
|
||||
|
||||
class NoteManager {
|
||||
protected $wiki;
|
||||
|
@ -36,26 +37,37 @@ class NoteManager {
|
|||
$this->eeGroup = $meeo_config['groupeEE'];
|
||||
}
|
||||
|
||||
public function allBulletins() {
|
||||
$eleveManager = $this->wiki->services->get(EleveManager::class);
|
||||
$eleves = $eleveManager->getAll();
|
||||
|
||||
$bulletins = [];
|
||||
foreach ( $eleves as $eleve) {
|
||||
$bulletins[] = new Bulletin($this->wiki, $eleve);
|
||||
}
|
||||
return $bulletins;
|
||||
}
|
||||
|
||||
public function viewBulletins() {
|
||||
$eleveManager = $this->wiki->services->get(EleveManager::class);
|
||||
|
||||
include 'tools/meeo/libs/bulletin/Bulletin.lib.php';
|
||||
include 'tools/meeo/libs/classes/Classe.lib.php';
|
||||
|
||||
$loggedUser = $this->authController->getLoggedUser();
|
||||
|
||||
// echo "<p>".var_dump($loggedUser)."</p>";
|
||||
if (true) {//($this->userManager->isInGroup($this->eeGroup, $loggedUser['name'], false)) {
|
||||
$eleves = $eleveManager->getAll();
|
||||
|
||||
$bulletins = [];
|
||||
foreach ( $eleves as $eleve) {
|
||||
$bulletins[] = new Bulletin($this->wiki, $eleve);
|
||||
}
|
||||
// echo "<p>".var_dump($eleves)."</p>";
|
||||
// echo "<p>".var_dump($bulletins)."</p>";
|
||||
|
||||
$classes = [];
|
||||
$listClasse = $this->listManager->getOne('ListeClasses');
|
||||
foreach ($listClasse['label'] as $id => $classe) {
|
||||
array_push($classes, new Classe($this->wiki, $id, $classe));
|
||||
}
|
||||
// echo "<p>".var_dump($classes)."</p>";
|
||||
return $this->wiki->render('@meeo/edu_notes.twig', [
|
||||
"bulletins" => $bulletins,
|
||||
"classes" => $classes,
|
||||
"opened" => ""
|
||||
]);
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
<div id="accordion_bulletins" class="panel-group">
|
||||
{% for bulletin in bulletins|sort %}
|
||||
{% if bulletin.isVisible() %}
|
||||
{% include '@meeo/eleve_notes.twig' with { 'bulletin' : bulletin } %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<div class="panel-group">
|
||||
{% for classe in classes %}
|
||||
{% if classe.haveBulletins() %}
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">{{ classe.getName() }}</div>
|
||||
<div class="panel-body">
|
||||
<div id="accordion_bulletins" class="panel-group">
|
||||
{% for bulletin in classe.getBulletins() %}
|
||||
{% if bulletin.isVisible() %}
|
||||
{% include '@meeo/eleve_notes.twig' with { 'bulletin' : bulletin } %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue