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
public function courseware_action($unit_id = null): void
{
global $user;
Navigation::activateItem('course/courseware/unit');
if ($this->unitsNotFound) {
PageLayout::postMessage(MessageBox::info(_('Es wurde kein Lernmaterial gefunden.')));
return;
}
$user = User::findCurrent();
$this->setCoursewareSidebar();
$this->user_id = $user->id;
/** @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);
if ($unit_id === null) {
if (isset($lastStructuralElement) && $lastStructuralElement->canVisit(User::findCurrent())) {
if (isset($lastStructuralElement) && $lastStructuralElement->canVisit($user)) {
$this->redirectToFirstUnit('course', Context::getId(), $last);
} else {
$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