Add eleves liste
This commit is contained in:
parent
18b0707ffd
commit
06d8eb8b81
3 changed files with 80 additions and 11 deletions
|
@ -62,7 +62,7 @@ class CreateFormsCommand extends Command
|
|||
|
||||
private function absencesForm(FormManager $formManager, $meeo_config)
|
||||
{
|
||||
$formId = $meeo_config['absences']['formId'];
|
||||
$formId = $meeo_config['absencesFormId'];
|
||||
$data = [
|
||||
"bn_id_nature" => $formId,
|
||||
"bn_label_nature" => "Absences",
|
||||
|
@ -102,7 +102,7 @@ EOT,
|
|||
|
||||
private function notesForm(FormManager $formManager, $meeo_config)
|
||||
{
|
||||
$formId = $meeo_config['notes']['formId'];
|
||||
$formId = $meeo_config['notesFormId'];
|
||||
|
||||
$this->matiereList();
|
||||
|
||||
|
@ -146,7 +146,7 @@ EOT,
|
|||
|
||||
private function elevesForms(FormManager $formManager, $meeo_config) {
|
||||
|
||||
$formId = $meeo_config['eleves']['formId'];
|
||||
$formId = $meeo_config['elevesFormId'];
|
||||
|
||||
$this->classeList();
|
||||
|
||||
|
@ -162,7 +162,7 @@ EOT,
|
|||
texte***bf_titre***Nom d'utilisateur*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
|
||||
texte***bf_nom***Nom complet*** *** *** *** ***text***1*** *** *** * *** * *** *** *** ***
|
||||
champs_mail***bf_mail***Email*** *** % *** ***form*** ***1***0*** *** * *** % *** *** *** ***
|
||||
liste***ListeClasse***Liste déroulante*** *** *** ***bf_classe*** ***1*** *** *** * *** * *** *** *** ***
|
||||
liste***ListeClasses***Classe*** *** ***aucune***bf_classe*** ***1*** *** *** * *** * *** *** *** ***
|
||||
EOT,
|
||||
"bn_ce_i18n" => "fr-FR",
|
||||
"bn_only_one_entry" => "N",
|
||||
|
|
72
commands/UpdateElevesFromYunohostCommand.php
Normal file
72
commands/UpdateElevesFromYunohostCommand.php
Normal 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;
|
||||
}
|
||||
}
|
11
config.yaml
11
config.yaml
|
@ -1,12 +1,9 @@
|
|||
parameters:
|
||||
meeo:
|
||||
eleves:
|
||||
formId: 6
|
||||
absences:
|
||||
formId: 7
|
||||
notes:
|
||||
formId: 8
|
||||
elevesFormId: 5
|
||||
elevesFormId: 6
|
||||
absencesFormId: 7
|
||||
notesFormId: 8
|
||||
yunohostFormId: 5
|
||||
groupeEE: 'EquipeEducative'
|
||||
services:
|
||||
_defaults:
|
||||
|
|
Loading…
Reference in a new issue