Skip to content

Commit

Permalink
Merge pull request #37 from ritzalam/fix-freeform-poll
Browse files Browse the repository at this point in the history
Answers of Typed Response polls are not stored correctly
  • Loading branch information
kepstin authored Jun 23, 2023
2 parents 29622ea + e878299 commit 7635e4e
Show file tree
Hide file tree
Showing 5 changed files with 773 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/spec/reports/
/tmp/
/vendor/
Gemfile.lock

# rspec failure tracking
.rspec_status
Expand Down
6 changes: 6 additions & 0 deletions lib/bbbevents/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ def user_responded_to_poll_record_event(e)
return unless attendee = @attendees[@externalUserId[intUserId]]

if poll = @polls[poll_id]
if poll.type == 'R-'
poll.votes[@externalUserId[intUserId]] = e["answer"]

# We want to store the responses as options.
poll.options.insert(e["answerId"].to_i, e["answer"])
end
poll.votes[@externalUserId[intUserId]] = poll.options[e["answerId"].to_i]
end

Expand Down
6 changes: 5 additions & 1 deletion lib/bbbevents/poll.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module BBBEvents
class Poll
attr_accessor :id, :start, :published, :options, :votes
attr_accessor :id, :type, :question, :start, :published, :options, :votes

def initialize(poll_event)
@id = poll_event["pollId"]
@type = poll_event["type"]
@question = poll_event["question"].nil? ? "" : "#{poll_event['question']}"
@published = false
@options = JSON.parse(poll_event["answers"]).map { |opt| opt["key"] }
@votes = {}
Expand All @@ -27,6 +29,8 @@ def to_json
def as_json
{
id: @id,
type: @type,
question: @question,
published: @published,
options: @options,
start: BBBEvents.format_datetime(@start),
Expand Down
Loading

0 comments on commit 7635e4e

Please sign in to comment.