diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2026-01-23 14:06:53 +0100 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2026-01-23 14:06:53 +0100 |
| commit | 7f2d6724d202bda20a77994b5ae7df567102cca1 (patch) | |
| tree | c48b7a40e551b2c9a217fbe8824c0d8de967b77a | |
| parent | 7a1d567fc0a263f28d75f49ef8a9b9bba580ab05 (diff) | |
rewrite Course creation wizard steps to new wizardcourse-creation-wizard
| -rw-r--r-- | app/controllers/course/wizard.php | 46 | ||||
| -rw-r--r-- | lib/classes/coursewizardsteps/BasicDataWizardStep.php | 74 |
2 files changed, 74 insertions, 46 deletions
diff --git a/app/controllers/course/wizard.php b/app/controllers/course/wizard.php index b1cfcbb..f264444 100644 --- a/app/controllers/course/wizard.php +++ b/app/controllers/course/wizard.php @@ -26,37 +26,8 @@ class Course_WizardController extends AuthenticatedController { parent::before_filter($action, $args); - if ($GLOBALS['user']->perms === 'user') { - throw new AccessDeniedException(); - } - - $this->dialog = Request::isXhr(); - $this->studygroup = Request::bool('studygroup', $this->flash['studygroup'] ?? false); - - // Feels a bit hacky - $this->is_copy = isset($_SESSION['coursewizard'][$args[1] ?? '']['source_id']); - - if (!$this->studygroup) { - if ($this->is_copy) { - PageLayout::setTitle(_('Veranstaltung kopieren')); - } else { - PageLayout::setTitle(_('Neue Veranstaltung anlegen')); - } - - $navigation = new Navigation(_('Neue Veranstaltung anlegen'), 'dispatch.php/course/wizard'); - Navigation::addItem('/browse/my_courses/new_course', $navigation); - Navigation::activateItem('/browse/my_courses/new_course'); - } else { - $this->flash['studygroup'] = true; + $GLOBALS['perm']->check('dozent'); - PageLayout::setTitle(_('Neue Studiengruppe anlegen')); - - $navigation = new Navigation(_('Neue Studiengruppe anlegen'), 'dispatch.php/course/wizard?studygroup=1'); - Navigation::addItem('/browse/my_courses/new_course', $navigation); - Navigation::activateItem('/browse/my_courses/new_course'); - } - - $this->steps = CourseWizardStepRegistry::findBySQL("`enabled`=1 ORDER BY `number`"); } /** @@ -64,7 +35,20 @@ class Course_WizardController extends AuthenticatedController */ public function index_action() { - $this->redirect('course/wizard/step/0' . ($this->studygroup ? '?studygroup=1&stgteil_id='.Request::option('stgteil_id') : '')); + $steps = CourseWizardStepRegistry::findBySQL("`enabled` = 1 ORDER BY `number`"); + + $parts = []; + + foreach ($steps as $step) { + $instance = new $step->classname(); + $template = $instance->getStepTemplate([], 0, ''); + if ($template instanceof \Studip\Forms\Form) { + $template->noButtons()->useStore()->setId($step->classname); + $parts[] = \Studip\WizardPart::create($step->classname, $template, $step->name); + } + } + + $this->render_wizard($parts); } /** diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php index 2e265c3..ef02c05 100644 --- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php +++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php @@ -23,23 +23,67 @@ class BasicDataWizardStep implements CourseWizardStep * @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. + * @return Studip\Forms\Form a form object. */ 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('studygroups/index'); - $values[__CLASS__]['lecturers'][$GLOBALS['user']->id] = 1; - } else { - $tpl = $factory->open('basicdata/index'); - } - if ($this->setupTemplateAttributes($tpl, $values, $stepnumber, $temp_id)) { - return $tpl->render(); - } + $types = array_map(fn ($type) => ['id' => $type['id'], 'name' => $type['name']], SemType::getTypes()); + $semesters = array_reverse(Semester::getAll()); + $institutes = Institute::getMyInstitutes(); + + $form = Studip\Forms\Form::fromSORM( + new Course(), + [ + 'legend' => _('Grunddaten'), + 'fields' => [ + 'status' => [ + 'type' => 'select', + 'label' => _('Typ'), + 'options' => array_combine( + array_column($types, 'id'), + array_column($types, 'name') + ), + 'required' => true + ], + 'start_semester' => [ + 'type' => 'select', + 'label' => _('Semester'), + 'value' => Semester::findDefault()->id, + 'options' => array_combine( + array_map(fn ($semester) => $semester->id, $semesters), + array_map(fn ($semester) => $semester->name, $semesters) + ), + 'required' => true + ], + 'name' => [ + 'type' => 'text', + 'label' => _('Veranstaltungstitel'), + 'required' => true, + 'maxlength' => '255' + ], + 'veranstaltungsnummer' => [ + 'type' => 'text', + 'label' => _('Veranstaltungsnummer') + ], + 'beschreibung' => [ + 'type' => 'i18n_textarea', + 'label' => _('Beschreibung') + ], + 'institut_id' => [ + 'type' => 'select', + 'label' => _('Heimateinrichtung'), + 'required' => true, + 'value' => current($institutes)['Institut_id'], + 'options' => array_combine( + array_column($institutes, 'Institut_id'), + array_column($institutes, 'Name') + ) + ] + ] + ] + ); - return ''; + return $form; } protected function setupTemplateAttributes($tpl, $values, $stepnumber, $temp_id) @@ -59,7 +103,7 @@ class BasicDataWizardStep implements CourseWizardStep } // Pre-set institute for studygroup assignment. $values['institute'] = Config::get()->STUDYGROUP_DEFAULT_INST; - // Normal course. + // Normal course. } else { if (!$class['course_creation_forbidden'] && !$class['studygroup_mode']) { $typestruct[$class['name']][] = $type; @@ -702,7 +746,7 @@ class BasicDataWizardStep implements CourseWizardStep $values[$index] = new I18NString($values[$index], $values[$index . '_i18n'] ?? []); - // Current index is not set (yet), create an empty I18NString + // Current index is not set (yet), create an empty I18NString } else { $values[$index] = new I18NString('', $translations); |
