mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
72 lines
3.1 KiB
PHP
72 lines
3.1 KiB
PHP
<?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 grade related steps definitions.
|
|
*
|
|
* @package core_grades
|
|
* @category test
|
|
* @copyright 2014 Mark Nelson <markn@moodle.com>
|
|
* @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\Gherkin\Node\TableNode as TableNode;
|
|
|
|
class behat_grade extends behat_base {
|
|
|
|
/**
|
|
* Enters a grade via the gradebook for a specific grade item and user when viewing the 'Grader report' with editing mode turned on.
|
|
*
|
|
* @Given /^I give the grade "(?P<grade_number>(?:[^"]|\\")*)" to the user "(?P<username_string>(?:[^"]|\\")*)" for the grade item "(?P<grade_activity_string>(?:[^"]|\\")*)"$/
|
|
* @param int $grade
|
|
* @param string $userfullname the user's fullname as returned by fullname()
|
|
* @param string $itemname
|
|
* @return Given
|
|
*/
|
|
public function i_give_the_grade($grade, $userfullname, $itemname) {
|
|
$gradelabel = $userfullname . ' ' . $itemname;
|
|
$fieldstr = get_string('useractivitygrade', 'gradereport_grader', $gradelabel);
|
|
|
|
return new Given('I set the field "' . $this->escape($fieldstr) . '" to "' . $grade . '"');
|
|
}
|
|
|
|
/**
|
|
* Changes the settings of a grade item or category or the course.
|
|
*
|
|
* Teacher must be either on the grade setup page or on the Grader report page with editing mode turned on.
|
|
*
|
|
* @Given /^I set the following settings for grade item "(?P<grade_item_string>(?:[^"]|\\")*)":$/
|
|
* @param string $gradeitem
|
|
* @param TableNode $data
|
|
* @return Given[]
|
|
*/
|
|
public function i_set_the_following_settings_for_grade_item($gradeitem, TableNode $data) {
|
|
$savechanges = get_string('savechanges', 'grades');
|
|
$edit = $this->getSession()->getSelectorsHandler()->xpathLiteral(get_string('edit') . ' ');
|
|
$gradeitem = $this->getSession()->getSelectorsHandler()->xpathLiteral($gradeitem);
|
|
$linkxpath = "//a[./img[starts-with(@title,$edit) and contains(@title,$gradeitem)]]";
|
|
return array(
|
|
new Given('I click on "' . $this->escape($linkxpath) . '" "xpath_element"'),
|
|
new Given('I set the following fields to these values:', $data),
|
|
new Given('I press "' . $this->escape($savechanges) . '"'),
|
|
);
|
|
}
|
|
}
|