Skip to content

Commit 60ce1d6

Browse files
committed
fix: 回覧板の回答CSVの選択肢がラベルでなくIDで出力されて、何が選ばれたのかわからない
NetCommons3/NetCommons3/issues/1641
1 parent 4604b79 commit 60ce1d6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Controller/CircularNoticesController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,13 @@ public function download() {
506506
$csvFile->add($header);
507507

508508
// 回答データ整形
509+
$choices = array();
510+
foreach ($content['CircularNoticeChoice'] as $choice) {
511+
$choices[$choice['id']] = $choice;
512+
}
509513
$content = $content['CircularNoticeContent'];
510514
foreach ($targetUsers as $targetUser) {
511-
$answer = $this->__parseAnswer($content['reply_type'], $targetUser);
515+
$answer = $this->__parseAnswer($content['reply_type'], $targetUser, $choices);
512516

513517
$readDatetime = __d('circular_notices', 'Unread');
514518
if ($targetUser['CircularNoticeTargetUser']['read_datetime']) {
@@ -550,9 +554,10 @@ public function download() {
550554
*
551555
* @param string $replyType 回答種別
552556
* @param array $targetUser 回答者
557+
* @param array $choices 選択肢情報
553558
* @return null|string
554559
*/
555-
private function __parseAnswer($replyType, $targetUser) {
560+
private function __parseAnswer($replyType, $targetUser, $choices) {
556561
$answer = null;
557562
switch ($replyType) {
558563
case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_TEXT:
@@ -562,6 +567,10 @@ private function __parseAnswer($replyType, $targetUser) {
562567
case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_MULTIPLE_SELECTION:
563568
$selectionValues = explode(CircularNoticeComponent::SELECTION_VALUES_DELIMITER,
564569
$targetUser['CircularNoticeTargetUser']['reply_selection_value']);
570+
// 取り出したreply_selection_valueの値を選択肢のラベルに変換する
571+
foreach ($selectionValues as &$selectVal) {
572+
$selectVal = $choices[$selectVal]['value'] ?? '';
573+
}
565574
$answer = implode(__d('circular_notices', 'Answer separator'), $selectionValues);
566575
break;
567576
}

0 commit comments

Comments
 (0)