forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-49434 availability: Use renderables for multiple messages
Co-Authored-By: Andrew Nicols <[email protected]>
- Loading branch information
1 parent
9325cd9
commit c7b7385
Showing
6 changed files
with
162 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Represents multiple availability messages. | ||
* | ||
* These are messages like 'Not available until <date>'. This class includes | ||
* multiple messages so that they can be rendered into a combined display, e.g. | ||
* using bulleted lists. | ||
* | ||
* The tree structure of this object matches that of the availability | ||
* restrictions. | ||
* | ||
* @package core_availability | ||
* @copyright 2015 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
/** | ||
* Represents multiple availability messages. | ||
* | ||
* These are messages like 'Not available until <date>'. This class includes | ||
* multiple messages so that they can be rendered into a combined display, e.g. | ||
* using bulleted lists. | ||
* | ||
* The tree structure of this object matches that of the availability | ||
* restrictions. | ||
* | ||
* @package core_availability | ||
* @copyright 2015 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class core_availability_multiple_messages implements renderable { | ||
/** @var bool True if this object represents the root of the tree */ | ||
public $root; | ||
/** @var bool True if items use the AND operator (false = OR) */ | ||
public $andoperator; | ||
/** @var bool True if this part of the tree is marked 'hide entirely' for non-matching users */ | ||
public $treehidden; | ||
/** @var array Array of child items (may be string or this type) */ | ||
public $items; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param bool $root True if this object represents the root of the tree | ||
* @param bool $andoperator True if items use the AND operator (false = OR) | ||
* @param bool $treehidden True if this part of the tree is marked 'hide entirely' for non-matching users | ||
* @param array $items Array of items (may be string or this type) | ||
*/ | ||
public function __construct($root, $andoperator, $treehidden, array $items) { | ||
$this->root = $root; | ||
$this->andoperator = $andoperator; | ||
$this->treehidden = $treehidden; | ||
$this->items = $items; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
availability/condition/completion/tests/behat/conditional_bug.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
@availability @availability_completion | ||
Feature: Confirm that conditions on completion no longer cause a bug | ||
In order to use completion conditions | ||
As a teacher | ||
I need it to not break when I set up certain conditions on some modules | ||
|
||
Background: | ||
Given the following "courses" exist: | ||
| fullname | shortname | format | | ||
| Course 1 | C1 | topics | | ||
And the following "users" exist: | ||
| username | | ||
| teacher1 | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| teacher1 | C1 | editingteacher | | ||
And the following config values are set as admin: | ||
| enableavailability | 1 | | ||
| enablecompletion | 1 | | ||
|
||
@javascript | ||
Scenario: Multiple completion conditions on glossary | ||
# Set up course. | ||
Given I log in as "teacher1" | ||
And I follow "Course 1" | ||
And I navigate to "Edit settings" node in "Course administration" | ||
And I expand all fieldsets | ||
And I set the field "Enable completion tracking" to "Yes" | ||
And I press "Save and display" | ||
And I turn editing mode on | ||
|
||
# Add a couple of Pages with manual completion. | ||
And I add a "Page" to section "1" and I fill the form with: | ||
| Name | Page1 | | ||
| Page content | x | | ||
And I add a "Page" to section "1" and I fill the form with: | ||
| Name | Page2 | | ||
| Page content | x | | ||
|
||
# Add a Glossary. | ||
When I add a "Glossary" to section "1" | ||
And I set the following fields to these values: | ||
| Name | TestGlossary | | ||
And I expand all fieldsets | ||
|
||
# Add restrictions to the previous Pages being complete. | ||
And I press "Add restriction..." | ||
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue" | ||
And I set the field "Activity or resource" to "Page1" | ||
And I press "Add restriction..." | ||
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue" | ||
And I set the field with xpath "//div[@class='availability-item'][preceding-sibling::div]//select[@name='cm']" to "Page2" | ||
And I press "Save and return to course" | ||
And I should see "Not available unless:" in the ".activity.glossary" "css_element" | ||
And I should see "The activity Page1 is marked complete" in the ".activity.glossary" "css_element" | ||
And I should see "The activity Page2 is marked complete" in the ".activity.glossary" "css_element" | ||
And I follow "TestGlossary" | ||
|
||
# Behat will automatically check there is no error on this page. | ||
Then I should see "TestGlossary" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters