Skip to content
Snippets Groups Projects
Select Git revision
  • cd04c76f0f7948bd262c290f3bbe1a22a2c7722f
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

BasicDataWizardStep.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.
    BasicDataWizardStep.php 31.74 KiB
    <?php
    /**
     * BasicDataWizardStep.php
     * Course wizard step for getting the basic course data.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     *
     * @author      Thomas Hackl <thomas.hackl@uni-passau.de>
     * @copyright   2015 Stud.IP Core-Group
     * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
     * @category    Stud.IP
     */
    
    class BasicDataWizardStep implements CourseWizardStep
    {
        /**
         * Returns the Flexi template for entering the necessary values
         * for this step.
         *
         * @param Array $values Pre-set values
         * @param int $stepnumber which number has the current step in the wizard?
         * @param String $temp_id temporary ID for wizard workflow
         * @return String a Flexi template for getting needed data.
         */
        public function getStepTemplate($values, $stepnumber, $temp_id)
        {
            // Load template from step template directory.
            $factory = new Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views/course/wizard/steps');
            if (!empty($values[__CLASS__]['studygroup'])) {
                $tpl = $factory->open('basicdata/index_studygroup');
                $values[__CLASS__]['lecturers'][$GLOBALS['user']->id] = 1;
            } else {
                $tpl = $factory->open('basicdata/index');
            }
            if ($this->setupTemplateAttributes($tpl, $values, $stepnumber, $temp_id)) {
                return $tpl->render();
            }
    
            return '';
        }
    
        protected function setupTemplateAttributes($tpl, $values, $stepnumber, $temp_id)
        {
            // We only need our own stored values here.
            $values = $values[__CLASS__] ?? [];
            // Get all available course types and their categories.
            $typestruct = [];
            $admission_turnout_mandatory_types = [];
            foreach (SemType::getTypes() as $type) {
                $class = $type->getClass();
                // Creates a studygroup.
                if (!empty($values['studygroup'])) {
                    // Get all studygroup types.
                    if ($class['studygroup_mode']) {
                        $typestruct[$class['name']][] = $type;
                    }
                    // Pre-set institute for studygroup assignment.
                    $values['institute'] = Config::get()->STUDYGROUP_DEFAULT_INST;
                // Normal course.
                } else {
                    if (!$class['course_creation_forbidden'] && !$class['studygroup_mode']) {
                        $typestruct[$class['name']][] = $type;
                        if ($class['admission_turnout_mandatory']) {
                            $admission_turnout_mandatory_types[] = $type['id'];
                        }
                    }
                }