Skip to content
Snippets Groups Projects
Commit 2ab989c7 authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

Resolve "Fragebogen: Single Choice CSV-Export unnötig kompliziert"

Closes #4308

Merge request studip/studip!3110
parent e0cea7c6
No related branches found
No related tags found
No related merge requests found
...@@ -113,28 +113,49 @@ class Vote extends QuestionnaireQuestion implements QuestionType ...@@ -113,28 +113,49 @@ class Vote extends QuestionnaireQuestion implements QuestionType
$output = []; $output = [];
$options = $this['questiondata']['options'] ? $this['questiondata']['options']->getArrayCopy() : []; $options = $this['questiondata']['options'] ? $this['questiondata']['options']->getArrayCopy() : [];
$multiplechoice = (bool) $this['questiondata']['multiplechoice'];
if ($multiplechoice) {
foreach ($options as $key => $option) {
$answerOption = [];
$countNobodys = 0;
foreach ($this->answers as $answer) {
$answerData = $answer['answerdata']->getArrayCopy();
if ($answer['user_id'] && $answer['user_id'] != 'nobody') {
$userId = $answer['user_id'];
} else {
$countNobodys++;
$userId = _('unbekannt') . ' ' . $countNobodys;
}
if (in_array($key, (array) $answerData['answers'])) {
$answerOption[$userId] = 1;
} else {
$answerOption[$userId] = 0;
}
}
$output[$option] = $answerOption;
}
} else {
foreach ($options as $key => $option) {
$answerOption = []; $answerOption = [];
$countNobodys = 0; $countNobodys = 0;
foreach ($this->answers as $answer) { foreach ($this->answers as $answer) {
$answerData = $answer['answerdata']->getArrayCopy(); $answerData = $answer['answerdata']->getArrayCopy();
if ($answer['user_id'] && $answer['user_id'] != 'nobody') { if ($answer['user_id'] && $answer['user_id'] !== 'nobody') {
$userId = $answer['user_id']; $userId = $answer['user_id'];
} else { } else {
$countNobodys++; $userId = _('unbekannt') . ' ' . ++$countNobodys;
$userId = _('unbekannt').' '.$countNobodys;
}
if (in_array($key, (array) $answerData['answers'])) {
$answerOption[$userId] = 1;
} else {
$answerOption[$userId] = 0;
} }
$answerOption[$userId] = $options[$answerData['answers']];
} }
$output[$option] = $answerOption;
$question = strip_tags($this['questiondata']['description']);
$output[$question] = $answerOption;
} }
return $output; return $output;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment