diff --git a/app/controllers/contents/courseware.php b/app/controllers/contents/courseware.php index 0183655cdef78c0f15984efdca499cb256fc7f5c..1551fbd72edd889cf9084e0977e4e6779065036b 100644 --- a/app/controllers/contents/courseware.php +++ b/app/controllers/contents/courseware.php @@ -76,7 +76,7 @@ class Contents_CoursewareController extends CoursewareController /** @var array<mixed> $last */ $last = UserConfig::get($this->user_id)->getValue('COURSEWARE_LAST_ELEMENT'); - if ($unit_id === null) { + if (empty($unit_id)) { $this->redirectToFirstUnit('user', $this->user_id, $last); return; diff --git a/app/controllers/course/courseware.php b/app/controllers/course/courseware.php index 46419a88e85665d5e2d7d9b8d9630c30bd95f768..967d993b763336bea06677fba9fc3f272e9deda0 100644 --- a/app/controllers/course/courseware.php +++ b/app/controllers/course/courseware.php @@ -44,6 +44,7 @@ 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.'))); diff --git a/app/controllers/courseware_controller.php b/app/controllers/courseware_controller.php index fb2b39c4e1462a9ddce759c1d0e21dba2d206f36..138a98627267fd0a2f52f8bc6373c3cbc1c7fcef 100644 --- a/app/controllers/courseware_controller.php +++ b/app/controllers/courseware_controller.php @@ -5,12 +5,22 @@ use Courseware\Unit; abstract class CoursewareController extends AuthenticatedController { + public function before_filter(&$action, &$args): void + { + parent::before_filter($action, $args); + + if ($action === 'index' && Request::int('element_id')) { + $element = StructuralElement::find(Request::int('element_id')); + $this->redirect($this->action_url('courseware#/structural_element/' . $element->id, $element->findUnit()->id)); + } + } + public function redirectToFirstUnit(string $context, string $rangeId, array $last): void { $path = $context === 'user' ? 'contents' : $context; $last_element = $this->getLastElement($last, $context, $rangeId); if ($last_element) { - $unit = $last_element->findUnit($last); + $unit = $last_element->findUnit(); } else { $unit = Unit::findOneBySql('range_id = ? ORDER BY mkdate ASC', [$rangeId]); } diff --git a/resources/vue/courseware-shelf-app.js b/resources/vue/courseware-shelf-app.js index d0d86255f038991f8773c632ad47f55a35da6983..68a8ac97debe84cbbd8fefa5260a92033cf0e931 100644 --- a/resources/vue/courseware-shelf-app.js +++ b/resources/vue/courseware-shelf-app.js @@ -7,6 +7,17 @@ import { mapResourceModules } from '@elan-ev/reststate-vuex'; import { StockImagesPlugin } from './plugins/stock-images.js'; const mountApp = async (STUDIP, createApp, element) => { + // handle studip 5.0 to 5.2 urls + const elemId = window.location.hash.match(/structural_element\/(\d+)/); + + if (elemId) { + let url = new URL(window.location.href); + url.searchParams.set('element_id', elemId[1]); + window.location.href = url; + + return false; + } + const getHttpClient = () => axios.create({ baseURL: STUDIP.URLHelper.getURL(`jsonapi.php/v1`, {}, true),