mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
MDL-78775 core_grades: Fix saving on grader report page
When we have a pagination on grader page and search for user that is not on first page, saving was throwing an error since page didn't have enough data
This commit is contained in:
parent
769c67045f
commit
9048eb1e53
@ -1038,6 +1038,12 @@ class grade_plugin_return {
|
||||
* @var int
|
||||
*/
|
||||
public $page;
|
||||
/**
|
||||
* Search string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $search;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -1051,6 +1057,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)) {
|
||||
@ -1204,6 +1211,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;
|
||||
}
|
||||
|
||||
|
2
grade/report/grader/amd/build/user.min.js
vendored
2
grade/report/grader/amd/build/user.min.js
vendored
@ -5,6 +5,6 @@ define("gradereport_grader/user",["exports","core_user/comboboxsearch/user","cor
|
||||
* @module gradereport_grader/user
|
||||
* @copyright 2023 Mathew May <mathew.solutions>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_user=_interopRequireDefault(_user),_url=_interopRequireDefault(_url),Repository=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Repository);const selectors_component=".user-search",selectors_courseid='[data-region="courseid"]',courseID=document.querySelector(selectors_component).querySelector(selectors_courseid).dataset.courseid;class User extends _user.default{constructor(){super()}static init(){return new User}fetchDataset(){return Repository.userFetch(courseID).then((r=>r.users))}selectAllResultsLink(){return _url.default.relativeUrl("/grade/report/grader/index.php",{id:courseID,searchvalue:this.getSearchTerm()},!1)}selectOneLink(userID){return _url.default.relativeUrl("/grade/report/grader/index.php",{id:courseID,searchvalue:this.getSearchTerm(),userid:userID},!1)}}return _exports.default=User,_exports.default}));
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_user=_interopRequireDefault(_user),_url=_interopRequireDefault(_url),Repository=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Repository);const selectors_component=".user-search",selectors_courseid='[data-region="courseid"]',courseID=document.querySelector(selectors_component).querySelector(selectors_courseid).dataset.courseid;class User extends _user.default{constructor(){super()}static init(){return new User}fetchDataset(){return Repository.userFetch(courseID).then((r=>r.users))}selectAllResultsLink(){return _url.default.relativeUrl("/grade/report/grader/index.php",{id:courseID,gpr_search:this.getSearchTerm()},!1)}selectOneLink(userID){return _url.default.relativeUrl("/grade/report/grader/index.php",{id:courseID,gpr_search:this.getSearchTerm(),gpr_userid:userID},!1)}}return _exports.default=User,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=user.min.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"user.min.js","sources":["../src/user.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Allow the user to search for learners within the grader report.\n *\n * @module gradereport_grader/user\n * @copyright 2023 Mathew May <mathew.solutions>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport UserSearch from 'core_user/comboboxsearch/user';\nimport Url from 'core/url';\nimport * as Repository from 'gradereport_grader/local/user/repository';\n\n// Define our standard lookups.\nconst selectors = {\n component: '.user-search',\n courseid: '[data-region=\"courseid\"]',\n};\nconst component = document.querySelector(selectors.component);\nconst courseID = component.querySelector(selectors.courseid).dataset.courseid;\n\nexport default class User extends UserSearch {\n\n constructor() {\n super();\n }\n\n static init() {\n return new User();\n }\n\n /**\n * Get the data we will be searching against in this component.\n *\n * @returns {Promise<*>}\n */\n fetchDataset() {\n return Repository.userFetch(courseID).then((r) => r.users);\n }\n\n /**\n * Build up the view all link.\n *\n * @returns {string|*}\n */\n selectAllResultsLink() {\n return Url.relativeUrl('/grade/report/grader/index.php', {\n id: courseID,\n searchvalue: this.getSearchTerm()\n }, false);\n }\n\n /**\n * Build up the view all link that is dedicated to a particular result.\n *\n * @param {Number} userID The ID of the user selected.\n * @returns {string|*}\n */\n selectOneLink(userID) {\n return Url.relativeUrl('/grade/report/grader/index.php', {\n id: courseID,\n searchvalue: this.getSearchTerm(),\n userid: userID,\n }, false);\n }\n}\n"],"names":["selectors","courseID","document","querySelector","dataset","courseid","User","UserSearch","constructor","fetchDataset","Repository","userFetch","then","r","users","selectAllResultsLink","Url","relativeUrl","id","searchvalue","this","getSearchTerm","selectOneLink","userID","userid"],"mappings":";;;;;;;q0BA2BMA,oBACS,eADTA,mBAEQ,2BAGRC,SADYC,SAASC,cAAcH,qBACdG,cAAcH,oBAAoBI,QAAQC,eAEhDC,aAAaC,cAE9BC,2CAKW,IAAIF,KAQfG,sBACWC,WAAWC,UAAUV,UAAUW,MAAMC,GAAMA,EAAEC,QAQxDC,8BACWC,aAAIC,YAAY,iCAAkC,CACrDC,GAAIjB,SACJkB,YAAaC,KAAKC,kBACnB,GASPC,cAAcC,eACHP,aAAIC,YAAY,iCAAkC,CACrDC,GAAIjB,SACJkB,YAAaC,KAAKC,gBAClBG,OAAQD,SACT"}
|
||||
{"version":3,"file":"user.min.js","sources":["../src/user.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Allow the user to search for learners within the grader report.\n *\n * @module gradereport_grader/user\n * @copyright 2023 Mathew May <mathew.solutions>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport UserSearch from 'core_user/comboboxsearch/user';\nimport Url from 'core/url';\nimport * as Repository from 'gradereport_grader/local/user/repository';\n\n// Define our standard lookups.\nconst selectors = {\n component: '.user-search',\n courseid: '[data-region=\"courseid\"]',\n};\nconst component = document.querySelector(selectors.component);\nconst courseID = component.querySelector(selectors.courseid).dataset.courseid;\n\nexport default class User extends UserSearch {\n\n constructor() {\n super();\n }\n\n static init() {\n return new User();\n }\n\n /**\n * Get the data we will be searching against in this component.\n *\n * @returns {Promise<*>}\n */\n fetchDataset() {\n return Repository.userFetch(courseID).then((r) => r.users);\n }\n\n /**\n * Build up the view all link.\n *\n * @returns {string|*}\n */\n selectAllResultsLink() {\n return Url.relativeUrl('/grade/report/grader/index.php', {\n id: courseID,\n gpr_search: this.getSearchTerm()\n }, false);\n }\n\n /**\n * Build up the view all link that is dedicated to a particular result.\n *\n * @param {Number} userID The ID of the user selected.\n * @returns {string|*}\n */\n selectOneLink(userID) {\n return Url.relativeUrl('/grade/report/grader/index.php', {\n id: courseID,\n gpr_search: this.getSearchTerm(),\n gpr_userid: userID,\n }, false);\n }\n}\n"],"names":["selectors","courseID","document","querySelector","dataset","courseid","User","UserSearch","constructor","fetchDataset","Repository","userFetch","then","r","users","selectAllResultsLink","Url","relativeUrl","id","gpr_search","this","getSearchTerm","selectOneLink","userID","gpr_userid"],"mappings":";;;;;;;q0BA2BMA,oBACS,eADTA,mBAEQ,2BAGRC,SADYC,SAASC,cAAcH,qBACdG,cAAcH,oBAAoBI,QAAQC,eAEhDC,aAAaC,cAE9BC,2CAKW,IAAIF,KAQfG,sBACWC,WAAWC,UAAUV,UAAUW,MAAMC,GAAMA,EAAEC,QAQxDC,8BACWC,aAAIC,YAAY,iCAAkC,CACrDC,GAAIjB,SACJkB,WAAYC,KAAKC,kBAClB,GASPC,cAAcC,eACHP,aAAIC,YAAY,iCAAkC,CACrDC,GAAIjB,SACJkB,WAAYC,KAAKC,gBACjBG,WAAYD,SACb"}
|
@ -59,7 +59,7 @@ export default class User extends UserSearch {
|
||||
selectAllResultsLink() {
|
||||
return Url.relativeUrl('/grade/report/grader/index.php', {
|
||||
id: courseID,
|
||||
searchvalue: this.getSearchTerm()
|
||||
gpr_search: this.getSearchTerm()
|
||||
}, false);
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ export default class User extends UserSearch {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,3 +358,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 I confirm "Student s42" in "user" search within the gradebook widget exists
|
||||
|
||||
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 |
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user