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 3b16d18ae90dc347a7d61087bb6c3ae7b60a879d..f344a92478eda019629138ec80d6211addd4d0d2 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 @@ -10,6 +10,9 @@ import DropdownList from '/imports/ui/components/dropdown/list/component'; import DropdownListItem from '/imports/ui/components/dropdown/list/item/component'; import { styles } from '../styles'; +const POLL_SETTINGS = Meteor.settings.public.poll; +const MAX_CUSTOM_FIELDS = POLL_SETTINGS.maxCustom; + const intlMessages = defineMessages({ quickPollLabel: { id: 'app.poll.quickPollTitle', @@ -47,7 +50,7 @@ const getAvailableQuickPolls = (slideId, parsedSlides, startPoll, pollTypes) => const pollItemElements = parsedSlides.map((poll) => { let { poll: label, type } = poll; let itemLabel = label; - let answers = null; + let letterAnswers = []; if (type !== pollTypes.YesNo && type !== pollTypes.YesNoAbstention && @@ -55,6 +58,16 @@ const getAvailableQuickPolls = (slideId, parsedSlides, startPoll, pollTypes) => { const { options } = itemLabel; itemLabel = options.join('/').replace(/[\n.)]/g, ''); + if (type === pollTypes.Custom) { + for (const option of options) { + const letterOption = option.replace(/[\r.)]/g, ''); + if (letterAnswers.length < MAX_CUSTOM_FIELDS) { + letterAnswers.push(letterOption); + } else { + break; + } + } + } } // removes any whitespace from the label @@ -72,7 +85,8 @@ const getAvailableQuickPolls = (slideId, parsedSlides, startPoll, pollTypes) => <DropdownListItem label={itemLabel} key={_.uniqueId('quick-poll-item')} - onClick={() => startPoll(type, slideId, answers)} + onClick={() => startPoll(type, slideId, letterAnswers)} + answers={letterAnswers} /> ); }); @@ -112,14 +126,15 @@ class QuickPollDropdown extends Component { if (quickPollOptions.length === 0) return null; + let answers = null; let quickPollLabel = ''; if (quickPolls.length > 0) { const { props: pollProps } = quickPolls[0]; quickPollLabel = pollProps.label; + answers = pollProps.answers; } let singlePollType = null; - let answers = null; if (quickPolls.length === 1 && quickPollOptions.length) { const { type } = quickPollOptions[0]; singlePollType = type; diff --git a/bigbluebutton-html5/imports/ui/components/poll/component.jsx b/bigbluebutton-html5/imports/ui/components/poll/component.jsx index bc2352767e25be3d4b6269239a5835bab52ca229..ed4de2a8051c4e2a1e7665f72c2ab05ed15e93f3 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/component.jsx @@ -151,7 +151,7 @@ const intlMessages = defineMessages({ const POLL_SETTINGS = Meteor.settings.public.poll; -const MAX_CUSTOM_FIELDS = POLL_SETTINGS.max_custom; +const MAX_CUSTOM_FIELDS = POLL_SETTINGS.maxCustom; const MAX_INPUT_CHARS = POLL_SETTINGS.maxTypedAnswerLength; const QUESTION_MAX_INPUT_CHARS = 400; const FILE_DRAG_AND_DROP_ENABLED = POLL_SETTINGS.allowDragAndDropFile; @@ -494,7 +494,7 @@ class Poll extends Component { label={intl.formatMessage(intlMessages.addOptionLabel)} color="default" icon="add" - disabled={optList.length === MAX_CUSTOM_FIELDS} + disabled={optList.length >= MAX_CUSTOM_FIELDS} onClick={() => this.handleAddOption()} /> )} diff --git a/bigbluebutton-html5/imports/ui/components/presentation/service.js b/bigbluebutton-html5/imports/ui/components/presentation/service.js index 5c82cda4af521a2ff2aabbd91d7157b3f6d3e6fa..df6a9180d7b1461a751b619c1bb2bcd7eeb113b8 100755 --- a/bigbluebutton-html5/imports/ui/components/presentation/service.js +++ b/bigbluebutton-html5/imports/ui/components/presentation/service.js @@ -4,6 +4,9 @@ import { Slides, SlidePositions } from '/imports/api/slides'; import Auth from '/imports/ui/services/auth'; import PollService from '/imports/ui/components/poll/service'; +const POLL_SETTINGS = Meteor.settings.public.poll; +const MAX_CUSTOM_FIELDS = POLL_SETTINGS.maxCustom; + const getCurrentPresentation = podId => Presentations.findOne({ podId, current: true, @@ -81,7 +84,7 @@ const parseCurrentSlideContent = (yesValue, noValue, abstentionValue, trueValue, content, } = currentSlide; - const pollRegex = /[1-6A-Fa-f][.)].*/g; + const pollRegex = /[1-9A-Ia-i][.)].*/g; let optionsPoll = content.match(pollRegex) || []; if (optionsPoll) optionsPoll = optionsPoll.map(opt => `\r${opt[0]}.`); @@ -120,10 +123,22 @@ const parseCurrentSlideContent = (yesValue, noValue, abstentionValue, trueValue, return acc; }, []).filter(({ options, - }) => options.length > 1 && options.length < 7).forEach(poll => quickPollOptions.push({ - type: `${pollTypes.Letter}${poll.options.length}`, - poll, - })); + }) => options.length > 1 && options.length < 10).forEach(poll => { + if (poll.options.length <= 5 || MAX_CUSTOM_FIELDS <= 5) { + const maxAnswer = poll.options.length > MAX_CUSTOM_FIELDS + ? MAX_CUSTOM_FIELDS + : poll.options.length + quickPollOptions.push({ + type: `${pollTypes.Letter}${maxAnswer}`, + poll, + }) + } else { + quickPollOptions.push({ + type: pollTypes.Custom, + poll, + }) + } + }); if (quickPollOptions.length > 0) { content = content.replace(new RegExp(pollRegex), ''); diff --git a/bigbluebutton-html5/private/config/settings.yml b/bigbluebutton-html5/private/config/settings.yml index 189402865f2cb1b9db701e89a1efbb682f463db9..8e6918b8daea4bddf6532da91c33b81416950bd2 100755 --- a/bigbluebutton-html5/private/config/settings.yml +++ b/bigbluebutton-html5/private/config/settings.yml @@ -379,7 +379,7 @@ public: toggleSelfVoice: false poll: enabled: true - max_custom: 5 + maxCustom: 5 allowDragAndDropFile: false maxTypedAnswerLength: 45 captions: