Compare commits
5 commits
9f269a1c52
...
b4e4473603
Author | SHA1 | Date | |
---|---|---|---|
|
b4e4473603 | ||
|
6aea33d65a | ||
|
b1260c72e2 | ||
|
62b3501427 | ||
|
3c5d9d3cab |
4 changed files with 163 additions and 8 deletions
|
@ -13,9 +13,10 @@ class AbsencesAction extends YesWikiAction
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$formId = $this->params->get('meeo_formId');
|
$meeo_config = $this->params->get('meeo');
|
||||||
$eleveIdentifier = $this->params->get('meeo_eleveIdentifier');
|
$formId = $meeo_config['absences']['formId'];
|
||||||
$groupeEE = $this->params->get('meeo_groupeEE');
|
$eleveIdentifier = 'listefiche'.$meeo_config['elevesFormId'];
|
||||||
|
$groupeEE = $meeo_config['groupeEE'];
|
||||||
|
|
||||||
$entryManager = $this->getService(EntryManager::class);
|
$entryManager = $this->getService(EntryManager::class);
|
||||||
$userManager = $this->getService(UserManager::class);
|
$userManager = $this->getService(UserManager::class);
|
||||||
|
@ -23,6 +24,7 @@ class AbsencesAction extends YesWikiAction
|
||||||
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
|
if ( $userManager->isInGroup($groupeEE, admincheck: false) ) {
|
||||||
$entries = $entryManager->search(['formsIds' => $formId]);
|
$entries = $entryManager->search(['formsIds' => $formId]);
|
||||||
$grouped_entries = [];
|
$grouped_entries = [];
|
||||||
|
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
$identifier = $entry[$eleveIdentifier];
|
$identifier = $entry[$eleveIdentifier];
|
||||||
$nom = $entryManager->getOne($identifier)['bf_nom'];
|
$nom = $entryManager->getOne($identifier)['bf_nom'];
|
||||||
|
|
155
commands/CreateFormsCommand.php
Normal file
155
commands/CreateFormsCommand.php
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace YesWiki\Meeo\Commands;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use YesWiki\Wiki;
|
||||||
|
use YesWiki\Bazar\Service\FormManager;
|
||||||
|
use YesWiki\Core\Service\PageManager;
|
||||||
|
use YesWiki\Core\Service\TripleStore;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
|
||||||
|
class CreateFormsCommand extends Command
|
||||||
|
{
|
||||||
|
protected $wiki;
|
||||||
|
|
||||||
|
public function __construct(Wiki &$wiki)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->wiki = $wiki;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
// the name of the command : ./yeswicli helloworld:hello"
|
||||||
|
->setName('meeo:createforms')
|
||||||
|
// the short description shown while running "./yeswicli list"
|
||||||
|
->setDescription('Permet de créer les formulaires pour ')
|
||||||
|
|
||||||
|
// the full command description shown when running the command with
|
||||||
|
// the "--help" option
|
||||||
|
// ->setHelp("This command display the message \"Hello !\" with options for uppercase of add a username.\n" .
|
||||||
|
// "The argument \"username\" can be used to add a username. Example : \n" .
|
||||||
|
// "Command line'./yeswicli helloworld:hello \"John Smith\"' gives \"Hello John Smith !\"")
|
||||||
|
|
||||||
|
// add argument for username
|
||||||
|
// second parameter could be InputArgument::OPTIONAL <=> null, InputArgument::REQUIRED, InputArgument::IS_ARRAY
|
||||||
|
// third parameter is the description
|
||||||
|
// forth parameter is default value
|
||||||
|
// ->addArgument('username', InputArgument::OPTIONAL, 'Username')
|
||||||
|
|
||||||
|
// add option to display output as UPPERCASE
|
||||||
|
// second parameter null|string is shortcut
|
||||||
|
// third parameter null|int could be InputOption::VALUE_NONE <=> null, InputOption::VALUE_REQUIRED
|
||||||
|
// , InputOption::VALUE_OPTIONAL, InputOption::VALUE_IS_ARRAY, InputOption::VALUE_NEGATABLE
|
||||||
|
// forth parameter is the description
|
||||||
|
// ->addOption('uppercase', 'u', InputOption::VALUE_NONE, 'Display output in UPPERCASE')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function absencesForm(FormManager $formManager, $meeo_config)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
"bn_id_nature" => $meeo_config['absences']['formId'],
|
||||||
|
"bn_label_nature" => "Absences",
|
||||||
|
"bn_description" => "Absences des élèves",
|
||||||
|
"bn_condition" => "",
|
||||||
|
"bn_sem_context" => "",
|
||||||
|
"bn_sem_type" => "",
|
||||||
|
"bn_sem_use_template" => "1",
|
||||||
|
"bn_template" => <<<EOT
|
||||||
|
titre***Absence : {{bf_eleve}} - {{bf_date_debut_evenement}}***Titre Automatique***
|
||||||
|
listefiche***5***Elève*** *** *** *** *** ***1*** *** *** * *** * *** *** *** ***
|
||||||
|
listedatedeb***bf_date_debut***Debut*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** ***
|
||||||
|
listedatedeb***bf_date_fin***Fin*** *** ***today*** *** ***1*** *** *** * *** * *** *** *** ***
|
||||||
|
textelong***bf_commentaire***Commentaire*** *** *** *** ***wiki***0*** *** *** * *** * *** *** *** ***
|
||||||
|
EOT,
|
||||||
|
"bn_ce_i18n" => "fr-FR",
|
||||||
|
"bn_only_one_entry" => "N",
|
||||||
|
"bn_only_one_entry_message" => null
|
||||||
|
];
|
||||||
|
|
||||||
|
$existingForm = $formManager->getOne($meeo_config['absences']['formId']);
|
||||||
|
if ($existingForm)
|
||||||
|
return $formManager->update($data);
|
||||||
|
|
||||||
|
return $formManager->create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function matiereList()
|
||||||
|
{
|
||||||
|
$pageManager = $this->wiki->services->get(PageManager::class);
|
||||||
|
$tripleStore = $this->wiki->services->get(TripleStore::class);
|
||||||
|
|
||||||
|
if (!$pageManager->getOne('ListeMatiere')) {
|
||||||
|
$pageManager->save('ListeMatière', '{"label":{"francais":"Français","math":"Math"},"titre_liste":"Matieres"}');
|
||||||
|
// in case, there is already some triples for 'ListOuinonLms', delete them
|
||||||
|
$tripleStore->delete('ListeMatière', 'http://outils-reseaux.org/_vocabulary/type', null);
|
||||||
|
// create the triple to specify this page is a list
|
||||||
|
$tripleStore->create('ListeMatière', 'http://outils-reseaux.org/_vocabulary/type', 'liste', '', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function notesForm(FormManager $formManager, $meeo_config)
|
||||||
|
{
|
||||||
|
$existingForm = $formManager->getOne($meeo_config['notes']['formId']);
|
||||||
|
if ($existingForm)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->matiereList();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
"bn_id_nature" => $meeo_config['notes']['formId'],
|
||||||
|
"bn_label_nature" => "Notes",
|
||||||
|
"bn_description" => "Notes des élèves",
|
||||||
|
"bn_condition" => "",
|
||||||
|
"bn_sem_context" => "",
|
||||||
|
"bn_sem_type" => "",
|
||||||
|
"bn_sem_use_template" => "1",
|
||||||
|
"bn_template" => <<<EOT
|
||||||
|
titre*** ***Titre Automatique***
|
||||||
|
liste***ListeMatière***Matière*** *** *** ***bf_matiere*** ***1*** *** *** * *** * *** *** *** ***
|
||||||
|
listefiche***5***Elève*** *** *** ***bf_eleve*** ***1*** *** *** * *** * *** *** *** ***
|
||||||
|
texte***bf_note***Note***0***20*** *** ***number***1*** *** *** * *** * *** *** *** ***
|
||||||
|
texte***bf_coef***Coefficient***0.5***10***1*** ***number***0*** *** *** * *** * *** *** *** ***
|
||||||
|
EOT,
|
||||||
|
"bn_ce_i18n" => "fr-FR",
|
||||||
|
"bn_only_one_entry" => "N",
|
||||||
|
"bn_only_one_entry_message" => null
|
||||||
|
];
|
||||||
|
|
||||||
|
return $formManager->create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$formManager = $this->wiki->services->get(FormManager::class);
|
||||||
|
$params = $this->wiki->services->get(ParameterBagInterface::class);
|
||||||
|
if (!$params->has('meeo')) {
|
||||||
|
$result = $formManager->getAll();
|
||||||
|
$lastFormId = array_key_last($result);
|
||||||
|
$meeo_config = [
|
||||||
|
'absences' => [
|
||||||
|
'formId' => $lastFormId + 1,
|
||||||
|
],
|
||||||
|
'notes' => [
|
||||||
|
'formId' => $lastFormId + 2,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$meeo_config = $params->get('meeo');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->absencesForm($formManager, $meeo_config);
|
||||||
|
|
||||||
|
$this->notesForm($formManager, $meeo_config);
|
||||||
|
|
||||||
|
echo 'Succeed\n';
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,4 @@
|
||||||
parameters:
|
parameters:
|
||||||
meeo_formId: '6'
|
|
||||||
meeo_eleveIdentifier: listefiche5bf_eleve
|
|
||||||
meeo_groupeEE: EquipeEducative
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
_defaults:
|
_defaults:
|
||||||
autowire: true
|
autowire: true
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
<div>
|
<div>
|
||||||
<h5>{{ entry['bf_date_debut_evenement'] }}</h5>
|
<h5>{{ entry['bf_date_debut_evenement']|date("m/d/Y H:i") }} - {{ entry['bf_date_fin_evenement']|date("m/d/Y H:i") }}</h5>
|
||||||
{% if entry['bf_commentaire']|default %}
|
{% if entry['bf_commentaire']|default %}
|
||||||
<p>{{ entry['bf_commentaire'] }}</p>
|
<p>{{ entry['bf_commentaire'] }}</p>
|
||||||
|
{% else %}
|
||||||
|
<p>Aucune information</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue