Skip to content

WR498018 Fix grade performance - #119

Open
SimonThornett wants to merge 1 commit into
MOODLE_405_STABLEfrom
WR498018-fix-grade-performance
Open

SimonThornett wants to merge 1 commit into
MOODLE_405_STABLEfrom
WR498018-fix-grade-performance

Conversation

@SimonThornett

Copy link
Copy Markdown

Fixes #118

I've made the following changes in mod/subcourse/locallib.php:

  • New helper subcourse_get_gradeable_userids():

    • When user IDs are passed: it checks each one with has_capability('mod/subcourse:begraded', $context, $userid, false), so the admin override is ignored as before. Duplicates, zero or negative IDs and the guest user are skipped, and deleted users fail the check. This is the path the event observers and lib.php:465 use, so a single-user event no longer loads the course roster.
    • When no user IDs are passed: one query using get_with_capability_join(), returning user IDs only and no longer sorting by lastname.
  • Grades are now loaded in one batch with grade_grade::fetch_users_grades(), instead of one query per user. How each grade is worked out hasn't changed.

Tests: I added test_subcourse_fetch_refgrades_requested_users to the existing tests/locallib_test.php. It covers passing a single user, users without the capability, the admin and guest users, invalid IDs, a user with no grade, and fetching everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant