Skip to content

Commit

Permalink
- ignore Gemfile.lock
Browse files Browse the repository at this point in the history
 - on typed response pools, store the question and responses properly
  • Loading branch information
ritzalam committed Jun 22, 2023
1 parent 29622ea commit 98c4d3c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 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: 5 additions & 1 deletion lib/bbbevents/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ def user_responded_to_poll_record_event(e)
return unless attendee = @attendees[@externalUserId[intUserId]]

if poll = @polls[poll_id]
poll.votes[@externalUserId[intUserId]] = poll.options[e["answerId"].to_i]
if poll.type == 'R-'
poll.votes[@externalUserId[intUserId]] = e["answer"]
else
poll.votes[@externalUserId[intUserId]] = poll.options[e["answerId"].to_i]
end
end

attendee.engagement[:poll_votes] += 1
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
10 changes: 9 additions & 1 deletion spec/poll_2_6_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@

context "#poll json timestamp format" do
it "has fixed poll json timestamp format." do
puts @poll.as_json[:start]
expect(@poll.as_json[:start]).to eq('2023-05-17T18:59:56.000+00:00')
end
end

context "#poll typed response format" do
it "has correct question." do
poll = @sample.polls.last
expect(poll.as_json[:start]).to eq('2023-05-17T19:00:49.000+00:00')
expect(poll.as_json[:type]).to eq('R-')
expect(poll.as_json[:question]).to eq('what is your name?')
end
end
end

0 comments on commit 98c4d3c

Please sign in to comment.