mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-78673 grade: Address random failure due to toast
This commit is contained in:
parent
e0c28bebcb
commit
7961e169b1
81
grade/tests/behat/behat_grades.php
Normal file
81
grade/tests/behat/behat_grades.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?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/>.
|
||||
|
||||
// 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');
|
||||
|
||||
/**
|
||||
* Behat grade related steps definitions.
|
||||
*
|
||||
* @package core_grades
|
||||
* @copyright 2022 Mathew May <mathew.solutions>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_grades extends behat_base {
|
||||
|
||||
/**
|
||||
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
|
||||
*
|
||||
* Recognised page names are:
|
||||
* | pagetype | name meaning | description |
|
||||
* | [report] view | Course name | The view page for the specified course and report |
|
||||
*
|
||||
* @param string $type identifies which type of page this is - for example "Grader > View"
|
||||
* @param string $identifier identifies the particular page - for example "Course name"
|
||||
* @return moodle_url the corresponding URL.
|
||||
*/
|
||||
protected function resolve_page_instance_url(string $type, string $identifier): moodle_url {
|
||||
$type = strtolower($type);
|
||||
if (strpos($type, '>') !== false) {
|
||||
[$pluginname, $type] = explode('>', $type);
|
||||
$pluginname = strtolower(trim($pluginname));
|
||||
|
||||
// Fetch the list of plugins.
|
||||
$plugins = \core_component::get_plugin_list('gradereport');
|
||||
|
||||
if (array_key_exists($pluginname, $plugins)) {
|
||||
$plugin = $pluginname;
|
||||
} else {
|
||||
$plugins = array_combine(
|
||||
array_keys($plugins),
|
||||
array_keys($plugins),
|
||||
);
|
||||
|
||||
// This plugin is not in the list of plugins. Check the pluginname string.
|
||||
$names = array_map(fn($name) => strtolower(get_string('pluginname', "gradereport_{$name}")), $plugins);
|
||||
$result = array_search($pluginname, $names);
|
||||
if ($result === false) {
|
||||
throw new \coding_exception("Unknown plugin '{$pluginname}'");
|
||||
}
|
||||
$plugin = $result;
|
||||
}
|
||||
}
|
||||
$type = trim($type);
|
||||
|
||||
switch ($type) {
|
||||
case 'view':
|
||||
return new moodle_url(
|
||||
"/grade/report/{$plugin}/index.php",
|
||||
['id' => $this->get_course_id($identifier)]
|
||||
);
|
||||
default:
|
||||
throw new \coding_exception(
|
||||
"Unknown page type '$type' for page identifier '$identifier'"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -50,15 +50,11 @@ Feature: Average grades are displayed in the gradebook
|
||||
|
||||
Scenario: Grade a grade item and ensure the results display correctly in the gradebook
|
||||
# Check the admin grade table
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
Given I am on the "Course 1" "grades > Grader report > View" page logged in as "admin"
|
||||
Then I should see "50.00" in the ".avg.r0.lastrow .c1" "css_element"
|
||||
Then I should see "50.00" in the ".avg.r0.lastrow .c2" "css_element"
|
||||
And I log out
|
||||
|
||||
# Check the user grade table
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "User report" in the course gradebook
|
||||
When I am on the "Course 1" "grades > user > View" page logged in as "student1"
|
||||
Then I should see "50.00" in the ".level2.column-grade" "css_element"
|
||||
Then I should see "50.00" in the ".level2.column-average" "css_element"
|
||||
And I log out
|
||||
|
Loading…
x
Reference in New Issue
Block a user