[Notes] creation d'une classe bulletin
This commit is contained in:
parent
262715db5e
commit
768ec94d92
6 changed files with 184 additions and 42 deletions
|
@ -5,7 +5,6 @@ namespace YesWiki\Meeo;
|
||||||
use YesWiki\Core\YesWikiAction;
|
use YesWiki\Core\YesWikiAction;
|
||||||
use YesWiki\Bazar\Service\EntryManager;
|
use YesWiki\Bazar\Service\EntryManager;
|
||||||
use YesWiki\Core\Service\UserManager;
|
use YesWiki\Core\Service\UserManager;
|
||||||
use YesWiki\Bazar\Service\ListManager;
|
|
||||||
|
|
||||||
class NotesAction extends YesWikiAction
|
class NotesAction extends YesWikiAction
|
||||||
{
|
{
|
||||||
|
@ -23,27 +22,28 @@ class NotesAction extends YesWikiAction
|
||||||
|
|
||||||
$entryManager = $this->getService(EntryManager::class);
|
$entryManager = $this->getService(EntryManager::class);
|
||||||
$userManager = $this->getService(UserManager::class);
|
$userManager = $this->getService(UserManager::class);
|
||||||
$listManager = $this->getService(ListManager::class);
|
|
||||||
|
|
||||||
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
|
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
|
||||||
$eleves = $entryManager->search(['formsIds' => $meeo_config['elevesFormId']]);
|
$eleves = $entryManager->search(['formsIds' => $meeo_config['elevesFormId']]);
|
||||||
$entries = $entryManager->search(['formsIds' => $formId]);
|
$entries = $entryManager->search(['formsIds' => $formId]);
|
||||||
$matieres = $listManager->getOne('ListeMatiere');
|
|
||||||
|
include 'tools/meeo/libs/Bulletin.lib.php';
|
||||||
|
|
||||||
|
$bulletins = [];
|
||||||
|
foreach ( $eleves as $eleve) {
|
||||||
|
$bulletins[] = new Bulletin($this->wiki, $eleve, "Passerelle");
|
||||||
|
}
|
||||||
// echo var_dump($eleves);
|
// echo var_dump($eleves);
|
||||||
// echo var_dump($entries);
|
// echo var_dump($entries);
|
||||||
// echo var_dump($matieres);
|
// echo var_dump($matieres);
|
||||||
return $this->render('@meeo/edu_notes.twig', [
|
return $this->render('@meeo/edu_notes.twig', [
|
||||||
"eleves" => $eleves,
|
"bulletins" => $bulletins,
|
||||||
"entries" => $entries,
|
|
||||||
"matieres" => $matieres,
|
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$entries = $entryManager->search(['formsIds' => $formId]);
|
$entries = $entryManager->search(['formsIds' => $formId]);
|
||||||
$matieres = $listManager->getOne('ListeMatiere');
|
|
||||||
|
|
||||||
return $this->render('@meeo/eeleve_notes.twig', [
|
return $this->render('@meeo/eeleve_notes.twig', [
|
||||||
"entries" => $entries,
|
"bulletin" => $bulletin,
|
||||||
"matieres" => $matieres,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
59
libs/Bulletin.lib.php
Normal file
59
libs/Bulletin.lib.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace YesWiki\Meeo;
|
||||||
|
|
||||||
|
include 'tools/meeo/libs/Matiere.lib.php';
|
||||||
|
|
||||||
|
use YesWiki\Bazar\Service\ListManager;
|
||||||
|
|
||||||
|
class Bulletin {
|
||||||
|
private $eleve;
|
||||||
|
private $classe;
|
||||||
|
private $matieres = [];
|
||||||
|
|
||||||
|
public function __construct($wiki, $eleve, $classe) {
|
||||||
|
$this->eleve = $eleve;
|
||||||
|
// echo var_dump($eleve);
|
||||||
|
$this->classe = $classe;
|
||||||
|
|
||||||
|
$listManager = $wiki->services->get(ListManager::class);
|
||||||
|
$matieres = $listManager->getOne('ListeMatiere');
|
||||||
|
foreach ($matieres['label'] as $id => $nom) {
|
||||||
|
$this->matieres[] = new Matiere($wiki, $this, $id, $nom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId() {
|
||||||
|
return $this->eleve['bf_titre'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNom() {
|
||||||
|
return $this->eleve['bf_nom'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClass() {
|
||||||
|
return $this->classe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMoyenne() {
|
||||||
|
$total = 0;
|
||||||
|
foreach ( $this->matieres as $matiere) {
|
||||||
|
$total += $matiere->getMoyenne();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total / count($this->matieres);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMatieres() {
|
||||||
|
return $this->matieres;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isVisible() {
|
||||||
|
foreach ($this->matieres as $matiere) {
|
||||||
|
if ( !$matiere->isVisible() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
libs/Matiere.lib.php
Normal file
56
libs/Matiere.lib.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace YesWiki\Meeo;
|
||||||
|
|
||||||
|
include 'tools/meeo/libs/Note.lib.php';
|
||||||
|
|
||||||
|
use YesWiki\Bazar\Service\EntryManager;
|
||||||
|
|
||||||
|
class Matiere {
|
||||||
|
private $id;
|
||||||
|
private $nom;
|
||||||
|
private $notes;
|
||||||
|
|
||||||
|
public function __construct($wiki, Bulletin $bulletin, string $id, string $nom) {
|
||||||
|
$this->id = $id;
|
||||||
|
$this->nom = $nom;
|
||||||
|
|
||||||
|
$eleveId = $bulletin->getId();
|
||||||
|
|
||||||
|
$entryManager = $wiki->services->get(EntryManager::class);
|
||||||
|
$entries = $entryManager->search(['formsIds' => 7, 'queries' =>[
|
||||||
|
'listefiche5bf_eleve' => $eleveId,
|
||||||
|
'listeListeMatièrebf_matiere' => $id
|
||||||
|
]]);
|
||||||
|
// echo var_dump($entries)."\n\n";
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
$this->notes[] = new Note($entry['bf_intitule'], $entry['bf_note'], $entry['bf_coef']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId() {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNom() {
|
||||||
|
return $this->nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMoyenne() {
|
||||||
|
$total = 0;
|
||||||
|
$totalCoef = 0.0;
|
||||||
|
foreach ($this->notes as $note) {
|
||||||
|
$total += $note->getNote() * $note->getCoef();
|
||||||
|
$totalCoef += $note->getCoef();
|
||||||
|
}
|
||||||
|
return $total / $totalCoef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNotes() {
|
||||||
|
return $this->notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isVisible() {
|
||||||
|
return $this->notes;
|
||||||
|
}
|
||||||
|
}
|
27
libs/Note.lib.php
Normal file
27
libs/Note.lib.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace YesWiki\Meeo;
|
||||||
|
|
||||||
|
class Note {
|
||||||
|
private $intitule;
|
||||||
|
private $note;
|
||||||
|
private $coef;
|
||||||
|
|
||||||
|
public function __construct(string $intitule, int $note, float $coef = 1.0) {
|
||||||
|
$this->intitule = $intitule;
|
||||||
|
$this->note = $note;
|
||||||
|
$this->coef = $coef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIntitule() {
|
||||||
|
return $this->intitule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNote() {
|
||||||
|
return $this->note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCoef() {
|
||||||
|
return $this->coef;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
<div id="accordion" class="panel-group" role="tablist" aria-multiselectable="true">
|
<div id="accordion" class="panel-group" role="tablist" aria-multiselectable="true">
|
||||||
{% for identifier, eleve in eleves|sort %}
|
{% for bulletin in bulletins|sort %}
|
||||||
{% set filteredEntries = entries|filter(e => e['listefiche5bf_eleve'] == identifier) %}
|
{% if bulletin.isVisible() %}
|
||||||
{% if filteredEntries|default %}
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<button id="head_{{ identifier }}" class="panel-heading collapsed" data-parent="#accordion" data-target="#{{ identifier }}" data-toggle="collapse" aria-expanded="false">
|
<button id="head_{{ bulletin.getId() }}" class="panel-heading collapsed" data-parent="#accordion" data-target="#{{ bulletin.getId() }}" data-toggle="collapse" aria-expanded="false">
|
||||||
<h4 class="panel-title">{{ eleve['bf_nom'] }}</h4>
|
<h4 class="panel-title">{{ bulletin.getNom() }}</h4>
|
||||||
|
<p>
|
||||||
|
{{ bulletin.getClass() }}<br/>
|
||||||
|
Moyenne Générale : {{ bulletin.getMoyenne() }}
|
||||||
|
</p>
|
||||||
</button>
|
</button>
|
||||||
<div id="{{ identifier }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
<div id="{{ bulletin.getId() }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
||||||
|
{% include '@meeo/eleve_notes.twig' with { 'bulletin' : bulletin } %}
|
||||||
{% include '@meeo/eleve_notes.twig' with { 'entries' : filteredEntries } %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,28 +1,26 @@
|
||||||
<div id="accordion" class="panel-group" role="tablist" aria-multiselectable="true">
|
<div id="accordion" class="panel-group" role="tablist" aria-multiselectable="true">
|
||||||
{% for identifier, matiere in matieres['label'] %}
|
{% for matiere in bulletin.getMatieres() %}
|
||||||
{% set filteredEntries = entries|filter(e => e['listeListeMatièrebf_matiere'] == identifier) %}
|
<div class="panel panel-primary">
|
||||||
{% if filteredEntries|default %}
|
<button id="head_{{ bulletin.getId() }}_{{ matiere.getId() }}" class="panel-heading collapsed" data-parent="#accordion" data-target="#{{ bulletin.getId() }}_{{ matiere.getId() }}" data-toggle="collapse" aria-expanded="false">
|
||||||
<div class="panel panel-primary">
|
<h4 class="panel-title">{{ matiere.getNom() }}</h4>
|
||||||
<button id="head_{{ identifier }}" class="panel-heading collapsed" data-parent="#accordion" data-target="#{{ identifier }}" data-toggle="collapse" aria-expanded="false">
|
<p>Moyenne : {{ matiere.getMoyenne() }}</p>
|
||||||
<h4 class="panel-title">{{ identifier }}</h4>
|
</button>
|
||||||
</button>
|
<div id="{{ bulletin.getId() }}_{{ matiere.getId() }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
||||||
<div id="{{ identifier }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
{% for note in matiere.getNotes() %}
|
||||||
{% for idEntry, entry in filteredEntries %}
|
<div>
|
||||||
<span>
|
{% if note.getNote() >= 20 %}
|
||||||
{% if entry['bf_note'] >= 20 %}
|
<i class="fa fa-star" style="color:gold"></i>
|
||||||
<i class="fa fa-star" style="color:gold"></i>
|
{% elseif note.getNote() >= 15 %}
|
||||||
{% elseif entry['bf_note'] >= 15 %}
|
<i class="fa fa-heart" style="color:red"></i>
|
||||||
<i class="fa fa-heart" style="color:red"></i>
|
{% elseif note.getNote() >= 12 %}
|
||||||
{% elseif entry['bf_note'] >= 12 %}
|
<i class="fa fa-smile" style="color:green"></i>
|
||||||
<i class="fa fa-smile" style="color:green"></i>
|
{% elseif note.getNote() >= 9 %}
|
||||||
{% elseif entry['bf_note'] >= 9 %}
|
<i class="fa fa-thumbs-up" style="color:green"></i>
|
||||||
<i class="fa fa-thumbs-up" style="color:green"></i>
|
{% endif %}
|
||||||
{% endif %}
|
{{ note.getIntitule() }} : {{ note.getNote() }}
|
||||||
{{ entry['bf_intitule'] }} : {{ entry['bf_note'] }}
|
</div>
|
||||||
</span>
|
{% endfor %}
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue