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

fix #2100

Closes #2100

Merge request studip/studip!1358
parent 454b905a
No related branches found
No related tags found
1 merge request!4Draft: Icon creation
...@@ -22,6 +22,8 @@ class Contents_CoursewareController extends CoursewareController ...@@ -22,6 +22,8 @@ class Contents_CoursewareController extends CoursewareController
PageLayout::setTitle(_('Courseware')); PageLayout::setTitle(_('Courseware'));
$this->user = $GLOBALS['user']; $this->user = $GLOBALS['user'];
$this->licenses = $this->getLicenses();
$this->unitsNotFound = Unit::countBySql('range_id = ?', [$this->user->id]) === 0;
} }
/** /**
...@@ -38,8 +40,6 @@ class Contents_CoursewareController extends CoursewareController ...@@ -38,8 +40,6 @@ class Contents_CoursewareController extends CoursewareController
Navigation::activateItem('/contents/courseware/shelf'); Navigation::activateItem('/contents/courseware/shelf');
$this->user_id = $GLOBALS['user']->id; $this->user_id = $GLOBALS['user']->id;
$this->setShelfSidebar(); $this->setShelfSidebar();
$this->licenses = $this->getLicenses();
} }
private function setShelfSidebar(): void private function setShelfSidebar(): void
...@@ -63,6 +63,14 @@ class Contents_CoursewareController extends CoursewareController ...@@ -63,6 +63,14 @@ class Contents_CoursewareController extends CoursewareController
{ {
global $perm, $user; global $perm, $user;
Navigation::activateItem('/contents/courseware/courseware');
if ($this->unitsNotFound) {
PageLayout::postMessage(MessageBox::info(_('Es wurde kein Lernmaterial gefunden.')));
return;
}
$this->setCoursewareSidebar();
$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');
...@@ -78,9 +86,6 @@ class Contents_CoursewareController extends CoursewareController ...@@ -78,9 +86,6 @@ class Contents_CoursewareController extends CoursewareController
$unit = Unit::find($unit_id); $unit = Unit::find($unit_id);
if (isset($unit)) { if (isset($unit)) {
$this->setEntryElement('user', $unit, $last, $this->user_id); $this->setEntryElement('user', $unit, $last, $this->user_id);
Navigation::activateItem('/contents/courseware/courseware');
$this->licenses = $this->getLicenses();
$this->setCoursewareSidebar();
} }
} }
...@@ -315,7 +320,6 @@ class Contents_CoursewareController extends CoursewareController ...@@ -315,7 +320,6 @@ class Contents_CoursewareController extends CoursewareController
$this->user_id = $struct->owner_id; $this->user_id = $struct->owner_id;
$this->licenses = $this->getLicenses();
$this->oer_enabled = Config::get()->OERCAMPUS_ENABLED && $perm->have_perm(Config::get()->OER_PUBLIC_STATUS); $this->oer_enabled = Config::get()->OERCAMPUS_ENABLED && $perm->have_perm(Config::get()->OER_PUBLIC_STATUS);
......
...@@ -30,18 +30,25 @@ class Course_CoursewareController extends CoursewareController ...@@ -30,18 +30,25 @@ class Course_CoursewareController extends CoursewareController
$this->studip_module = checkObjectModule('CoursewareModule', true); $this->studip_module = checkObjectModule('CoursewareModule', true);
object_set_visit_module($this->studip_module->getPluginId()); object_set_visit_module($this->studip_module->getPluginId());
$this->last_visitdate = object_get_visit(Context::getId(), $this->studip_module->getPluginId()); $this->last_visitdate = object_get_visit(Context::getId(), $this->studip_module->getPluginId());
$this->licenses = $this->getLicenses();
$this->unitsNotFound = Unit::countBySql('range_id = ?', [Context::getId()]) === 0;
} }
public function index_action(): void public function index_action(): void
{ {
Navigation::activateItem('course/courseware/shelf'); Navigation::activateItem('course/courseware/shelf');
$this->licenses = $this->getLicenses();
$this->setIndexSidebar(); $this->setIndexSidebar();
} }
public function courseware_action($unit_id = null): void public function courseware_action($unit_id = null): void
{ {
global $perm, $user; global $perm, $user;
Navigation::activateItem('course/courseware/unit');
if ($this->unitsNotFound) {
PageLayout::postMessage(MessageBox::info(_('Es wurde kein Lernmaterial gefunden.')));
return;
}
$this->setCoursewareSidebar();
$this->user_id = $user->id; $this->user_id = $user->id;
/** @var array<mixed> $last */ /** @var array<mixed> $last */
...@@ -58,10 +65,6 @@ class Course_CoursewareController extends CoursewareController ...@@ -58,10 +65,6 @@ class Course_CoursewareController extends CoursewareController
$unit = Unit::find($unit_id); $unit = Unit::find($unit_id);
if (isset($unit)) { if (isset($unit)) {
$this->setEntryElement('course', $unit, $last, Context::getId()); $this->setEntryElement('course', $unit, $last, Context::getId());
Navigation::activateItem('course/courseware/unit');
$this->licenses = $this->getLicenses();
$this->setCoursewareSidebar();
} }
} }
......
<? if (!$unitsNotFound): ?>
<div <div
id="courseware-index-app" id="courseware-index-app"
entry-element-id="<?= htmlReady($entry_element_id) ?>" entry-element-id="<?= htmlReady($entry_element_id) ?>"
...@@ -8,3 +9,4 @@ ...@@ -8,3 +9,4 @@
licenses='<?= htmlReady($licenses) ?>' licenses='<?= htmlReady($licenses) ?>'
> >
</div> </div>
<? endif; ?>
<? if (!$unitsNotFound): ?>
<div <div
id="courseware-index-app" id="courseware-index-app"
entry-element-id="<?= htmlReady($entry_element_id) ?>" entry-element-id="<?= htmlReady($entry_element_id) ?>"
...@@ -8,3 +9,4 @@ ...@@ -8,3 +9,4 @@
licenses='<?= htmlReady($licenses) ?>' licenses='<?= htmlReady($licenses) ?>'
> >
</div> </div>
<? endif; ?>
...@@ -37,7 +37,9 @@ trait CoursewareInstancesHelper ...@@ -37,7 +37,9 @@ trait CoursewareInstancesHelper
$chunks = explode('_', $rangeId); $chunks = explode('_', $rangeId);
$courseId = $chunks[0]; $courseId = $chunks[0];
$unitId = $chunks[1] ?? null; $unitId = $chunks[1] ?? null;
if ($unitId === '') {
throw new BadRequestException('Unit id must not be empty.');
}
if ($unitId) { if ($unitId) {
$unit = Unit::findOneBySQL('range_id = ? AND id = ?', [$courseId, $unitId]); $unit = Unit::findOneBySQL('range_id = ? AND id = ?', [$courseId, $unitId]);
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment