update smart slides to detect user response poll
This commit is contained in:
parent
7c91152427
commit
3e9c858717
@ -34,6 +34,10 @@ const intlMessages = defineMessages({
|
||||
id: 'app.poll.abstention',
|
||||
description: 'Poll Abstention option value',
|
||||
},
|
||||
typedRespLabel: {
|
||||
id: 'app.poll.userResponse.label',
|
||||
description: 'quick poll typed response label',
|
||||
}
|
||||
});
|
||||
|
||||
const propTypes = {
|
||||
@ -44,7 +48,20 @@ const propTypes = {
|
||||
amIPresenter: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
const handleClickQuickPoll = (layoutContextDispatch) => {
|
||||
const QuickPollDropdown = (props) => {
|
||||
const {
|
||||
amIPresenter,
|
||||
intl,
|
||||
parseCurrentSlideContent,
|
||||
startPoll,
|
||||
currentSlide,
|
||||
activePoll,
|
||||
className,
|
||||
layoutContextDispatch,
|
||||
pollTypes,
|
||||
} = props;
|
||||
|
||||
const handleClickQuickPoll = (layoutContextDispatch) => {
|
||||
layoutContextDispatch({
|
||||
type: ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN,
|
||||
value: true,
|
||||
@ -55,17 +72,31 @@ const handleClickQuickPoll = (layoutContextDispatch) => {
|
||||
});
|
||||
Session.set('forcePollOpen', true);
|
||||
Session.set('pollInitiated', true);
|
||||
};
|
||||
};
|
||||
|
||||
const getAvailableQuickPolls = (
|
||||
const getAvailableQuickPolls = (
|
||||
slideId, parsedSlides, startPoll, pollTypes, layoutContextDispatch,
|
||||
) => {
|
||||
) => {
|
||||
const pollItemElements = parsedSlides.map((poll) => {
|
||||
const { poll: label } = poll;
|
||||
const { type } = poll;
|
||||
const { type, poll: pollData } = poll;
|
||||
let itemLabel = label;
|
||||
const letterAnswers = [];
|
||||
|
||||
if (type === 'R-') {
|
||||
return (
|
||||
<Dropdown.DropdownListItem
|
||||
label={intl.formatMessage(intlMessages.typedRespLabel)}
|
||||
key={_.uniqueId('quick-poll-item')}
|
||||
onClick={() => {
|
||||
handleClickQuickPoll(layoutContextDispatch);
|
||||
startPoll(type, slideId, letterAnswers, pollData?.question);
|
||||
}}
|
||||
question={pollData?.question}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (type !== pollTypes.YesNo
|
||||
&& type !== pollTypes.YesNoAbstention
|
||||
&& type !== pollTypes.TrueFalse) {
|
||||
@ -114,21 +145,7 @@ const getAvailableQuickPolls = (
|
||||
sizes.push(label.length);
|
||||
return el;
|
||||
});
|
||||
};
|
||||
|
||||
class QuickPollDropdown extends Component {
|
||||
render() {
|
||||
const {
|
||||
amIPresenter,
|
||||
intl,
|
||||
parseCurrentSlideContent,
|
||||
startPoll,
|
||||
currentSlide,
|
||||
activePoll,
|
||||
className,
|
||||
layoutContextDispatch,
|
||||
pollTypes,
|
||||
} = this.props;
|
||||
};
|
||||
|
||||
const parsedSlide = parseCurrentSlideContent(
|
||||
intl.formatMessage(intlMessages.yesOptionLabel),
|
||||
@ -146,11 +163,14 @@ class QuickPollDropdown extends Component {
|
||||
if (quickPollOptions.length === 0) return null;
|
||||
|
||||
let answers = null;
|
||||
let question = '';
|
||||
let quickPollLabel = '';
|
||||
|
||||
if (quickPolls.length > 0) {
|
||||
const { props: pollProps } = quickPolls[0];
|
||||
quickPollLabel = pollProps.label;
|
||||
answers = pollProps.answers;
|
||||
question = pollProps.question;
|
||||
}
|
||||
|
||||
let singlePollType = null;
|
||||
@ -166,7 +186,7 @@ class QuickPollDropdown extends Component {
|
||||
tooltipLabel={intl.formatMessage(intlMessages.quickPollLabel)}
|
||||
onClick={() => {
|
||||
handleClickQuickPoll(layoutContextDispatch);
|
||||
startPoll(singlePollType, currentSlide.id, answers);
|
||||
startPoll(singlePollType, currentSlide.id, answers, question);
|
||||
}}
|
||||
size="lg"
|
||||
disabled={!!activePoll}
|
||||
@ -208,7 +228,6 @@ class QuickPollDropdown extends Component {
|
||||
) : (
|
||||
btn
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
QuickPollDropdown.propTypes = propTypes;
|
||||
|
@ -81,7 +81,7 @@ class LiveResult extends PureComponent {
|
||||
if (response) {
|
||||
const formattedAnswers = [];
|
||||
response.answerIds.forEach((answerId) => {
|
||||
const formattedMessageIndex = answers[answerId].key.toLowerCase();
|
||||
const formattedMessageIndex = answers[answerId]?.key?.toLowerCase();
|
||||
const formattedAnswer = defaultPoll && pollAnswerIds[formattedMessageIndex]
|
||||
? intl.formatMessage(pollAnswerIds[formattedMessageIndex])
|
||||
: answers[answerId].key;
|
||||
@ -115,7 +115,7 @@ class LiveResult extends PureComponent {
|
||||
const pollStats = [];
|
||||
|
||||
answers.reduce(caseInsensitiveReducer, []).map((obj) => {
|
||||
const formattedMessageIndex = obj.key.toLowerCase();
|
||||
const formattedMessageIndex = obj?.key?.toLowerCase();
|
||||
const pct = Math.round(obj.numVotes / numResponders * 100);
|
||||
const pctFotmatted = `${Number.isNaN(pct) ? 0 : pct}%`;
|
||||
|
||||
|
@ -43,12 +43,12 @@ export default withTracker((params) => {
|
||||
presentationId,
|
||||
} = params;
|
||||
|
||||
const startPoll = (type, id, answers) => {
|
||||
const startPoll = (type, id, answers = [], question = '') => {
|
||||
Session.set('openPanel', 'poll');
|
||||
Session.set('forcePollOpen', true);
|
||||
window.dispatchEvent(new Event('panelChanged'));
|
||||
|
||||
makeCall('startPoll', PollService.pollTypes, type, id, false, '', false, answers);
|
||||
makeCall('startPoll', PollService.pollTypes, type, id, false, question, false, answers);
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -83,6 +83,12 @@ const parseCurrentSlideContent = (yesValue, noValue, abstentionValue, trueValue,
|
||||
content,
|
||||
} = currentSlide;
|
||||
|
||||
const questionRegex = /.*?\?$/gm;
|
||||
let question = content.match(questionRegex) || '';
|
||||
|
||||
const doubleQuestionRegex = /\?{2}/gm;
|
||||
let doubleQuestion = content.match(doubleQuestionRegex) || null;
|
||||
|
||||
const pollRegex = /[1-9A-Ia-i][.)].*/g;
|
||||
let optionsPoll = content.match(pollRegex) || [];
|
||||
if (optionsPoll) optionsPoll = optionsPoll.map((opt) => `\r${opt[0]}.`);
|
||||
@ -139,6 +145,15 @@ const parseCurrentSlideContent = (yesValue, noValue, abstentionValue, trueValue,
|
||||
}
|
||||
});
|
||||
|
||||
if (question.length > 0 && optionsPoll.length === 0 && !doubleQuestion) {
|
||||
quickPollOptions.push({
|
||||
type: `R-`,
|
||||
poll: {
|
||||
question: question[0],
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (quickPollOptions.length > 0) {
|
||||
content = content.replace(new RegExp(pollRegex), '');
|
||||
}
|
||||
|
@ -311,7 +311,7 @@
|
||||
"app.poll.clickHereToSelect": "Click here to select",
|
||||
"app.poll.question.label" : "Write your question...",
|
||||
"app.poll.optionalQuestion.label" : "Write your question (optional)...",
|
||||
"app.poll.userResponse.label" : "User Response",
|
||||
"app.poll.userResponse.label" : "Typed Response",
|
||||
"app.poll.responseTypes.label" : "Response Types",
|
||||
"app.poll.optionDelete.label" : "Delete",
|
||||
"app.poll.responseChoices.label" : "Response Choices",
|
||||
|
Loading…
Reference in New Issue
Block a user