Skip to content
Snippets Groups Projects
Select Git revision
  • d674bcfb9f36cdae233f4bc5d5952848860c9bc0
  • 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

Semester.class.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.
    CoursewareContext.php 1.32 KiB
    <?php
    
    namespace Studip\Activity;
    
    class CoursewareContext extends Context
    {
    
        public function __construct($courseware, $observer)
        {
            $this->courseware = $courseware;
            $this->observer = $observer;
    
            $id = explode('_' , $this->courseware->id);
            $this->context = $id[0];
            $this->range_id = $id[1];
        }
    
        protected function getProvider()
        {
            $this->addProvider('Studip\Activity\CoursewareProvider');
    
            return $this->provider;
        }
    
        public function getRangeId()
        {
            return $this->range_id;
        }
    
        public function getContextType()
        {
            if ($this->context === 'user') {
                return \Context::USER;
            }
    
            if ($this->context === 'course') {
                return \Context::COURSE;
            }
    
            throw new \UnexpectedValueException("Unknown context type {$this->context}");
        }
    
        public function getContextFullname($format = 'default')
        {
            if ($this->context === 'user') {
                $user = \User::find($this->range_id);
    
                return $user->getFullname($format);
            }
    
            if ($this->context === 'course') {
                $course = \Course::find($this->range_id);
    
                return $course->getFullname($format);
            }
    
            throw new \UnexpectedValueException("Unknown context {$this->context}");
        }
    
    }