Merge branch 'MDL-45398-master' of git://github.com/sammarshallou/moodle

This commit is contained in:
Marina Glancy 2014-05-08 12:04:53 +08:00
commit f69c0d572e
3 changed files with 61 additions and 5 deletions

View File

@ -43,7 +43,7 @@ foreach (core_component::get_plugin_list('availability') as $plugin => $plugindi
core_collator::asort($plugins);
// Do plugin actions.
$pageurl = new moodle_url('/' . $CFG->admin . '/availabilityconditions.php');
$pageurl = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/');
if (($plugin = optional_param('plugin', '', PARAM_PLUGIN))) {
require_sesskey();
if (!array_key_exists($plugin, $plugins)) {
@ -103,8 +103,6 @@ foreach ($plugins as $plugin => $name) {
// Make enable control. This is a POST request (using a form control rather
// than just a link) because it makes a database change.
$targeturl = new moodle_url('availabilityconditions.php', array(
'plugin' => $plugin, 'action' => $enabledaction, 'sesskey' => sesskey()));
$enablecontrol = html_writer::tag('form', html_writer::div(
html_writer::empty_tag('input', array('type' => 'hidden',
'name' => 'sesskey', 'value' => sesskey())) .
@ -116,7 +114,7 @@ foreach ($plugins as $plugin => $name) {
'src' => $OUTPUT->pix_url('t/' . $enabledaction), 'alt' => $enabledstr,
'title' => $enabledstr))
), array(
'method' => 'post', 'action' => 'availabilityconditions.php'));
'method' => 'post', 'action' => './'));
$table->add_data(array($namespan, $version, $enablecontrol));
}

View File

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig) {
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',

View File

@ -0,0 +1,58 @@
@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 I log in as "admin"
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 I set the following administration settings values:
| Enable conditional access | 1 |
And I am on homepage
And I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"
# 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 I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I am on homepage
When I navigate to "Manage restrictions" node in "Site administration > Plugins > Availability restrictions"
# Check the icon is there (it should be a Hide icon, meaning is currently visible).
Then "input[title=Hide]" "css_element" should exist in the "Restriction by date" "table_row"
# Click the icon. It should toggle to hidden (title=Show).
And I click on "input[title=Hide]" "css_element" in the "Restriction by date" "table_row"
And "input[title=Show]" "css_element" should exist in the "Restriction by date" "table_row"
# Toggle it back to visible (title=Hide).
And I click on "input[title=Show]" "css_element" in the "Restriction by date" "table_row"
And "input[title=Hide]" "css_element" 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 "input[title=Hide]" "css_element" in the "Restriction by grade" "table_row"
And I am on homepage
And I follow "Course 1"
And I turn editing mode on
And I add a "Page" to section "1"
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"