From 5d3606226b217fa22e9f16382e775a4ab1b7b429 Mon Sep 17 00:00:00 2001 From: comete-upn <logicielslibres@liste.parisnanterre.fr> Date: Mon, 7 Feb 2022 10:01:22 +0100 Subject: [PATCH] =?UTF-8?q?Nouvelle=20option=20pour=20ne=20pas=20afficher?= =?UTF-8?q?=20le=20bloc=20aux=20=C3=A9tudiant=E2=8B=85e=E2=8B=85s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- block_career.php | 6 ++++++ edit_form.php | 10 ++++++---- lang/en/block_career.php | 10 +++++++--- lang/fr/block_career.php | 5 +++++ settings.php | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 settings.php diff --git a/block_career.php b/block_career.php index a17fbac..fa4266b 100644 --- a/block_career.php +++ b/block_career.php @@ -65,6 +65,12 @@ class block_career extends block_base if (empty($this->config)) { $this->config = new stdClass(); } + if (empty($this->config->showstudents)) { + $this->config->showstudents = get_config('block_career', 'showstudentsbydefault'); + } + if (!$this->config->showstudents && current(get_user_roles(context_course::instance($COURSE->id), $USER->id))->shortname == 'student') { + return; + } $request = $DB->get_records_sql('SELECT * FROM {block_career} WHERE course = ?', array($COURSE->id)); // var_dump($request); diff --git a/edit_form.php b/edit_form.php index 29a08b2..865524f 100644 --- a/edit_form.php +++ b/edit_form.php @@ -11,10 +11,12 @@ function specific_definition($mform) { // Adding an element to the form - // $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); + $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); + + // Option to show/hide the block to students + $mform->addElement('advcheckbox', 'config_showstudents', get_string('config_showstudents', 'block_career'), get_string('config_showstudents_desc', 'block_career')); + $mform->setDefault('config_showstudents', get_config('block_career', 'showstudentsbydefault')); } } -?> - - +?> \ No newline at end of file diff --git a/lang/en/block_career.php b/lang/en/block_career.php index 20d5ecd..54d0957 100644 --- a/lang/en/block_career.php +++ b/lang/en/block_career.php @@ -1,9 +1,9 @@ <?php $string['date_release'] = '{$a->month}.{$a->date}.{$a->year}'; $string['career'] = 'Moodle Version'; - $string['career:addinstance'] = 'Ajouter un block Parcours'; - $string['career:myaddinstance'] = 'Ajouter un block Parcours sur ma page'; - $string['pluginname'] = 'Path block'; + $string['career:addinstance'] = 'Add a new career block'; + $string['career:myaddinstance'] = 'Add a new career block to Dashboard'; + $string['pluginname'] = 'Path block'; $string['release'] = 'Release: '; $string['title_plugin'] = 'Path'; $string['titleadd_plugin'] = 'New Path'; @@ -16,4 +16,8 @@ $string['add_path'] = 'Add a path'; $string['any_carrer'] = 'No Path in this course.'; $string['list_title'] = 'Edit path list'; + $string['setting_showstudents'] = 'Show the block to students'; + $string['setting_showstudents_desc'] = 'If unselected, the block will be hidden to students by default.'; + $string['config_showstudents'] = 'Show the block to students'; + $string['config_showstudents_desc'] = 'If unselected, the block will be hidden to students.'; ?> \ No newline at end of file diff --git a/lang/fr/block_career.php b/lang/fr/block_career.php index b7c93cc..7cbfa72 100644 --- a/lang/fr/block_career.php +++ b/lang/fr/block_career.php @@ -4,6 +4,7 @@ $string['career:addinstance'] = 'Ajouter un block Parcours'; $string['career:myaddinstance'] = 'Ajouter un block Parcours sur ma page'; $string['pluginname'] = 'Bloc Parcours'; + $string['release'] = 'Version : '; $string['title_plugin'] = 'Parcours'; $string['titleadd_plugin'] = 'Ajouter un parcours'; $string['titleaddname_plugin'] = 'Nom'; @@ -15,4 +16,8 @@ $string['add_path'] = 'Ajouter un parcours'; $string['any_carrer'] = 'Pas de parcours.'; $string['list_title'] = 'Édition des parcours'; + $string['setting_showstudents'] = 'Afficher le bloc aux étudiant·e·s'; + $string['setting_showstudents_desc'] = 'Si décoché, le bloc sera caché par défaut aux étudiant·e·s.'; + $string['config_showstudents'] = 'Afficher le bloc aux étudiant·e·s'; + $string['config_showstudents_desc'] = 'Si décoché, le bloc sera caché aux étudiant·e·s.'; ?> \ No newline at end of file diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..d4c2d6e --- /dev/null +++ b/settings.php @@ -0,0 +1,37 @@ +<?php +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. + +/** + * Settings for the career block + * + * @package block_career + * @category block + * @copyright 2018 Softia/Université lorraine + * @author Myriam Delaruelle / vrignaud camille/ faouzi / Thomas Fradet + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +if ($ADMIN->fulltree) { + // Default for showing/hiding the block to students + $settings->add(new admin_setting_configcheckbox( + 'block_career/showstudentsbydefault', + get_string('setting_showstudents', 'block_career'), + get_string('setting_showstudents_desc', 'block_career'), + 1 + )); +} -- GitLab