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
$output = [];
$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 = [];
$countNobodys = 0;
foreach ($this->answers as $answer) {
$answerData = $answer['answerdata']->getArrayCopy();
if ($answer['user_id'] && $answer['user_id'] != 'nobody') {
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;
$userId = _('unbekannt') . ' ' . ++$countNobodys;
}
$answerOption[$userId] = $options[$answerData['answers']];
}
$output[$option] = $answerOption;
$question = strip_tags($this['questiondata']['description']);
$output[$question] = $answerOption;
}
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