mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-38805_master' of git://github.com/dmonllao/moodle
This commit is contained in:
commit
23726a43d4
100
completion/tests/behat/behat_completion.php
Normal file
100
completion/tests/behat/behat_completion.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Completion steps definitions.
|
||||
*
|
||||
* @package core_completion
|
||||
* @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\Behat\Context\Step\Given as Given,
|
||||
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
|
||||
/**
|
||||
* Steps definitions to deal with course and activities completion.
|
||||
*
|
||||
* @package core_completion
|
||||
* @category test
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_completion extends behat_base {
|
||||
|
||||
/**
|
||||
* Checks that the specified user has completed the specified activity of the current course.
|
||||
*
|
||||
* @Then /^"(?P<user_fullname_string>(?:[^"]|\\")*)" user has completed "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
||||
* @param string $userfullname
|
||||
* @param string $activityname
|
||||
*/
|
||||
public function user_has_completed_activity($userfullname, $activityname) {
|
||||
|
||||
// Will throw an exception if the element can not be hovered.
|
||||
$xpath = "//table[@id='completion-progress']/descendant::img[contains(@title, '" . $userfullname . ", " . $activityname . ": Completed')]";
|
||||
|
||||
return array(
|
||||
new Given('I go to the current course activity completion report'),
|
||||
new Given('I hover "' . $xpath . '" "xpath_element"')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the specified user has not completed the specified activity of the current course.
|
||||
*
|
||||
* @Then /^"(?P<user_fullname_string>(?:[^"]|\\")*)" user has not completed "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
||||
* @param string $userfullname
|
||||
* @param string $activityname
|
||||
*/
|
||||
public function user_has_not_completed_activity($userfullname, $activityname) {
|
||||
|
||||
$xpath = "//table[@id='completion-progress']/descendant::img[contains(@title, '" . $userfullname . ", " . $activityname . ": Not completed')]";
|
||||
return array(
|
||||
new Given('I go to the current course activity completion report'),
|
||||
new Given('I hover "' . $xpath . '" "xpath_element"')
|
||||
);
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes to the current course activity completion report.
|
||||
*
|
||||
* @Given /^I go to the current course activity completion report$/
|
||||
*/
|
||||
public function go_to_the_current_course_activity_completion_report() {
|
||||
|
||||
$steps = array();
|
||||
|
||||
// Expand reports node if we can't see the link.
|
||||
try {
|
||||
$this->find('xpath', "//*[@id='settingsnav']/descendant::li/descendant::li[not(contains(@class,'collapsed'))]/descendant::p[contains(., 'Activity completion')]");
|
||||
} catch (ElementNotFoundException $e) {
|
||||
$steps[] = new Given('I expand "Reports" node');
|
||||
}
|
||||
|
||||
$steps[] = new Given('I follow "Activity completion"');
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
}
|
47
completion/tests/behat/enable_manual_complete_mark.feature
Normal file
47
completion/tests/behat/enable_manual_complete_mark.feature
Normal file
@ -0,0 +1,47 @@
|
||||
@core_completion
|
||||
Feature: Allow students to manually mark an activity as complete
|
||||
In order to let students decide when an activity is completed
|
||||
As a moodle teacher
|
||||
I need to allow students to mark activities as completed
|
||||
|
||||
@javascript
|
||||
Scenario: Mark an activity as completed
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | Frist | teacher1@asd.com |
|
||||
| student1 | Student | First | student1@asd.com |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "admin"
|
||||
And I set the following administration settings values:
|
||||
| Enable completion tracking | 1 |
|
||||
| Enable conditional access | 1 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I follow "Edit settings"
|
||||
And I fill the moodle form with:
|
||||
| Completion tracking | Enabled, control via completion and activity settings |
|
||||
| Completion tracking begins on enrolment | 1 |
|
||||
And I press "Save changes"
|
||||
When I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
Then "Student First" user has not completed "Test forum name" activity
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I press "Mark as complete: Test forum name"
|
||||
And I wait "3" seconds
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I expand "Reports" node
|
||||
And I follow "Activity completion"
|
||||
And "Student First" user has completed "Test forum name" activity
|
@ -53,7 +53,6 @@ class behat_field_manager {
|
||||
* @return behat_form_field
|
||||
*/
|
||||
public static function get_field(NodeElement $fieldnode, $locator, Session $session) {
|
||||
global $CFG;
|
||||
|
||||
// Get the field type if is part of a moodleform.
|
||||
if (self::is_moodleform_field($fieldnode)) {
|
||||
@ -65,6 +64,23 @@ class behat_field_manager {
|
||||
$type = 'field';
|
||||
}
|
||||
|
||||
return self::get_field_instance($type, $fieldnode, $session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the appropiate behat_form_field according to the provided type.
|
||||
*
|
||||
* It defaults to behat_form_field.
|
||||
*
|
||||
* @param string $type The field type (checkbox, date_selector, text...)
|
||||
* @param NodeElement $fieldnode
|
||||
* @param Session $session The behat session
|
||||
* @return behat_form_field
|
||||
*/
|
||||
public static function get_field_instance($type, NodeElement $fieldnode, Session $session) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$classname = 'behat_form_' . $type;
|
||||
|
||||
// Fallsback on the default form field if nothing specific exists.
|
||||
|
Loading…
x
Reference in New Issue
Block a user