Skip to content
Snippets Groups Projects
Commit 14a70b44 authored by David Siegfried's avatar David Siegfried Committed by Jan-Hendrik Willms
Browse files

fixes #3949

Closes #3949

Merge request studip/studip!2806
parent cfd7d78c
No related branches found
No related tags found
No related merge requests found
...@@ -52,22 +52,20 @@ class Course_CoursewareController extends CoursewareController ...@@ -52,22 +52,20 @@ class Course_CoursewareController extends CoursewareController
public function courseware_action($unit_id = null): void public function courseware_action($unit_id = null): void
{ {
global $user;
Navigation::activateItem('course/courseware/unit'); Navigation::activateItem('course/courseware/unit');
if ($this->unitsNotFound) { if ($this->unitsNotFound) {
PageLayout::postMessage(MessageBox::info(_('Es wurde kein Lernmaterial gefunden.'))); PageLayout::postMessage(MessageBox::info(_('Es wurde kein Lernmaterial gefunden.')));
return; return;
} }
$user = User::findCurrent();
$this->setCoursewareSidebar(); $this->setCoursewareSidebar();
$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($user->id)->getValue('COURSEWARE_LAST_ELEMENT');
$lastStructuralElement = \Courseware\StructuralElement::findOneById($last); $lastStructuralElement = \Courseware\StructuralElement::findOneById($last);
if ($unit_id === null) { if ($unit_id === null) {
if (isset($lastStructuralElement) && $lastStructuralElement->canVisit(User::findCurrent())) { if (isset($lastStructuralElement) && $lastStructuralElement->canVisit($user)) {
$this->redirectToFirstUnit('course', Context::getId(), $last); $this->redirectToFirstUnit('course', Context::getId(), $last);
} else { } else {
$this->redirectToFirstUnit('course', Context::getId(), []); $this->redirectToFirstUnit('course', Context::getId(), []);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment