diff --git a/block_career.php b/block_career.php index a17fbacc7423dfa1e6b5dc8a3a2fb3d8f7f0a1ad..fa4266ba94a067403aa05a3cee4a4be5562d045d 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 29a08b26e1b8a8b09a2393da2954399ae3a00c37..865524fd79032140591383eb22bc5e5225d69229 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 20d5ecddd3f1e2bda33052a5655837e29eeddb02..54d095706a289ef71ae0e6bcf5333047d99fb089 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 b7c93cce0444763b72f283e085650f68e41b2f8b..7cbfa72295d404bffdb7ad8a3801b6e32785e2b2 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 0000000000000000000000000000000000000000..d4c2d6e329803c4ade9f9e23666bb87e8f5c809d --- /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 + )); +}