Skip to content
Snippets Groups Projects
Course.class.php 35.9 KiB
Newer Older

        $name_sort = Config::get()->IMPORTANT_SEMNUMBER ? 'VeranstaltungsNummer, Name' : 'Name';

        return Course::findBySQL(
            "LEFT JOIN semester_courses ON (semester_courses.course_id = seminare.Seminar_id)
             WHERE Seminar_id IN (?)
             ORDER BY semester_courses.semester_id IS NULL DESC, start_time DESC, {$name_sort}",
            [$seminar_ids]
        );
    }

    /**
     * Returns whether this course is a studygroup
     * @return bool
     */
    public function isStudygroup()
    {
        return in_array($this->status, studygroup_sem_types());
    }

    /**
     *
     */
    public function setDefaultTools()
    {
        $this->tools = [];
        foreach (array_values($this->getSemClass()->getActivatedModuleObjects()) as $module) {
            PluginManager::getInstance()->setPluginActivated($module->getPluginId(), $this->id, true);
            $this->tools[] = ToolActivation::find([$this->id, $module->getPluginId()]);
        }
    }

    /**
     * @param $name string name of tool / plugin
     * @return bool
     */
    public function isToolActive($name)
    {
        $plugin = PluginEngine::getPlugin($name);
        return $plugin && $this->tools->findOneby('plugin_id', $plugin->getPluginId());
    }

    /**
     * returns all activated plugins/modules for this course
     * @return StudipModule[]
     */
    public function getActivatedTools()
    {
        return array_filter($this->tools->getStudipModule());
    }
Moritz Strohm's avatar
Moritz Strohm committed

    /**
     * @see Range::__toString()
     */
    public function __toString() : string
    {
        return $this->getFullName();
    }