update ui for multiple choice

This commit is contained in:
Simon Hirtreiter 2021-02-04 15:43:04 +01:00
parent 1c4186d7fd
commit 4c2d2d8244
3 changed files with 6 additions and 5 deletions

View File

@ -3,11 +3,11 @@ import Polls from '/imports/api/polls';
import Logger from '/imports/startup/server/logger'; import Logger from '/imports/startup/server/logger';
export default function userResponded({ body }) { export default function userResponded({ body }) {
const { pollId, userId, answerId } = body; const { pollId, userId, answerIds } = body;
check(pollId, String); check(pollId, String);
check(userId, String); check(userId, String);
check(answerId, Number); check(answerIds, Array);
const selector = { const selector = {
id: pollId, id: pollId,
@ -18,7 +18,7 @@ export default function userResponded({ body }) {
users: userId, users: userId,
}, },
$push: { $push: {
responses: { userId, answerId }, responses: { userId, answerId: answerIds[0] },
}, },
}; };
@ -26,7 +26,7 @@ export default function userResponded({ body }) {
const numberAffected = Polls.update(selector, modifier); const numberAffected = Polls.update(selector, modifier);
if (numberAffected) { if (numberAffected) {
Logger.info(`Updating Poll response (userId: ${userId}, response: ${answerId}, pollId: ${pollId})`); Logger.info(`Updating Poll response (userId: ${userId}, response: ${answerIds[0]}, pollId: ${pollId})`);
} }
} catch (err) { } catch (err) {
Logger.error(`Updating Poll responses: ${err}`); Logger.error(`Updating Poll responses: ${err}`);

View File

@ -34,7 +34,7 @@ export default function publishVote(pollId, pollAnswerId) {
requesterId: requesterUserId, requesterId: requesterUserId,
pollId, pollId,
questionId: 0, questionId: 0,
answerId: pollAnswerId, answerIds: [pollAnswerId],
}; };
/* /*

View File

@ -15,6 +15,7 @@ export default function addPoll(meetingId, requesterId, poll) {
key: String, key: String,
}, },
], ],
isMultipleChoice: Boolean
}); });
const userSelector = { const userSelector = {