aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFinn Schneider <schneider@data-quest.de>2026-02-20 18:24:08 +0100
committerFinn Schneider <schneider@data-quest.de>2026-03-13 17:25:01 +0000
commit31a373c968d2fb4e66c58e763ea9cc81f1eb668d (patch)
tree11fe17bcdba90e481f58c5360ee14f6fd466ae0b
parent3e9c3e5439d53d187d9e7892139dae88f0f60f8d (diff)
preedit
-rw-r--r--app/controllers/evaluation/profiles.php52
-rw-r--r--app/views/evaluation/profiles/index.php4
-rw-r--r--app/views/evaluation/profiles/preedit.php48
3 files changed, 85 insertions, 19 deletions
diff --git a/app/controllers/evaluation/profiles.php b/app/controllers/evaluation/profiles.php
index acf602f..7c89c09 100644
--- a/app/controllers/evaluation/profiles.php
+++ b/app/controllers/evaluation/profiles.php
@@ -11,22 +11,24 @@ class Evaluation_ProfilesController extends AuthenticatedController
);
}
+ public function preedit_action()
+ {
+ $this->semesters = $this->getAvailableSemesters(true);
+ $this->render_template('evaluation/profiles/preedit');
+ }
+
public function edit_action(string $id = null): void
{
+ $sem_preselect = Request::get('sem_select');
if ($id) {
$profile = QuestionnaireEvalCentralProfile::find($id);
$semesters = [$profile->semester_id => $profile->semester->name];
} else {
- $profile = new QuestionnaireEvalCentralProfile();
- $semesters = [];
- Semester::findEachBySQL(
- function($row) use (&$semesters) {
- $semesters[$row['semester_id']] = $row['name'];
- },
- "`semester_id` NOT IN (SELECT `semester_id` FROM `questionnaire_eval_central_profiles`)
- ORDER BY `beginn` desc"
- );
+ $profile_preselect = QuestionnaireEvalCentralProfile::find($sem_preselect);
+ $profile = QuestionnaireEvalCentralProfile::build($profile_preselect);
+ $semesters = $this->getAvailableSemesters();
}
+ $is_fill = $sem_preselect || $id;
$template_array = [];
Questionnaire::findEachBySQL(
@@ -60,7 +62,7 @@ class Evaluation_ProfilesController extends AuthenticatedController
'mapper' => function($value) {
return implode(',', $value);
},
- 'value' => $id && $profile->optional_templates ?
+ 'value' => $is_fill && $profile->optional_templates ?
explode(',', $profile->optional_templates) : null
],
'startdate' => [
@@ -68,41 +70,41 @@ class Evaluation_ProfilesController extends AuthenticatedController
'name' => 'startdate',
'required' => true,
'type' => 'datetimepicker',
- 'value' => $id ? $profile->startdate : time() //TODO sem
+ 'value' => $is_fill ? $profile->startdate : time() //TODO sem
],
'stopdate' => [
'label' => _('Ende'),
'required' => true,
'type' => 'datetimepicker',
- 'value' => $id ? $profile->stopdate : time(), //TODO sem
+ 'value' => $is_fill ? $profile->stopdate : time(), //TODO sem
'mindate' => 'startdate'
],
'anonymous' => [
'label' => _('Anonyme Teilnahme'),
'type' => 'checkbox',
- 'value' => $id ? $profile->anonymous : true
+ 'value' => $is_fill ? $profile->anonymous : true
],
'editanswers' => [
'label' => _('Antworten revidierbar'),
'type' => 'checkbox',
- 'value' => $id ? $profile->editanswers : false
+ 'value' => $is_fill ? $profile->editanswers : false
],
'resultvisibility' => [
'label' => _('Zeitpunkt der Ergebnis-Einsicht'),
'type' => 'select',
'options' => QuestionnaireEvalCentralProfile::getTranslatedVisibilityOptions(),
- 'value' => $id ? $profile->resultvisibility : 'never'
+ 'value' => $is_fill ? $profile->resultvisibility : 'never'
],
'result_visible_for' => [
'label' => _('Ergebnis-Einsicht für (Evaluations-Admins immer)'),
'type' => 'select',
'options' => QuestionnaireEvalCentralProfile::getTranslatedVisibilityOptions(true),
- 'value' => $id ? $profile->result_visible_for : null
+ 'value' => $is_fill ? $profile->result_visible_for : null
],
'minimum_responses' => [
'label' => _('Mindestrücklauf'),
'type' => 'number',
- 'value' => $id ? $profile->minimum_responses : 8,
+ 'value' => $is_fill ? $profile->minimum_responses : 8,
'min' => 0
]
]
@@ -114,6 +116,22 @@ class Evaluation_ProfilesController extends AuthenticatedController
$this->render_form($form);
}
+ public function getAvailableSemesters(bool $reverse = false): array
+ {
+ $semesters = [];
+ Semester::findEachBySQL(
+ function($row) use (&$semesters) {
+ $semesters[$row['semester_id']] = $row['name'];
+ },
+ $reverse ?
+ "`semester_id` IN (SELECT `semester_id` FROM `questionnaire_eval_central_profiles`)
+ ORDER BY `beginn` desc" :
+ "`semester_id` NOT IN (SELECT `semester_id` FROM `questionnaire_eval_central_profiles`)
+ ORDER BY `beginn` desc"
+ );
+ return $semesters;
+ }
+
public function bulkdelete_action(): void
{
CSRFProtection::verifyUnsafeRequest();
diff --git a/app/views/evaluation/profiles/index.php b/app/views/evaluation/profiles/index.php
index 71c9ad0..3b1f672 100644
--- a/app/views/evaluation/profiles/index.php
+++ b/app/views/evaluation/profiles/index.php
@@ -90,8 +90,8 @@ use Studip\Button;
$actions = new ActionsWidget();
$actions->addLink(
_('Profil anlegen'),
- $controller->url_for('evaluation/profiles/edit'),
+ $controller->url_for('evaluation/profiles/preedit'),
Icon::create('add'),
- ['data-dialog' => '']
+ ['data-dialog' => 'size=auto']
);
Sidebar::Get()->addWidget($actions);
diff --git a/app/views/evaluation/profiles/preedit.php b/app/views/evaluation/profiles/preedit.php
new file mode 100644
index 0000000..38a2479
--- /dev/null
+++ b/app/views/evaluation/profiles/preedit.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * @var Evaluation_ProfilesController $controller
+ */
+?>
+
+<form method="post">
+ <?= CSRFProtection::tokenTag() ?>
+ <h2>Leeres Profil anlegen</h2>
+ <div>
+ <div class="clickable">
+ <button
+ class="as-link"
+ formaction="<?= $controller->link_for('/edit') ?>"
+ data-dialog="size=default"
+ style="vertical-align: center"
+ >
+ <?= Icon::create('add')->asSvg(50) ?>
+ <p><?= _('Neu anlegen') ?></p>
+ </button>
+ </div>
+</form>
+
+<form method="post">
+ <?= CSRFProtection::tokenTag() ?>
+ <h2>Profildaten übernehmen</h2>
+ <label>
+ Aus Profil von Semester</br>
+ <select name="sem_select">
+ <?php foreach ($controller->semesters as $key => $semester) : ?>
+ <option value="<?= $key ?>"><?= $semester ?></option>
+ <?php endforeach ?>
+ </select>
+ </label>
+ </br>
+ </br>
+ <div class="clickable">
+ <button
+ class="as-link"
+ formaction="<?= $controller->link_for('/edit') ?>"
+ data-dialog="size=default"
+ >
+ <?= Icon::create('copy')->asSvg(50) ?>
+ <p><?= _('Daten übernehmen') ?></p>
+ </button>
+ </div>
+ </div>
+</form>