From aa22011a9e61b47d368562f4314c87ee972762e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michaela=20Br=C3=BCckner?= <brueckner@data-quest.de>
Date: Wed, 10 Jan 2024 12:44:53 +0100
Subject: initial commit, re #3616

---
 app/views/course/wizard/step.php                   |  4 ++
 .../course/wizard/steps/studygroups/index.php      | 79 ++++++++++++++++++++++
 .../coursewizardsteps/BasicDataWizardStep.php      |  3 +-
 3 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 app/views/course/wizard/steps/studygroups/index.php

diff --git a/app/views/course/wizard/step.php b/app/views/course/wizard/step.php
index 0fe1dfc..c32a09b 100644
--- a/app/views/course/wizard/step.php
+++ b/app/views/course/wizard/step.php
@@ -23,11 +23,15 @@
                 !empty($dialog) ? ['data-dialog' => 'size=50%'] : []
             ) ?>
         <? endif; ?>
+        <? if (!$studygroup) : ?>
             <?= Studip\Button::create(
                 _('Weiter'),
                 'next',
                 !empty($dialog) ? ['data-dialog' => 'size=50%'] : []
             ) ?>
+        <? else : ?>
+            <?= Studip\Button::createAccept(_('Studiengruppe anlegen'), 'create') ?>
+        <? endif; ?>
         </footer>
     </form>
 <? else : ?>
diff --git a/app/views/course/wizard/steps/studygroups/index.php b/app/views/course/wizard/steps/studygroups/index.php
new file mode 100644
index 0000000..e270033
--- /dev/null
+++ b/app/views/course/wizard/steps/studygroups/index.php
@@ -0,0 +1,79 @@
+<legend>
+    <?= _('Grunddaten') ?>
+</legend>
+
+<label class="">
+    <span class="required"><?= _('Name') ?></span>
+    <input type="text" name="name" id="wizard-name" maxlength="254" value="<?= htmlReady($values['name'] ?? '') ?>" required/>
+</label>
+
+<? if(count($types) > 1) : ?>
+    <label class="">
+        <span class="required"><?= _('Typ') ?></span>
+        <select name="coursetype" id="wizard-coursetype">
+            <?php foreach ($types as $class => $subtypes) : ?>
+                <optgroup label="<?= htmlReady($class) ?>">
+                    <?php foreach ($subtypes as $type) : ?>
+                        <option value="<?= $type['id'] ?>"<?= $type['id'] == $values['coursetype'] ? ' selected="selected"' : '' ?>>
+                            <?= htmlReady($type['name']) ?>
+                        </option>
+                    <?php endforeach ?>
+                </optgroup>
+            <?php endforeach ?>
+        </select>
+    </label>
+<? else : ?>
+    <? $type = array_values($types)[0]; ?>
+    <input type="hidden" name="coursetype" value="<?= htmlReady($type[0]['id']) ?>">
+<? endif ?>
+
+
+<label class="">
+    <?= _('Beschreibung') ?>
+    <textarea name="description" id="wizard-description"
+              rows="4"><?= htmlReady($values['description'] ?? '') ?></textarea>
+</label>
+
+
+<label class="">
+    <span class="required"><?= _('Zugang') ?></span>
+
+    <select name="access" id="wizard-access">
+        <option value="all"
+            <? if (isset($values['access']) && $values['access'] === 'all') echo 'selected'; ?>>
+            <?= _('offen für alle') ?>
+        </option>
+        <option value="invite"
+            <? if (isset($values['access']) && $values['access'] === 'invite') echo 'selected'; ?>>
+            <?= _('auf Anfrage') ?>
+        </option>
+        <?php if (Config::get()->STUDYGROUPS_INVISIBLE_ALLOWED) : ?>
+            <option value="invisible"
+                <? if (isset($values['access']) && $values['access'] === 'invisible') echo 'selected'; ?>>
+                <?= _('unsichtbar') ?>
+            </option>
+        <?php endif ?>
+    </select>
+</label>
+
+
+<label><span class="required"><?= _('Nutzungsbedingungen')?></span></label>
+
+<? if ($GLOBALS['perm']->have_perm('admin')) : ?>
+    <p style="font-weight: bold;">
+        <?= _('Ich habe die eingetragenen Personen darüber informiert, dass in Ihrem Namen eine Studiengruppe angelegt wird und versichere, dass Sie mit folgenden Nutzungsbedingungen einverstandenen sind:') ?>
+    </p>
+<? endif ?>
+<?= formatReady(Config::Get()->STUDYGROUP_TERMS) ?>
+
+<label>
+    <input type="checkbox" name="accept" id="wizard-accept" required>
+    <?= _('Einverstanden') ?>
+</label>
+
+<input type="hidden" name="institute" value="<?= $values['institute'] ?>"/>
+<input type="hidden" name="start_time" value="<?= $values['start_time'] ?>"/>
+<input type="hidden" name="studygroup" value="1"/>
+<?php foreach ($values['lecturers'] as $id => $assigned) : ?>
+    <input type="hidden" name="lecturers[<?= $id ?>]" value="1"/>
+<?php endforeach ?>
diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
index 4f424e8..f169af9 100644
--- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php
+++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
@@ -29,8 +29,9 @@ class BasicDataWizardStep implements CourseWizardStep
     {
         // Load template from step template directory.
         $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'] . '/app/views/course/wizard/steps');
+
         if (!empty($values[__CLASS__]['studygroup'])) {
-            $tpl = $factory->open('basicdata/index_studygroup');
+            $tpl = $factory->open('studygroups/index');
             $values[__CLASS__]['lecturers'][$GLOBALS['user']->id] = 1;
         } else {
             $tpl = $factory->open('basicdata/index');
-- 
cgit v1.0

