MDL-47059 Grades: Update the grade_grade if the finalgrade/or the grademax has changed.
[moodle.git] / grade / tests / behat / behat_grade.php
... / ...
CommitLineData
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Behat grade related steps definitions.
19 *
20 * @package core_grades
21 * @category test
22 * @copyright 2014 Mark Nelson <markn@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
27
28require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
29
30use Behat\Behat\Context\Step\Given as Given;
31
32class behat_grade extends behat_base {
33
34 /**
35 * Enters a grade via the gradebook for a specific grade item and user when viewing the 'Grader report' with editing mode turned on.
36 *
37 * @Given /^I give the grade "(?P<grade_number>(?:[^"]|\\")*)" to the user "(?P<username_string>(?:[^"]|\\")*)" for the grade item "(?P<grade_activity_string>(?:[^"]|\\")*)"$/
38 * @param int $grade
39 * @param string $userfullname the user's fullname as returned by fullname()
40 * @param string $itemname
41 * @return Given
42 */
43 public function i_give_the_grade($grade, $userfullname, $itemname) {
44 $gradelabel = $userfullname . ' ' . $itemname;
45 $fieldstr = get_string('useractivitygrade', 'gradereport_grader', $gradelabel);
46
47 return new Given('I set the field "' . $this->escape($fieldstr) . '" to "' . $grade . '"');
48 }
49}