From 54d56524c9ae9e479776e86e3bec365cab2ae303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Tue, 24 Oct 2023 15:50:36 -0300 Subject: [PATCH] Fix: Poll answers not being translated in learning dashboard --- .../src/components/PollsTable.jsx | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/bbb-learning-dashboard/src/components/PollsTable.jsx b/bbb-learning-dashboard/src/components/PollsTable.jsx index 390a8e1530..8093eb5e7b 100644 --- a/bbb-learning-dashboard/src/components/PollsTable.jsx +++ b/bbb-learning-dashboard/src/components/PollsTable.jsx @@ -47,6 +47,49 @@ const PollsTable = (props) => { ); } + const pollAnswerIds = { + true: { + id: 'app.poll.answer.true', + description: 'label for poll answer True', + }, + false: { + id: 'app.poll.answer.false', + description: 'label for poll answer False', + }, + yes: { + id: 'app.poll.answer.yes', + description: 'label for poll answer Yes', + }, + no: { + id: 'app.poll.answer.no', + description: 'label for poll answer No', + }, + abstention: { + id: 'app.poll.answer.abstention', + description: 'label for poll answer Abstention', + }, + a: { + id: 'app.poll.answer.a', + description: 'label for poll answer A', + }, + b: { + id: 'app.poll.answer.b', + description: 'label for poll answer B', + }, + c: { + id: 'app.poll.answer.c', + description: 'label for poll answer C', + }, + d: { + id: 'app.poll.answer.d', + description: 'label for poll answer D', + }, + e: { + id: 'app.poll.answer.e', + description: 'label for poll answer E', + }, + }; + const commonUserProps = { field: 'User', headerName: intl.formatMessage({ id: 'app.learningDashboard.pollsTable.userLabel', defaultMessage: 'User' }), @@ -280,7 +323,9 @@ const PollsTable = (props) => { sortable: true, valueGetter: (params) => { const colVal = params?.row[params?.field]; - return colVal === '' ? '' : colVal?.join(', '); + const key = pollAnswerIds[colVal[0]?.toLowerCase()] + ? [intl.formatMessage(pollAnswerIds[colVal[0].toLowerCase()])] : colVal; + return key === '' ? '' : key?.join(', '); }, renderCell: (params) => { // Here we count each poll vote in order to find out the most common answer.