This commit is contained in:
Sara Arjona
2026-03-02 17:17:06 +01:00
2 changed files with 15 additions and 7 deletions
@@ -80,8 +80,7 @@ class course_navigation {
return $this->redirect($response, $nextcm->get_url());
}
}
return $this->page_not_found($request, $response);
return $this->redirect_to_course($response, $cm->get_course()->id);
}
/**
@@ -217,7 +216,7 @@ class course_navigation {
return $this->redirect(
$response,
new url('/course/section.php', ['id' => $section->id]),
course_get_url($modinfo->get_course(), $section, ['navigation' => true]),
);
}
@@ -266,7 +265,7 @@ class course_navigation {
): ResponseInterface {
return $this->redirect(
$response,
new url('/course/view.php', ['id' => $courseid]),
course_get_url($courseid),
);
}
}
@@ -132,7 +132,7 @@ final class course_navigation_test extends route_testcase {
'id' => 'cm3', // Students cannot see stealth modules in the course page.
],
];
yield 'Last activity of a course (student)' => [
yield 'Last activity of a section (student)' => [
'cmsdef' => [
['name' => 'cm1'],
['name' => 'cm2', 'options' => ['visible' => false]],
@@ -143,6 +143,15 @@ final class course_navigation_test extends route_testcase {
'id' => '1',
],
];
yield 'Last activity of a course (student)' => [
'cmsdef' => [
['name' => 'cm1', 'options' => ['section' => 2]],
],
'current' => 'cm1',
'expected' => [
'type' => 'course',
],
];
yield 'With next module being a subsection (student)' => [
'cmsdef' => [
['name' => 'cm1', 'options' => ['section' => 2]],
@@ -628,13 +637,13 @@ final class course_navigation_test extends route_testcase {
case 'section':
$sectioninfo = $coursemodinfo->get_section_info($elementid);
$this->assertEquals(
new url('/course/section.php', ['id' => $sectioninfo->id]),
course_get_url($courseid, $sectioninfo, ['navigation' => true]),
new url($location)
);
break;
case 'course':
$this->assertEquals(
new url('/course/view.php', ['id' => $courseid]),
course_get_url($courseid),
new url($location)
);
break;