Merge branch 'MDL-43941-master' of git://github.com/andrewnicols/moodle

Conflicts:
	course/yui/build/moodle-course-toolboxes/moodle-course-toolboxes-min.js
This commit is contained in:
Sam Hemelryk 2014-02-11 14:10:52 +13:00
commit b73fd8608a
8 changed files with 80 additions and 52 deletions

View File

@ -39,3 +39,57 @@ Feature: Toggle activities visibility from the course page
And I log in as "student1"
And I follow "Course 1"
And "Test forum name" activity should be hidden
@javascript
Scenario: Activities can be shown and hidden inside a hidden section
Given the following "users" exists:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
And the following "courses" exists:
| fullname | shortname | format | numsections |
| Course 1 | C1 | topics | 2 |
And the following "course enrolments" exists:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Forum" to section "2" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
| Visible | Show |
When I hide section "2"
Then "Test forum name" activity should be hidden
And I open "Test forum name" actions menu
And I click on "Show" "link" in the "Test forum name" activity
And "Test forum name" activity should be visible
And I open "Test forum name" actions menu
And I click on "Hide" "link" in the "Test forum name" activity
And "Test forum name" activity should be hidden
@javascript
Scenario: Activities can be shown and hidden inside an orphaned section
Given the following "users" exists:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
And the following "courses" exists:
| fullname | shortname | format | numsections |
| Course 1 | C1 | topics | 2 |
And the following "course enrolments" exists:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Forum" to section "2" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
| Visible | Show |
When I click on ".reduce-sections" "css_element"
Then "Test forum name" activity should be visible
And I open "Test forum name" actions menu
And I click on "Hide" "link" in the "Test forum name" activity
And "Test forum name" activity should be hidden
And I open "Test forum name" actions menu
And I click on "Show" "link" in the "Test forum name" activity
And "Test forum name" activity should be visible

View File

@ -351,6 +351,23 @@ class behat_course extends behat_base {
// Section should be hidden.
$exception = new ExpectationException('The section is not hidden', $this->getSession());
$this->find('xpath', $sectionxpath . "[contains(concat(' ', normalize-space(@class), ' '), ' hidden ')]", $exception);
}
/**
* Checks that all actiities in the specified section are hidden. You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
*
* @Then /^all activities in section "(?P<section_number>\d+)" should be hidden$/
* @throws ExpectationException
* @throws ElementNotFoundException Thrown by behat_base::find
* @param int $sectionnumber
*/
public function section_activities_should_be_hidden($sectionnumber) {
$sectionxpath = $this->section_exists($sectionnumber);
// Preventive in case there is any action in progress.
// Adding it here because we are interacting (click) with
// the elements, not necessary when we just find().
$this->i_wait_until_section_is_available($sectionnumber);
// The checking are different depending on user permissions.
if ($this->is_course_editor()) {
@ -362,50 +379,19 @@ class behat_course extends behat_base {
if ($activities = $this->get_section_activities($sectionxpath)) {
$dimmedexception = new ExpectationException('There are activities that are not dimmed', $this->getSession());
$visibilityexception = new ExpectationException('There are activities which visibility icons are clickable', $this->getSession());
foreach ($activities as $activity) {
// Dimmed.
$this->find('xpath', "//div[contains(concat(' ', normalize-space(@class), ' '), ' activityinstance ')]" .
"/a[contains(concat(' ', normalize-space(@class), ' '), ' dimmed ')]", $dimmedexception, $activity);
// Non-JS browsers can not click on img elements.
if ($this->running_javascript()) {
// Expanding the actions menu if it is not shown.
$classes = array_flip(explode(' ', $activity->getAttribute('class')));
if (empty($classes['action-menu-shown'])) {
$actionsmenu = $this->find('css', "a[role='menuitem']", false, $activity);
$actionsmenu->click();
}
// To check that the visibility is not clickable we check the funcionality rather than the applied style.
$visibilityiconnode = $this->find('css', 'a.editing_show img', false, $activity);
$visibilityiconnode->click();
}
// We ensure that we still see the show icon.
$visibilityiconnode = $this->find('css', 'a.editing_show img', $visibilityexception, $activity);
// It is there only when running JS scenarios.
if ($this->running_javascript()) {
// Collapse the actions menu if it is displayed.
$classes = array_flip(explode(' ', $activity->getAttribute('class')));
if (!empty($classes['action-menu-shown'])) {
$actionsmenu = $this->find('css', "a[role='menuitem']", false, $activity);
$actionsmenu->click();
}
}
}
}
} else {
// There shouldn't be activities.
if ($this->get_section_activities($sectionxpath)) {
throw new ExpectationException('There are activities in the section and they should be hidden', $this->getSession());
}
}
}
/**

View File

@ -77,6 +77,7 @@ Feature: Course activity controls works as expected
And I hide section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be hidden
And all activities in section "1" should be hidden
And I show section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be visible
@ -151,6 +152,7 @@ Feature: Course activity controls works as expected
And I hide section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be hidden
And all activities in section "1" should be hidden
And I show section "1"
And "#section-2" "css_element" <should_see_other_sections> exists
And section "1" should be visible

View File

@ -59,11 +59,15 @@ Feature: Show/hide course sections
And section "3" should be hidden
And I reload the page
And section "1" should be hidden
And all activities in section "1" should be hidden
And section "2" should be visible
And section "3" should be hidden
And all activities in section "1" should be hidden
And I log out
And I log in as "student1"
And I follow "Course 1"
And section "1" should be hidden
And all activities in section "1" should be hidden
And section "2" should be visible
And section "3" should be hidden
And all activities in section "1" should be hidden

View File

@ -555,12 +555,6 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
// Prevent the default button action
ev.preventDefault();
// Return early if the current section is hidden
var section = activity.ancestor(M.course.format.get_section_selector(Y));
if (section && section.hasClass(CSS.SECTIONHIDDENCLASS)) {
return this;
}
// Get the element we're working on
var element = activity;
var value = this.handle_resource_dim(button, activity, action);

File diff suppressed because one or more lines are too long

View File

@ -555,12 +555,6 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
// Prevent the default button action
ev.preventDefault();
// Return early if the current section is hidden
var section = activity.ancestor(M.course.format.get_section_selector(Y));
if (section && section.hasClass(CSS.SECTIONHIDDENCLASS)) {
return this;
}
// Get the element we're working on
var element = activity;
var value = this.handle_resource_dim(button, activity, action);

View File

@ -351,12 +351,6 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
// Prevent the default button action
ev.preventDefault();
// Return early if the current section is hidden
var section = activity.ancestor(M.course.format.get_section_selector(Y));
if (section && section.hasClass(CSS.SECTIONHIDDENCLASS)) {
return this;
}
// Get the element we're working on
var element = activity;
var value = this.handle_resource_dim(button, activity, action);