From 3d6314012fd3101eea1057e850dc666d7df296de Mon Sep 17 00:00:00 2001
From: Ramon Souza <contato@ramonsouza.com>
Date: Mon, 5 Apr 2021 14:50:50 -0300
Subject: [PATCH] localized quick poll answers

---
 .../quick-poll-dropdown/component.jsx         | 43 ++++++++++++++++---
 .../presentation-toolbar/container.jsx        |  4 +-
 2 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/component.jsx b/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/component.jsx
index 3755fb501d..c6fd754a13 100644
--- a/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/component.jsx
+++ b/bigbluebutton-html5/imports/ui/components/actions-bar/quick-poll-dropdown/component.jsx
@@ -43,14 +43,41 @@ const propTypes = {
   amIPresenter: PropTypes.bool.isRequired,
 };
 
-const getAvailableQuickPolls = (slideId, parsedSlides, startPoll) => {
+const getLocalizedAnswers = (type, intl) => {
+  switch (type) {
+    case 'TF':
+      return [
+        intl.formatMessage(intlMessages.trueOptionLabel),
+        intl.formatMessage(intlMessages.falseOptionLabel),
+      ];
+    case 'YN':
+      return [
+        intl.formatMessage(intlMessages.yesOptionLabel),
+        intl.formatMessage(intlMessages.noOptionLabel),
+      ];
+    case 'YNA':
+      return [
+        intl.formatMessage(intlMessages.yesOptionLabel),
+        intl.formatMessage(intlMessages.noOptionLabel),
+        intl.formatMessage(intlMessages.abstentionOptionLabel),
+      ];
+    default:
+      return null;
+  }
+};
+
+const getAvailableQuickPolls = (slideId, parsedSlides, startPoll, intl) => {
   const pollItemElements = parsedSlides.map((poll) => {
-    const { poll: label, type } = poll;
+    let { poll: label, type } = poll;
     let itemLabel = label;
+    let answers = null;
 
     if (type !== 'YN' && type !== 'YNA' && type !== 'TF') {
       const { options } = itemLabel;
       itemLabel = options.join('/').replace(/[\n.)]/g, '');
+    } else {
+      answers = getLocalizedAnswers(type, intl);
+      type = 'custom';
     }
 
     // removes any whitespace from the label
@@ -68,7 +95,7 @@ const getAvailableQuickPolls = (slideId, parsedSlides, startPoll) => {
       <DropdownListItem
         label={itemLabel}
         key={_.uniqueId('quick-poll-item')}
-        onClick={() => startPoll(type, slideId)}
+        onClick={() => startPoll(type, slideId, answers)}
       />
     );
   });
@@ -103,7 +130,7 @@ class QuickPollDropdown extends Component {
     );
 
     const { slideId, quickPollOptions } = parsedSlide;
-    const quickPolls = getAvailableQuickPolls(slideId, quickPollOptions, startPoll);
+    const quickPolls = getAvailableQuickPolls(slideId, quickPollOptions, startPoll, intl);
 
     if (quickPollOptions.length === 0) return null;
 
@@ -114,18 +141,24 @@ class QuickPollDropdown extends Component {
     }
 
     let singlePollType = null;
+    let answers = null;
     if (quickPolls.length === 1 && quickPollOptions.length) {
       const { type } = quickPollOptions[0];
       singlePollType = type;
     }
 
+    if (singlePollType === 'TF' || singlePollType === 'YN' || singlePollType === 'YNA') {
+      answers = getLocalizedAnswers(singlePollType, intl);
+      singlePollType = 'custom';
+    }
+
     let btn = (
       <Button
         aria-label={intl.formatMessage(intlMessages.quickPollLabel)}
         className={styles.quickPollBtn}
         label={quickPollLabel}
         tooltipLabel={intl.formatMessage(intlMessages.quickPollLabel)}
-        onClick={() => startPoll(singlePollType, currentSlide.id)}
+        onClick={() => startPoll(singlePollType, currentSlide.id, answers)}
         size="lg"
         disabled={!!activePoll}
       />
diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx b/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx
index 8c6814dc01..f98e188118 100755
--- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx
+++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx
@@ -34,11 +34,11 @@ export default withTracker((params) => {
     presentationId,
   } = params;
 
-  const startPoll = (type, id) => {
+  const startPoll = (type, id, answers) => {
     Session.set('openPanel', 'poll');
     Session.set('forcePollOpen', true);
 
-    makeCall('startPoll', type, id, '');
+    makeCall('startPoll', type, id, '', answers);
   };
 
   return {
-- 
GitLab