[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\Bazar\Service\EntryManager;
|
||||
use YesWiki\Core\Service\UserManager;
|
||||
use YesWiki\Bazar\Service\ListManager;
|
||||
|
||||
class NotesAction extends YesWikiAction
|
||||
{
|
||||
|
@ -23,27 +22,28 @@ class NotesAction extends YesWikiAction
|
|||
|
||||
$entryManager = $this->getService(EntryManager::class);
|
||||
$userManager = $this->getService(UserManager::class);
|
||||
$listManager = $this->getService(ListManager::class);
|
||||
|
||||
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
|
||||
$eleves = $entryManager->search(['formsIds' => $meeo_config['elevesFormId']]);
|
||||
$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($entries);
|
||||
// echo var_dump($matieres);
|
||||
return $this->render('@meeo/edu_notes.twig', [
|
||||
"eleves" => $eleves,
|
||||
"entries" => $entries,
|
||||
"matieres" => $matieres,
|
||||
"bulletins" => $bulletins,
|
||||
]);
|
||||
} else {
|
||||
$entries = $entryManager->search(['formsIds' => $formId]);
|
||||
$matieres = $listManager->getOne('ListeMatiere');
|
||||
|
||||
return $this->render('@meeo/eeleve_notes.twig', [
|
||||
"entries" => $entries,
|
||||
"matieres" => $matieres,
|
||||
"bulletin" => $bulletin,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
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">
|
||||
{% for identifier, eleve in eleves|sort %}
|
||||
{% set filteredEntries = entries|filter(e => e['listefiche5bf_eleve'] == identifier) %}
|
||||
{% if filteredEntries|default %}
|
||||
{% for bulletin in bulletins|sort %}
|
||||
{% if bulletin.isVisible() %}
|
||||
<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">
|
||||
<h4 class="panel-title">{{ eleve['bf_nom'] }}</h4>
|
||||
<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">{{ bulletin.getNom() }}</h4>
|
||||
<p>
|
||||
{{ bulletin.getClass() }}<br/>
|
||||
Moyenne Générale : {{ bulletin.getMoyenne() }}
|
||||
</p>
|
||||
</button>
|
||||
<div id="{{ identifier }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
||||
|
||||
{% include '@meeo/eleve_notes.twig' with { 'entries' : filteredEntries } %}
|
||||
<div id="{{ bulletin.getId() }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
||||
{% include '@meeo/eleve_notes.twig' with { 'bulletin' : bulletin } %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
<div id="accordion" class="panel-group" role="tablist" aria-multiselectable="true">
|
||||
{% for identifier, matiere in matieres['label'] %}
|
||||
{% set filteredEntries = entries|filter(e => e['listeListeMatièrebf_matiere'] == identifier) %}
|
||||
{% if filteredEntries|default %}
|
||||
{% for matiere in bulletin.getMatieres() %}
|
||||
<div class="panel panel-primary">
|
||||
<button id="head_{{ identifier }}" class="panel-heading collapsed" data-parent="#accordion" data-target="#{{ identifier }}" data-toggle="collapse" aria-expanded="false">
|
||||
<h4 class="panel-title">{{ identifier }}</h4>
|
||||
<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">
|
||||
<h4 class="panel-title">{{ matiere.getNom() }}</h4>
|
||||
<p>Moyenne : {{ matiere.getMoyenne() }}</p>
|
||||
</button>
|
||||
<div id="{{ identifier }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
||||
{% for idEntry, entry in filteredEntries %}
|
||||
<span>
|
||||
{% if entry['bf_note'] >= 20 %}
|
||||
<div id="{{ bulletin.getId() }}_{{ matiere.getId() }}" class="panel-collapse collapse in" style="padding:5px" aria-expanded="false">
|
||||
{% for note in matiere.getNotes() %}
|
||||
<div>
|
||||
{% if note.getNote() >= 20 %}
|
||||
<i class="fa fa-star" style="color:gold"></i>
|
||||
{% elseif entry['bf_note'] >= 15 %}
|
||||
{% elseif note.getNote() >= 15 %}
|
||||
<i class="fa fa-heart" style="color:red"></i>
|
||||
{% elseif entry['bf_note'] >= 12 %}
|
||||
{% elseif note.getNote() >= 12 %}
|
||||
<i class="fa fa-smile" style="color:green"></i>
|
||||
{% elseif entry['bf_note'] >= 9 %}
|
||||
{% elseif note.getNote() >= 9 %}
|
||||
<i class="fa fa-thumbs-up" style="color:green"></i>
|
||||
{% endif %}
|
||||
{{ entry['bf_intitule'] }} : {{ entry['bf_note'] }}
|
||||
</span>
|
||||
{{ note.getIntitule() }} : {{ note.getNote() }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
Loading…
Reference in a new issue