From 3b41f51cde8107d6143ef0644305af1c8bd55e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michaela=20Br=C3=BCckner?= Date: Wed, 11 Mar 2026 15:17:34 +0100 Subject: re #6193 --- app/views/questionnaire/answer.php | 13 +++- lib/models/Vote.php | 2 + public/assets/images/icons/icons.svg | 2 +- .../apps/questionnaires/QuestionnaireAnswer.vue | 39 ++++++++-- .../vue/components/questionnaires/VoteAnswer.vue | 91 ++++++++++++++-------- 5 files changed, 104 insertions(+), 43 deletions(-) diff --git a/app/views/questionnaire/answer.php b/app/views/questionnaire/answer.php index 779eb67..3af9499 100644 --- a/app/views/questionnaire/answer.php +++ b/app/views/questionnaire/answer.php @@ -72,9 +72,18 @@ $questionnaire_data['questions'] = $grouped; withProps(['questionnaireData' => $questionnaire_data]) ?> + ->withProps(['questionnaireData' => $questionnaire_data, + 'config' => [ + 'isAnswerable' => $questionnaire->isAnswerable(), + 'isEditable' => $questionnaire->isEditable(), + 'isCopyable' => $questionnaire->isCopyable(), + 'isRunning' => $questionnaire->isRunning(), + 'resultsVisible' => $questionnaire->resultsVisible(), + 'countAnswers' => $questionnaire->countAnswers() + ] + ]) ?> - +
isAnswerable()) : ?> "return STUDIP.Questionnaire.beforeAnswer.call(this);"]) ?> diff --git a/lib/models/Vote.php b/lib/models/Vote.php index a386aaf..566101e 100644 --- a/lib/models/Vote.php +++ b/lib/models/Vote.php @@ -72,6 +72,8 @@ class Vote extends QuestionnaireQuestion implements QuestionType $answer = $this->getMyAnswer(); $answers = Request::getArray('answers'); + var_dump($answers); + exit; $freetext_answer = $answers[$this->getId()]['answerdata']['freetext']; $userAnswer = null; diff --git a/public/assets/images/icons/icons.svg b/public/assets/images/icons/icons.svg index cbc76e3..c94a21d 100644 --- a/public/assets/images/icons/icons.svg +++ b/public/assets/images/icons/icons.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/vue/apps/questionnaires/QuestionnaireAnswer.vue b/resources/vue/apps/questionnaires/QuestionnaireAnswer.vue index 178930c..169550a 100644 --- a/resources/vue/apps/questionnaires/QuestionnaireAnswer.vue +++ b/resources/vue/apps/questionnaires/QuestionnaireAnswer.vue @@ -7,8 +7,6 @@ :data-dialog="asDialog ? true : null" :data-secure="activateFormSecure" > - -
@@ -40,14 +38,11 @@ - -
-
{{ $gettext('Die Teilnahme ist anonym.') }} {{ $gettext('Die Teilnahme ist nicht anonym.') }} @@ -55,7 +50,35 @@ {{ $gettext('Sie können den Fragebogen beantworten bis zum %{date} um %{time} Uhr.', {date:getFormattedDate, time:getFormattedTime}) }}
+
+ + + + + + + + + + +
+ + {{ config }} diff --git a/resources/vue/components/questionnaires/VoteAnswer.vue b/resources/vue/components/questionnaires/VoteAnswer.vue index 7ee5cbd..57ff98a 100644 --- a/resources/vue/components/questionnaires/VoteAnswer.vue +++ b/resources/vue/components/questionnaires/VoteAnswer.vue @@ -1,18 +1,6 @@ - - @@ -68,31 +75,38 @@ const props = defineProps({ }) const shuffledOptions = ref([]) -const userAnswer = ref(null) // Radio -// Für Checkbox später automatisch Array +const userAnswer = ref([]) +const freeTextAnswer = ref('') +const freeTextEnabled = ref(false) function prepareAnswers() { - const options = [...props.question.questiondata.options] + const options = props.question.questiondata.options + + // Antworten mit Originalindex kombinieren + const mapped = options.map((answer, index) => ({ + answer, + index + })) + // Shuffle falls aktiviert if (props.question.questiondata.randomize == 1) { - for (let i = options.length - 1; i > 0; i--) { + for (let i = mapped.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)) - ;[options[i], options[j]] = [options[j], options[i]] + ;[mapped[i], mapped[j]] = [mapped[j], mapped[i]] } } - shuffledOptions.value = options + shuffledOptions.value = mapped } + function initUserAnswer() { + const answers = props.question.responseData?.answers ?? [] + if (props.question.questiondata.multiplechoice == 1) { - // Checkbox → Array - userAnswer.value = Array.isArray(props.question.responseData) - ? props.question.responseData - : [] + userAnswer.value = answers } else { - // Radio → Einzelwert - userAnswer.value = props.question.responseData || null + userAnswer.value = answers[0] ?? null } } @@ -112,3 +126,12 @@ watch( + -- cgit v1.0