Merge branch 'MDL-38945_master' of git://github.com/dmonllao/moodle
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Behat groups-related steps definitions.
|
||||
*
|
||||
* @package core_group
|
||||
* @category test
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
||||
|
||||
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
|
||||
|
||||
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
|
||||
/**
|
||||
* Groups-related steps definitions.
|
||||
*
|
||||
* @package core_group
|
||||
* @category test
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_groups extends behat_base {
|
||||
|
||||
/**
|
||||
* Add the specified user to the group. You should be in the groups page when running this step.
|
||||
*
|
||||
* @Given /^I add "(?P<username_string>(?:[^"]|\\")*)" user to "(?P<group_name_string>(?:[^"]|\\")*)" group$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $username
|
||||
* @param string $groupname
|
||||
*/
|
||||
public function i_add_user_to_group($username, $groupname) {
|
||||
global $DB;
|
||||
|
||||
$user = $DB->get_record('user', array('username' => $username));
|
||||
$userfullname = fullname($user);
|
||||
|
||||
// We don't know the option text as it contains the number of users in the group.
|
||||
$select = $this->find_field('groups');
|
||||
$xpath = "//select[@id='groups']/descendant::option[contains(., '" . $groupname . "')]";
|
||||
$groupoption = $this->find('xpath', $xpath);
|
||||
$fulloption = $groupoption->getText();
|
||||
$select->selectOption($fulloption);
|
||||
|
||||
// Here we don't need to wait for the AJAX response.
|
||||
$this->find_button('Add/remove users')->click();
|
||||
|
||||
// Wait for add/remove members page to be loaded.
|
||||
$this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")');
|
||||
|
||||
// Getting the option and selecting it.
|
||||
$select = $this->find_field('addselect');
|
||||
$xpath = "//select[@id='addselect']/descendant::option[contains(., '" . $userfullname . "')]";
|
||||
$memberoption = $this->find('xpath', $xpath);
|
||||
$fulloption = $memberoption->getText();
|
||||
$select->selectOption($fulloption);
|
||||
|
||||
// Click add button.
|
||||
$this->find_button('Add')->click();
|
||||
|
||||
// Wait for the page to load.
|
||||
$this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")');
|
||||
|
||||
// Returning to the main groups page.
|
||||
$this->find_button('Back to groups')->click();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
@core_group
|
||||
Feature: Organize students into groups
|
||||
In order to organize course activities in groups
|
||||
As a moodle teacher
|
||||
I need to group students
|
||||
|
||||
@javascript
|
||||
Scenario: Assign students to groups
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category | groupmode |
|
||||
| Course 1 | C1 | 0 | 1 |
|
||||
And the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
| student0 | Student | 0 | student0@asd.com |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
| student2 | Student | 2 | student2@asd.com |
|
||||
| student3 | Student | 3 | student3@asd.com |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student0 | C1 | student |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
| student3 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
And I press "Create group"
|
||||
And I fill the moodle form with:
|
||||
| Group name | Group 1 |
|
||||
And I press "Save changes"
|
||||
And I press "Create group"
|
||||
And I fill the moodle form with:
|
||||
| Group name | Group 2 |
|
||||
And I press "Save changes"
|
||||
When I add "student0" user to "Group 1" group
|
||||
And I add "student1" user to "Group 1" group
|
||||
And I add "student2" user to "Group 2" group
|
||||
And I add "student3" user to "Group 2" group
|
||||
Then I select "Group 1 (2)" from "groups"
|
||||
And I wait "5" seconds
|
||||
And the "members" select box should contain "Student 0"
|
||||
And the "members" select box should contain "Student 1"
|
||||
And the "members" select box should not contain "Student 2"
|
||||
And I select "Group 2 (2)" from "groups"
|
||||
And I wait "5" seconds
|
||||
And the "members" select box should contain "Student 2"
|
||||
And the "members" select box should contain "Student 3"
|
||||
And the "members" select box should not contain "Student 0"
|
||||
And I follow "Participants"
|
||||
And I select "Group 1" from "Separate groups"
|
||||
And I should see "Student 0"
|
||||
And I should see "Student 1"
|
||||
And I should not see "Student 2"
|
||||
And I select "Group 2" from "Separate groups"
|
||||
And I should see "Student 2"
|
||||
And I should see "Student 3"
|
||||
And I should not see "Student 0"
|
||||
Reference in New Issue
Block a user