Skip to content

Commit

Permalink
MDL-83617 gradereport_grader: fix encoding url
Browse files Browse the repository at this point in the history
When changing the number of grades per page, the redirect url was encoded twice.
  • Loading branch information
jboulen committed Nov 1, 2024
1 parent d015c4c commit ec34d2f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion grade/report/grader/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
}

$perpagedata = [
'baseurl' => new moodle_url('/grade/report/grader/index.php', ['id' => s($courseid), 'report' => 'grader']),
'baseurl' => (new moodle_url('/grade/report/grader/index.php', ['id' => s($courseid), 'report' => 'grader']))->out(false),
'options' => []
];
foreach ($pagingoptions as $key => $name) {
Expand Down
2 changes: 1 addition & 1 deletion grade/report/grader/templates/perpage.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</label>
{{#js}}
document.getElementById('{{uniqid}}').addEventListener('change', function(e) {
var url = new URL('{{baseurl}}');
var url = new URL('{{{baseurl}}}');
url.searchParams.set('perpage', e.target.value);
window.location.href = url;
Expand Down
1 change: 1 addition & 0 deletions grade/report/grader/tests/behat/pagination.feature
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Feature: grader report pagination
Then I should see "103" node occurrences of type "tr" in the "user-grades" "table"
And I should see "2" in the ".stickyfooter .pagination" "css_element"
And I should not see "3" in the ".stickyfooter .pagination" "css_element"
And the url should match "/grade/report/grader/index\.php\?id=[0-9]+&report=grader&perpage=100$"

@javascript
Scenario: The pagination bar is only displayed when there is more than one page
Expand Down
19 changes: 19 additions & 0 deletions lib/tests/behat/behat_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ public function i_am_on_course_index() {
$this->execute('behat_general::i_visit', ['/course/index.php']);
}

/**
* Checks, that current page PATH matches regular expression
*
* Example: Then the url should match "/course/index\.php"
* Example: Then the url should match "/mod/forum/view\.php\?id=[0-9]+"
* Example: And the url should match "^http://moodle\.org"
*
* @Then /^the url should match (?P<pattern>"(?:[^"]|\\")*")$/
*/
public function the_url_should_match($pattern) {
$url = $this->getSession()->getCurrentUrl();

if (preg_match($pattern, $url) === 1) {
return;
}

throw new ExpectationException(sprintf('The url "%s" should match with %s', $url, $pattern), $this->getSession());
}

/**
* Reloads the current page.
*
Expand Down

0 comments on commit ec34d2f

Please sign in to comment.