Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-43332 core_grades: automated basic grade viewing functionality pe…

…rformed in MDLQA-317
  • Loading branch information...
commit 0deddeed2ff7598a30e895fbbaf0464bb9d45a14 1 parent 0e088ae
@markn86 markn86 authored
View
49 grade/tests/behat/behat_grade.php
@@ -0,0 +1,49 @@
+<?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;
+
+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 fill in "' . $this->escape($fieldstr) . '" with "' . $grade . '"');
+ }
+}
View
55 grade/tests/behat/grade_view.feature
@@ -0,0 +1,55 @@
+@core @core_grades
+Feature: Viewing the gradebook
+ In order to check the expected results are displayed
+ As a teacher
+ I need to assign grades and check that they display correctly in the gradebook.
+
+ @javascript
+ Scenario: Grade a grade item and ensure the results display correctly in the gradebook
+ Given the following "courses" exists:
+ | fullname | shortname | format |
+ | Course 1 | C1 | topics |
+ And the following "users" exists:
+ | username | firstname | lastname | email |
+ | teacher1 | Teacher | 1 | teacher1@asd.com |
+ | student1 | Student | 1 | student1@asd.com |
+ And the following "course enrolments" exists:
+ | user | course | role |
+ | teacher1 | C1 | editingteacher |
+ | student1 | C1 | student |
+ And I log in as "teacher1"
+ And I follow "Course 1"
+ And I turn editing mode on
+ And I add a "Assignment" to section "1" and I fill the form with:
+ | Assignment name | Test assignment name |
+ | Description | Submit your online text |
+ | assignsubmission_onlinetext_enabled | 1 |
+ And I log out
+ And I log in as "student1"
+ And I follow "Course 1"
+ And I follow "Test assignment name"
+ When I press "Add submission"
+ And I fill the moodle form with:
+ | Online text | This is a submission |
+ And I press "Save changes"
+ Then I should see "Submitted for grading"
+ And I log out
+ And I log in as "teacher1"
+ And I follow "Course 1"
+ And I follow "Grades"
+ And I turn editing mode on
+ And I give the grade "80.00" to the user "Student 1" for the grade item "Test assignment name"
+ And I press "Update"
+ And I select "User report" from "Grade report"
+ And the "Grade report" select box should contain "Grader report"
+ And the "Grade report" select box should contain "Outcomes report"
+ And the "Grade report" select box should contain "User report"
+ And the "Select all or one user" select box should contain "All users (1)"
+ And I log out
+ And I log in as "student1"
+ And I follow "Course 1"
+ And I follow "Grades"
+ And I should see "80.00" in the "Test assignment name" "table_row"
+ And I select "Overview report" from "Grade report"
+ And I should see "80.00" in the "overview-grade" "table"
+
Please sign in to comment.
Something went wrong with that request. Please try again.