diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala index aba3186cdc661a7a41769ac87f3e0db0c2b6056a..a1ff8bd7990b1fb991494a8c922453d912f731f7 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Polls.scala @@ -255,6 +255,7 @@ object Polls { shape += "numRespondents" -> new Integer(result.numRespondents) shape += "numResponders" -> new Integer(result.numResponders) shape += "type" -> WhiteboardKeyUtil.POLL_RESULT_TYPE + shape += "pollType" -> result.questionType shape += "id" -> result.id shape += "status" -> WhiteboardKeyUtil.DRAW_END_STATUS @@ -644,7 +645,7 @@ class Poll(val id: String, val questions: Array[Question], val numRespondents: I } def toSimplePollResultOutVO(): SimplePollResultOutVO = { - new SimplePollResultOutVO(id, questions(0).text, questions(0).toSimpleVotesOutVO(), numRespondents, _numResponders) + new SimplePollResultOutVO(id, questions(0).questionType, questions(0).text, questions(0).toSimpleVotesOutVO(), numRespondents, _numResponders) } } diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/domain/Meeting2x.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/domain/Meeting2x.scala index 81cbd48e81df85f692c427605d16ad67d289f1c8..7076bdfe8cd3a48e85144596b3ffa3ee4717637d 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/domain/Meeting2x.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/domain/Meeting2x.scala @@ -77,7 +77,7 @@ case class Meeting2x(defaultProps: DefaultProps, meetingStatus: MeetingStatus) case class SimpleAnswerOutVO(id: Int, key: String) case class SimplePollOutVO(id: String, answers: Array[SimpleAnswerOutVO]) case class SimpleVoteOutVO(id: Int, key: String, numVotes: Int) -case class SimplePollResultOutVO(id: String, questionText: Option[String], answers: Array[SimpleVoteOutVO], numRespondents: Int, numResponders: Int) +case class SimplePollResultOutVO(id: String, questionType: String, questionText: Option[String], answers: Array[SimpleVoteOutVO], numRespondents: Int, numResponders: Int) case class Responder(userId: String, name: String) case class AnswerVO(id: Int, key: String, text: Option[String], responders: Option[Array[Responder]]) case class QuestionVO(id: Int, questionType: String, multiResponse: Boolean, questionText: Option[String], answers: Option[Array[AnswerVO]]) diff --git a/bigbluebutton-html5/imports/api/polls/server/handlers/userVoted.js b/bigbluebutton-html5/imports/api/polls/server/handlers/userVoted.js index e4efe888606d4c63bb385ce114800f0ef6a49ff0..b82087d8bb7a1b7f99ffc0b4fd68e5271837dfef 100644 --- a/bigbluebutton-html5/imports/api/polls/server/handlers/userVoted.js +++ b/bigbluebutton-html5/imports/api/polls/server/handlers/userVoted.js @@ -7,6 +7,7 @@ export default function userVoted({ body }, meetingId) { check(meetingId, String); check(poll, { id: String, + questionType: String, questionText: String, answers: [ { diff --git a/bigbluebutton-html5/imports/api/polls/server/methods/startPoll.js b/bigbluebutton-html5/imports/api/polls/server/methods/startPoll.js index 728fbab6d74cd8a38312f61bddb8c5fc73c89a36..f37caca858e0f94bc1a13ebdef8214bbccf832a6 100644 --- a/bigbluebutton-html5/imports/api/polls/server/methods/startPoll.js +++ b/bigbluebutton-html5/imports/api/polls/server/methods/startPoll.js @@ -3,7 +3,7 @@ import { check } from 'meteor/check'; import { extractCredentials } from '/imports/api/common/server/helpers'; import Logger from '/imports/startup/server/logger'; -export default function startPoll(pollType, pollId, question, answers) { +export default function startPoll(pollTypes, pollType, pollId, question, answers) { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; let EVENT_NAME = 'StartPollReqMsg'; @@ -23,7 +23,7 @@ export default function startPoll(pollType, pollId, question, answers) { question, }; - if (pollType === 'custom') { + if (pollType === pollTypes.Custom) { EVENT_NAME = 'StartCustomPollReqMsg'; check(answers, Array); payload.answers = answers; diff --git a/bigbluebutton-html5/imports/ui/components/poll/component.jsx b/bigbluebutton-html5/imports/ui/components/poll/component.jsx index 7a75ee3b307c562689272c3745c671a102589d33..bc2352767e25be3d4b6269239a5835bab52ca229 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/component.jsx @@ -351,6 +351,7 @@ class Poll extends Component { currentPoll, pollAnswerIds, usernames, + isDefaultPoll, } = this.props; return ( @@ -365,6 +366,7 @@ class Poll extends Component { currentPoll, pollAnswerIds, usernames, + isDefaultPoll, }} handleBackClick={this.handleBackClick} /> diff --git a/bigbluebutton-html5/imports/ui/components/poll/container.jsx b/bigbluebutton-html5/imports/ui/components/poll/container.jsx index 34a200b6061a55337cd95d16be30eb07eabc9025..6cfdbb2fc31b1d539392aafb899c2007e44685e8 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/container.jsx @@ -35,9 +35,11 @@ export default withTracker(() => { const pollId = currentSlide ? currentSlide.id : PUBLIC_CHAT_KEY; - const startPoll = (type, question = '') => makeCall('startPoll', type, pollId, question); + const pollTypes = Service.pollTypes; - const startCustomPoll = (type, question = '', answers) => makeCall('startPoll', type, pollId, question, answers); + const startPoll = (type, question = '') => makeCall('startPoll', pollTypes, type, pollId, question); + + const startCustomPoll = (type, question = '', answers) => makeCall('startPoll', pollTypes, type, pollId, question, answers); const stopPoll = () => makeCall('stopPoll'); diff --git a/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx b/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx index a762390d207d819090834503690f9c2a7db6ddfe..aa7ec79bebd1ddc7bdd0351f3655c29aa0bbc11e 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/live-result/component.jsx @@ -46,15 +46,17 @@ const getResponseString = (obj) => { class LiveResult extends PureComponent { static getDerivedStateFromProps(nextProps) { const { - currentPoll, intl, pollAnswerIds, usernames, + currentPoll, intl, pollAnswerIds, usernames, isDefaultPoll, } = nextProps; if (!currentPoll) return null; const { - answers, responses, users, numRespondents, + answers, responses, users, numRespondents, pollType } = currentPoll; + const defaultPoll = isDefaultPoll(pollType); + const currentPollQuestion = (currentPoll.question) ? currentPoll.question : ''; let userAnswers = responses @@ -85,7 +87,7 @@ class LiveResult extends PureComponent { <td className={styles.resultLeft}>{user.name}</td> <td data-test="receivedAnswer" className={styles.resultRight}> { - pollAnswerIds[formattedMessageIndex] + defaultPoll && pollAnswerIds[formattedMessageIndex] ? intl.formatMessage(pollAnswerIds[formattedMessageIndex]) : user.answer } @@ -110,7 +112,7 @@ class LiveResult extends PureComponent { <div className={styles.main} key={_.uniqueId('stats-')}> <div className={styles.left}> { - pollAnswerIds[formattedMessageIndex] + defaultPoll && pollAnswerIds[formattedMessageIndex] ? intl.formatMessage(pollAnswerIds[formattedMessageIndex]) : obj.key } diff --git a/bigbluebutton-html5/imports/ui/components/poll/service.js b/bigbluebutton-html5/imports/ui/components/poll/service.js index b161193ff027e2e4d9f6c5fe4df5f410cd2bf0ac..a50f1c122e8172d6be0ee7789410b28232232942 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/service.js +++ b/bigbluebutton-html5/imports/ui/components/poll/service.js @@ -23,7 +23,7 @@ const pollTypes = { A3: 'A-3', A4: 'A-4', A5: 'A-5', - Custom: 'custom', + Custom: 'CUSTOM', Response: 'R-', } diff --git a/bigbluebutton-html5/imports/ui/components/polling/component.jsx b/bigbluebutton-html5/imports/ui/components/polling/component.jsx index 21f782255c1293e401dd3b1c8ef926653c436a10..51f776bad857885f19d3def8fcb4c83cc9f70f36 100644 --- a/bigbluebutton-html5/imports/ui/components/polling/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/polling/component.jsx @@ -92,7 +92,8 @@ class Polling extends Component { handleVote, handleTypedVote, pollAnswerIds, - pollTypes + pollTypes, + isDefaultPoll, } = this.props; const { @@ -101,7 +102,8 @@ class Polling extends Component { if (!poll) return null; - const { stackOptions, answers, question } = poll; + const { stackOptions, answers, question, pollType } = poll; + const defaultPoll = isDefaultPoll(pollType); const pollAnswerStyles = { [styles.pollingAnswers]: true, @@ -144,7 +146,7 @@ class Polling extends Component { {poll.answers.map((pollAnswer) => { const formattedMessageIndex = pollAnswer.key.toLowerCase(); let label = pollAnswer.key; - if (pollAnswerIds[formattedMessageIndex]) { + if (defaultPoll && pollAnswerIds[formattedMessageIndex]) { label = intl.formatMessage(pollAnswerIds[formattedMessageIndex]); } diff --git a/bigbluebutton-html5/imports/ui/components/polling/container.jsx b/bigbluebutton-html5/imports/ui/components/polling/container.jsx index 7f2c9ce1c0f6699e32a5f47a615bac0333cd1420..d9b8838b762bbaeb384f2f18e9d62861dac84cae 100644 --- a/bigbluebutton-html5/imports/ui/components/polling/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/polling/container.jsx @@ -38,6 +38,7 @@ export default withTracker(() => { poll, pollAnswerIds: PollService.pollAnswerIds, pollTypes: PollService.pollTypes, + isDefaultPoll: PollService.isDefaultPoll, isMeteorConnected: Meteor.status().connected, }); })(PollingContainer); 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 cb15aec55ca3a126e9fa6b7899e489db4d4fefa2..9bd3030ef4507fa6a6352abb96e93d0a14936457 100755 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-toolbar/container.jsx @@ -4,6 +4,7 @@ import { withTracker } from 'meteor/react-meteor-data'; import PresentationService from '/imports/ui/components/presentation/service'; import MediaService from '/imports/ui/components/media/service'; import Service from '/imports/ui/components/actions-bar/service'; +import PollService from '/imports/ui/components/poll/service'; import { makeCall } from '/imports/ui/services/api'; import PresentationToolbar from './component'; import PresentationToolbarService from './service'; @@ -39,7 +40,7 @@ export default withTracker((params) => { Session.set('forcePollOpen', true); window.dispatchEvent(new Event('panelChanged')); - makeCall('startPoll', type, id, '', answers); + makeCall('startPoll', PollService.pollTypes, type, id, '', answers); }; return { diff --git a/bigbluebutton-html5/imports/ui/components/whiteboard/annotations/poll/component.jsx b/bigbluebutton-html5/imports/ui/components/whiteboard/annotations/poll/component.jsx index 8a570a4974e95db471e19b0e8e31b6c6bb1e07e5..56ff52db43fb8da8dfc20399059e2e38edce0c0f 100644 --- a/bigbluebutton-html5/imports/ui/components/whiteboard/annotations/poll/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/whiteboard/annotations/poll/component.jsx @@ -213,7 +213,7 @@ class PollDrawComponent extends Component { // if (!state.initialState) return; const { annotation } = this.props; - const { points, result } = annotation; + const { points, result, pollType } = annotation; const { slideWidth, slideHeight, intl } = this.props; // group duplicated responses and keep track of the number of removed items @@ -253,30 +253,14 @@ class PollDrawComponent extends Component { // adding value of the iterator to each line needed to create unique // keys while rendering at the end const arrayLength = reducedResult.length; + const { pollAnswerIds } = PollService; + const isDefaultPoll = PollService.isDefaultPoll(pollType); for (let i = 0; i < arrayLength; i += 1) { const _tempArray = []; const _result = reducedResult[i]; - let isDefaultPoll; - switch (_result.key.toLowerCase()) { - case 'true': - case 'false': - case 'yes': - case 'no': - case 'abstention': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - isDefaultPoll = true; - break; - default: - isDefaultPoll = false; - break; - } if (isDefaultPoll) { - _result.key = intl.formatMessage({ id: `app.poll.answer.${_result.key.toLowerCase()}` }); + _result.key = intl.formatMessage(pollAnswerIds[_result.key.toLowerCase()]); } if (_result.key.length > MAX_DISPLAYED_CHARS) { @@ -318,9 +302,8 @@ class PollDrawComponent extends Component { const maxLineHeight = (innerHeight * 0.75) / textArray.length; const lineToMeasure = textArray[0]; - const { pollAnswerIds } = PollService; const messageIndex = lineToMeasure[0].toLowerCase(); - if (pollAnswerIds[messageIndex]) { + if (isDefaultPoll && pollAnswerIds[messageIndex]) { lineToMeasure[0] = intl.formatMessage(pollAnswerIds[messageIndex]); } @@ -420,7 +403,8 @@ class PollDrawComponent extends Component { let label = textArray[i][0]; const formattedMessageIndex = label.toLowerCase(); - if (pollAnswerIds[formattedMessageIndex]) { + const isDefaultPoll = PollService.isDefaultPoll(annotation.pollType); + if (isDefaultPoll && pollAnswerIds[formattedMessageIndex]) { label = intl.formatMessage(pollAnswerIds[formattedMessageIndex]); }