first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,46 @@
<?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/>.
/**
* Privacy Subsystem implementation for tool_availabilityconditions.
*
* @package tool_availabilityconditions
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_availabilityconditions\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for tool_availabilityconditions implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+115
View File
@@ -0,0 +1,115 @@
<?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/>.
/**
* Provides an overview of installed availability conditions.
*
* You can also enable/disable them from this screen.
*
* @package tool_availabilityconditions
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/tablelib.php');
admin_externalpage_setup('manageavailability');
// Get sorted list of all availability condition plugins.
$plugins = array();
foreach (core_component::get_plugin_list('availability') as $plugin => $plugindir) {
if (get_string_manager()->string_exists('pluginname', 'availability_' . $plugin)) {
$strpluginname = get_string('pluginname', 'availability_' . $plugin);
} else {
$strpluginname = $plugin;
}
$plugins[$plugin] = $strpluginname;
}
core_collator::asort($plugins);
// Do plugin actions.
$pageurl = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/');
if (($plugin = optional_param('plugin', '', PARAM_PLUGIN))) {
require_sesskey();
if (!array_key_exists($plugin, $plugins)) {
throw new \moodle_exception('invalidcomponent', 'error', $pageurl);
}
$action = required_param('action', PARAM_ALPHA);
switch ($action) {
case 'hide' :
$class = \core_plugin_manager::resolve_plugininfo_class('availability');
$class::enable_plugin($plugin, false);
break;
case 'show' :
$class = \core_plugin_manager::resolve_plugininfo_class('availability');
$class::enable_plugin($plugin, true);
break;
}
// Always redirect back after an action.
redirect($pageurl);
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('manageplugins', 'availability'));
// Show a table of installed availability conditions.
$table = new flexible_table('availabilityconditions_administration_table');
$table->define_columns(array('name', 'version', 'enable'));
$table->define_headers(array(get_string('plugin'),
get_string('version'), get_string('hide') . '/' . get_string('show')));
$table->define_baseurl($PAGE->url);
$table->set_attribute('id', 'availabilityconditions');
$table->set_attribute('class', 'admintable generaltable');
$table->setup();
$enabledlist = core\plugininfo\availability::get_enabled_plugins();
foreach ($plugins as $plugin => $name) {
// Get version or ? if unknown.
$version = get_config('availability_' . $plugin);
if (!empty($version->version)) {
$version = $version->version;
} else {
$version = '?';
}
// Get enabled status and use to grey out name if necessary.
$enabled = in_array($plugin, $enabledlist);
if ($enabled) {
$enabledaction = 'hide';
$enabledstr = get_string('hide');
$class = '';
} else {
$enabledaction = 'show';
$enabledstr = get_string('show');
$class = 'dimmed_text';
}
// Make enable control. This is a POST request (using a form control rather
// than just a link) because it makes a database change.
$params = array('sesskey' => sesskey(), 'plugin' => $plugin, 'action' => $enabledaction);
$url = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/', $params);
$enablecontrol = html_writer::link($url, $OUTPUT->pix_icon('t/' . $enabledaction, $enabledstr));
$table->add_data([$name, $version, $enablecontrol], $class);
}
$table->print_html();
echo $OUTPUT->footer();
@@ -0,0 +1,27 @@
<?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/>.
/**
* Strings for availability conditions options.
*
* @package core_availability
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['manageplugins'] = 'Manage restrictions';
$string['pluginname'] = 'Availability condition management';
$string['privacy:metadata'] = 'The Availability condition management plugin does not store any personal data.';
@@ -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/>.
/**
* Adds settings links to admin tree.
*
* @package tool_availabilityconditions
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig && !empty($CFG->enableavailability)) {
$ADMIN->add('modules', new admin_category('availabilitysettings',
new lang_string('type_availability_plural', 'plugin')));
$ADMIN->add('availabilitysettings', new admin_externalpage('manageavailability',
new lang_string('manageplugins', 'tool_availabilityconditions'),
$CFG->wwwroot . '/' . $CFG->admin . '/tool/availabilityconditions/'));
foreach (core_plugin_manager::instance()->get_plugins_of_type('availability') as $plugin) {
/** @var \core\plugininfo\format $plugin */
$plugin->load_settings($ADMIN, 'availabilitysettings', $hassiteconfig);
}
}
@@ -0,0 +1,62 @@
@tool @tool_availabilityconditions
Feature: Manage availability conditions
In order to control availability restrictions
As an administrator
I need to see the list of restrictions and hide or show them
@javascript
Scenario: Display list of availability conditions
# Check the report doesn't show when not enabled.
Given the following config values are set as admin:
| unaddableblocks | | theme_boost|
And I log in as "admin"
And I turn editing mode on
And I add the "Administration" block if not present
And the following config values are set as admin:
| enableavailability | 0 |
And I expand "Site administration" node
When I expand "Plugins" node
Then I should not see "Availability restrictions"
# Enable it and check I can now see and click on it.
And the following config values are set as admin:
| enableavailability | 1 |
And I am on homepage
And I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
# Having clicked on it, I should also see the list of plugins.
And I should see "Restriction by date"
And I should see "Restriction by grades"
@javascript
Scenario: Hide and show conditions
# Get to the right page
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "activity" exists:
| activity | page |
| course | C1 |
| name | P1 |
And I log in as "admin"
When I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
# Check the icon is there (it should be a Hide icon, meaning is currently visible).
Then "Hide" "icon" should exist in the "Restriction by date" "table_row"
# Click the icon. It should toggle to hidden (title=Show).
And I click on "Hide" "icon" in the "Restriction by date" "table_row"
And "Show" "icon" should exist in the "Restriction by date" "table_row"
# Toggle it back to visible (title=Hide).
And I click on "Show" "icon" in the "Restriction by date" "table_row"
And "Hide" "icon" should exist in the "Restriction by date" "table_row"
# OK, toggling works. Set the grade one to Hide and we'll go see if it actually worked.
And I click on "Hide" "icon" in the "Restriction by grade" "table_row"
And I am on the "P1" "page activity editing" page
And I expand all fieldsets
And I click on "Add restriction..." "button"
And "Add restriction..." "dialogue" should be visible
And "Date" "button" should exist in the "Add restriction..." "dialogue"
And "Grade" "button" should not exist in the "Add restriction..." "dialogue"
@@ -0,0 +1,29 @@
<?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/>.
/**
* Version
*
* @package tool_availabilityconditions
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200;
$plugin->requires = 2024041600;
$plugin->component = 'tool_availabilityconditions';