Skip to content

Fix Moodle 5.1+ compatibility for course request form#3076

Open
weilai-irl wants to merge 1 commit intoMOODLE_500_STABLEfrom
wip-125409-m500
Open

Fix Moodle 5.1+ compatibility for course request form#3076
weilai-irl wants to merge 1 commit intoMOODLE_500_STABLEfrom
wip-125409-m500

Conversation

@weilai-irl
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 27, 2026 11:51
@weilai-irl weilai-irl self-assigned this Feb 27, 2026
@weilai-irl weilai-irl added this to the 2026-01 milestone Feb 27, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Moodle 5.1+ compatibility for the course request form by adapting to the relocation of the core course request form class in Moodle 5.1. In Moodle 5.1+, the course request form was moved from course/request_form.php (class course_request_form) to course/classes/form/request_course.php (class \core_course\form\request_course). The solution uses a file-existence check and class aliasing to maintain backward compatibility with pre-5.1 Moodle versions while supporting the new structure.

Changes:

  • Implements version-agnostic compatibility using file_exists() checks to detect which Moodle version is in use
  • Uses class_alias to create a common parent class reference (parent_request_course) regardless of Moodle version
  • Updates the class inheritance to extend the aliased parent class instead of directly extending course_request_form
Comments suppressed due to low confidence (1)

local/o365/classes/form/courserequestform.php:31

  • Consider using more descriptive variable names for clarity. The current names $pathbelowmoodle51 and $pathsincemoodle51 could be improved to something like $legacypath and $modernpath, or $pathpre51 and $pathfrom51, which would be more intuitive and easier to understand at a glance.
$pathbelowmoodle51 = $CFG->dirroot . '/course/request_form.php';
$pathsincemoodle51 = $CFG->dirroot . '/course/classes/form/request_course.php';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants