MDL-82525 user: correct course parameter for course profile page.

This commit is contained in:
Paul Holden 2024-07-18 08:49:42 +01:00
parent d8a1a67fd7
commit fd63451ecc
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
2 changed files with 3 additions and 3 deletions

View File

@ -1417,11 +1417,11 @@ class core_user {
// Get courseid from context if provided.
if ($context && $coursecontext = $context->get_course_context(false)) {
$params['courseid'] = $coursecontext->instanceid;
$params['course'] = $coursecontext->instanceid;
}
// If courseid is not set or is set to site id, then return profile page, otherwise return view page.
if (!isset($params['courseid']) || $params['courseid'] == SITEID) {
if (!isset($params['course']) || $params['course'] == SITEID) {
return new moodle_url('/user/profile.php', $params);
} else {
return new moodle_url('/user/view.php', $params);

View File

@ -892,7 +892,7 @@ class user_test extends \advanced_testcase {
// Display profile url at course context.
$course = $this->getDataGenerator()->create_course();
$coursecontext = \context_course::instance($course->id);
$this->assertEquals("https://www.example.com/moodle/user/view.php?id={$user->id}&courseid={$course->id}",
$this->assertEquals("https://www.example.com/moodle/user/view.php?id={$user->id}&course={$course->id}",
\core_user::get_profile_url($user, $coursecontext));
// Throw error if userid is invalid.