Add eleves liste

This commit is contained in:
mckmonster 2024-07-17 10:42:47 +02:00
parent 18b0707ffd
commit 06d8eb8b81
3 changed files with 80 additions and 11 deletions

View file

@ -62,7 +62,7 @@ class CreateFormsCommand extends Command
private function absencesForm(FormManager $formManager, $meeo_config) private function absencesForm(FormManager $formManager, $meeo_config)
{ {
$formId = $meeo_config['absences']['formId']; $formId = $meeo_config['absencesFormId'];
$data = [ $data = [
"bn_id_nature" => $formId, "bn_id_nature" => $formId,
"bn_label_nature" => "Absences", "bn_label_nature" => "Absences",
@ -102,7 +102,7 @@ EOT,
private function notesForm(FormManager $formManager, $meeo_config) private function notesForm(FormManager $formManager, $meeo_config)
{ {
$formId = $meeo_config['notes']['formId']; $formId = $meeo_config['notesFormId'];
$this->matiereList(); $this->matiereList();
@ -146,7 +146,7 @@ EOT,
private function elevesForms(FormManager $formManager, $meeo_config) { private function elevesForms(FormManager $formManager, $meeo_config) {
$formId = $meeo_config['eleves']['formId']; $formId = $meeo_config['elevesFormId'];
$this->classeList(); $this->classeList();
@ -162,7 +162,7 @@ EOT,
texte***bf_titre***Nom d'utilisateur*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** texte***bf_titre***Nom d'utilisateur*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
texte***bf_nom***Nom complet*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** texte***bf_nom***Nom complet*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
champs_mail***bf_mail***Email*** *** % *** ***form*** ***1***0*** *** * *** % *** *** *** *** champs_mail***bf_mail***Email*** *** % *** ***form*** ***1***0*** *** * *** % *** *** *** ***
liste***ListeClasse***Liste déroulante*** *** *** ***bf_classe*** ***1*** *** *** * *** * *** *** *** *** liste***ListeClasses***Classe*** *** ***aucune***bf_classe*** ***1*** *** *** * *** * *** *** *** ***
EOT, EOT,
"bn_ce_i18n" => "fr-FR", "bn_ce_i18n" => "fr-FR",
"bn_only_one_entry" => "N", "bn_only_one_entry" => "N",

View file

@ -0,0 +1,72 @@
<?php
namespace YesWiki\Meeo\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use YesWiki\Wiki;
use YesWiki\Bazar\Service\EntryManager;
class UpdateElevesFromYunohostCommand 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:update')
// the short description shown while running "./yeswicli list"
->setDescription('Update la liste des élèves depuis les utilisateurs Yunohost')
// 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')
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
$entryManager = $this->wiki->services->get(EntryManager::class);
$params = $this->wiki->services->get(ParameterBagInterface::class);
$meeo_config = $params->get('meeo');
$yunohostFormId = $meeo_config['yunohostFormId'];
$elevesFormId = $meeo_config['elevesFormId'];
$yunohostEntries = $entryManager->search(['formsIds' => $yunohostFormId]);
foreach ($yunohostEntries as $yunohostEntry) {
$eleveEntry = $entryManager->search(['formsIds' => $elevesFormId, 'queries' => [
'bf_titre' => $yunohostEntry['bf_titre']
]]);
if ($eleveEntry == null) {
$entryManager->create($elevesFormId, [
'bf_titre' => $yunohostEntry['bf_titre'],
'bf_nom' => $yunohostEntry['bf_nom'],
'bf_mail' => $yunohostEntry['bf_mail'],
'antispam' => 1
]);
}
}
return Command::SUCCESS;
}
}

View file

@ -1,12 +1,9 @@
parameters: parameters:
meeo: meeo:
eleves: elevesFormId: 6
formId: 6 absencesFormId: 7
absences: notesFormId: 8
formId: 7 yunohostFormId: 5
notes:
formId: 8
elevesFormId: 5
groupeEE: 'EquipeEducative' groupeEE: 'EquipeEducative'
services: services:
_defaults: _defaults: