1441 |
ariadna |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Test page for admin setting hide_if functionality dependent on a configmultiselect setting.
|
|
|
19 |
*
|
|
|
20 |
* @package core
|
|
|
21 |
* @copyright 2024 Lars Bonczek (@innoCampus, TU Berlin)
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
require_once(__DIR__ . '/../../../../config.php');
|
|
|
26 |
|
|
|
27 |
defined('BEHAT_SITE_RUNNING') || die();
|
|
|
28 |
|
|
|
29 |
global $CFG, $PAGE, $OUTPUT;
|
|
|
30 |
require_once($CFG->libdir . '/adminlib.php');
|
|
|
31 |
$PAGE->set_url('/lib/tests/behat/fixtures/multiselect_hide_if_admin_settingspage.php');
|
|
|
32 |
require_login();
|
|
|
33 |
$PAGE->set_context(core\context\system::instance());
|
|
|
34 |
|
|
|
35 |
// Set up dummy admin settings page.
|
|
|
36 |
$settings = new \admin_settingpage('hide_if_admin_settingspage', 'hide_if Test');
|
|
|
37 |
|
|
|
38 |
$settings->add(new admin_setting_configmultiselect('multiselect1', 'multiselect1', '', [], [
|
|
|
39 |
1 => 'Option 1',
|
|
|
40 |
2 => 'Option 2',
|
|
|
41 |
]));
|
|
|
42 |
|
|
|
43 |
$settings->add(new admin_setting_configcheckbox('hideIfEq_', "Hide if selection 'eq' []", '', false));
|
|
|
44 |
$settings->add(new admin_setting_configcheckbox('hideIfIn_', "Hide if selection 'in' []", '', false));
|
|
|
45 |
$settings->add(new admin_setting_configcheckbox('hideIfNeq_', "Hide if selection 'neq' []", '', false));
|
|
|
46 |
$settings->add(new admin_setting_configcheckbox('hideIfEq1', "Hide if selection 'eq' ['1']", '', false));
|
|
|
47 |
$settings->add(new admin_setting_configcheckbox('hideIfIn1', "Hide if selection 'in' ['1']", '', false));
|
|
|
48 |
$settings->add(new admin_setting_configcheckbox('hideIfNeq1', "Hide if selection 'neq' ['1']", '', false));
|
|
|
49 |
$settings->add(new admin_setting_configcheckbox('hideIfEq12', "Hide if selection 'eq' ['1', '2']", '', false));
|
|
|
50 |
$settings->add(new admin_setting_configcheckbox('hideIfIn12', "Hide if selection 'in' ['1', '2']", '', false));
|
|
|
51 |
$settings->add(new admin_setting_configcheckbox('hideIfNeq12', "Hide if selection 'neq' ['1', '2']", '', false));
|
|
|
52 |
|
|
|
53 |
$settings->hide_if('hideIfEq_', 'multiselect1[]', 'eq', '');
|
|
|
54 |
$settings->hide_if('hideIfIn_', 'multiselect1[]', 'in', '');
|
|
|
55 |
$settings->hide_if('hideIfNeq_', 'multiselect1[]', 'neq', '');
|
|
|
56 |
$settings->hide_if('hideIfEq1', 'multiselect1[]', 'eq', '1');
|
|
|
57 |
$settings->hide_if('hideIfIn1', 'multiselect1[]', 'in', '1');
|
|
|
58 |
$settings->hide_if('hideIfNeq1', 'multiselect1[]', 'neq', '1');
|
|
|
59 |
$settings->hide_if('hideIfEq12', 'multiselect1[]', 'eq', '1|2');
|
|
|
60 |
$settings->hide_if('hideIfIn12', 'multiselect1[]', 'in', '1|2');
|
|
|
61 |
$settings->hide_if('hideIfNeq12', 'multiselect1[]', 'neq', '1|2');
|
|
|
62 |
|
|
|
63 |
echo $OUTPUT->header();
|
|
|
64 |
|
|
|
65 |
$context = [
|
|
|
66 |
'actionurl' => $PAGE->url->out(false),
|
|
|
67 |
'sesskey' => sesskey(),
|
|
|
68 |
'settings' => $settings->output_html(),
|
|
|
69 |
'showsave' => true,
|
|
|
70 |
];
|
|
|
71 |
echo $OUTPUT->render_from_template('core_admin/settings', $context);
|
|
|
72 |
|
|
|
73 |
$opts = [
|
|
|
74 |
'dependencies' => $settings->get_dependencies_for_javascript(),
|
|
|
75 |
];
|
|
|
76 |
$PAGE->requires->js_call_amd('core/showhidesettings', 'init', [$opts]);
|
|
|
77 |
|
|
|
78 |
echo $OUTPUT->footer();
|