Skip to content
Snippets Groups Projects
Commit feb28852 authored by Ron Lucke's avatar Ron Lucke
Browse files

fix #3437

Closes #3437

Merge request studip/studip!2464
parent 1c2d4c6a
No related branches found
No related tags found
No related merge requests found
...@@ -64,10 +64,14 @@ class Course_CoursewareController extends CoursewareController ...@@ -64,10 +64,14 @@ class Course_CoursewareController extends CoursewareController
$this->user_id = $user->id; $this->user_id = $user->id;
/** @var array<mixed> $last */ /** @var array<mixed> $last */
$last = UserConfig::get($this->user_id)->getValue('COURSEWARE_LAST_ELEMENT'); $last = UserConfig::get($this->user_id)->getValue('COURSEWARE_LAST_ELEMENT');
$lastStructuralElement = \Courseware\StructuralElement::findOneById($last);
if ($unit_id === null) { if ($unit_id === null) {
if ($lastStructuralElement->canVisit($user)) {
$this->redirectToFirstUnit('course', Context::getId(), $last); $this->redirectToFirstUnit('course', Context::getId(), $last);
} else {
$this->redirectToFirstUnit('course', Context::getId(), []);
}
return; return;
} }
...@@ -75,7 +79,12 @@ class Course_CoursewareController extends CoursewareController ...@@ -75,7 +79,12 @@ class Course_CoursewareController extends CoursewareController
$this->unit_id = null; $this->unit_id = null;
$unit = Unit::find($unit_id); $unit = Unit::find($unit_id);
if (isset($unit)) { if (isset($unit)) {
if ($lastStructuralElement->canVisit($user)) {
$this->setEntryElement('course', $unit, $last, Context::getId()); $this->setEntryElement('course', $unit, $last, Context::getId());
} else {
$rootElement = [Context::getId() => $unit->structural_element->id];
$this->setEntryElement('course', $unit, $rootElement, Context::getId());
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment