Skip to content

Commit

Permalink
MDL-80744 core_grades: Fix grade reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Jun 13, 2024
1 parent 40c8392 commit 96e8bf3
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 145 deletions.
4 changes: 2 additions & 2 deletions grade/report/grader/amd/build/user.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion grade/report/grader/amd/build/user.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 17 additions & 13 deletions grade/report/grader/amd/src/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import UserSearch from 'core_user/comboboxsearch/user';
import Url from 'core/url';
import * as Repository from 'gradereport_grader/local/user/repository';

// Define our standard lookups.
Expand All @@ -34,12 +33,17 @@ const courseID = component.querySelector(selectors.courseid).dataset.courseid;

export default class User extends UserSearch {

constructor() {
/**
* Construct the class.
* @param {string} baseUrl The base URL for the page.
*/
constructor(baseUrl) {
super();
this.baseUrl = baseUrl;
}

static init() {
return new User();
static init(baseUrl) {
return new User(baseUrl);
}

/**
Expand All @@ -57,10 +61,10 @@ export default class User extends UserSearch {
* @returns {string|*}
*/
selectAllResultsLink() {
return Url.relativeUrl('/grade/report/grader/index.php', {
id: courseID,
gpr_search: this.getSearchTerm()
}, false);
const url = new URL(this.baseUrl);
url.searchParams.set('id', this.courseID);
url.searchParams.set('gpr_search', this.getSearchTerm());
return url.toString();
}

/**
Expand All @@ -70,10 +74,10 @@ export default class User extends UserSearch {
* @returns {string|*}
*/
selectOneLink(userID) {
return Url.relativeUrl('/grade/report/grader/index.php', {
id: courseID,
gpr_search: this.getSearchTerm(),
gpr_userid: userID,
}, false);
const url = new URL(this.baseUrl);
url.searchParams.set('id', this.courseID);
url.searchParams.set('gpr_search', this.getSearchTerm());
url.searchParams.set('gpr_userid', userID);
return url.toString();
}
}
27 changes: 3 additions & 24 deletions grade/report/grader/classes/output/action_bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,9 @@ public function export_for_template(\renderer_base $output): array {
}

$resetlink = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]);
$searchinput = $OUTPUT->render_from_template('core_user/comboboxsearch/user_selector', [
'currentvalue' => $this->usersearch,
'courseid' => $courseid,
'instance' => rand(),
'resetlink' => $resetlink->out(false),
'group' => 0,
'name' => 'usersearch',
'value' => json_encode([
'userid' => $this->userid,
'search' => $this->usersearch,
]),
]);
$searchdropdown = new comboboxsearch(
true,
$searchinput,
null,
'user-search d-flex',
null,
'usersearchdropdown overflow-auto',
null,
false,
);
$data['searchdropdown'] = $searchdropdown->export_for_template($output);

// Why groupid = 0
$userselectorrenderer = new \core_course\output\actionbar\user_selector($course, $resetlink, $this->userid, 0, $this->usersearch);
$data['searchdropdown'] = $userselectorrenderer->export_for_template($output);
// The collapsed column dialog is aligned to the edge of the screen, we need to place it such that it also aligns.
$collapsemenudirection = right_to_left() ? 'dropdown-menu-left' : 'dropdown-menu-right';

Expand Down
4 changes: 2 additions & 2 deletions grade/report/grader/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
$graderreportsilast = optional_param('silast', null, PARAM_NOTAGS);

$studentsperpage = optional_param('perpage', null, PARAM_INT);
$baseurl = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]);

$PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
$PAGE->set_pagelayout('report');
$PAGE->requires->js_call_amd('gradereport_grader/stickycolspan', 'init');
$PAGE->requires->js_call_amd('gradereport_grader/user', 'init');
$PAGE->requires->js_call_amd('gradereport_grader/user', 'init', [$baseurl->out(false)]);
$PAGE->requires->js_call_amd('gradereport_grader/feedback_modal', 'init');
$PAGE->requires->js_call_amd('core_grades/gradebooksetup_forms', 'init');

Expand All @@ -60,7 +61,6 @@

// Conditionally add the group JS if we have groups enabled.
if ($course->groupmode) {
$baseurl = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]);
$PAGE->requires->js_call_amd('core_course/actionbar/group', 'init', [$baseurl->out(false)]);
}

Expand Down
2 changes: 1 addition & 1 deletion grade/report/singleview/amd/build/grade.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 96e8bf3

Please sign in to comment.