Skip to content
Snippets Groups Projects
Select Git revision
  • 183bc8155a7db20e17d1d9074d4907f4c417656f
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

courseware.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    courseware.php 11.65 KiB
    <?php
    
    use \Courseware\StructuralElement;
    
    class Contents_CoursewareController extends AuthenticatedController
    {
        /**
         * Callback function being called before an action is executed.
         *
         * @SuppressWarnings(PHPMD.CamelCaseMethodName)
         * @SuppressWarnings(PHPMD.Superglobals)
         */
        public function before_filter(&$action, &$args)
        {
            parent::before_filter($action, $args);
    
            PageLayout::setHelpKeyword('Basis.Courseware'); // set keyword for new help
    
            PageLayout::setTitle(_('Courseware'));
    
            $this->user = $GLOBALS['user'];
        }
    
        /**
         * Entry point of the controller that displays the courseware projects overview
         *
         * @param string $action
         * @param string $widgetId
         * @SuppressWarnings(PHPMD.CamelCaseMethodName)
         * @SuppressWarnings(PHPMD.Superglobals)
         * @SuppressWarnings(PHPMD.UnusedFormalParameter)
         */
        public function index_action($action = false, $widgetId = null)
        {
            Navigation::activateItem('/contents/courseware/projects');
            $this->setProjectsSidebar($action);
    
            $this->elements = $this->getProjects('all');
        }
    
        /**
         * Show Courseware of current user
         *
         * @param string $action
         * @param string $widgetId
         * @SuppressWarnings(PHPMD.CamelCaseMethodName)
         * @SuppressWarnings(PHPMD.Superglobals)
         * @SuppressWarnings(PHPMD.UnusedFormalParameter)
         */
        public function courseware_action($action = false, $widgetId = null)
        {
            global $perm;
    
            Navigation::activateItem('/contents/courseware/courseware');
            $this->user_id = $GLOBALS['user']->id;
    
            $this->setCoursewareSidebar();
    
            $last = UserConfig::get($this->user_id)->getValue('COURSEWARE_LAST_ELEMENT');
    
            if ($last[$this->user_id]) {
                $this->entry_element_id = $last['global'];
                $struct = \Courseware\StructuralElement::findOneBySQL(
                    "id = ? AND range_id = ? AND range_type = 'user'",
                    [$this->entry_element_id, $this->user_id]
                );
            }
    
            // load courseware for current user
            if (!$this->entry_element_id || !$struct || !$struct->canRead($GLOBALS['user'])) {