Merge branch 'MDL-78775-402' of https://github.com/ilyatregubov/moodle into MOODLE_402_STABLE

This commit is contained in:
Huong Nguyen
2023-10-17 10:47:41 +07:00
7 changed files with 98 additions and 8 deletions
+13
View File
@@ -1051,6 +1051,12 @@ class grade_plugin_return {
* @var int
*/
public $page;
/**
* Search string
*
* @var string
*/
public $search;
/**
* Constructor
@@ -1064,6 +1070,7 @@ class grade_plugin_return {
$this->userid = optional_param('gpr_userid', null, PARAM_INT);
$this->groupid = optional_param('gpr_groupid', null, PARAM_INT);
$this->page = optional_param('gpr_page', null, PARAM_INT);
$this->search = optional_param('gpr_search', '', PARAM_NOTAGS);
foreach ($params as $key => $value) {
if (property_exists($this, $key)) {
@@ -1217,6 +1224,12 @@ class grade_plugin_return {
if (!empty($this->page)) {
$result .= '<input type="hidden" name="gpr_page" value="'.$this->page.'" />';
}
if (!empty($this->search)) {
$result .= html_writer::empty_tag('input',
['type' => 'hidden', 'name' => 'gpr_search', 'value' => $this->search]);
}
return $result;
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -224,7 +224,7 @@ export default class UserSearch extends GradebookSearchClass {
selectAllResultsLink() {
return Url.relativeUrl('/grade/report/grader/index.php', {
id: courseID,
searchvalue: this.getSearchTerm()
gpr_search: this.getSearchTerm()
}, false);
}
@@ -237,8 +237,8 @@ export default class UserSearch extends GradebookSearchClass {
selectOneLink(userID) {
return Url.relativeUrl('/grade/report/grader/index.php', {
id: courseID,
searchvalue: this.getSearchTerm(),
userid: userID,
gpr_search: this.getSearchTerm(),
gpr_userid: userID,
}, false);
}
@@ -40,7 +40,7 @@ class action_bar extends \core_grades\output\action_bar {
public function __construct(\context_course $context) {
parent::__construct($context);
$this->usersearch = optional_param('searchvalue', '', PARAM_NOTAGS);
$this->usersearch = optional_param('gpr_search', '', PARAM_NOTAGS);
}
/**
@@ -340,3 +340,80 @@ Feature: Within the grader report, test that we can search for users
# One of the users' phone numbers also matches.
And I wait until "View all results (2)" "link" exists
Then "Student s42" "list_item" should exist in the ".user-search" "css_element"
Scenario: As a teacher I save grades using search and pagination
Given "42" "users" exist with the following data:
| username | students[count] |
| firstname | Student |
| lastname | test[count] |
| email | students[count]@example.com |
And "42" "course enrolments" exist with the following data:
| user | students[count] |
| course | C1 |
| role |student |
And I reload the page
And I turn editing mode on
And the field "perpage" matches value "20"
# Search for a single user on second page and save grades.
When I set the field "Search users" to "test42"
And I wait until "View all results (1)" "link" exists
And I press the enter key
And I wait until the page is ready
And I give the grade "80.00" to the user "Student test42" for the grade item "Test assignment one"
And I press "Save changes"
And I wait until the page is ready
Then the field "Search users" matches value "test42"
And the following should exist in the "user-grades" table:
| -1- |
| Student test42 |
And I set the field "Search users" to "test4"
And I click on "Student test41" "option_role"
And I wait until the page is ready
And I give the grade "70.00" to the user "Student test41" for the grade item "Test assignment one"
And I press "Save changes"
And I wait until the page is ready
Then the field "Search users" matches value "test4"
And the following should exist in the "user-grades" table:
| -1- |
| Student test41 |
And the following should exist in the "user-grades" table:
| -1- |
| Student test42 |
And I click on "Clear" "link" in the ".user-search" "css_element"
And I wait until the page is ready
And the following should not exist in the "user-grades" table:
| -1- |
| Student test42 |
And I click on "2" "link" in the ".stickyfooter .pagination" "css_element"
And I wait until the page is ready
And the following should exist in the "user-grades" table:
| -1- |
| Student test41 |
| Student test42 |
# Set grade for a single user on second page without search and save grades.
And I give the grade "70.00" to the user "Student test41" for the grade item "Test assignment one"
And I press "Save changes"
And I wait until the page is ready
# We are still on second page.
And the following should exist in the "user-grades" table:
| -1- |
| Student test41 |
| Student test42 |
# Search for multiple users on second page and save grades.
And I set the field "Search users" to "test4"
And I wait until "View all results (4)" "link" exists
And I press the enter key
And I wait until the page is ready
And I give the grade "10.00" to the user "Student test42" for the grade item "Test assignment one"
And I give the grade "20.00" to the user "Student test40" for the grade item "Test assignment one"
And I give the grade "30.00" to the user "Student test41" for the grade item "Test assignment one"
And I give the grade "40.00" to the user "Student test4" for the grade item "Test assignment one"
And I press "Save changes"
And I wait until the page is ready
Then the field "Search users" matches value "test4"
And the following should exist in the "user-grades" table:
| -1- |
| Student test4 |
| Student test40 |
| Student test41 |
| Student test42 |
+2 -2
View File
@@ -214,8 +214,8 @@ abstract class grade_report {
// init gtree in child class
// Set any url params.
$this->usersearch = optional_param('searchvalue', '', PARAM_NOTAGS);
$this->userid = optional_param('userid', -1, PARAM_INT);
$this->usersearch = optional_param('gpr_search', '', PARAM_NOTAGS);
$this->userid = optional_param('gpr_userid', -1, PARAM_INT);
}
/**